<?php

namespace Modules\Evaluation\MenuContextuel;

use Helpers\Outil\MenuContextuel;
use Helpers\Trad\ITrad;
use Helpers\Trad\Trad;
use PDO;
use Skeleton\Router;

class GroupOfRatersMenuContextuel extends MenuContextuel
{
    /**
     * @var array<mixed> droit
     */
    public $droit;
    
    /**
     * __construct
     *
     * @param  PDO $pdo
     * @param  Router $router
     * @param  ITrad $trad
     * @param  array<mixed> $droit
     * @return void
     */
    public function __construct(PDO $pdo, Router $router, ITrad $trad, array $droit)
    {
        parent::__construct($pdo, $router, $trad);
        $this->droit = $droit;
    }

    /**
     * @param string $id
     * @param string $mode
     * @param string $group
     * @return array<mixed>
     */
    public function generate(string $id, string $mode, string $group): array
    {
        $menuContextuel = [];

        if ($this->droit['HA_BIBQTCM']) {
            $menuContextuel['listeSecondaire'][] = [
                'lien' => $this->router->generateUri(
                    'Evaluation.GroupOfRaters.creatEdit',
                    ['id' => $id, 'mode' => $mode, 'group' => $group]
                ),
                'libelle' => $this->trad->t('Modifier'),
            ];
    
            $menuContextuel['listeSecondaire'][] = [
                'lien' => '',
                'libelle' => $this->trad->t('Supprimer'),
                'lienJs' => $this->popupConfirm(
                    false,
                    $this->router->generateUri(
                        'Evaluation.GroupOfRaters.delete',
                        ['id' => $id, 'mode' => $mode, 'group' => $group]
                    ),
                    Trad::strBuild($this->trad->t('Voulez-vous supprimer le groupe @1@ ?'), $group),
                    false,
                    'divRefresh',
                ),
            ];
        }

        return $menuContextuel;
    }
}
