<% title t("views.listings.edit.heading") %>

<%= t("views.listings.edit.heading") %>

<%= form_for(@listing, html: { class: "grid gap-6 mb-6" }) do |f| %>
<%= t("views.listings.edit.notice") %>
<%= render partial: "form_errors", locals: { listing: @listing } %> <% if (@listing.bumped_at && @listing.bumped_at > 24.hours.ago) || @listing.updated_at && !@listing.published %>
<%= f.label "title", class: "crayons-field__label" %> <%= f.text_field "title", maxlength: 128, placeholder: t("views.listings.form.title.placeholder"), class: "crayons-textfield" %>
<%= f.label "body_markdown", class: "crayons-field__label" %> <%= f.text_area "body_markdown", maxlength: 400, placeholder: t("views.listings.form.body_markdown.placeholder"), class: "crayons-textfield" %>

<%= t("views.listings.form.body_markdown.description") %>

<%= f.label "tag_list", class: "crayons-field__label" %> <%= f.text_field "tag_list", value: @listing.cached_tag_list, placeholder: t("views.listings.form.tags.placeholder"), class: "crayons-textfield" %>
<%= f.label "expires_at", "Custom Expire Date", class: "crayons-field__label" %> <%= f.date_field "expires_at", min: Date.tomorrow, max: @listing.natural_expiration_date, class: "crayons-textfield m:max-w-50" %>

<%= t("views.listings.form.expiry.description") %>

<%= f.label "location", class: "crayons-field__label" %> <%= f.text_field "location", maxlength: 32, placeholder: t("views.listings.form.location.placeholder"), class: "crayons-textfield m:max-w-50" %>

<%= t("views.listings.form.location.description") %>

<% if @listing.published %> <%= f.submit t("views.listings.edit.update"), class: "crayons-btn" %> <% else %> <%= f.submit t("views.listings.edit.update_draft"), class: "crayons-btn crayons-btn--secondary" %> <% end %>
<% end %> <% end %> <%= form_for(@listing, html: { class: "pt-6 mt-6 border-t-1 border-solid border-0 border-base-20 flex items-center" }) do |f| %> <% if @listing.published == false %> <%= f.submit t("views.listings.edit.publish"), class: "crayons-btn mr-4" %>

<%= t("views.listings.edit.not_published.text_html", not: tag.strong(t("views.listings.edit.not_published.not"), class: "color-accent-danger")) %>

<% else %> <%= f.submit t("views.listings.edit.unpublish"), class: "crayons-btn crayons-btn--danger" %> <% end %> <% end %>
<% if @listing.bumped_at %> <%= form_for(@listing, html: { class: "crayons-card grid gap-6 p-6 mb-6" }) do |f| %>

<%= t("views.listings.edit.bump.subtitle") %>

<%= t("views.listings.edit.bump.description") %>

<%= f.submit t("views.listings.edit.bump.button"), class: "crayons-btn crayons-btn--secondary mr-4" %>

<%= t("views.listings.edit.bump.last", date: time_ago_in_words(@listing.bumped_at, scope: :"datetime.distance_in_words_ago")) %>

<% end %> <% end %>