<?php
/**
 * This file is part of the Flurrybox EnhancedPrivacy package.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Flurrybox EnhancedPrivacy
 * to newer versions in the future.
 *
 * @copyright Copyright (c) 2018 Flurrybox, Ltd. (https://flurrybox.com/)
 * @license   GNU General Public License ("GPL") v3.0
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/** @var \Flurrybox\EnhancedPrivacy\Block\Customer\Privacy\Settings $block */
?>
<div class="block block-dashboard-info">
    <div class="block-title">
        <strong><?= __('Information'); ?></strong>
    </div>
    <div class="block-content">
        <p><?= $block->escapeHtml($block->getPrivacyHelper()->getInformation()); ?></p>
    </div>
</div>
<?php if ($block->getPrivacyHelper()->isAccountExportEnabled()) : ?>
<div class="block block-dashboard-info">
    <div class="block-title">
        <strong><?= $block->getPrivacyHelper()->getExportTitle(); ?></strong>
    </div>
    <div class="block-content">
        <p><?= $block->escapeHtml($block->getPrivacyHelper()->getAccountExportInformation()); ?></p>
        <div class="actions-toolbar">
            <div class="primary">
                <button type="button" class="action submit primary" id="exportData">
                    <span><?= $block->getPrivacyHelper()->getExportButtonText(); ?></span>
                </button>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>
<?php if ($block->getPrivacyHelper()->isAccountDeletionEnabled()) : ?>
<div class="block block-dashboard-info">
    <div class="block-title">
        <strong><?= $block->getPrivacyHelper()->getDeletionTitle(); ?></strong>
    </div>
    <div class="block-content">
        <?php if ($block->isAccountToBeDeleted()): ?>
        <p><?= $block->escapeHtml($block->getPrivacyHelper()->getAccountDeletionInfo()); ?></p>
        <strong><?= __('Attention!'); ?></strong>
        <p><?= __('Your account will be deleted soon. You can undo this action.'); ?></p>
        <div class="actions-toolbar">
            <div class="primary">
                <button type="button" class="action submit primary" id="undoDeletion">
                    <span><?= __('Undo deletion'); ?></span>
                </button>
            </div>
        </div>
        <?php else: ?>
        <p><?= $block->escapeHtml($block->getPrivacyHelper()->getAccountDeletionInfo()); ?></p>
        <?php if ($block->shouldAnonymize()): ?>
        <p><?= $block->escapeHtml($block->getPrivacyHelper()->getAnonymizationMessage()); ?></p>
        <?php endif; ?>
        <div class="actions-toolbar">
            <div class="primary">
                <button type="button" class="button-red action submit primary" id="deleteData">
                    <span><?= $block->getPrivacyHelper()->getDeletionButtonText(); ?></span>
                </button>
            </div>
        </div>
        <?php endif; ?>
    </div>
</div>
<?php endif; ?>
<script type="text/javascript">
    require(['jquery'], function ($) {
        'use strict';

        <?php if ($block->getPrivacyHelper()->isAccountExportEnabled()) : ?>
        $('#exportData').click(function () {
            location.href = '<?= $block->getExportPageUrl(); ?>';
        });
        <?php endif; ?>

        <?php if ($block->getPrivacyHelper()->isAccountDeletionEnabled()) : ?>
        <?php if ($block->isAccountToBeDeleted()): ?>
        $('#undoDeletion').click(function () {
            location.href = '<?= $block->getUndoDeletePageUrl(); ?>';
        });
        <?php else: ?>
        $('#deleteData').click(function () {
            location.href = '<?= $block->getDeletePageUrl(); ?>';
        });
        <?php endif; ?>
        <?php endif; ?>
    });
</script>
