<?php

$this->layout('main', ['title' => __('My Account'), 'manual' => true]);

/** @var \App\Entity\User $user */
?>

<div class="row">
    <div class="col-md-4">
        <div class="card mb-4">
            <div class="card-body">
                <div class="media">
                    <?php
                    if ('' !== $avatarServiceUrl): ?>
                        <a class="align-self-center mr-3" href="<?=$avatarServiceUrl?>" target="_blank">
                            <img src="<?=$avatar?>" style="width: 64px; height: auto;" alt="">
                        </a>
                    <?php
                    endif; ?>
                    <div class="media-body">
                        <h2 class="card-title mt-2">
                            <?php
                            if (!empty($user->getName())): ?>
                                <?=$this->e($user->getName())?>
                            <?php
                            else: ?>
                                <?=__('My Account')?>
                            <?php
                            endif; ?>
                        </h2>
                        <h3 class="card-subtitle">
                            <?=$this->e($user->getEmail())?>
                        </h3>
                    </div>
                </div>
            </div>
            <div class="card-actions">
                <a class="btn btn-outline-primary" href="<?=$router->named('profile:edit')?>">
                    <i class="material-icons" aria-hidden="true">edit</i>
                    <?=__('Edit Profile')?>
                </a>
            </div>
        </div>
        <div class="card">
            <div class="card-header bg-primary-dark">
                <h2 class="card-title"><?=__('Roles')?></h2>
            </div>
            <ul class="list-group list-group-flush">
                <?php
                foreach ($user->getRoles() as $role): ?>
                    <li class="list-group-item"><?=$this->e($role->getName())?></li>
                <?php
                endforeach; ?>
            </ul>
        </div>
    </div>
    <div class="col-md-4 mt-4 mt-md-0">
        <div class="card">
            <div class="card-header bg-primary-dark">
                <h2 class="card-title"><?=__('Customization')?></h2>
            </div>
            <div class="card-body">
                <?=$profileView?>
            </div>
            <div class="card-actions">
                <a class="btn btn-outline-primary" href="<?=$router->named('profile:edit')?>#customization">
                    <i class="material-icons" aria-hidden="true">edit</i>
                    <?=__('Customize')?>
                </a>
            </div>
        </div>
    </div>
    <div class="col-md-4 mt-4 mt-md-0">
        <div class="card">
            <div class="card-header bg-primary-dark mb-3">
                <h2 class="card-title"><?=__('Two-Factor Authentication')?></h2>
            </div>
            <div class="card-body">
                <?php
                if (null !== $user->getTwoFactorSecret()): ?>
                    <h3 class="card-subtitle text-success"><?=__('Enabled')?></h3>
                <?php
                else: ?>
                    <h3 class="card-subtitle text-danger"><?=__('Disabled')?></h3>
                <?php
                endif; ?>

                <p class="card-text mt-3"><?=__(
                        'Two-factor authentication improves the security of your account by requiring a second one-time access code in addition to your password when you log in.'
                    )?></p>
            </div>
            <div class="card-actions">
                <?php
                if (null !== $user->getTwoFactorSecret()): ?>
                    <a class="btn btn-outline-primary" href="<?=$router->named('profile:2fa:disable')?>">
                        <i class="material-icons" aria-hidden="true">lock_open</i>
                        <?=__('Disable Two-Factor')?>
                    </a>
                <?php
                else: ?>
                    <a class="btn btn-outline-primary" href="<?=$router->named('profile:2fa:enable')?>">
                        <i class="material-icons" aria-hidden="true">lock</i>
                        <?=__('Enable Two-Factor')?>
                    </a>
                <?php
                endif; ?>
            </div>
        </div>
    </div>
</div>
