<?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
 */

declare(strict_types=1);

use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\StoreConfig;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;
use Magento\Theme\Block\Html\Header\Logo;

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

/** @var StoreConfig $storeConfig */
$storeConfig = $viewModels->require(StoreConfig::class);

// Get store information
$storeName = $storeConfig->getStoreConfig('general/store_information/name') ?: 'Banyo';
$storePhone = $storeConfig->getStoreConfig('general/store_information/phone') ?: '+44 116 274 4059';
$storeStreet1 = $storeConfig->getStoreConfig('general/store_information/street_line1') ?: '64 St Barnabas Rd';
$storeCity = $storeConfig->getStoreConfig('general/store_information/city') ?: 'Leicester';
$storeRegion = $storeConfig->getStoreConfig('general/store_information/region_id') ?: 'Leicester Shire';
$storePostcode = $storeConfig->getStoreConfig('general/store_information/postcode') ?: 'LE5 4BD';
$storeCountry = $storeConfig->getStoreConfig('general/store_information/country_id') ?: 'UK';

// Get base URL
$baseUrl = $block->getUrl('');
$storeUrl = rtrim($baseUrl, '/');

// Get logo URL - fallback to hardcoded value if not available
$logoUrl = $storeUrl . '/media/logo/stores/1/NexusStoreLogo.png';

// Get short description
$storeDescription = $storeConfig->getStoreConfig('general/store_information/description') ?: 'Banyo is a leading online retailer of bathroom and kitchen products in the UK.';
?>
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "OnlineStore",
      "name": "<?= $escaper->escapeJs($storeName) ?>",
      "legalName": "Banyo UK Ltd.",
      "url": "<?= $escaper->escapeJs($storeUrl) ?>/",
      "@id": "<?= $escaper->escapeJs($storeUrl) ?>/#onlineStore",
      "logo": "<?= $escaper->escapeJs($logoUrl) ?>",
      "description": "<?= $escaper->escapeJs($storeDescription) ?>",
      "contactPoint": {
        "@type": "ContactPoint",
        "contactType": "customer support",
        "telephone": "<?= $escaper->escapeJs($storePhone) ?>",
        "availableLanguage": "English",
        "email": "info@banyo.co.uk"
      },
      "sameAs": [
        "https://www.facebook.com/BanyoUK/",
        "https://www.pinterest.co.uk/BanyoUK/",
        "https://x.com/BanyoUK",
        "https://www.youtube.com/channel/UCZ2T_VPkqY5X3rd2AZ80zeg",
        "https://www.trustpilot.com/review/www.banyo.co.uk"
      ]
    }
  ]
}
</script>
