diff --git a/lib/maker_passport_web/components/layouts/app.html.heex b/lib/maker_passport_web/components/layouts/app.html.heex
index 67b3190..fc4d94c 100644
--- a/lib/maker_passport_web/components/layouts/app.html.heex
+++ b/lib/maker_passport_web/components/layouts/app.html.heex
@@ -1,26 +1,6 @@
<.flash_group flash={@flash} />
- <%= if @current_user && !@current_user.profile_complete do %>
-
-
-
-
-
- Your profile is incomplete.
- <.link navigate={~p"/profiles/#{@current_user.profile.id}"} class="font-medium underline hover:text-yellow-600">
- Complete your profile here
-
-
-
-
-
- <% end %>
<%= @inner_content %>
diff --git a/lib/maker_passport_web/components/layouts/root.html.heex b/lib/maker_passport_web/components/layouts/root.html.heex
index c8784dd..f2658a5 100644
--- a/lib/maker_passport_web/components/layouts/root.html.heex
+++ b/lib/maker_passport_web/components/layouts/root.html.heex
@@ -90,6 +90,28 @@
+ -
+ <%= if !@current_user.profile_complete do %>
+
+
+
+
+
+ Your profile is incomplete.
+ <.link navigate={~p"/profiles/#{@current_user.profile.id}/edit-profile"} class="font-medium underline hover:text-yellow-600">
+ Complete your profile here
+
+
+
+
+
+ <% end %>
+
-
<.link
href={~p"/profiles/#{@current_user.profile.id}"}
diff --git a/lib/maker_passport_web/live/profile_live/show.ex b/lib/maker_passport_web/live/profile_live/show.ex
index 8637088..3411d44 100644
--- a/lib/maker_passport_web/live/profile_live/show.ex
+++ b/lib/maker_passport_web/live/profile_live/show.ex
@@ -9,23 +9,37 @@ defmodule MakerPassportWeb.ProfileLive.Show do
alias MakerPassport.Maker.Skill
@impl true
- def mount(_params, _session, socket) do
- user = socket.assigns.current_user
- profile = Maker.get_profile_with_skills_by_user_id!(user.id)
+ def mount(_params, session, socket) do
+ {:ok, socket}
+ end
+
+ @impl true
+ def handle_params(%{"id" => id} = params, _, socket) do
+ profile = Maker.get_profile!(id)
skills = ordered_skills(profile)
socket =
socket
- |> assign(:user_id, user.id)
- |> assign_new(:form, fn ->
- to_form(Maker.change_profile(profile))
- end)
- |> assign_new(:skills_form, fn ->
- to_form(Skill.changeset(%Skill{}))
- end)
+ |> assign(:profile, profile)
|> assign(:skills, skills)
- |> assign(temporary_assigns: [skills: []])
- {:ok, socket}
+ |> assign(:page_title, page_title(socket.assigns.live_action))
+
+ {:noreply, apply_action(socket, socket.assigns.live_action, params)}
+ end
+
+ defp apply_action(socket, :show, _params) do
+ socket
+ end
+
+ defp apply_action(socket, :edit_profile, _params) do
+ socket
+ |> assign_new(:form, fn ->
+ to_form(Maker.change_profile(socket.assigns.profile))
+ end)
+ |> assign_new(:skills_form, fn ->
+ to_form(Skill.changeset(%Skill{}))
+ end)
+ |> assign(:page_title, "Edit Profile")
end
defp ordered_skills(profile) do
@@ -40,17 +54,6 @@ defmodule MakerPassportWeb.ProfileLive.Show do
{:noreply, socket}
end
- @impl true
- def handle_params(%{"id" => id}, _, socket) do
- profile = Maker.get_profile!(id)
-
- socket =
- socket
- |> assign(:page_title, page_title(socket.assigns.live_action))
- |> assign(:profile, profile)
- {:noreply, socket}
- end
-
@impl true
def handle_event("save_skill", %{"search-field" => skill_name}, socket) do
save_skill(socket, skill_name, socket.assigns.profile)
diff --git a/lib/maker_passport_web/router.ex b/lib/maker_passport_web/router.ex
index 070e048..9685051 100644
--- a/lib/maker_passport_web/router.ex
+++ b/lib/maker_passport_web/router.ex
@@ -21,6 +21,7 @@ defmodule MakerPassportWeb.Router do
pipe_through :browser
live "/", HomeLive.Index, :index
+ live "/profiles", ProfileLive.Index, :index
end
# Other scopes may use custom stacks.
@@ -69,12 +70,10 @@ defmodule MakerPassportWeb.Router do
live "/users/settings", UserSettingsLive, :edit
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
- live "/profiles", ProfileLive.Index, :index
# live "/profiles/new", ProfileLive.Index, :new
# live "/profiles/me", ProfileLive.MyProfile
# live "/profiles/me/edit", ProfileLive.MyProfile, :edit
- live "/profiles/:id", ProfileLive.Show, :show
live "/profiles/:id/edit-profile", ProfileLive.Show, :edit_profile
# live "/profiles/:id/edit", ProfileLive.Index, :edit
# live "/profiles/:id/show/edit", ProfileLive.Show, :edit
@@ -90,6 +89,8 @@ defmodule MakerPassportWeb.Router do
on_mount: [{MakerPassportWeb.UserAuth, :mount_current_user}] do
live "/users/confirm/:token", UserConfirmationLive, :edit
live "/users/confirm", UserConfirmationInstructionsLive, :new
+
+ live "/profiles/:id", ProfileLive.Show, :show
end
end
end