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

<div class="card shadow-sm border-0">

    @php $headLine = "<i class='fa-solid fa-plus'></i> " . e(__('Novo projeto')); @endphp

    @php $listQuery = $filterParams ?? []; @endphp

    @include('components.buttons._headLineButtonsBackAdd', [
        'headLine' => $headLine,
        'routeBack' => 'admin.cronogramas.dashboard',
        'routeBackParams' => $listQuery,
        'nameBack' => __('Voltar'),
        'permission' => 'GERENCIADOR_DE_CRONOGRAMAS',
    ])

    <div class="card-body">
        @include('errors.messageFlash')

        <form id="cr-project-form" data-project-id="" data-msg-draft="{{ __('Rascunho salvo') }}" method="post" action="{{ route('admin.cronogramas.projetos.store') }}" class="row g-3">
            @csrf
            <div class="col-12">
                <label for="name" class="form-label">{{ __('Nome do projeto') }} <span class="text-danger">*</span></label>
                <input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name') }}" required maxlength="200">
                @error('name')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-12">
                <label for="description" class="form-label">{{ __('Descrição') }}</label>
                <textarea name="description" id="description" class="form-control @error('description') is-invalid @enderror" rows="4">{{ old('description') }}</textarea>
                @error('description')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="start_date" class="form-label">{{ __('Data de início') }}</label>
                <input type="date" name="start_date" id="start_date" class="form-control @error('start_date') is-invalid @enderror" value="{{ old('start_date') }}">
                @error('start_date')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>
            <div class="col-md-6">
                <label for="planned_end_date" class="form-label">{{ __('Data fim prevista') }}</label>
                <input type="date" name="planned_end_date" id="planned_end_date" class="form-control @error('planned_end_date') is-invalid @enderror" value="{{ old('planned_end_date') }}">
                @error('planned_end_date')<div class="invalid-feedback">{{ $message }}</div>@enderror
            </div>

            @include('components.cronogramas.project-scopes-form', [
                'scopeOptions' => $scopeOptions ?? ['structures' => collect(), 'unidades' => collect(), 'empresas' => collect()],
                'selectedScopes' => $selectedScopes ?? ['structures' => [], 'unidades' => [], 'empresas' => []],
            ])

            <div class="col-12 d-flex align-items-center gap-3">
                <button type="submit" class="btn btn-primary">{{ __('Criar projeto') }}</button>
                <span class="small text-muted" id="cr-project-autosave" aria-live="polite"></span>
            </div>
        </form>
    </div>
</div>

@endsection

@push('after-scripts')
    <script src="{{ asset('pmar/js/cronogramas/project-scopes-selector.js') }}" defer></script>
    <script src="{{ asset('pmar/js/cronogramas.js') }}"></script>
@endpush
