<?php

/** @var \FiloBlu\Storelocator\Block\System\Config\Button\GmbLogin $block */
$googleApi = $block->getGoogleApi();
?>
<?php
if ($block->isGoogleMyBusinessEnabled()): ?>
    <div class="gmb-buttons-container">
        <p>Before login,enable integration and compile the following fields: App Name - Client Id - Client Secret - Redirect URI</p>
        <a style="display:inline-block; height:30px; border:1px solid #4285F4; line-height:30px; padding:0px 10px 0px 10px; background:transparent -moz-linear-gradient(center top , #4387FD, #4683EA) repeat scroll 0% 0%; color:#000; text-decoration:none; font-size:13px; font-family:Arial, sans-serif; font-weight:bold; border-radius:2px;margin-bottom:5px;" href="<?php echo $this->_googleApi->getClient()->createAuthUrl() ?>">Sign in to Google</a>
    </div>

    <div class="gmb-buttons-container">
        <?php
        if (!$googleApi->getClient()->isAccessTokenExpired()): ?>

            <p style="max-width: 300px; overflow: auto;"><?= $googleApi->getClient()->getAccessToken() ?></p>
            <p><b>Available accounts:</b></p>
            <ul>
                <?php foreach ($googleApi->getAccountList() as $account): ?>
                    <li><?= $account->getAccountName() . ' - Role: ' . $account->getRole() . ' - [' . $account->getName() . ']' ?></li>
                <?php endforeach; ?>
            </ul>
        <?php else: ?>
            <p style="color: red;">Token is expired</p>
        <?php endif; ?>
    </div>
<?php
endif;