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

41 lines
1 KiB
Text

<.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>
<:actions>
<.link patch={~p"/exams/new"}>
<.button>New Exam</.button>
</.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>
</div>
<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"
>
Remove
</button>
</div>
</div>
<.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>