<?php
if (!defined('VFM_APP')) {
    return;
}

if ($gateKeeper->isUserLoggedIn()) {
    return;
}

$providers = array();

if (!empty($setUp->getConfig('oauth_google_client_id'))) {
    $providers[] = array(
        'id'     => 'google',
        'label'  => 'Google',
        'icon'   => 'bi bi-google',
        'color'  => '#DB4437',
    );
}

if (!empty($setUp->getConfig('oauth_github_client_id'))) {
    $providers[] = array(
        'id'     => 'github',
        'label'  => 'GitHub',
        'icon'   => 'bi bi-github',
        'color'  => '#333',
    );
}

if (!empty($setUp->getConfig('oauth_linkedin_client_id'))) {
    $providers[] = array(
        'id'     => 'linkedin',
        'label'  => 'LinkedIn',
        'icon'   => 'bi bi-linkedin',
        'color'  => '#0A66C2',
    );
}

if (empty($providers)) {
    return;
}
?>
<div class="sso-section mt-3">
    <div class="sso-divider mb-3 position-relative text-center">
        <span class="text-muted small"><?php echo $setUp->getString('or'); ?></span>
    </div>
    <div class="d-grid gap-2">
    <?php foreach ($providers as $p) { ?>
        <a href="vfm-admin/assets/oauth/callback.php?provider=<?php echo $p['id']; ?>"
           class="btn btn-outline-secondary sso-btn"
           style="--sso-color: <?php echo $p['color']; ?>">
            <i class="<?php echo $p['icon']; ?>"></i>
            <?php echo $setUp->getString('sign_in_with').' '. $p['label']; ?>
        </a>
    <?php } ?>
    </div>
</div>
