@model CheckGiftCardBalanceModel

@using Nop.Core
@using Nop.Services.Customers
@inject IWorkContext workContext
@inject ICustomerService customerService

@{
    var isRegisterCustomer = await customerService.IsRegisteredAsync(await workContext.GetCurrentCustomerAsync());
    Layout = isRegisterCustomer ? "_ColumnsTwo" : "_ColumnsOne";

    //title
    NopHtml.AddTitleParts(T("PageTitle.CheckGiftCardBalance").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-account-page");
}

@if (isRegisterCustomer)
{
    @section left
    {
        @await Component.InvokeAsync(typeof(CustomerNavigationViewComponent), new { selectedTabId = CustomerNavigationEnum.CheckGiftCardBalance })
    }
}

<div class="page account-page check-gift-card-balance-page">
    <div class="page-title">
        @if (isRegisterCustomer)
        {
            <h1>@T("Account.MyAccount") - @T("PageTitle.CheckGiftCardBalance")</h1>
        }
        else
        {
            <h1>@T("PageTitle.CheckGiftCardBalance")</h1>
        }
    </div>
    <div class="page-body">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerCheckGiftCardBalanceTop, additionalData = Model })
        @if (!string.IsNullOrEmpty(Model.Message))
        {
            <div class="message-error">
                @Model.Message
            </div>
        }
        @if (!string.IsNullOrEmpty(Model.Result))
        {
            <div class="result">
                @string.Format(T("ShoppingCart.Totals.GiftCardInfo.Remaining").Text, @Model.Result)
            </div>
        }
        <form asp-controller="Customer" asp-action="CheckGiftCardBalance" method="post">
            <div asp-validation-summary="ModelOnly" class="message-error"></div>
            <div class="fieldset">
                <div class="form-fields">
                    <div class="inputs">
                        <label asp-for="GiftCardCode" asp-postfix=":"></label>
                        <input asp-for="GiftCardCode" placeholder="@T("ShoppingCart.GiftCardCouponCode.Tooltip")" class="fullname" />
                        <nop-required />
                        <span asp-validation-for="GiftCardCode"></span>
                    </div>
                    <nop-captcha />
                </div>
            </div>
            <div class="buttons">
                <button type="submit" name="checkbalancegiftcard" id="checkbalancegiftcard" class="button-1 check-gift-card-balance-button">@T("CheckGiftCard.GiftCardCouponCode.Button")</button>
                <script asp-location="Footer">
                    $(function() {
                        $('#giftcardcouponcode').keydown(function (event) {
                            if (event.keyCode == 13) {
                                $('#checkbalancegiftcard').trigger('click');
                                return false;
                            }
                        });
                    });
                </script>
            </div>
        </form>
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerCheckGiftCardBalanceBottom, additionalData = Model })
    </div>
</div>