Skip to content

Commit

Permalink
Fixed Compile Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Dec 22, 2024
1 parent 8232414 commit 1af6dd9
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions lib/animina_web/live/beta_register.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,17 @@ defmodule AniminaWeb.BetaRegisterLive do
{:ok, socket}
end

@impl true
defp extract_birthday(%{"birthday" => birthday}) do
case BirthdayValidator.validate_birthday(birthday) do
{:ok, birthday} ->
birthday

{:error, _} ->
nil
end
end

@impl true
def handle_params(%{"step" => "user_details"}, _url, socket) do
if socket.assigns.initial_user_details == default_user_params() do
{:noreply,
Expand All @@ -68,16 +77,6 @@ defmodule AniminaWeb.BetaRegisterLive do
end
end

defp extract_birthday(%{"birthday" => birthday}) do
case BirthdayValidator.validate_birthday(birthday) do
{:ok, birthday} ->
birthday

{:error, _} ->
nil
end
end

def handle_params(%{"step" => step}, _url, socket) do
{color, page_title_str, title_str, info_text_str} =
step_info(step, socket.assigns.language, @max_flags)
Expand Down Expand Up @@ -230,34 +229,6 @@ defmodule AniminaWeb.BetaRegisterLive do
end
end

defp create_flags(user, flags, color) do
Enum.with_index(flags)
|> Enum.each(fn {flag_id, index} ->
%{
"user_id" => user.id,
"flag_id" => flag_id,
"color" => color,
"position" => index + 1
}
|> UserFlags.create()
end)
end

defp get_link(route, params) do
if params == %{} do
route
else
"#{route}?#{URI.encode_query(params)}"
end
end

def handle_info({:potential_partners, users}, socket) do
{:noreply,
socket
|> assign(:searching_potential_partners, false)
|> assign(:number_of_potential_partners, Enum.count(users))}
end

def handle_event("select_flag", %{"color" => color, "flagid" => flagid}, socket) do
socket = update_flags_array(:add, color, flagid, socket)
{:noreply, socket}
Expand Down Expand Up @@ -311,6 +282,36 @@ defmodule AniminaWeb.BetaRegisterLive do
end
end

defp create_flags(user, flags, color) do
Enum.with_index(flags)
|> Enum.each(fn {flag_id, index} ->
%{
"user_id" => user.id,
"flag_id" => flag_id,
"color" => color,
"position" => index + 1
}
|> UserFlags.create()
end)
end

defp get_link(route, params) do
if params == %{} do
route
else
"#{route}?#{URI.encode_query(params)}"
end
end

@impl true

def handle_info({:potential_partners, users}, socket) do
{:noreply,
socket
|> assign(:searching_potential_partners, false)
|> assign(:number_of_potential_partners, Enum.count(users))}
end

defp update_flags_array(:add, color, flagid, socket) do
assign_key = get_assign_key(color)

Expand Down

0 comments on commit 1af6dd9

Please sign in to comment.