<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes 2020-present. All rights reserved.
 * This product is licensed per Magento install
 * See https://hyva.io/license
 */

use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\HeroiconsOutline;
use Magento\Customer\Block\Account\Dashboard\Address;
use Magento\Framework\Escaper;

/** @var Address $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */

/** @var HeroiconsOutline $heroicons */
$heroicons = $viewModels->require(HeroiconsOutline::class);
?>
<div class="block block-dashboard-addresses">
    <h2 class="block-title my-6 flex justify-between items-center card">
        <span class="text-2xl block"><?= $escaper->escapeHtml(__('Address Book')) ?></span>
        <a class="action edit inline-block underline"
           href="<?= $escaper->escapeUrl($block->getAddressBookUrl()) ?>"
        >
            <span><?= $escaper->escapeHtml(__('Manage Addresses')) ?></span>
        </a>
    </h2>
    <div class="block-content">
        <div class="flex flex-wrap justify-between -m-4">
            <div class="lg:w-1/2 w-full p-4">
                <div class="flex p-8 sm:flex-row flex-col h-full card rounded-md">
                    <div class="grow">
                        <h3 class="text-gray-900 text-lg title-font font-medium mb-3">
                            <span><?= $escaper->escapeHtml(__('Default Billing Address')) ?></span>
                        </h3>
                        <div class="font-inter text-base text-black">
                            <?= $block->getPrimaryBillingAddressHtml() ?>
                        </div>
                        <a
                            class="mt-3 w-full inline-flex items-center font-bold font-inter text-sm text-primary"
                            href="<?= $escaper->escapeUrl($block->getPrimaryBillingAddressEditUrl()) ?>"
                            data-ui-id="default-billing-edit-link"
                            aria-label="<?= $escaper->escapeHtmlAttr(__('Edit Address - billing default')) ?>"
                        >
                            <span><?= $escaper->escapeHtml(__('Edit Address')) ?></span>
                            <?= $heroicons->arrowRightHtml('ml-2', 16, 16, ['aria-hidden' => 'true']); ?>
                        </a>
                    </div>
                </div>
            </div>
            <div class="lg:w-1/2 w-full p-4">
                <div class="flex p-8 sm:flex-row flex-col h-full card rounded-md">
                    <div class="grow">
                        <h3 class="text-gray-900 text-lg title-font font-medium mb-3">
                            <span><?= $escaper->escapeHtml(__('Default Shipping Address')) ?></span>
                        </h3>
                        <div class="font-inter text-base text-black">
                            <?= $block->getPrimaryShippingAddressHtml() ?>
                        </div>
                        <a
                            class="mt-3 w-full inline-flex items-center font-bold font-inter text-sm text-primary"
                            href="<?= $escaper->escapeUrl($block->getPrimaryShippingAddressEditUrl()) ?>"
                            data-ui-id="default-billing-edit-link"
                            aria-label="<?= $escaper->escapeHtmlAttr(__('Edit Address - shipping default')) ?>"
                        >
                            <span><?= $escaper->escapeHtml(__('Edit Address')) ?></span>
                            <?= $heroicons->arrowRightHtml('ml-2', 16, 16, ['aria-hidden' => 'true']); ?>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
