<?php

declare(strict_types=1);

namespace PpPhp\Core\Designer;

use PpPhp\Core\Designer\Templates\ListPageTemplate;
use PpPhp\Core\Designer\Templates\AddPageTemplate;
use PpPhp\Core\Designer\Templates\EditPageTemplate;
use PpPhp\Core\Designer\Templates\ViewPageTemplate;
use PpPhp\Core\Designer\Templates\PrintPageTemplate;
use PpPhp\Core\Designer\Templates\ImportPageTemplate;
use PpPhp\Core\Designer\Templates\ExportPageTemplate;
use PpPhp\Core\Designer\Templates\DashboardPageTemplate;
use PpPhp\Core\Designer\Templates\LoginPageTemplate;
use PpPhp\Core\Designer\Templates\RegisterPageTemplate;
use PpPhp\Core\Designer\Templates\ProfilePageTemplate;
use PpPhp\Core\Designer\Templates\ChangePasswordPageTemplate;
use PpPhp\Core\Designer\Templates\ResetPasswordPageTemplate;
use PpPhp\Core\Designer\Templates\ForgotPasswordPageTemplate;
use PpPhp\Core\Designer\Templates\TwoFactorPageTemplate;

class TemplateFactory
{
    public static function make(
        string $table,
        string $pageType,
        array $fields = [],
        array $options = []
    ): ?DesignerTemplate {
        return match (true) {
            $pageType === 'login' => new LoginPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'register' => new RegisterPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'profile' => new ProfilePageTemplate($table, $pageType, $fields, $options),
            $pageType === 'change_password' => new ChangePasswordPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'reset_password' => new ResetPasswordPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'forgot_password' => new ForgotPasswordPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'two_factor' => new TwoFactorPageTemplate($table, $pageType, $fields, $options),
            $pageType === 'list' => new ListPageTemplate($table, $pageType, $fields),
            $pageType === 'add' => new AddPageTemplate($table, $pageType, $fields),
            $pageType === 'edit' => new EditPageTemplate($table, $pageType, $fields),
            $pageType === 'view' => new ViewPageTemplate($table, $pageType, $fields),
            $pageType === 'print' => new PrintPageTemplate($table, $pageType, $fields),
            $pageType === 'import' => new ImportPageTemplate($table, $pageType, $fields),
            $pageType === 'export' => new ExportPageTemplate($table, $pageType, $fields),

            str_starts_with($pageType, 'dashboard') || $pageType === 'central_dashboard' => new DashboardPageTemplate($table, $pageType, $fields),

            default => null,
        };
    }
}
