<?php

declare(strict_types=1);

namespace App\ApiResource;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use App\State\WorkHourBulkUpsertProcessor;

#[ApiResource(
    operations: [
        new Post(
            uriTemplate: '/work-hours/bulk-upsert',
            security: "is_granted('ROLE_USER')",
            output: WorkHourBulkUpsertResult::class,
            processor: WorkHourBulkUpsertProcessor::class
        ),
    ]
)]
final class WorkHourBulkUpsert
{
    public string $workDate = '';

    /**
     * @var list<array{
     *     employeeId:int,
     *     morningFrom?:?string,
     *     morningTo?:?string,
     *     afternoonFrom?:?string,
     *     afternoonTo?:?string,
     *     eveningFrom?:?string,
     *     eveningTo?:?string,
     *     isPresentMorning?:bool,
     *     isPresentAfternoon?:bool,
     *     dayHoursMinutes?:?int,
     *     nightHoursMinutes?:?int,
     *     hasBreakfast?:bool,
     *     hasLunch?:bool,
     *     hasOvernight?:bool,
     *     delete?:bool
     * }>
     *
     * Le flag `delete` (défaut false) autorise la suppression d'une ligne existante
     * quand l'entrée est vide. Sans lui, une entrée vide sur une ligne existante est
     * un no-op (garde anti-perte de données contre les grilles périmées).
     */
    public array $entries = [];
}
