.header>
Listing Todos
<:actions>
<.link patch={~p"/todos/new"}>
<.button>New Todo
<.table
id="todos"
rows={@streams.todos}
row_click={fn {_id, todo} -> JS.navigate(~p"/todos/#{todo}") end}
>
<:col :let={{_id, todo}} label="Description"><%= todo.description %>
<:col :let={{_id, todo}} label="Emoji"><%= todo.emoji %>
<:col :let={{_id, todo}} label="Completed at"><%= todo.completed_at %>
<:action :let={{_id, todo}}>
<.link navigate={~p"/todos/#{todo}"}>Show
<.link patch={~p"/todos/#{todo}/edit"}>Edit
<:action :let={{id, todo}}>
<.link
phx-click={JS.push("delete", value: %{id: todo.id}) |> hide("##{id}")}
data-confirm="Are you sure?"
>
Delete
<.modal :if={@live_action in [:new, :edit]} id="todo-modal" show on_cancel={JS.patch(~p"/todos")}>
<.live_component
module={HomemanWeb.TodoLive.FormComponent}
id={@todo.id || :new}
title={@page_title}
action={@live_action}
todo={@todo}
patch={~p"/todos"}
/>