<.back_to_link
diff --git a/lib/spazio_solazzo_web/live/admin/dashboard_live.html.heex b/lib/spazio_solazzo_web/live/admin/dashboard_live.html.heex
index 67cbbd9..d181282 100644
--- a/lib/spazio_solazzo_web/live/admin/dashboard_live.html.heex
+++ b/lib/spazio_solazzo_web/live/admin/dashboard_live.html.heex
@@ -1,4 +1,4 @@
-
+
diff --git a/lib/spazio_solazzo_web/live/admin/walk_in_live.html.heex b/lib/spazio_solazzo_web/live/admin/walk_in_live.html.heex
index 6f9d9cc..7ca8c54 100644
--- a/lib/spazio_solazzo_web/live/admin/walk_in_live.html.heex
+++ b/lib/spazio_solazzo_web/live/admin/walk_in_live.html.heex
@@ -1,4 +1,4 @@
-
+
<.back_to_link
diff --git a/lib/spazio_solazzo_web/live/assign_path_hook.ex b/lib/spazio_solazzo_web/live/assign_path_hook.ex
new file mode 100644
index 0000000..2a96549
--- /dev/null
+++ b/lib/spazio_solazzo_web/live/assign_path_hook.ex
@@ -0,0 +1,17 @@
+defmodule SpazioSolazzoWeb.AssignPathHook do
+ @moduledoc """
+ Attach a `handle_params` hook on any live view that injects the current path from the URL into the socket assigns
+ """
+
+ import Phoenix.Component
+ import Phoenix.LiveView
+
+ def on_mount(:default, _params, _session, socket) do
+ {:cont, attach_hook(socket, :set_current_path, :handle_params, &handle_path_update/3)}
+ end
+
+ defp handle_path_update(_params, url, socket) do
+ %{path: path} = URI.parse(url)
+ {:cont, assign(socket, :current_path, path)}
+ end
+end
diff --git a/lib/spazio_solazzo_web/live/landing/coworking_live.html.heex b/lib/spazio_solazzo_web/live/landing/coworking_live.html.heex
index de7e0bf..ef61825 100644
--- a/lib/spazio_solazzo_web/live/landing/coworking_live.html.heex
+++ b/lib/spazio_solazzo_web/live/landing/coworking_live.html.heex
@@ -1,4 +1,4 @@
-
+
<.page_header
booking_path={~p"/book/space/#{@space.slug}"}
booking_label="Request a desk"
diff --git a/lib/spazio_solazzo_web/live/landing/meeting_live.html.heex b/lib/spazio_solazzo_web/live/landing/meeting_live.html.heex
index 64a179b..ea5035c 100644
--- a/lib/spazio_solazzo_web/live/landing/meeting_live.html.heex
+++ b/lib/spazio_solazzo_web/live/landing/meeting_live.html.heex
@@ -1,4 +1,4 @@
-
+
<.page_header
booking_path={~p"/book/space/#{@space.slug}"}
booking_label="Booking request"
diff --git a/lib/spazio_solazzo_web/live/landing/music_live.html.heex b/lib/spazio_solazzo_web/live/landing/music_live.html.heex
index f4828a0..bc18e4b 100644
--- a/lib/spazio_solazzo_web/live/landing/music_live.html.heex
+++ b/lib/spazio_solazzo_web/live/landing/music_live.html.heex
@@ -1,4 +1,4 @@
-
+
<.page_header
booking_path={~p"/book/space/#{@space.slug}"}
booking_label="Booking request"
diff --git a/lib/spazio_solazzo_web/live/user/profile_live.html.heex b/lib/spazio_solazzo_web/live/user/profile_live.html.heex
index 7ec3312..7ed380b 100644
--- a/lib/spazio_solazzo_web/live/user/profile_live.html.heex
+++ b/lib/spazio_solazzo_web/live/user/profile_live.html.heex
@@ -1,4 +1,4 @@
-
+
<.back_to_link
navigate={~p"/"}
diff --git a/lib/spazio_solazzo_web/router.ex b/lib/spazio_solazzo_web/router.ex
index 8952eb7..a9fbff8 100644
--- a/lib/spazio_solazzo_web/router.ex
+++ b/lib/spazio_solazzo_web/router.ex
@@ -31,7 +31,8 @@ defmodule SpazioSolazzoWeb.Router do
ash_authentication_live_session :unauthenticated_routes,
on_mount: [
- {SpazioSolazzoWeb.LiveUserAuth, :live_user_optional}
+ {SpazioSolazzoWeb.LiveUserAuth, :live_user_optional},
+ SpazioSolazzoWeb.AssignPathHook
] do
live "/", PageLive
live "/arcipelago", CoworkingLive
@@ -41,7 +42,8 @@ defmodule SpazioSolazzoWeb.Router do
ash_authentication_live_session :no_user_routes,
on_mount: [
- {SpazioSolazzoWeb.LiveUserAuth, :live_no_user}
+ {SpazioSolazzoWeb.LiveUserAuth, :live_no_user},
+ SpazioSolazzoWeb.AssignPathHook
] do
live "/sign-in/callback", AuthCallbackLive
live "/sign-in", SignInLive
@@ -49,7 +51,8 @@ defmodule SpazioSolazzoWeb.Router do
ash_authentication_live_session :authenticated_routes,
on_mount: [
- {SpazioSolazzoWeb.LiveUserAuth, :live_user_required}
+ {SpazioSolazzoWeb.LiveUserAuth, :live_user_required},
+ SpazioSolazzoWeb.AssignPathHook
] do
live "/book/space/:space_slug", SpaceBookingLive
live "/bookings/cancel", BookingCancellationLive
@@ -58,7 +61,8 @@ defmodule SpazioSolazzoWeb.Router do
ash_authentication_live_session :admin_routes,
on_mount: [
- {SpazioSolazzoWeb.LiveUserAuth, :live_admin_required}
+ {SpazioSolazzoWeb.LiveUserAuth, :live_admin_required},
+ SpazioSolazzoWeb.AssignPathHook
] do
live "/admin/dashboard", Admin.DashboardLive
live "/admin/bookings", Admin.BookingManagementLive