@inherits ViewModelTemplate<ParagraphViewModel>
@using Dynamicweb.Rendering
@using Dynamicweb.Frontend

@{
    var widgetTitle = Model?.Item?.GetString("Title") ?? Translate("Pending quotes");
    var baseUrl = string.Empty;
    var icon = "/Files/Images/Icons/file-lines.svg";
    
    if((Model?.Item?.TryGetLink("BaseLink", out var baseLinkViewModel) ?? false)) {
        baseUrl = baseLinkViewModel.Url;
        var basePageId = baseLinkViewModel?.PageId ?? 0;
        var basePage = Dynamicweb.Content.Services.Pages.GetPage(basePageId);
        var basePageIcon = basePage?.Icon;
        icon = !string.IsNullOrEmpty(basePageIcon) ? basePageIcon : icon;
    }
}

<div class="card h-100" style="--swift-content-padding: 1.25rem;">
    <div class="card-body">
        <div class="hstack flex-wrap gap-2 mb-2">
            <div class="d-grid p-2 rounded-2" style="background-color: color-mix(in srgb, var(--bs-orange) 10%, transparent);">
                <span class="icon fs-5" style="color: var(--bs-orange);">@ReadFile(icon)</span>
            </div>
            <span class="fs-7 fw-semibold text-body text-opacity-75">@(widgetTitle)</span>
        </div>
        <div data-swift-htmx-widget="@(Model?.ID)"
            hx-get="/dwapi/ecommerce/orders/search?Type=quote&PageSize=999&ShopId=@(Pageview?.Area?.EcomShopId)" 
            hx-headers='{"x-dw-template": "/Designs/Swift-v2/Paragraph/Swift-v2_Dashboard_Number/Numbers/Quotes.cshtml", "accept": "text/html", "x-dw-culture": "@(Pageview?.Area?.CultureInfo?.Name)"}'
            hx-vals='{"baseUrl": "@(baseUrl)", "ShowPricesWithVat": "@(Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat)"}'
            hx-ext="swift-auth"
            hx-trigger="tokenFetched.swift.authentication from:body"
            hx-swap="innerHTML">
            <div class="hstack gap-3 placeholder-glow py-3">
                <div class="placeholder bg-primary-subtle rounded-pill w-100" style="max-width: 35px;"></div>
            </div>
        </div>
    </div>
</div>