<?php

namespace apexl\Io\modules\userDisplay\components\TwoFactorAuth;

use apexl\Config\Singleton;
use apexl\Io\includes\Hook;
use apexl\Io\includes\Routes;
use apexl\Io\modules\display\components\BasicLink;
use apexl\Io\modules\display\components\ColWrapper;
use apexl\Io\modules\display\components\ContentTitle;
use apexl\Io\modules\display\components\defaultWrapper;
use apexl\Io\modules\display\components\DisplayTable;
use apexl\Io\modules\display\components\FormComponent;
use apexl\Io\modules\display\components\genericComponents;
use apexl\Io\modules\display\components\ImageTile;
use apexl\Io\modules\display\components\MessageList;
use apexl\Io\modules\display\components\RowWrapper;
use apexl\Io\modules\display\components\SimpleButton;
use apexl\Io\modules\subscription\entities\subscriptionEntity;
use apexl\Io\modules\subscription\services\subscriptionService;
use apexl\Io\modules\user\entities\roleEntity;
use apexl\Io\modules\user\entities\userEntity;
use apexl\Io\modules\user\entities\userNotificationEntity;
use apexl\Io\modules\user\services\currentUser;
use apexl\Io\modules\user\services\Permissions;

class Totp2FaTiles
{
    public static function setupTile($data)
    {
        $components = [];

        $components[] = (new RowWrapper())
            ->addClass('justify-content-center')
            ->addComponent(
                (new ColWrapper())
                    ->addClass('border p-4 col-md-6 text-center totp-qr-box')
                    ->addComponents([
                        (new ContentTitle())
                            ->addTitle('Step 1: Scan QR Code')
                            ->addContent('Open your authenticator app and scan the image below to link your account.'),
                        (new ImageTile())
                            ->src($data['qrCode'])
                    ])
            );

        $components[] = (new RowWrapper())
            ->addClass('justify-content-center')
            ->addComponent(
                (new ColWrapper())
                    ->addClass('border p-4 col-md-6 text-center enter-6-digits-box')
                    ->addComponents([
                        (new ContentTitle())
                            ->addTitle('Step 2: 6-Digit Verification Code')
                            ->addContent('Enter the code provided by your Authenticator App after scanning the QR code above.'),
                        (new FormComponent())
                            ->src(Routes::getRoutePattern('user.display.forms.enter2faCode', ['entryType' => 'setup']))
                    ])
            );

        $components[] = (new RowWrapper())
            ->addClass('justify-content-center')
            ->addComponent(
                (new ColWrapper())
                    ->addClass('col-md-6 text-center')
                    ->addComponents([
                        (new BasicLink())
                            ->addRoute(Routes::getRoutePattern('home'))
                            ->addText("No thank you,  I'll do it later")
                            ->addClass('btn btn-secondary')
                    ])
            );
               
        
        return $components;
    }

    public static function authenticateTile()
    {
        $components = [];

        $components[] = (new RowWrapper())
            ->addClass('justify-content-center')
            ->addComponent(
                (new ColWrapper())
                    ->addClass('border p-4 col-md-6 text-center enter-6-digits-box')
                    ->addComponents([
                        (new ContentTitle())
                            ->addTitle('Enter 6-Digit Verification Code')
                            ->addContent('Please check the code provided by your Authenticator App and enter it below:'),
                        (new FormComponent())
                            ->src(Routes::getRoutePattern('user.display.forms.enter2faCode', ['entryType' => 'authenticate']))
                    ])
            );


        return $components;
    }

}