<?php

namespace App\Controller\Admin;


use App\Entity\CollectifData;
use App\Entity\Common\TaxRate;
use App\Entity\Configuration;
use App\Entity\IndividualData;
use App\Entity\Site\Page;
use App\Entity\Territory;
use App\Entity\Thematic;
use App\Entity\User\GroupUser;
use App\Entity\User\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Controller\Dashboard\DashboardController as SovDashboardController;

class DashboardController extends SovDashboardController
{
    const ROLE_ADMIN = "ROLE_ADMIN";
    const ROLE_SUPER_ADMIN = "ROLE_SUPER_ADMIN";

    private $adminUrlGenerator;

    public function __construct(AdminUrlGenerator $adminUrlGenerator)
    {
        $this->adminUrlGenerator = $adminUrlGenerator;
    }

    public function configureMenuItems(): iterable
    {

        $urlCreate = $this->adminUrlGenerator
            ->setController(CollectifDataCrudController::class)
            ->setAction('new')
            ->generateUrl();

        yield MenuItem::linkToDashboard('dashboard', 'circle');
        yield MenuItem::subMenu('account', 'user')
            ->setSubItems(
                [
                    MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
                    MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
                ]
            );
        yield MenuItem::subMenu('user', 'user')
            ->setPermission(self::ROLE_ADMIN)
            ->setSubItems(
                [
                    MenuItem::linkToCrud('user_index', '', User::class),
                ]
            );
        yield MenuItem::subMenu('data_individual', 'user')
            ->setPermission(self::ROLE_ADMIN)
            ->setSubItems(
                [
                    MenuItem::linkToCrud('data_individual_validate', '', IndividualData::class),
                    MenuItem::linkToCrud('data_individual_waiting', '', IndividualData::class),
                ]
            );
        yield MenuItem::subMenu('data_collectif', 'user')
            ->setPermission(self::ROLE_ADMIN)
            ->setSubItems(
                [
                    MenuItem::linkToCrud('data_collectif_validate', '', CollectifData::class),
                    MenuItem::linkToCrud('data_collectif_waiting', '', CollectifData::class),
                ]
            );
        yield MenuItem::linkToCrud('thematic', 'copy', Thematic::class)
            ->setPermission(self::ROLE_ADMIN);
        yield MenuItem::linkToCrud('territory', 'copy', Territory::class)
            ->setPermission(self::ROLE_SUPER_ADMIN);
        yield MenuItem::linkToCrud('configuration', 'copy', Configuration::class)
            ->setPermission(self::ROLE_SUPER_ADMIN);
        yield MenuItem::linkToCrud('page', 'copy', Page::class)
            ->setPermission(self::ROLE_ADMIN);
    }
}
