- content_for :head
  = vite_javascript_tag 'cocoon'

= form_with(model: purchase_order, url: purchase_order.persisted? ? warehouse_purchase_order_path(purchase_order) : warehouse_purchase_orders_path) do |form|
  - if purchase_order.errors.any?
    = render layout: 'shared/banner', locals: {color: 'alert'} do
      b hey, slight issue:
      ul
        - purchase_order.errors.each do |error|
          li= error.full_message

  div
    = form.label :supplier_name, "Supplier Name:"
    = form.text_field :supplier_name, class: 'form-control', required: true

  div
    = form.label :supplier_id, "Supplier ID (from Zenventory, optional):"
    = form.number_field :supplier_id, class: 'form-control'

  div
    = form.label :required_by_date, "Required By Date:"
    = form.date_field :required_by_date, class: 'form-control'

  .py-3
    = form.label :notes, "Notes:"
    .display-block
      = form.text_area :notes, class: 'form-control', rows: 4

  h4 Line Items:
  #line_items
    = form.fields_for :line_items do |line_item|
      = render 'line_item_fields', f: line_item

    .links
      = link_to_add_association 'Add item', form, :line_items

  .pt-3
    = form.submit "Save", class: 'form-control'
