{t("On-Call & Schedules")}

<%= if @tab == "escalation-policies" do %> <.link navigate={~p"/schedules/escalation-policies/new"} class="inline-flex items-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-500 transition-colors" > <.icon name="hero-plus" class="h-4 w-4" /> {t("New Policy")} <% else %> <.link navigate={~p"/schedules/new"} class="inline-flex items-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-500 transition-colors" > <.icon name="hero-plus" class="h-4 w-4" /> {t("New Schedule")} <% end %>

{t("Define on-call rotations and escalation policies for alert notifications.")}

<.link patch={~p"/schedules?tab=schedules"} class={[ "inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium transition-colors", @tab == "schedules" && "bg-gray-900 text-white dark:bg-white dark:text-gray-900", @tab != "schedules" && "bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700" ]} > {t("Schedules")} <.link patch={~p"/schedules?tab=escalation-policies"} class={[ "inline-flex items-center px-3 py-1.5 rounded-full text-xs font-medium transition-colors", @tab == "escalation-policies" && "bg-gray-900 text-white dark:bg-white dark:text-gray-900", @tab != "escalation-policies" && "bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700" ]} > {t("Escalation Policies")}
<%= if @tab == "escalation-policies" do %> <%= if Enum.empty?(@policies) do %>
<.icon name="hero-arrow-trending-up" class="h-12 w-12 text-gray-300 dark:text-gray-600 mx-auto mb-4" />

{t("No escalation policies")}

{t("Create an escalation policy to define how alerts are escalated to on-call users.")}

<% else %>
<%= for policy <- @policies do %> <% end %>
{t("Name")} {t("Levels")}
{policy.name} {length(policy.rules)}
<% end %> <% else %> <%!-- Search input --%>
<.icon name="hero-magnifying-glass" class="h-4 w-4 text-gray-400" />
<%!-- Date navigation header --%>
{window_label(@start_date, @range_days)}
<%= if Enum.empty?(@schedules) do %>
<.icon name="hero-calendar-days" class="h-12 w-12 text-gray-300 dark:text-gray-600 mx-auto mb-4" />

{t("No schedules")}

{t("Create an on-call schedule to define rotation coverage.")}

<% else %>
<%= for schedule <- @schedules do %> <% days = days_in_window(@start_date, @range_days) %> <% today_idx = today_offset(@start_date, @range_days) %>
<.link navigate={~p"/schedules/#{schedule.id}"} class="text-base font-semibold text-blue-600 dark:text-blue-400 hover:underline" > {schedule.name}

{schedule.timezone}

{t("On-Call Now")}

<%= if schedule.current_on_call do %> {schedule.current_on_call_name} <% else %> {t("No one")} <% end %>
<%!-- Day header row --%>
<%= for {day, idx} <- Enum.with_index(days) do %>
{Calendar.strftime(day, "%a")}
{Calendar.strftime(day, "%-d")}
<% end %>
<%!-- Gantt strip --%>
<%= for segment <- schedule.segments do %>
{segment.label}
<% end %> <%= if today_idx do %>
<% end %>
<% end %>
<.pagination meta={@pagination} path={~p"/schedules"} params={ %{ "tab" => @tab, "start" => Date.to_iso8601(@start_date), "range" => Integer.to_string(@range_days), "search" => @search } } /> <% end %> <% end %>