more changes to notes

This commit is contained in:
2022-11-24 12:43:34 -05:00
parent 2ce4fe3cc8
commit a0a0697f2d
9 changed files with 102 additions and 21 deletions

View File

@ -20,6 +20,22 @@ defmodule MemexWeb.NoteLive.Show do
|> assign(:note, Notes.get_note!(id, current_user))}
end
defp page_title(:show), do: "show note"
defp page_title(:edit), do: "edit note"
@impl true
def handle_event(
"delete",
_params,
%{assigns: %{note: note, current_user: current_user}} = socket
) do
{:ok, %{title: title}} = Notes.delete_note(note, current_user)
socket =
socket
|> put_flash(:info, gettext("%{title} deleted", title: title))
|> push_navigate(to: Routes.note_index_path(Endpoint, :index))
{:noreply, socket}
end
defp page_title(:show), do: gettext("show note")
defp page_title(:edit), do: gettext("edit note")
end