{% extends 'pages/settings/settings.twig' %}
{% import 'macros/form.twig' as f %}
{% import 'macros/base.twig' as m %}

{% block title %}{{ __('settings.profile') }}{% endblock %}

{% block row_content %}
    <form action="" enctype="multipart/form-data" method="post">
        {{ csrf() }}

        <div class="row g-4">
            <div class="col-md-12">
                <strong class="help-block">
                    {{ f.entry_required() }} = {{ __('settings.profile.entry_required') }}
                </strong>
            </div>

            <div class="col-md-12">
                {{ m.info(__('settings.profile.user_details.info')) }}
                {{ f.input(
                    'nick',
                    __('settings.profile.nick'),
                    'text',
                    {'value': user.name, 'disabled': true}
                ) }}
                {% if config('enable_pronoun') %}
                    {{ f.input(
                        'pronoun',
                        __('settings.profile.pronoun'),
                        'text',
                        {'value': user.personalData.pronoun ,'max_length': 15}
                    ) }}
                    {{ m.info(__('settings.profile.pronoun.info')) }}
                {% endif %}
                {% if config('enable_user_name') %}
                    {{ f.input(
                        'first_name',
                        __('settings.profile.firstname'),
                        'text',
                        {'value': user.personalData.first_name, 'max_length': 64}
                    ) }}
                    {{ f.input(
                        'last_name',
                        __('settings.profile.lastname'),
                        'text',
                        {'value': user.personalData.last_name, 'max_length': 64}
                    ) }}
                {% endif %}
            </div>

            {% if config('enable_planned_arrival') %}
                <div class="col-md-12">
                    {{ f.input(
                        'planned_arrival_date',
                        __('settings.profile.planned_arrival_date'),
                        'date',
                        {
                            'value': user.personalData.planned_arrival_date.format('Y-m-d'),
                            'required': true,
                            'entry_required_icon': true,
                            'min': config('buildup_start') ? config('buildup_start').format('Y-m-d') : '',
                            'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
                        }
                    ) }}
                    {% set planned_departure_date = user.personalData.planned_departure_date %}
                    {{ f.input(
                        'planned_departure_date',
                        __('settings.profile.planned_departure_date'),
                        'date',
                        {
                            'value': planned_departure_date ? planned_departure_date.format('Y-m-d') : '',
                            'min': config('buildup_start') ? config('buildup_start').format('Y-m-d') : '',
                            'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
                        }
                    ) }}
                </div>
            {% endif %}

            <div class="col-md-12">
                {% if config('enable_dect') %}
                    {{ f.input(
                        'dect',
                        __('settings.profile.dect'),
                        'text',
                        {'value': user.contact.dect, 'max_length': 40}
                    ) }}
                {% endif %}
                {{ f.input(
                    'mobile',
                    __('settings.profile.mobile'),
                    'text',
                    {'value': user.contact.mobile, 'max_length': 40}
                ) }}
                {% if config('enable_mobile_show') %}
                    {{ f.checkbox(
                        'mobile_show',
                        __('settings.profile.mobile_show'),
                        user.settings.mobile_show
                    ) }}
                {% endif %}
                {{ f.input(
                    'email',
                    __('settings.profile.email'),
                    'email',
                    {'value': user.email, 'max_length': 254, 'required': true, 'entry_required_icon': true}
                ) }}
            </div>

            <div class="col-md-12">
                {{ f.checkbox(
                    'email_shiftinfo',
                    __('settings.profile.email_shiftinfo', [config('app_name')]),
                    user.settings.email_shiftinfo
                ) }}
                {{ f.checkbox(
                    'email_news',
                    __('settings.profile.email_news'),
                    user.settings.email_news
                ) }}
                {{ f.checkbox(
                    'email_human',
                    __('settings.profile.email_by_human_allowed'),
                    user.settings.email_human
                ) }}
                {% if config('enable_goody') %}
                    {% set privacy_email = config('privacy_email') %}
                    {% set email_goody_label = __('settings.profile.email_goody') ~
                        (privacy_email ? ' ' ~ __('settings.profile.privacy', [privacy_email]) : '')
                    %}
                    {{ f.checkbox(
                        'email_goody',
                        email_goody_label,
                        user.settings.email_goody,
                        user.settings.email_goody,
                        false,
                        true
                    ) }}
                {% endif %}
            </div>

            {% if config('enable_tshirt_size') %}
                <div class="col-md-12">
                    {{ f.select(
                        'shirt_size',
                        config('tshirt_sizes'),
                        __('settings.profile.shirt_size'),
                        user.personalData.shirt_size,
                        {'required': true, 'entry_required_icon': true}
                    ) }}
                </div>
            {% endif %}

            <div class="col-md-12">
                {{ m.info(__('settings.profile.angeltypes.info', [url('/angeltypes')]), true) }}
            </div>

            <div class="col-md-12">
                {{ f.submit() }}
            </div>
        </div>
    </form>
{% endblock %}