<commit_before>@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel
@{
    Layout = "_LayoutPos";
    var anyInventoryItems = Model.Items.Any(item => item.Inventory.HasValue);
}

<div class="container d-flex h-100">
    <div class="justify-content-center align-self-center text-center mx-auto px-2 py-3 w-100 m-auto">
        <partial name="_StatusMessage" />

        <h1 class="mb-4">@Model.Title</h1>
        @if (!string.IsNullOrEmpty(Model.Description))
        {
            <div class="row">
                <div class="overflow-hidden col-12">@Safe.Raw(Model.Description)</div>
            </div>
        }
        <div class="row  card-deck my-3 mx-auto">
            @for (int x = 0; x < Model.Items.Length; x++)
            {
                var item = Model.Items[x];
                var buttonText = (string.IsNullOrEmpty(item.BuyButtonText) ? 
                    item.Custom?
                    Model.CustomButtonText :
                    Model.ButtonText
                        : item.BuyButtonText)
                    .Replace("{0}",item.Price.Formatted)
                    .Replace("{Price}",item.Price.Formatted);
                <div class="card my-2" data-id="@x">
                    @if (!String.IsNullOrWhiteSpace(item.Image))
                    {
                        <img class="card-img-top" src="@item.Image" alt="Card image cap" asp-append-version="true">
                    }
                    <div class="card-body pb-0">
                        <h5 class="card-title">@item.Title</h5>
                        @if (!String.IsNullOrWhiteSpace(item.Description))
                        {
                            <p class="card-text">@Safe.Raw(item.Description)</p>
                        }
                    </div>
                    <div class="card-footer bg-transparent border-0">
                        @if (!item.Inventory.HasValue || item.Inventory.Value > 0)
                        {
                            <div class="w-100">
                                @if (item.Custom)
                                {
                                    <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
                                        <input type="hidden" name="choicekey" value="@item.Id"/>
                                        <div class="input-group">
                                            <div class="input-group-prepend">
                                                <span class="input-group-text">@Model.CurrencySymbol</span>
                                            </div>
                                            <input class="form-control" type="number" min="@item.Price.Value" step="@Model.Step" name="amount"
                                                   value="@item.Price.Value" placeholder="Amount" style="flex: 2 0 80px;">
                                            <div class="input-group-append flex-fill">
                                                <button class="btn btn-primary text-nowrap flex-fill" type="submit">
                                                    @(item.BuyButtonText ?? Model.CustomButtonText)
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                }
                                else
                                {
                                    <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false">
                                        <button type="submit" name="choiceKey" class="js-add-cart btn btn-primary" value="@item.Id">
                                            @buttonText
                                        </button>
                                    </form>
                                }
                            </div>
                        }
                        @if (item.Inventory.HasValue)
                        {

                            <div class="w-100 pt-2 text-center text-muted">
                                @if (item.Inventory > 0)
                                {
                                    <span>@item.Inventory left</span>
                                }
                                else
                                {
                                    <span>Sold out</span>
                                }
                            </div>
                        }else if (anyInventoryItems)
                        {
                            <div class="w-100 pt-2">&nbsp;</div>
                        }
                    </div>
                </div>
            }
            @if (Model.ShowCustomAmount)
            {
                <div class="card my-2">
                    <div class="card-body my-auto pb-0">
                        <h5 class="card-title">Custom Amount</h5>
                        <p class="card-text">Create invoice to pay custom amount</p>

                    </div>
                    <div class="card-footer bg-transparent border-0">
                        <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">@Model.CurrencySymbol</span>
                                </div>
                                <input class="form-control" type="number" min="0" step="@Model.Step" name="amount" placeholder="Amount">
                                <div class="input-group-append">
                                    <button class="btn btn-primary" type="submit">@Model.CustomButtonText</button>
                                </div>
                            </div>
                        </form>
                        @if (anyInventoryItems)
                        {
                            <div class="w-100 pt-2">&nbsp;</div>
                        }
                    </div>
                </div>
            }
        </div>
    </div>
</div><commit_msg>Unify POS app card markup<commit_after>@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel
@{
    Layout = "_LayoutPos";
    var anyInventoryItems = Model.Items.Any(item => item.Inventory.HasValue);
}

<div class="container d-flex h-100">
    <div class="justify-content-center align-self-center text-center mx-auto px-2 py-3 w-100 m-auto">
        <partial name="_StatusMessage" />

        <h1 class="mb-4">@Model.Title</h1>
        @if (!string.IsNullOrEmpty(Model.Description))
        {
            <div class="row">
                <div class="overflow-hidden col-12">@Safe.Raw(Model.Description)</div>
            </div>
        }
        <div class="row  card-deck my-3 mx-auto">
            @for (int x = 0; x < Model.Items.Length; x++)
            {
                var item = Model.Items[x];
                var buttonText = (string.IsNullOrEmpty(item.BuyButtonText) ?
                    item.Custom?
                    Model.CustomButtonText :
                    Model.ButtonText
                        : item.BuyButtonText)
                    .Replace("{0}",item.Price.Formatted)
                    .Replace("{Price}",item.Price.Formatted);
                <div class="card my-2" data-id="@x">
                    @if (!String.IsNullOrWhiteSpace(item.Image))
                    {
                        <img class="card-img-top" src="@item.Image" alt="Card image cap" asp-append-version="true">
                    }
                    @{CardBody(item.Title, item.Description);}
                    <div class="card-footer bg-transparent border-0">
                        @if (!item.Inventory.HasValue || item.Inventory.Value > 0)
                        {
                            @if (item.Custom)
                                {
                                    <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
                                        <input type="hidden" name="choicekey" value="@item.Id"/>
                                        @{PayFormInputContent(item.BuyButtonText ?? Model.CustomButtonText, item.Price.Value, item.Price.Value);}
                                    </form>
                                }
                                else
                                {
                                    <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false">
                                        <button type="submit" name="choiceKey" class="js-add-cart btn btn-primary" value="@item.Id">
                                            @buttonText
                                        </button>
                                    </form>
                                }
                        }
                        @if (item.Inventory.HasValue)
                        {

                            <div class="w-100 pt-2 text-center text-muted">
                                @if (item.Inventory > 0)
                                {
                                    <span>@item.Inventory left</span>
                                }
                                else
                                {
                                    <span>Sold out</span>
                                }
                            </div>
                        }
                        else if (anyInventoryItems)
                        {
                            <div class="w-100 pt-2">&nbsp;</div>
                        }
                    </div>
                </div>
            }
            @if (Model.ShowCustomAmount)
            {
                <div class="card my-2">
                    @{CardBody("Custom Amount", "Create invoice to pay custom amount");}
                    <div class="card-footer bg-transparent border-0">
                        <form method="post" asp-controller="AppsPublic" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
                            @{PayFormInputContent(Model.CustomButtonText);}
                        </form>
                        @if (anyInventoryItems)
                        {
                            <div class="w-100 pt-2">&nbsp;</div>
                        }
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@functions {
    private void PayFormInputContent(string buttonText, decimal? minPriceValue = null, decimal? priceValue = null)
    {
        <div class="input-group">
            <div class="input-group-prepend">
                <span class="input-group-text">@Model.CurrencySymbol</span>
            </div>
            <input class="form-control" type="number" min="@(minPriceValue ?? 0)" step="@Model.Step" name="amount" placeholder="Amount" value="@priceValue">
            <div class="input-group-append">
               <button class="btn btn-primary text-nowrap" type="submit">
                    @buttonText
                </button>
            </div>
        </div>
    }

    private void CardBody(string title, string description)
    {
        <div class="card-body my-auto pb-0">
            <h5 class="card-title">@title</h5>
            @if (!String.IsNullOrWhiteSpace(description))
            {
                <p class="card-text">@Safe.Raw(description)</p>
            }
        </div>
    }
}
{'fraction_non_alphanumeric': 0.11602023608768972, 'fraction_numerical': 0.007251264755480607, 'mean_word_length': 0.9894330761489433, 'pattern_counts': {'":': 0, '<': 140, '<?xml version=': 0, '>': 144, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 51, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1367553', 'n_tokens_mistral': 2934, 'n_tokens_neox': 2747, 'n_words': 476}