@using Nop.Core.Domain.Tax;
@model TaxSettingsModel

<div class="card-body">
    <div class="form-group row">
        <div class="col-md-3">
            <nop-override-store-checkbox asp-for="TaxBasedOn_OverrideForStore" asp-input="TaxBasedOn" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
            <nop-label asp-for="TaxBasedOn" />
        </div>
        <div class="col-md-9">
            <nop-select asp-for="TaxBasedOn" asp-items="Model.TaxBasedOnValues" />
            <span asp-validation-for="TaxBasedOn"></span>
        </div>
    </div>
    <div class="form-group row" id="automaticallyDetectCountry-group">
        <div class="col-md-3">
            <nop-override-store-checkbox asp-for="AutomaticallyDetectCountry_OverrideForStore" asp-input="AutomaticallyDetectCountry" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
            <nop-label asp-for="AutomaticallyDetectCountry" />
        </div>
        <div class="col-md-9">
            <nop-editor asp-for="AutomaticallyDetectCountry" />
            <span asp-validation-for="AutomaticallyDetectCountry"></span>
        </div>
    </div>
    <div class="form-group row advanced-setting">
        <div class="col-md-3">
            <nop-override-store-checkbox asp-for="DefaultTaxCategoryId_OverrideForStore" asp-input="DefaultTaxCategoryId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
            <nop-label asp-for="DefaultTaxCategoryId" />
        </div>
        <div class="col-md-9">
            <nop-select asp-for="DefaultTaxCategoryId" asp-items="Model.TaxCategories" />
            <span asp-validation-for="DefaultTaxCategoryId"></span>
        </div>
    </div>
    <div class="form-group row advanced-setting">
        <div class="col-md-3">
            <nop-override-store-checkbox asp-for="TaxBasedOnPickupPointAddress_OverrideForStore" asp-input="TaxBasedOnPickupPointAddress" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
            <nop-label asp-for="TaxBasedOnPickupPointAddress" />
        </div>
        <div class="col-md-9">
            <nop-editor asp-for="TaxBasedOnPickupPointAddress" />
            <span asp-validation-for="TaxBasedOnPickupPointAddress"></span>
        </div>
    </div>
    <div class="form-group row advanced-setting">
        <div class="col-md-3">
            <nop-override-store-checkbox asp-for="PricesIncludeTax_OverrideForStore" asp-input="PricesIncludeTax" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
            <nop-label asp-for="PricesIncludeTax" />
        </div>
        <div class="col-md-9">
            <nop-editor asp-for="PricesIncludeTax" />
            <span asp-validation-for="PricesIncludeTax"></span>
        </div>
    </div>
</div>
<script>
    $(function() {
        $("#@Html.IdFor(model => model.TaxBasedOn)").click(toggleBasedOnMethod);
        toggleBasedOnMethod();
    });

    function toggleBasedOnMethod() {
        var defaultAddress = '@((int)TaxBasedOn.DefaultAddress)';

        var selectedBasedOnMethodId = $('#@Html.IdFor(model => model.TaxBasedOn)').val();
        if (selectedBasedOnMethodId && selectedBasedOnMethodId == defaultAddress) {
            $('#automaticallyDetectCountry-group').hideElement();
        } else {
            $('#automaticallyDetectCountry-group').showElement();
        }
    }
</script>
