ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Views/Checkout/BillingAddress.cshtml
@model CheckoutBillingAddressModel
@inject IPageHeadBuilder pagebuilder
@{
    Layout = "_ColumnsOneClean";

    //title
    pagebuilder.AddTitleParts(T("PageTitle.Checkout").Text);
}
<div class="page checkout-page billing-address-page">
    @await Component.InvokeAsync("CheckoutProgress", new { step = CheckoutProgressStep.Address })
    <h2 class="generalTitle text-sm-center ">@T("Checkout.BillingAddress")</h2>
    <div class="checkout-data">
        <form asp-route="CheckoutBillingAddress" method="post">
            <div class="billing-addresses">
                @await Component.InvokeAsync("Widget", new { widgetZone = "checkout_billing_address_top" })
                @if (Model.ShipToSameAddressAllowed)
                {
                    <div class="ship-to-same-address">
                        <label class="custom-control custom-checkbox">
                            <input asp-for="ShipToSameAddress" class="custom-control-input" />
                            <span class="custom-control-label"></span>
                            <span class="custom-control-description">@T("Checkout.ShipToSameAddress")</span>
                        </label>
                    </div>

                }
                @if (Model.ExistingAddresses.Any())
                {
                    <div class="select-billing-address">
                        <h5><strong>@T("Checkout.SelectBillingAddress")</strong></h5>
                        <div class="row">
                            @foreach (var item in Model.ExistingAddresses)
                            {
                                <div class="col-12 col-sm-6 col-md-6 col-lg-4">
                                    <div class="card address-item">
                                        <h5 class="card-header">
                                            @item.FirstName @item.LastName
                                        </h5>
                                        <div class="card-body">
                                            <ul class="address-box pl-0">
                                                <li class="email">
                                                    <label>@T("Address.Fields.Email"):</label>
                                                    <span>@item.Email</span>
                                                </li>
                                                @if (item.PhoneEnabled)
                                                {
                                                    <li class="phone">
                                                        <label>@T("Address.Fields.PhoneNumber"):</label>
                                                        <span>@item.PhoneNumber</span>
                                                    </li>
                                                }
                                                @if (item.FaxEnabled)
                                                {
                                                    <li class="fax">
                                                        <label>@T("Address.Fields.FaxNumber"):</label>
                                                        <span>@item.FaxNumber</span>
                                                    </li>
                                                }
                                                @if (item.CompanyEnabled && !String.IsNullOrEmpty(item.Company))
                                                {
                                                    <li class="company">
                                                        @item.Company
                                                    </li>
                                                }
                                                @if (item.VatNumberEnabled && !String.IsNullOrEmpty(item.VatNumber))
                                                {
                                                    <li class="vatnumber">
                                                        @item.VatNumber
                                                    </li>
                                                }
                                                @if (item.StreetAddressEnabled)
                                                {
                                                    <li class="address1">
                                                        @item.Address1
                                                    </li>
                                                }
                                                @if (item.StreetAddress2Enabled && !String.IsNullOrEmpty(item.Address2))
                                                {
                                                    <li class="address2">
                                                        @item.Address2
                                                    </li>
                                                }
                                                @if (item.CityEnabled || item.StateProvinceEnabled || item.ZipPostalCodeEnabled)
                                                {
                                                    <li class="city-state-zip">
                                                        @if (item.CityEnabled)
                                                        {
                                                            @item.City
                                                        }
                                                        @if (item.CityEnabled && (item.StateProvinceEnabled || item.ZipPostalCodeEnabled))
                                                        {
                                                            <text>,</text>
                                                        }
                                                        @if (item.StateProvinceEnabled)
                                                        {
                                                            @item.StateProvinceName
                                                        }
                                                        @if (item.ZipPostalCodeEnabled)
                                                        {
                                                            @item.ZipPostalCode
                                                        }
                                                    </li>
                                                }
                                                @if (item.CountryEnabled && !String.IsNullOrEmpty(item.CountryName))
                                                {
                                                    <li class="country">
                                                        @item.CountryName
                                                    </li>
                                                }
                                                @if (!String.IsNullOrEmpty(item.FormattedCustomAddressAttributes))
                                                {
                                                    <li class="custom-attributes-view">
                                                        @Html.Raw(item.FormattedCustomAddressAttributes)
                                                    </li>
                                                }
                                            </ul>
                                        </div>
                                        <div class="card-footer select-button">
                                            <input type="button" value="@T("Checkout.BillToThisAddress")" class="btn btn-secondary select-billing-address-button" onclick="selectBillingAddress@(item.Id)()" />
                                            <script asp-location="Footer">
                                                        function selectBillingAddress@(item.Id)() {
                                                            if ($('#@Html.IdFor(model => model.ShipToSameAddress)').is(':checked')) {
                                                                setLocation('@Html.Raw(Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id, shipToSameAddress = "true"}))');
                                                            } else {
                                                                setLocation('@Url.RouteUrl("CheckoutSelectBillingAddress", new {addressId = item.Id })');
                                                            }
                                                        }
                                            </script>
                                        </div>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>
                }
                @await Component.InvokeAsync("Widget", new { widgetZone = "checkout_billing_address_middle" })
                <div class="new-billing-address">
                    @if (Model.ExistingAddresses.Any())
                    {
                        <h5><strong>@T("Checkout.OrEnterNewAddress")</strong></h5>
                    }
                    else
                    {
                        <h5>
                            <strong>@T("Checkout.EnterBillingAddress")</strong>
                        </h5>
                    }
                    <div class="enter-address">
                        <div asp-validation-summary="ModelOnly" class="message-error"></div>
                        @{
                            var dataDictAddress = new ViewDataDictionary(ViewData);
                            dataDictAddress.TemplateInfo.HtmlFieldPrefix = "NewAddress";
                            <partial name="_CreateOrUpdateAddress" model="Model.NewAddress" view-data="dataDictAddress" />
                        }
                    </div>
                </div>
                @await Component.InvokeAsync("Widget", new { widgetZone = "checkout_billing_address_bottom" })
            </div>
            <div class="col-12 buttons mt-1 mb-1 pl-0">
                <input type="submit" name="nextstep" value="@T("Checkout.NextButton")" class="btn btn-info new-address-next-step-button" />
            </div>
        </form>
        <div class="order-summary">
            <h2 class="generalTitle"><strong>@T("Checkout.OrderSummary")</strong></h2>
            @await Component.InvokeAsync("OrderSummary")
        </div>
    </div>
</div>
