@extends('layouts.guest')

@section('content')
    <div class="">
        <div class="">
            <div class="">
                <div class="h2">Регистрация</div>
                <div class="">
                    <form action="{{ route('company.create') }}" method="{{ $type ? 'post' : 'get' }}">
                        @csrf
                        <div class="mb-3">
                            <label for="companyType" class="form-label">Статус регистрации</label>
                            @if ($type)
                                <input type="text" class="form-control d-none" id="companyType" name="type"
                                    value="{{ $type }}">
                            @endif
                            <select class="form-select" @if ($type) disabled @endif id="companyType"
                                name="type" value="{{ old('type') }}">
                                @foreach ($typesList as $typesItem)
                                    <option value="{{ $typesItem->value }}"
                                        @if ($type == $typesItem->value) selected @endif>{{ __($typesItem->name) }}
                                    </option>
                                @endforeach
                            </select>
                            @error('type')
                                <span class="invalid-feedback d-block" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        <div class="mb-3">
                            <label for="companyType" class="form-label">Город</label>
                            @if ($type)
                                <input type="text" class="form-control d-none" id="companyCity" name="city_id"
                                    value="{{ $city_id }}">
                            @endif
                            <select class="form-select" @if ($type && $city_id) disabled @endif id="companyCity"
                                name="city_id" value="{{ old('city') }}">
                                @foreach ($citiesList as $cityItem)
                                    <option value="{{ $cityItem->id }}" @if ($city_id && $city_id == $cityItem->id) selected @endif>
                                        {{ __($cityItem->name) }}</option>
                                @endforeach
                            </select>
                            @error('city')
                                <span class="invalid-feedback d-block" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        @if ($type)
                            <div class="mb-3">
                                <label for="companyName"
                                    class="form-label">{{ __(ucfirst(strtolower($type)) . ' name') }}</label>
                                <input type="text" class="form-control" id="companyName" name="name"
                                    value="{{ old('name') }}">
                                @error('name')
                                    <span class="invalid-feedback d-block" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>

                            @if($type != Modules\Main\Models\Company\CompanyType::SelfEmployer->value)
                                <div class="mb-3">
                                    <label for="companyInn" class="form-label">{{ __('Inn') }}</label>
                                    <input type="text" class="form-control" id="companyInn" name="inn"
                                        value="{{ old('inn') }}">
                                    @error('inn')
                                        <span class="invalid-feedback d-block" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            @endif
                            <div class="mb-3 d-none">
                                <label for="companyLegalAddress" class="form-label">{{ __('Legal address') }}</label>
                                <input type="text" class="form-control" id="companyLegalAddress" name="legal_address"
                                    value="{{ old('legal_address') }}">
                                @error('legal_address')
                                    <span class="invalid-feedback d-block" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="companyPhone" class="form-label">{{ __('Phone') }}</label>
                                <input type="text" class="form-control" id="companyPhone" name="phone"
                                    value="{{ old('phone') }}">
                                @error('phone')
                                    <span class="invalid-feedback d-block" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="companyEmail" class="form-label">{{ __('Email') }}</label>
                                <input type="text" class="form-control" id="companyEmail" name="email"
                                    value="{{ old('email') }}">
                                @error('email')
                                    <span class="invalid-feedback d-block" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                                <span class="fst-italic">
                                    На данный электронный адрес мы направим логин и пароль администратора для входа в личный
                                    кабинет
                                </span>
                            </div>
                        @endif
                        <input type="submit" class="btn btn-primary" value="Продолжить">
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
