@extends('layouts.app')
@section('content')
    <div style="max-width:700px">
        <form method="POST" action="">
            @csrf
            <div class="mb-3">
                <img src="../../images/icons/user.png" class="img-fluid align-middle" style="height: 100px;">
            </div>
            <div class="row">
                <div class="col">
                    <div class="form-floating mb-3">
                        <input id="user.firstName" name="user[firstName]"
                            value="{{ Auth::user()->getPartialsName()['secondName'] }} {{ Auth::user()->getPartialsName()['familyName'] }}"
                            class="form-control rounded-4 bg-white @error('user.firstName') is-invalid @enderror"
                            name="user.firstName" required placeholder="Имя">
                        <label for="user.firstName">Имя</label>
                        @error('user.firstName')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                </div>
                <div class="col">
                    <div class="form-floating mb-3">
                        <input id="user.secondName" name="user[secondName]"
                            value="{{ Auth::user()->getPartialsName()['firstName'] }}"
                            class="form-control rounded-4 bg-white @error('user.secondName') is-invalid @enderror"
                            name="user.secondName" required placeholder="Фамилия">
                        <label for="user.secondName">Фамилия</label>
                        @error('user.secondName')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col">
                    <div class="form-floating mb-3">
                        <input id="user.email" name="user[email]" value="{{ Auth::user()->email }}"
                            class="form-control rounded-4 bg-white @error('user.email') is-invalid @enderror"
                            name="user.email" required placeholder="Электронная почта">
                        <label for="user.email">Электронная почта</label>
                        @error('user.email')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                </div>
                <div class="col">
                    <div class="form-floating mb-3">
                        <input id="user.phone" name="user[phone]" value="{{ Auth::user()->phone }}"
                            class="form-control rounded-4 bg-white @error('user.phone') is-invalid @enderror"
                            name="user.phone" required placeholder="Телефон">
                        <label for="user.phone">Телефон</label>
                        @error('user.phone')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                </div>
            </div>

            <div class="mb-3">
                <div class="form-check form-switch ">
                    <input class="form-check-input" type="checkbox" role="switch" id="switchCheckChecked" checked>
                    <label class="form-check-label" for="switchCheckChecked">Соглашаюсь на получение рекламных рассылок</label>
                </div>
            </div>

            <div class="form-floating d-none">
                <input id="details.address" name="details[address]" value=""
                    class="form-control rounded-4 bg-white @error('details.address') is-invalid @enderror" required
                    placeholder="Телеграм ник">
                <label for="details.address">Телеграм ник</label>
                @error('details.address')
                    <span class="invalid-feedback" role="alert">
                        <strong>{{ $message }}</strong>
                    </span>
                @enderror
            </div>
            <div class="my-3 d-flex">
                <div class="me-2">Мои права: </div>
                <div class="hstack gap-2">
                    @foreach (auth()->user()->roles as $role)
                        @if($role->id != Modules\User\Models\Role::AGENT && $role->id != Modules\User\Models\Role::COMPANY_ADMIN)
                            <div class="badge bg-secondary">
                                {{ __($role->name) }}
                            </div>
                        @endif
                    @endforeach
                    @if($adminCompany = AdminCompanyOfUser())
                        @if($adminCompany->type !== Modules\Main\Models\Company\CompanyType::SelfEmployer->value)
                            <div class="badge bg-secondary">
                                Администратор в {{ $adminCompany->name }}
                            </div>
                        @endif
                    @endif
                    @if($agentCompany = AgentCompanyOfUser())
                        @if($agentCompany->type == Modules\Main\Models\Company\CompanyType::SelfEmployer->value)
                            <div class="badge bg-secondary">
                                Самозанятый
                            </div>
                        @else
                            <div class="badge bg-secondary">
                                Агент в {{ $agentCompany->name }}
                            </div>
                        @endif
                    @endif
                </div>
            </div>

            <button class="btn rounded-4 text-light fw-bold fs-5 w-100 py-3" style="background-color: #20184d;">
                Сохранить изменения
            </button>
        </form>
    </div>
@endsection