@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Nova Unidade de Saúde")
@section('content')

    <form action="{{ route('admin.unidadesSaude.store') }}" method="post" enctype="multipart/form-data">
        <div class="container">
            <div class="row">
                <div class="col-sm-12 col-md-6">
                    <div class="card shadow">
                        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center mb-3">
                            <h5 class="my-2">Nova Unidade de Saúde</h5>
                        </div>
                        <div class="card-body">
                            @csrf
                            @include("errors.messageFlash")

                            <div class="mb-3">
                                <label for="type" class="form-label text-bold">Pertence a: <span class="span-admin-create">*</span></label>
                                <select class="form-control" name="structure_id" id="structureID">
                                    @foreach($secretarias as $secretaria)
                                        <option value="{{ $secretaria->id }}">{{ $secretaria->name }} ({{ $secretaria->abbreviation }})</option>
                                    @endforeach
                                </select>
                            </div>

                            <hr/>
                            <div class="mb-3">
                                <label for="type" class="form-label text-bold">Tipo de unidade: <span class="span-admin-create">*</span></label>
                                <select class="form-control" name="tipoUnidadeSaude" id="tipoUnidadeSaude">
                                    <option value="CEM">CEM</option>
                                    <option value="CEREST BIG">CEREST BIG</option>
                                    <option value="Centro de Reabilitação">Centro de Reabilitação</option>
                                    <option value="Clínica">Clínica</option>
                                    <option value="Coordenação de Centro Odontológico">Coordenação de Centro Odontológico</option>
                                    <option value="COVSA">COVSA</option>
                                    <option value="CVEPI">CVEPI</option>
                                    <option value="ESF">ESF</option>
                                    <option value="HMJ">HMJ</option>
                                    <option value="Imunização">Imunização</option>
                                    <option value="NASF">Nasf</option>
                                    <option value="Programa Melhor em Casa">Programa Melhor em Casa</option>
                                    <option value="Sala Lilas">Sala Lilas</option>
                                    <option value="SAMU">SAMU</option>
                                    <option value="SPA">SPA</option>
                                    <option value="UPA">UPA</option>
                                    <option value="Vigilância Ambiental">Vigilância Ambiental</option>
                                </select>
                            </div>
                            <hr/>

                            <div class="mb-3">
                                <label for="foto" class="form-label text-bold">Foto da unidade:</label>
                                <input type="file" class="form-control" name="foto" id="foto" accept="image/jpeg,image/jpg,image/png,image/gif" />
                            </div>
                            <hr/>

                            <div class="mb-3">
                                <label for="nome" class="form-label text-bold">Nome da unidade de saúde: <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('nome') is-invalid @enderror" name="nome" id="nome" autocomplete="off" value="{{ old('nome') }}">
                                @error('nome')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="telefone" class="form-label text-bold">Telefone:</label>
                                <input type="text" class="form-control @error('telefone') is-invalid @enderror" name="telefone" id="telefone" autocomplete="off" value="{{ old('telefone') }}">
                    @error('telefone')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="email" class="form-label text-bold">Email:</label>
                                <input type="email" class="form-control @error('email') is-invalid @enderror" name="email" id="email" autocomplete="off" value="{{ old('email') }}">
                    @error('email')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>

                            <hr>

                            <div class="mb-3">
                                <label for="domicilio" class="form-label text-bold">Tipo de imóvel: <span class="span-admin-create">*</span></label>
                                <select class="form-control @error('domicilio') is-invalid @enderror" name="domicilio" id="domicilio">
                                    @foreach(App\Enums\StatusDomicilio::cases() as $status)
                                        <option value="{{ $status->name }}" {{ old('domicilio') == $status->name ? 'selected' : '' }}>
                                            {{ $status->value }}
                                        </option>
                                    @endforeach
                                </select>
    @error('domicilio')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="cep" class="form-label">CEP <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('cep') is-invalid @enderror" name="cep" id="zipCode" oninput="aplicarMascaraCEP(this)" autocomplete="off" value="{{ old('cep') }}" required>
    @error('cep')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="logradouro" class="form-label">Logradouro <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('logradouro') is-invalid @enderror" name="logradouro" id="street" autocomplete="off" value="{{ old('logradouro') }}">
                    @error('logradouro')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="numero" class="form-label">Número</label>
                                <input type="text" class="form-control @error('numero') is-invalid @enderror" name="numero" id="numero" value="{{ old('numero') }}">
                    @error('numero')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="complemento" class="form-label">Complemento</label>
                                <input type="text" class="form-control" name="complemento" id="complemento" value="{{ old('complemento') }}">
                            </div>
                            <div class="mb-3">
                                <label for="cidade" class="form-label">Cidade <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('cidade') is-invalid @enderror" name="cidade" id="city" autocomplete="off" value="{{ old('cidade') }}">
                    @error('cidade')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="bairro" class="form-label">Bairro <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('bairro') is-invalid @enderror" name="bairro" id="neighborhood" autocomplete="off" value="{{ old('bairro') }}">
                    @error('bairro')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="uf" class="form-label">UF <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('uf') is-invalid @enderror" name="uf" id="state" maxlength="2" autocomplete="off" value="{{ old('uf') }}">
                    @error('uf')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="latitude" class="form-label">Latitude </label>
                                <input type="text" class="form-control @error('latitude') is-invalid @enderror" name="latitude" id="latitude" value="{{ old('latitude') }}" autocomplete="off">
                                @error('latitude')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="longitude" class="form-label">Longitude </label>
                                <input type="text" class="form-control @error('longitude') is-invalid @enderror" name="longitude" id="longitude" value="{{ old('longitude') }}" autocomplete="off">
                                @error('longitude')
                                    <small class="text-danger">{{ $message }}</small>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="informacoes" class="form-label text-bold">Informações:</label>
                                <textarea class="form-control textarea-body @error('informacoes') is-invalid @enderror" style="height: 400px" name="informacoes" id="informacoes">{{ old('informacoes') }}</textarea>
            @error('informacoes')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="status" class="form-label text-bold">Status: <span class="span-admin-create">*</span></label>
                                <select class="form-control @error('status') is-invalid @enderror" name="status" id="status">
                                    @foreach(App\Enums\StatusEnum::cases() as $status)
                                        <option value="{{ $status->name }}">{{ $status->value }}</option>
                                    @endforeach
                                </select>
                                @error('status')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>
                            @include('components.buttons._backAndSend', [
                                    'textBack' => 'Voltar', 
                                    'textSend' => 'Cadastrar', 
                                    'routeBack' => 'admin.unidadesSaude.index'
                                ]
                            )
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

@endsection