2024-11-14 23:33:29 +02:00
|
|
|
<.header>
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("Listing Exams")}
|
2024-11-15 00:45:18 +02:00
|
|
|
<div>
|
2024-12-11 22:22:40 +02:00
|
|
|
<button phx-click="sort" phx-value-by="subject" class="font-light">
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("Sort by Subject")}
|
2024-12-11 22:22:40 +02:00
|
|
|
</button>
|
2024-11-15 00:45:18 +02:00
|
|
|
<a>|</a>
|
|
|
|
|
2024-12-11 22:22:40 +02:00
|
|
|
<button phx-click="sort" phx-value-by="date" class="font-light">
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("Sort by Date")}
|
2024-12-11 22:22:40 +02:00
|
|
|
</button>
|
2024-11-15 00:45:18 +02:00
|
|
|
</div>
|
2024-11-14 23:33:29 +02:00
|
|
|
<:actions>
|
|
|
|
<.link patch={~p"/exams/new"}>
|
2024-12-01 18:31:23 +02:00
|
|
|
<.button class="dark:bg-sky-300 text-white dark:text-black/80 dark:hover:bg-sky-400">
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("New Exam")}
|
2024-12-01 18:31:23 +02:00
|
|
|
</.button>
|
2024-11-14 23:33:29 +02:00
|
|
|
</.link>
|
|
|
|
</:actions>
|
|
|
|
</.header>
|
|
|
|
|
2024-11-15 00:45:18 +02:00
|
|
|
<div class="divide-y">
|
|
|
|
<div :for={exam <- @exams} class="py-2 flex gap-2">
|
|
|
|
<div class="grow">
|
2024-12-12 18:19:53 +02:00
|
|
|
<div class="font-bold">{exam.subject}</div>
|
2024-12-09 21:05:13 +02:00
|
|
|
<div class="font-sm">
|
2024-12-12 18:19:53 +02:00
|
|
|
{exam.date} |
|
2024-12-10 00:39:52 +02:00
|
|
|
<b>
|
2024-12-12 18:19:53 +02:00
|
|
|
{case Date.diff(exam.date, Date.utc_today()) do
|
2024-12-10 00:39:52 +02:00
|
|
|
0 -> gettext("Today")
|
2024-12-12 18:19:53 +02:00
|
|
|
1 -> gettext("Tommorow")
|
|
|
|
x when x > 1 -> ngettext("Tomorrow", "%{count} days left", x)
|
|
|
|
x when x < 0 -> ngettext("Yesterday", "%{count} days passed", x * -1)
|
|
|
|
end}
|
2024-12-10 00:39:52 +02:00
|
|
|
</b>
|
2024-12-09 21:05:13 +02:00
|
|
|
</div>
|
2024-11-14 23:33:29 +02:00
|
|
|
</div>
|
2024-11-27 18:02:28 +02:00
|
|
|
<button
|
|
|
|
phx-click="edit"
|
|
|
|
phx-value-id={exam.id}
|
|
|
|
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-3 rounded-md"
|
|
|
|
>
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("Edit")}
|
2024-11-27 18:02:28 +02:00
|
|
|
</button>
|
2024-11-15 00:45:18 +02:00
|
|
|
<button
|
|
|
|
phx-click="remove"
|
|
|
|
phx-value-id={exam.id}
|
|
|
|
class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 rounded-md"
|
2024-11-14 23:33:29 +02:00
|
|
|
>
|
2024-12-12 18:19:53 +02:00
|
|
|
{gettext("Remove")}
|
2024-11-15 00:45:18 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-11-14 23:33:29 +02:00
|
|
|
|
|
|
|
<.modal :if={@live_action in [:new, :edit]} id="exam-modal" show on_cancel={JS.patch(~p"/exams")}>
|
|
|
|
<.live_component
|
|
|
|
module={ExmrWeb.ExamLive.FormComponent}
|
|
|
|
id={@exam.id || :new}
|
|
|
|
title={@page_title}
|
|
|
|
action={@live_action}
|
|
|
|
exam={@exam}
|
|
|
|
patch={~p"/exams"}
|
|
|
|
/>
|
|
|
|
</.modal>
|