Skip to content

Commit

Permalink
#846 PANL Consent text of fresh test project 'has already been signed'
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Jun 10, 2024
1 parent 1ed6946 commit 3823dae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion core/systems/assignment/crew_page_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ defmodule Systems.Assignment.CrewPageBuilder do

Fabric.prepare_child(fabric, :onboarding_view_consent, Assignment.OnboardingConsentView, %{
revision: revision,
user: user
user: user,
create_signature?: not tester?
})
end
end
Expand Down
16 changes: 12 additions & 4 deletions core/systems/assignment/onboarding_consent_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,32 @@ defmodule Systems.Assignment.OnboardingConsentView do
}

@impl true
def update(%{id: id, revision: revision, user: user}, socket) do
def update(
%{id: id, revision: revision, user: user, create_signature?: create_signature?},
socket
) do
{
:ok,
socket
|> assign(
id: id,
revision: revision,
user: user
user: user,
create_signature?: create_signature?
)
|> update_clickwrap_view()
}
end

defp update_clickwrap_view(%{assigns: %{revision: revision, user: user}} = socket) do
defp update_clickwrap_view(
%{assigns: %{revision: revision, user: user, create_signature?: create_signature?}} =
socket
) do
child =
prepare_child(socket, :clickwrap_view, Consent.ClickWrapView, %{
revision: revision,
user: user
user: user,
create_signature?: create_signature?
})

show_child(socket, child)
Expand Down
10 changes: 9 additions & 1 deletion core/systems/consent/clickwrap_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ defmodule Systems.Consent.ClickWrapView do
}

@impl true
def update(%{id: id, revision: revision, user: user}, socket) do
def update(
%{id: id, revision: revision, user: user, create_signature?: create_signature?},
socket
) do
signature = Consent.Public.get_signature(revision, user)

{
Expand All @@ -19,6 +22,7 @@ defmodule Systems.Consent.ClickWrapView do
id: id,
revision: revision,
user: user,
create_signature?: create_signature?,
signature: signature
)
|> update_validation()
Expand Down Expand Up @@ -67,6 +71,10 @@ defmodule Systems.Consent.ClickWrapView do
}
end

def handle_accept(%{assigns: %{create_signature?: false}} = socket) do
socket |> send_event(:parent, "accept")
end

def handle_accept(%{assigns: %{signature: nil, revision: revision, user: user}} = socket) do
{:ok, %{consent_signature: signature}} = Consent.Public.create_signature(revision, user)

Expand Down

0 comments on commit 3823dae

Please sign in to comment.