{#
  Copyright (C) 2020 Graz University of Technology.

  invenio-theme-iform is free software; you can redistribute it and/or
  modify it under the terms of the MIT License; see LICENSE file for more
  details.
#}
{% extends config.INVENIO_THEME_IFORM_ACCOUNT_BASE %}
{% from "invenio_accounts/_macros.html" import render_field, form_errors %}

{% block page_body %}
    <div class="spacer-long"></div>

    <div class="ui container">
        <div class="ui stackable two column grid">
            <div class="centered row">
                <h1 class="ui header">{{ _("Create an Account") }}</h1>
            </div>

            <div class="column" id="switch_left">
                <div class="ui basic segment">
                    <h4 class="ui header">{{ _("Citeable. Discoverable.") }}</h4>
                    <p class="bodytext">
                        {{ _("Uploads get a Digital Object Identifier (DOI) to make them easily and uniquely citeable.") }}
                    </p>

                    <h4 class="ui header">{{ _("Communities.") }}</h4>
                    <p class="bodytext">
                        {{ _("Accept or reject uploads to your own community (e.g workshops, EU projects, institutions or entire disciplines).") }}
                    </p>
                    <h4 class="ui header">{{ _("Trusted Research Data Management") }}</h4>
                    <p class="bodytext">
                        {{ _("Built on top of I-Form expertise in the managing of research data.") }}
                    </p>
                </div>
            </div>

            <div class="column" id="switch_right">
                {# Sigup with SSO #}
                {%- if config.INVENIO_CONFIG_IFORM_SHIBBOLETH %}
                    <div class="ui divider"></div>
                    <a
                        href="{{ url_for('sso_saml.sso', idp='idp') }}"
                        class="login-page-button ui fluid large button"
                    >
                        <span style="font-size: 18px;">{{ _("Sign up with I-Form") }}</span>
                        <img
                            src="{{ url_for('static', filename=config.INVENIO_THEME_IFORM_ICON) }}"
                            height="20px"
                        />
                    </a>
                    <div class="ui inverted horizontal divider">
                        <span class="text-color">{{ _ ("Or") }}</span>
                    </div>
                {%- endif %}

                {%- block form_header %}
                    {# can add a header img #}
                    {%- block form_outer %}
                    {%- endblock form_outer %}
                {%- endblock form_header %}

                {%- with form = register_user_form %}
                    {%- set accordion_active = "active" if form.errors else "" %}
                    <div class="ui padded centered large form">
                        <div class="ui styled accordion">
                            <div class="title trigger {{ accordion_active }}">
                                {{ _("Sign up with repository credentials") }}
                                <i class="user icon button"></i>
                            </div>
                            <div class="content {{ accordion_active }}">
                                <form
                                    class="ui large form"
                                    action="{{ url_for_security('register') }}"
                                    method="POST"
                                    name="register_user_form"
                                >
                                    {{ form_errors(form) }}
                                    {{ form.hidden_tag() }}
                                    {%- block registration_form_fields scoped %}
                                        {{ render_field(form.email, icon="user icon", autofocus=True, errormsg=False) }}
                                        {{ render_field(form.password, icon="lock icon", errormsg=False) }}
                                        {%- if form.password_confirm %}
                                            {{ render_field(form.password_confirm, icon="lock icon", errormsg=False) }}
                                        {%- endif %}
                                    {%- endblock registration_form_fields %}

                                    {%- if form.recaptcha %}
                                        <div class="grouped fields">{{ form.recaptcha() }}</div>
                                    {%- endif %}

                                    <div class="centered row">
                                        <button type="submit" class="ui fluid large submit button">
                                            <i class="ui edit outline icon"></i>{{ _("Sign up") }}
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                {%- endwith %}
                <div class="ui divider"></div>
            </div>
        </div>
    </div>
{% endblock page_body %}
