<%= errors_summary_for task_request %>

<%= bootstrap_form_with model: model, url: [@project, @task_request, show_chat: true], local: true do |form| %>

  <div class="d-flex">
    <div class="row">
      <div class="col-xl-10 col-12">
        <div class="alert alert-info text-center text-md-left">
          <%= fa_icon "info-circle" %>
          <strong><%= t '.info_message' %></strong>
        </div>
      </div>
      <div class="col-xl-2 col-12">
        <%= form.submit t('.actions.chat_now'), class: "btn btn-block btn-warning pt-4 pb-4 mb-1", data: { disable_with: t("shared.disable_with") } %>
      </div>
    </div>
  </div>

  <%= form.text_area :description, label: t('.labels.description') %>
  <%= form.text_field :deadline, class: "datepicker-control", label: t('.labels.deadline') %>
  <%= form.number_field :time_allowed, label: t('.labels.time_allowed'), min: 2, step: 1, pattern: "\d+" %>
  <%= form.text_area :additional_notes, label: t('.labels.additional_notes') %>
  <%= field_set_tag content_tag(:span, t('.labels.files'), class: "h6 text-muted text-uppercase") do %>
    <div class="field d-none">
      <%= form.label :files %>
      <%= form.file_field :files, disable: true, direct_upload: true, multiple: true, id: "task_request_files", hide_label: true %>
      <% task_request.files.each do |file| %>
        <% unless file.persisted? %>
          <%= hidden_field_tag "#{task_request.model_name.param_key}[files][]", file.signed_id %>
        <% end %>
      <% end %>
    </div>

    <div class="dropzone field border-dashed" 
      data-accepted-files="audio/*,image/*,video/*,application/*"
      data-behavior="dropzone" 
      data-file-input-id="task_request_files" 
      data-existing-files="<%= mock_photos_json(task_request.files) %>" 
      data-placeholder="<%= dropzone_placeholder_message_for(task_request) %>"
      data-submit-button="#submit_folder"></div>
  <% end %>

  <div class="row align-items-center text-center mt-4">
    <%= link_to t("shared.cancel"), [project, :task_requests], class: "col-3 text-reset" %>
    <div class="col-9">
      <%= form.submit class: class_string("btn btn-block", ["btn-success", "btn-primary"] => task_request.new_record?), data: { disable_with: t("shared.disable_with") } %>
    </div>
  </div>
<% end %>
