{% import 'macro_functions.html.twig' as mf %}

<div class="mb-3 row">
    <label class="form-label col-3 col-form-label">{{ 'Domain action'|trans }}:</label>
    <div class="col domain-action-select">
        <div class="form-check form-check-inline">
            <input class="form-check-input" id="radioActionRegister" type="radio" name="config[action]" value="register" checked>
            <label class="form-check-label" for="radioActionRegister">{{ 'Register'|trans }}</label>
        </div>
        <div class="form-check form-check-inline">
            <input class="form-check-input" id="radioActionTransfer" type="radio" name="config[action]" value="transfer">
            <label class="form-check-label" for="radioActionTransfer">{{' Transfer'|trans }}</label>
        </div>
    </div>
</div>
<div class="mb-3 row domain-action domain-register">
    <label class="form-label col-3 col-form-label">{{ 'Register domain'|trans }}:</label>
    <div class="col">
        <div class="input-group mb-3">
            <input class="form-control w-50" type="text" name="config[register_sld]" value="{{ request.register_sld }}" placeholder="{{ 'Domain name to register'|trans }}">
            {{ mf.selectboxtld('config[register_tld]', guest.serviceDomain_tlds({ 'allow_register': 1 })) }}
        </div>
        <div class="input-group mb-3">
            <input class="form-control" type="text" name="config[register_years]" value="1" placeholder="{{ 'Years'|trans }}">
            <span class="input-group-text">{{ 'Years'|trans }}</span>
        </div>
    </div>
</div>
<div class="mb-3 row domain-action domain-transfer" style="display: none;">
    <label class="form-label col-3 col-form-label">{{ 'Transfer domain'|trans }}:</label>
    <div class="col">
        <div class="input-group mb-3">
            <input class="form-control w-50" type="text" name="config[transfer_sld]" value="{{ request.transfer_sld }}"  placeholder="{{ 'Domain name to transfer'|trans }}">
            {{ mf.selectboxtld('config[transfer_tld]', guest.serviceDomain_tlds({ "allow_transfer": 1 })) }}
        </div>
        <div class="input-group mb-3">
            <input class="form-control" type="text" name="config[transfer_code]" value="{{ request.transfer_code }}" placeholder="{{ 'Domain transfer code'|trans }}">
            <span class="input-group-text">{{ 'Years'|trans }}</span>
        </div>
    </div>
</div>

<script>
$(function() {
    $('.domain-action-select input').on('click', function() {
        $('.domain-action').hide();

        if($(this).val() == 'register') {
            $('.domain-action.domain-register').show();
        } else {
            $('.domain-action.domain-transfer').show();
        }
    });
});
</script>
