refactor: integrate approval ui review changes
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/production Build is failing

This commit is contained in:
Simon 2026-03-11 02:19:49 +01:00
parent 28f97184b3
commit f53a3ce3cc
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
13 changed files with 153 additions and 139 deletions

View file

@ -8,12 +8,14 @@ defmodule Mv.Membership.JoinRequest.Changes.ApproveRequest do
"""
use Ash.Resource.Change
alias Mv.Membership.JoinRequest.Changes.Helpers
@spec change(Ash.Changeset.t(), keyword(), Ash.Resource.Change.context()) :: Ash.Changeset.t()
def change(changeset, _opts, context) do
current_status = Ash.Changeset.get_data(changeset, :status)
if current_status == :submitted do
reviewed_by_id = actor_id(context.actor)
reviewed_by_id = Helpers.actor_id(context.actor)
changeset
|> Ash.Changeset.force_change_attribute(:status, :approved)
@ -26,12 +28,4 @@ defmodule Mv.Membership.JoinRequest.Changes.ApproveRequest do
)
end
end
defp actor_id(nil), do: nil
defp actor_id(actor) when is_map(actor) do
Map.get(actor, :id) || Map.get(actor, "id")
end
defp actor_id(_), do: nil
end