{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2023 TU Wien.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
{% set title = invenio_request.title %}
{% extends "invenio_requests/details/index.html" %}
{% from "invenio_requests/macros/request_header.html" import inclusion_request_header %}

{% block request_header %}
  {%- if current_user and current_user.is_authenticated %}
    {# only display the header for the receiver #}
    {%- set back_button_url = url_for("invenio_app_rdm_users.requests") %}
    {{
      inclusion_request_header(
        back_button_url=back_button_url,
        back_button_text=_("Back to requests"),
        request=invenio_request,
        accepted=request_is_accepted
      )
    }}
  {%- else %}
    <div class="computer-flex-header rel-mt-2">
      <div id="request-actions" class="flex align-items-start ml-auto mb-10">
        {% if request_is_accepted %}
          <div class="ui success message">
            <p>{{ _("Check your email on how to access the record") }}</p>
          </div>
        {% endif %}
      </div>
    </div>
  {%- endif %}

  <div>
    <p>
      <strong>Requester:</strong>
      {{ invenio_request.payload.full_name }} ({{ invenio_request.payload.email }})
    </p>
    <p>
      <strong>Access level:</strong>
      {{ invenio_request.payload.permission }}
    </p>
    <p>
      <strong>Record:</strong>
      <a href="{{ url_for('invenio_app_rdm_records.record_detail', pid_value=invenio_request.topic.record) }}"
          rel="noopener noreferrer" target="_blank"
          title="{{ _('Opens in new tab') }}"
      >
        {{ invenio_request.topic.record }}
      </a>
    </p>
  <div class="ui container rel-mt-2">
    {%- block user_dashboard_body %}
    {%- endblock user_dashboard_body %}
  </div>
  </div>
{% endblock %}
