{% extends "base.html" %}

{% block main %}
<div class="page-grid">
  <div class="page-grid__toolbar">
    <div class="page-grid__toolbar-utilities">
      <a href="{{ navigator.form_page(*portal.id).build()?.get_path() }}">
        <button class="button--secondary" style="margin-left: 0.5rem;" type="button">View Form</button>
      </a>
    </div>
  </div>
  <div class="page-grid__sidebar">
    <div style="padding: 1rem;">
      {{ workspace_nav | safe }}
    </div>
  </div>
  <main class="page-grid__main">
    <form method="post" action="update-prompts">
      <section>
        <h1>Prompts</h1>
        <div>
          {% for field_info in fields %}
          <div class="form-editor__field">
            <div class="form-editor__field-label">
              {{ field_info.field.table_label.clone().unwrap_or(field_info.field.name.clone()) }}
            </div>
            <div class="form-editor__field-prompt">
              <i18n-textarea
                field-id="{{ field_info.field.id }}"
                languages="{{ languages | json }}"
                value="{{ field_info.prompts | json }}"
              >
              </i18n-textarea>
            </div>
          </div>
          {% endfor %}
        </div>
        <button class="button--primary" type="submit">Save Prompts</button>
      </section>
    </form>
    <form method="post" action="update-form-transitions">
      <section>
        <h1>Destinations</h1>
        <form-transitions-editor
          identifier-hints="{{ identifier_hints | json }}"
          portals="{{ portals | json }}"
          value="{{ transitions | json }}"
        >
        </form-transitions-editor>
        <button class="button--primary" type="submit">Save Destinations</button>
      </section>
    </form>
  </main>
</div>
<script type="module" src="{{ settings.root_path }}/js_dist/i18n-textarea.webc.mjs"></script>
<script type="module" src="{{ settings.root_path }}/js_dist/form-transitions-editor.webc.mjs"></script>
{% endblock %}
