<x-ui.layout.page :title="__('performance.cycles')" page-icon="fe fe-repeat">
    @can('performance.create')
        <div class="card mb-3"><div class="card-body">
            <form method="POST" action="{{ route('hr.performance.cycles.store') }}" class="row g-3">@csrf
                <div class="col-md-4"><x-ui.form.input name="name" :label="__('performance.fields.name')" required /></div>
                <div class="col-md-3"><x-ui.form.input name="starts_at" type="date" :label="__('performance.fields.starts_at')" required /></div>
                <div class="col-md-3"><x-ui.form.input name="ends_at" type="date" :label="__('performance.fields.ends_at')" required /></div>
                <div class="col-md-2"><x-ui.form.select name="status" :label="__('performance.fields.status')" :options="['draft'=>__('performance.status.draft'),'active'=>__('performance.status.active'),'closed'=>__('performance.status.closed')]" required /></div>
                <div class="col-12"><x-ui.buttons.primary type="submit">{{ __('common.save') }}</x-ui.buttons.primary></div>
            </form>
        </div></div>
    @endcan
    <x-ui.operational.index-shell>
        <x-ui.table.table :columns="[['label'=>__('performance.fields.name')],['label'=>__('performance.fields.starts_at')],['label'=>__('performance.fields.ends_at')],['label'=>__('performance.fields.status')],['label'=>__('common.actions'),'align'=>'end']]">
            @forelse($cycles as $cycle)
                <x-ui.table.row><td>{{ $cycle->name }}</td><td>{{ $cycle->starts_at?->format('Y-m-d') }}</td><td>{{ $cycle->ends_at?->format('Y-m-d') }}</td><td>{{ __('performance.status.'.$cycle->status) }}</td>
                    <td class="text-end"><x-ui.action-modal.trigger :entity="__('performance.cycles')" :record="$cycle->name" :delete-url="auth()->user()?->can('performance.manage') ? route('hr.performance.cycles.destroy', $cycle) : null" /></td></x-ui.table.row>
            @empty<x-ui.table.row><td colspan="5"><x-ui.operational.empty-state :title="__('performance.empty_cycles')" /></td></x-ui.table.row>@endforelse
        </x-ui.table.table>
        <x-slot:pagination>{{ $cycles->links() }}</x-slot:pagination>
    </x-ui.operational.index-shell>
    <x-ui.action-modal />
</x-ui.layout.page>
