<?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\Address\Book;
use Magento\Framework\Escaper;

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

/** @var HeroiconsOutline $heroicons */
$heroicons = $viewModels->require(HeroiconsOutline::class);
?>
<div class="block block-addresses-default my-6">
    <div class="block-title text-2xl mb-6">
            <?= $escaper->escapeHtml(__('Default Addresses')) ?>
    </div>
    <div class="grid-cols-2 block-content md:grid gap-x-4 gap-y-0 my-6">
        <?php if ($customerDefaultBillingAddressId = $block->getDefaultBilling()): ?>
            <div class="box box-address-billing card">
                <div class="text-gray-900 text-lg title-font font-medium mb-3">
                    <span><?= $escaper->escapeHtml(__('Default Billing Address')) ?></span>
                </div>
                <div class="box-content">
                    <div class="font-sen text-base text-black">
                        <?= $block->getAddressHtml($block->getAddressById($customerDefaultBillingAddressId)) ?>
                    </div>
                </div>
                <div class="box-actions">
                    <a href="<?= $escaper->escapeUrl($block->getAddressEditUrl($customerDefaultBillingAddressId)) ?>"
                       class="inline-flex items-center w-full mt-3 font-bold font-sen text-sm text-primary"
                       >
                        <span>
                            <?= $escaper->escapeHtml(__('Change Billing Address')) ?>
                        </span>
                        <?= $heroicons->arrowRightHtml('ml-2', 16, 16); ?>
                    </a>
                </div>
            </div>
        <?php else: ?>
            <div class="box box-billing-address card">
                <div class="text-gray-900 text-lg title-font font-medium mb-3">
                    <span>
                        <?= $escaper->escapeHtml(__('Default Billing Address')) ?>
                    </span>
                </div>
                <div class="box-content">
                    <p><?= $escaper->escapeHtml(__('You have no default billing address in your address book.')) ?></p>
                </div>
            </div>
        <?php endif ?>

        <?php if ($customerDefaultShippingAddressId = $block->getDefaultShipping()): ?>
            <div class="box box-address-shipping card">
                <div class="text-gray-900 text-lg title-font font-medium mb-3">
                    <span><?= $escaper->escapeHtml(__('Default Shipping Address')) ?></span>
                </div>
                <div class="box-content">
                    <div class="font-sen text-base text-black">
                        <?= $block->getAddressHtml($block->getAddressById($customerDefaultShippingAddressId)) ?>
                    </div>
                </div>
                <div class="box-actions">
                    <a href="<?= $escaper->escapeUrl($block->getAddressEditUrl($customerDefaultShippingAddressId)) ?>"
                       class="inline-flex items-center w-full mt-3 font-bold font-sen text-sm text-primary"
                    >
                        <span><?= $escaper->escapeHtml(__('Change Shipping Address')) ?></span>
                        <?= $heroicons->arrowRightHtml('ml-2', 16, 16); ?>
                    </a>
                </div>
            </div>
        <?php else: ?>
            <div class="box box-shipping-address card">
                <div class="text-gray-900 text-lg title-font font-medium mb-3">
                    <span>
                        <?= $escaper->escapeHtml(__('Default Shipping Address')) ?>
                    </span>
                </div>
                <div class="box-content">
                    <p>
                        <?= $escaper->escapeHtml(__('You have no default shipping address in your address book.')) ?>
                    </p>
                </div>
            </div>
        <?php endif ?>
    </div>
</div>
