<%= form_with(model: reservation, class: "contents", data: { controller: "customer-search", customer_search_existing_id_value: (reservation.persisted? && reservation.customer ? reservation.customer.to_param : nil), customer_search_existing_label_value: (reservation.persisted? && reservation.customer ? "#{reservation.customer.full_name} (#{reservation.customer.original_phone})" : nil) }) do |form| %> <% if reservation.errors.any? %>

<%= t('reservations.form.errors.header', count: reservation.errors.count) %>

<% end %>
<%= form.label :customer, t('reservations.form.customer') %> <%= form.select :customer_composite_key, [], # Start with empty options { prompt: t('reservations.form.search_prompt') }, { selected: (reservation.persisted? && reservation.customer ? reservation.customer.to_param : nil), class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full", data: { customer_search_target: "select" } } %>
<%= form.label :phone_number, t('reservations.form.phone_number') %> <%= form.telephone_field :customer_original_phone, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full", data: { customer_search_target: "phoneField" } %>
<%= form.label :team_id, t('reservations.form.team') %> <%= form.collection_select :team_id, @company.teams, :id, :name, { prompt: t('reservations.form.select_team') }, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
<%= form.label :start_time, t('reservations.form.start_time') %> <%= form.datetime_field :start_time, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full", id: "start_time_field" %>
<%= form.label :end_time, t('reservations.form.end_time') %> <%= form.datetime_field :end_time, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full", id: "end_time_field" %>
<% if reservation.new_record? %> <%= form.submit t('reservations.form.create'), class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> <% else %> <%= form.submit t('reservations.form.update'), class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> <% end %>
<% end %>