From 971fd30be6c246649e1fe8197597434fd5043715 Mon Sep 17 00:00:00 2001 From: Krishna Penukonda Date: Thu, 2 Jul 2026 09:53:57 +0000 Subject: [PATCH] feat: add sidebar to /claim page Wrap /claim page in the shared sidebar layout to match /live and /n pages. --- lib/unfinal_web/live/claim_live.ex | 91 ++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/lib/unfinal_web/live/claim_live.ex b/lib/unfinal_web/live/claim_live.ex index fd5a7b2..9afb60f 100644 --- a/lib/unfinal_web/live/claim_live.ex +++ b/lib/unfinal_web/live/claim_live.ex @@ -2,17 +2,23 @@ defmodule UnfinalWeb.ClaimLive do use UnfinalWeb, :live_view alias Unfinal.NamespaceStore + alias UnfinalWeb.Layouts @impl true def mount(_params, session, socket) do with %{"authenticated" => true, "user" => %{"id" => user_id} = user} <- session do + claimed_namespace = NamespaceStore.namespace_for_user_id(user_id) + {:ok, assign(socket, user: user, - claimed_namespace: NamespaceStore.namespace_for_user_id(user_id), + authenticated: true, + claimed_namespace: claimed_namespace, + show_claim_link?: is_nil(claimed_namespace), namespace: "", message: nil, - error: nil + error: nil, + mobile_menu_open: false )} else _session -> @@ -54,6 +60,14 @@ defmodule UnfinalWeb.ClaimLive do end end + def handle_event("toggle_mobile_menu", _params, socket) do + {:noreply, assign(socket, mobile_menu_open: !socket.assigns.mobile_menu_open)} + end + + def handle_event("close_mobile_menu", _params, socket) do + {:noreply, assign(socket, mobile_menu_open: false)} + end + defp assign_validation(socket, namespace) do namespace = String.trim(namespace) @@ -86,37 +100,52 @@ defmodule UnfinalWeb.ClaimLive do @impl true def render(assigns) do ~H""" -
-

Claim your page

+
+
+ -
- You already claimed /n/{@claimed_namespace}. +
+
+

Claim your page

+ +
+ You already claimed /n/{@claimed_namespace}. +
+ + <.form + :if={!@claimed_namespace} + for={%{}} + as={:claim} + id="claim-form" + phx-change="validate" + phx-submit="claim" + class="flex flex-col gap-3" + > + + +

{@error}

+

{@message}

+ + +
+
- - <.form - :if={!@claimed_namespace} - for={%{}} - as={:claim} - id="claim-form" - phx-change="validate" - phx-submit="claim" - class="flex flex-col gap-3" - > - - -

{@error}

-

{@message}

- - -
+ """ end end