exmr/lib/exmr_web/live/exam_live/index.html.heex

51 lines
1.3 KiB
Text
Raw Normal View History

2024-11-14 23:33:29 +02:00
<.header>
Listing Exams
<div>
<button phx-click="sort" phx-value-by="subject" class="font-light">Sort by Subject</button>
<a>|</a>
<button phx-click="sort" phx-value-by="date" class="font-light">Sort by Date</button>
</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">
New Exam
</.button>
2024-11-14 23:33:29 +02:00
</.link>
</:actions>
</.header>
<div class="divide-y">
<div :for={exam <- @exams} class="py-2 flex gap-2">
<div class="grow">
<div class="font-bold"><%= exam.subject %></div>
<div class="font-sm"><%= exam.date %></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"
>
Edit
</button>
<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
>
Remove
</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>