Membership Fee 6 - UI Components & LiveViews closes #280 #304
1 changed files with 20 additions and 2 deletions
|
|
@ -374,14 +374,32 @@ defmodule MvWeb.MemberLive.Show.MembershipFeesComponent do
|
|||
:suspended -> :mark_as_suspended
|
||||
end
|
||||
|
||||
case Ash.update!(cycle, action) do
|
||||
updated_cycle ->
|
||||
case Ash.update(cycle, action: action) do
|
||||
{:ok, updated_cycle} ->
|
||||
updated_cycles = replace_cycle(socket.assigns.cycles, updated_cycle)
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:cycles, updated_cycles)
|
||||
|> put_flash(:info, gettext("Cycle status updated"))}
|
||||
|
||||
{:error, %Ash.Error.Invalid{} = error} ->
|
||||
error_msg =
|
||||
error.errors
|
||||
|> Enum.map(fn e -> e.message end)
|
||||
|> Enum.join(", ")
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(
|
||||
:error,
|
||||
gettext("Failed to update cycle status: %{errors}", errors: error_msg)
|
||||
)}
|
||||
|
||||
{:error, error} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, format_error(error))}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue