devel #167

Merged
inhji merged 6 commits from devel into main 2023-07-04 07:14:42 +02:00
Showing only changes of commit faa7acd064 - Show all commits

View file

@ -30,14 +30,18 @@ defmodule ChiyaWeb.AdminHomeLive do
|> Map.put_new("published_at", NaiveDateTime.local_now())
case Chiya.Notes.create_note(params) do
{:ok, _note} ->
{:noreply, socket |> put_flash(:info, "Note created!")}
{:ok, note} ->
{:noreply, socket
|> put_flash(:info, "Note created!")
|> push_navigate(to: ~p"/note/#{note.slug}")}
{:error, %Ecto.Changeset{} = changeset} ->
IO.inspect(changeset)
{:noreply,
socket |> put_flash(:error, "Could not create note!") |> assign(form: to_form(changeset))}
socket
|> put_flash(:error, "Could not create note!")
|> assign(form: to_form(changeset))}
end
end
@ -58,7 +62,7 @@ defmodule ChiyaWeb.AdminHomeLive do
<.simple_form for={@form} phx-change="validate" phx-submit="save">
<.input field={@form[:content]} type="textarea" />
<:actions>
<.button>Save</.button>
<.button>Publish</.button>
</:actions>
</.simple_form>
</section>