@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Novo Processo")
@section('content')

    <form action="{{ route('admin.processos.store') }}" method="post" enctype="multipart/form-data">
        <div class="container mt-4">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow">
                        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center mb-3">
                            <h5 class="mb-0">Novo Processo</h5>
                        </div>
                        <div class="card-body">
                            @csrf
                            @include("errors.messageFlash")

                            <div class="mb-3">
                                <label for="numero" class="form-label text-bold">Número SEI: <span class="span-admin-create">*</span></label>
                                <input type="text" class="form-control @error('numero') is-invalid @enderror" name="numero" id="numero" autocomplete="off" value="{{ old('numero', 'SEI-') }}" oninput="javascript:mascaraSEI(this)" >
                                @error('numero')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                                <small class="text-secondary text-bold">Ex. SEI-2025-13000911</small>
                            </div>

                            <div class="mb-3 text-wrap">
                                <label for="descricao" class="form-label text-bold">Fale sobre este processo:</label>
                                <textarea class="form-control textarea-comments @error('descricao') is-invalid @enderror" style="height: 200px" name="descricao" id="descricao">{{ old('descricao') }}</textarea>
                                @error('informacoes')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="interessados" class="form-label text-bold">
                                    Interessados: <span class="span-admin-create">*</span>
                                </label>

                                <div id="interessados-wrapper">
                                    <div class="input-group mb-2">
                                        <input type="text" class="form-control @error('interessados') is-invalid @enderror bg-light"
                                               name="interessados[]" autocomplete="off" value="{{ Auth::user()->matriculation }}" readonly="true"/>
                                    </div>
                                </div>

                                <span class="fs-3 text-success" id="add-interessado" style="cursor: pointer;">
                                    <i class="fa-solid fa-square-plus"></i>
                                </span>

                                @error('interessados')
                                    <small class="text-danger text-bold">{{ $message }}</small>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="andamento" class="form-label text-bold">Andamento do processo: <span class="span-admin-create">*</span></label>
                                <select class="form-control @error('andamento') is-invalid @enderror" name="andamento" id="andamento">
                                    @foreach(App\Enums\StatusAndamentoProcessoEnum::cases() as $status)
                                        <option value="{{ $status->name }}" {{ old('andamento') == $status->name ? 'selected' : '' }}>
                                            {{ $status->value }}
                                        </option>
                                    @endforeach
                                </select>
                                @error('andamento')
                                    <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.processos.index'
                                ]
                            )
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

@endsection