<commit_before>{# @var this \PatternSeek\ECommerce\Address #}
{# @var exec \PatternSeek\ComponentView\ExecHelper #}
{# @var state \PatternSeek\ECommerce\ViewState\AddressState #}
<div class="address" id="component-{{ this.handle }}">
    <fieldset>
        <legend>{{ state.trans.billing_address }}</legend>

        {% if this.flashMessage %}
            <strong class="message">{{ this.flashMessage }}</strong>
            <br>
        {% endif %}
        {% if this.flashError %}
            <strong class="error">{{ this.flashError }}</strong>
            <br>
        {% endif %}

{% if state.mode == 'view' %}
    {% set formBody %}
        {{ state.addressLine1 }}
        <br>
        
        {% if state.addressLine2 is not empty %}
            {{ state.addressLine2 }}
            <br>
        {% endif %}
        
        {% if state.addressLine2 is not empty %}
            {{ state.townOrCity }}
            <br>
        {% endif %}
        
        {% if state.addressLine2 is not empty %}
            {{ state.stateOrRegion }}
            <br>
        {% endif %}
        
        {{ state.postCode }}
        <br>
        {{ state.countryString }}
        <br>
        <input type="submit" value="{{ state.trans.edit_address }}" class="editAddress">
    {% endset %}
    {{ exec.replaceElementUsingForm( "editMode", "POST", formBody, "component-basket", "addressEdit" ) }}

{% else %}
    {% set formBody %}
        <input type="text"
               name="addressLine1"
               value="{{ state.addressLine1 }}"
               placeholder="{{ state.trans.address_line_1 }}"
               class="{{ state.requiredFields['addressLine1']?'required':'' }}">
        <br>
        <input type="text"
               name="addressLine2"
               value="{{ state.addressLine2 }}"
               placeholder="{{ state.trans.address_line_2 }}"
               class="{{ state.requiredFields['addressLine2']?'required':'' }}">
        <br>
        <input type="text" name="townOrCity"
               value="{{ state.townOrCity }}"
               placeholder="{{ state.trans.town_or_city }}"
               class="{{ state.requiredFields['townOrCity']?'required':'' }}">
        <br>
        <input type="text"
               name="stateOrRegion"
               value="{{ state.stateOrRegion }}"
               placeholder="{{ state.trans.state_or_region }}"
               class="{{ state.requiredFields['stateOrRegion']?'required':'' }}">
        <br>
        <input type="text"
               name="postCode"
               value="{{ state.postCode }}"
               placeholder="{{ state.trans.postcode }}"
               class="{{ state.requiredFields['postCode']?'required':'' }}">
        <br>
        <select name="countryCode"
                class="{{ state.requiredFields['countryCode']?'required':'' }}">
            <option value="">{{ state.trans.select }}</option>
            {% for code,country in state.trans.countriesByISO %}
                <option
                        value="{{ code|lower }}"
                        {% if code == state.countryCode %}
                            selected="selected"
                        {% endif %}
                        >
                    {{ country }}
                </option>
            {% endfor %}
        </select>
        <br><commit_msg>Add asterisks for required fields in address<commit_after>{# @var this \PatternSeek\ECommerce\Address #}
{# @var exec \PatternSeek\ComponentView\ExecHelper #}
{# @var state \PatternSeek\ECommerce\ViewState\AddressState #}
<div class="address" id="component-{{ this.handle }}">
    <fieldset>
        <legend>{{ state.trans.billing_address }}</legend>

        {% if this.flashMessage %}
            <strong class="message">{{ this.flashMessage }}</strong>
            <br>
        {% endif %}
        {% if this.flashError %}
            <strong class="error">{{ this.flashError }}</strong>
            <br>
        {% endif %}

{% if state.mode == 'view' %}
    {% set formBody %}
        {{ state.addressLine1 }}
        <br>
        
        {% if state.addressLine2 is not empty %}
            {{ state.addressLine2 }}
            <br>
        {% endif %}
        
        {% if state.addressLine2 is not empty %}
            {{ state.townOrCity }}
            <br>
        {% endif %}
        
        {% if state.addressLine2 is not empty %}
            {{ state.stateOrRegion }}
            <br>
        {% endif %}
        
        {{ state.postCode }}
        <br>
        {{ state.countryString }}
        <br>
        <input type="submit" value="{{ state.trans.edit_address }}" class="editAddress">
    {% endset %}
    {{ exec.replaceElementUsingForm( "editMode", "POST", formBody, "component-basket", "addressEdit" ) }}

{% else %}
    {% set formBody %}
        <input type="text"
               name="addressLine1"
               value="{{ state.addressLine1 }}"
               placeholder="{{ state.trans.address_line_1 }}"
               class="{{ state.requiredFields['addressLine1']?'required':'' }}">{{ state.requiredFields['addressLine1']?' *':'' }}
        <br>
        <input type="text"
               name="addressLine2"
               value="{{ state.addressLine2 }}"
               placeholder="{{ state.trans.address_line_2 }}"
               class="{{ state.requiredFields['addressLine2']?'required':'' }}">{{ state.requiredFields['addressLine2']?' *':'' }}
        <br>
        <input type="text" name="townOrCity"
               value="{{ state.townOrCity }}"
               placeholder="{{ state.trans.town_or_city }}"
               class="{{ state.requiredFields['townOrCity']?'required':'' }}">{{ state.requiredFields['townOrCity']?' *':'' }}
        <br>
        <input type="text"
               name="stateOrRegion"
               value="{{ state.stateOrRegion }}"
               placeholder="{{ state.trans.state_or_region }}"
               class="{{ state.requiredFields['stateOrRegion']?'required':'' }}">{{ state.requiredFields['stateOrRegion']?' *':'' }}
        <br>
        <input type="text"
               name="postCode"
               value="{{ state.postCode }}"
               placeholder="{{ state.trans.postcode }}"
               class="{{ state.requiredFields['postCode']?'required':'' }}">{{ state.requiredFields['postCode']?' *':'' }}
        <br>
        <select name="countryCode"
                class="{{ state.requiredFields['countryCode']?'required':'' }}">{{ state.requiredFields['countryCode']?' *':'' }}
            <option value="">{{ state.trans.select }}</option>
            {% for code,country in state.trans.countriesByISO %}
                <option
                        value="{{ code|lower }}"
                        {% if code == state.countryCode %}
                            selected="selected"
                        {% endif %}
                        >
                    {{ country }}
                </option>
            {% endfor %}
        </select>
        <br>
{'fraction_non_alphanumeric': 0.1691713181623014, 'fraction_numerical': 0.0040074423930156, 'mean_word_length': 1.7741167129813418, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5495143', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1814, 'n_words': 329}