-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: attendee credential association (#434)
- Loading branch information
1 parent
b20f659
commit 716dbdd
Showing
16 changed files
with
182 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
defmodule SafiraWeb.App.CredentialLive.Edit do | ||
use SafiraWeb, :app_view | ||
|
||
alias Safira.Accounts | ||
|
||
@impl true | ||
def mount(_params, _session, socket) do | ||
{:ok, socket} | ||
end | ||
|
||
@impl true | ||
def handle_params(_params, _url, socket) do | ||
{:noreply, socket |> assign(:modal_data, nil)} | ||
end | ||
|
||
@impl true | ||
def handle_event("scan", data, socket) do | ||
case safely_extract_id_from_url(data) do | ||
{:ok, id} -> | ||
if Accounts.credential_exists?(id) do | ||
if Accounts.credential_linked?(id) do | ||
{:noreply, socket |> assign(:modal_data, :already_linked)} | ||
else | ||
Accounts.link_credential(id, socket.assigns.current_user.attendee.id) | ||
{:noreply, socket |> push_navigate(to: ~p"/app")} | ||
end | ||
else | ||
{:noreply, socket |> assign(:modal_data, :not_found)} | ||
end | ||
|
||
{:error, _} -> | ||
{:noreply, socket |> assign(:modal_data, :invalid)} | ||
end | ||
end | ||
|
||
@impl true | ||
def handle_event("close-modal", _, socket) do | ||
{:noreply, socket |> assign(:modal_data, nil)} | ||
end | ||
|
||
def error_message(:not_found), | ||
do: gettext("This credential is not registered in the event's system! (404)") | ||
|
||
def error_message(:already_linked), | ||
do: gettext("This credential is already linked to another attendee! (400)") | ||
|
||
def error_message(:invalid), do: gettext("Not a valid credential! (400)") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule SafiraWeb.App.CredentialLive.Index do | ||
use SafiraWeb, :app_view | ||
|
||
alias Safira.Accounts | ||
|
||
@impl true | ||
def mount(_params, _session, socket) do | ||
{:ok, | ||
socket | ||
|> assign(:current_page, :credential) | ||
|> assign( | ||
:credential, | ||
Accounts.get_credential_of_attendee!(socket.assigns.current_user.attendee) | ||
)} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<.page title="Credential" size={:xl} title_class="font-terminal uppercase"> | ||
<p> | ||
<%= gettext( | ||
"The code below is used to identify you in case you are missing your physical credential." | ||
) %> | ||
</p> | ||
<div class="mt-24 mx-auto w-fit scale-125 sm:scale-150 p-1 bg-white rounded-xl select-none"> | ||
<%= draw_qr_code(@credential) |> raw %> | ||
<p class="text-center text-xs text-primaryDark font-semibold pb-1"> | ||
<%= @current_user.name %> | ||
</p> | ||
</div> | ||
</.page> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.