Skip to content

Commit

Permalink
fix: Display error for missing phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadyan committed May 18, 2023
1 parent 2a3cc71 commit d94db5d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>

<div class="form-group my-4 <%= if communication_mode != "sms", do: "d-none" %>" data-phone="input">
<%= if phone_number(@current_user) do %>
<%= if phone_number?(@current_user) do %>
<%= label form, :phone_number, "My phone number is:", class: "form__label d-block" %>
<div><%= @current_user |> phone_number() |> format_phone_number() %></div>
<div><%= link to: update_profile_url(@conn) do %>Change phone number<% end %></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

<div class="form-group my-3 <%= if communication_mode != "sms", do: "d-none", else: "" %>" data-phone="input">
<%= if keycloak_auth?() do %>
<%= if phone_number(@current_user) do %>
<%= if phone_number?(@current_user) do %>
<%= label form, :phone_number, "My phone number is:", class: "form__label d-block" %>
<div><%= @current_user |> phone_number() |> format_phone_number() %></div>
<% else %>
<p>Please enter your number in order to recieve text messages.</p>
<p class="font-weight-bold">Please enter your number in order to recieve text messages.</p>
<div><%= link to: update_profile_url(@conn) do %>Add phone number<% end %></div>
<%= error_tag form, :phone_number %>
<% end %>
<% else %>
<%= label form, :phone_number, "What’s your mobile phone number?", class: "form__label d-block" %>
Expand Down
5 changes: 5 additions & 0 deletions apps/concierge_site/lib/views/account_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ defmodule ConciergeSite.AccountView do
defdelegate email(user), to: User
defdelegate phone_number(user), to: User

def phone_number?(user) do
phone_number = User.phone_number(user)
is_binary(phone_number) and phone_number != ""
end

def fetch_field!(changeset, field) do
{_, value} = Changeset.fetch_field(changeset, field)
value
Expand Down

0 comments on commit d94db5d

Please sign in to comment.