<?php

namespace App\Controller;

use App\Container;
use App\Router\Request\IRequest;
use App\Router\Response\Response;
use Shared\Attributes\Route;
use Twig\Environment;
use Data\Core\Preferences;
use Shared\Log;

class UserController extends BaseController
{

    private Environment $twig;
    protected Preferences $preference;

    public function __construct()
    {
       session_start();
       $this->preference = new Preferences();
    }


    #[Route(path: '/', name: 'index', methods: ['GET'])]
    public function index(): Response
    {
        return $this->render('./page/index.html',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }

    #[Route(path: '/home', name: 'home', methods: ['GET'])]
    public function home(): Response
    {
        return $this->render('./page/home.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }


    #[Route(path: '/settings', name: 'settings', methods: ['GET'])]
    public function settings(IRequest $req): Response
    {
        return $this->render('./page/settings.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }

    #[Route(path: '/profile', name: 'profile', methods: ['GET'])]
    public function profile(): Response
    {
        return $this->render('./page/profile.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }

    #[Route(path: '/preferences', name: 'preferences', methods: ['POST'])]
    public function preferences(string $theme, IRequest $req): Response
    {
        /*TODO*/

        //  VALIDER LES DONNEES
        $this->preference->majCookie($theme);
       
        return $this->render('./page/settings.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }

    #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])]
    public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response
    {
        
       
        return $this->render('./page/settings.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => $prenom,
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }

    #[Route(path: '/mdp', name: 'mdp', methods: ['POST'])]
    public function mdp(string $ancienMotDePasse,string $nouveauMotDePasse,string $confirmerMotDePasse, IRequest $req): Response
    {
        
       // CONFIRMER LES DONNESS !!!!! IMPORTANT

        return $this->render('./page/settings.html.twig',[
            'css' => $this->preference->getCookie(),
            'pp' => "test2",
            'user' => "Doe",
            'role' => "Athlète",
            'friendship' => [],
            'analyzes' => [],
            'mails' => [],
            'users' => [],
            'infoUser' => [],
            'exos' => [],
            'member' => []
        ]);
    }
    
}