@extends('layouts.window.theme')
@section("title", env("APP_NAME") . " :: Cadastro de Pacientes com Fibromialgia")
@section('content')
<form action="{{ route('paginas.castracao.tutors.store')}}"
    enctype="multipart/form-data" method="POST">
    <div class="container d-flex justify-content-center align-items-center min-vh-100">
        <div class="row w-100 justify-content-center py-3">
            <div class="col-12">
                <div class="card shadow-lg">
                    <div class="card-header bg-primary text-white">
                        <div class="row align-items-center">
                            <div class="col">
                                <h4 class="mb-0">Cadastro de Tutores</h4>
                            </div>
                            <div class="col-auto text-end">
                                <a class="btn btn-md btn-outline-light" href="{{ route('paginas.home') }}">
                                    Sair
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        @if ($errors->any())
                        @foreach ($errors->all() as $error)
                        <div class="mb-3 alert alert-danger">
                            {!! $error !!}
                        </div>
                        @endforeach
                        @endif

                        @csrf
                        @method('post')

                        @if (session('success'))
                        <div class="alert alert-success">{{ session('success') }}</div>
                        @endif

                        @if (session('error'))
                        <div class="alert alert-danger">{{ session('error') }}</div>
                        @endif

                        @if (session('info'))
                        <div class="alert alert-info">{{ session('info') }}</div>
                        @endif


                        <div>

                            @csrf
                            <div class="mb-3">
                                <img src="{{ asset(optional($user)->photo ?? 'pmar/assets/img/icons/usuario.png') }}" class="img-fluid img-thumbnail src-fileoptional($user)->photo-image" alt="{{ optional($user)->firstName }} {{ optional($user)->lastName }}" title="{{ optional($user)->firstName }} {{ optional($user)->lastName }}" width="200px" />
                            </div>

                            <<div class="mb-3">
                                <label for="photo" class="form-label text-bold">
                                    Foto: <small class="text-secondary">(.jpg, .jpeg, .png)</small>
                                </label>

                                <div class="mb-2">
                                    <img src="{{ asset('storage/' . ($user->photo ?? 'contas/usuario.png')) }}"
                                        class="img-fluid img-thumbnail"
                                        alt="Foto do usuário"
                                        width="200px">
                                </div>

                                <input type="file" class="form-control" name="photo" id="photo"
                                    accept="image/jpeg,image/jpg,image/png,image/gif">
                        </div>

                        <div class="mb-3">
                            <label for="cpf" class="form-label">CPF</label>
                            <input type="text" name="cpf" id="cpf" class="form-control" required
                                value="{{ old('cpf', $cpfTmp) }}">
                        </div>

                        <div class="mb-3">
                            <label for="firstName" class="form-label text-bold">Nome: <span class="text-danger">*</span></label>
                            <input type="text" class="form-control @error('firstName') is-invalid @enderror" name="firstName" id="firstName" autocomplete="off" value="{{ old('firstName') }}">
                            @error('firstName')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>

                        <div class="mb-3">
                            <label for="lastName" class="form-label text-bold">Sobrenome: <span class="text-danger">*</span></label>
                            <input type="text" class="form-control @error('lastName') is-invalid @enderror" name="lastName" id="lastName" autocomplete="off" value="{{ old('lastName') }}">
                            @error('lastName')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>


                        <div class="mb-3">
                            <label for="phoneNumber" class="form-label">Telefone</label>
                            <input type="text" name="phoneNumber" id="phoneNumber" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="email" class="form-label">E-mail</label>
                            <input type="email" name="email" id="email" class="form-control" required>
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label">Senha</label>
                            <input type="password" name="password" id="password" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="tipo_tutor" class="form-label">Tipo de Tutor</label>
                            <select name="tipo_tutor" id="tipo_tutor" class="form-select" required>
                                @foreach(App\Enums\TutorEnum::cases() as $tutor)
                                <option value="{{ $tutor->name }}"
                                    {{ old('tipo_tutor') == $tutor->name ? 'selected' : '' }}>
                                    {{ $tutor->value }}
                                </option>
                                @endforeach
                            </select>
                        </div>

                        <hr>



                        <div class="mb-3">
                            <label for="cep" class="form-label">CEP</label>
                            <input type="text" name="cep" id="cep" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="logradouro" class="form-label">Logradouro</label>
                            <input type="text" name="logradouro" id="logradouro" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="complemento" class="form-label">Complemento</label>
                            <input type="text" name="complemento" id="complemento" class="form-control">
                        </div>

                        <div class="mb-3">
                            <label for="numero" class="form-label">Número</label>
                            <input type="text" name="numero" id="numero" class="form-control" >
                        </div>

                        <div class="mb-3">
                            <label for="bairro" class="form-label">Bairro</label>
                            <input type="text" name="bairro" id="bairro" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="cidade" class="form-label">Cidade</label>
                            <input type="text" name="cidade" id="cidade" class="form-control" required>
                        </div>

                        <div class="mb-3">
                            <label for="uf" class="form-label">UF</label>
                            <input type="text" name="uf" id="uf" class="form-control" maxlength="2" required>
                        </div>


                        <button type="submit" class="btn btn-primary">Salvar</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>

@endsection