@model ShoppingCartModel.DiscountBoxModel
@if (Model.Display)
{
<div class="coupon-box card">
    <div class="card-header">
        <h4 class="mb-0">@T("ShoppingCart.DiscountCouponCode")</h4>
    </div>
    <div class="card-body">
        <div class="hint">
            @T("ShoppingCart.DiscountCouponCode.Tooltip")
        </div>
        <div class="coupon-code">
            <input name="discountcouponcode" id="discountcouponcode" type="text" class="discount-coupon-code form-control" aria-label="@T("ShoppingCart.DiscountCouponCode.Label")" />
            <button type="submit" name="applydiscountcouponcode" id="applydiscountcouponcode"
                    class="btn btn-secondary button-2 apply-discount-coupon-code-button">
                    @T("ShoppingCart.DiscountCouponCode.Button")
                </button>
        </div>
        @foreach (var message in Model.Messages)
        {
            <div class="@(Model.IsApplied ? "message-success alert alert-success" : "message-failure alert alert-danger")">
                @message
            </div>
        }
        @foreach (var discount in Model.AppliedDiscountsWithCodes)
        {
            <div class="current-code">
                <span class="applied-discount-code">@string.Format(T("ShoppingCart.DiscountCouponCode.CurrentCode").Text, discount.CouponCode)</span>
                @*empty value (little hack for FormValueExistsAttribute)*@
                <button type="submit" name="removediscount-@discount.Id" class="remove-discount-button"></button>
            </div>
        }
    </div>    
</div>
    <script asp-location="Footer">
        $(function () {
            $('#discountcouponcode').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    $('#applydiscountcouponcode').trigger("click");
                    return false;
                }
            });
        });
    </script>
}