<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_SocialLogin
 * @copyright   Copyright (c) Mageplaza (http://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

$availableSocials = $block->getAvailableSocials();

function iconName($social){

	switch ($social){
		case "facebook":
			$class = "facebook-f";
			break;

		default:
			$class = $social;

	}
	return $class;


}

if ($block->canShow() && sizeof($availableSocials)):
    ?>
    <div class="block social-login-authentication-channel account-social-login">
        <div class="block-content">
            <?php foreach ($availableSocials as $key => $social): ?>
                <div class="social-btn social-btn-actions-toolbar <?= $key ?>-login">
                    <a class="btn btn-block btn-social btn-<?= $block->getBtnKey($key) ?>"
                       data-mage-init='{"socialProvider": {"url": "<?php echo $social['login_url'] ?>", "label": "<?php echo __('Login By %1', $social['label']) ?>"}}'>
                        <span><i class="fab fa-<?= iconName($key) ?>"></i></span>
                        <?php echo __('Sign in with %1', $social['label']) ?>
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
<?php endif; ?>