<%= if @live_action in [:new, :edit] do %> <%= live_modal @socket, Shift73kWeb.ShiftLive.FormComponent, id: @shift.id || :new, title: @page_title, action: @live_action, shift: @shift, return_to: Routes.shift_index_path(@socket, :index) %> <% end %>

<%= icon_div @socket, "bi-calendar2-date", [class: "icon baseline"] %> My Shifts

<%# month navigation %>

<%= Timex.format!(@cursor_date, "{Mfull} {YYYY}") %>

<%= for day <- Enum.to_list(@date_range) do %> <% Date.day_of_week(day, @current_user.week_start_at) |> IO.inspect(label: "day in date_range") %> <%= if Date.day_of_week(day, @current_user.week_start_at) == 1 do %>
<% end %>
<%= Timex.format!(day, "{WDfull}, {Mshort} {D}") %>
<% day_shifts = Enum.filter(@shifts, fn s -> s.date == day end) %> <%= if !Enum.empty?(day_shifts) do %>
<%= for shift <- day_shifts do %>
<%= format_shift_time(shift.time_start) |> String.trim_trailing("m") %> — <%= format_shift_time(shift.time_end) |> String.trim_trailing("m") %>
<%= shift.time_zone %>
<%= shift.subject %> <%= if shift.location do %> (<%= shift.location %>) <% end %>
<%= shift.description %>
<%= live_redirect "Show", to: Routes.shift_show_path(@socket, :show, shift) %> <%= live_patch "Edit", to: Routes.shift_index_path(@socket, :edit, shift) %> <%= link "Delete", to: "#", phx_click: "delete", phx_value_id: shift.id, data: [confirm: "Are you sure?"] %>
<% end %>
<% else %>
No shift scheduled
<% end %> <% end %>
<%= live_patch "New Shift", to: Routes.shift_index_path(@socket, :new) %>