diff --git a/lib/safira_web/live/backoffice/spotlights_live/form_component.ex b/lib/safira_web/live/backoffice/spotlights_live/form_component.ex new file mode 100644 index 00000000..8549727a --- /dev/null +++ b/lib/safira_web/live/backoffice/spotlights_live/form_component.ex @@ -0,0 +1,14 @@ +defmodule SafiraWeb.Backoffice.SpotlightLive.FormComponent do + use SafiraWeb, :live_component + + @impl true + def render(assigns) do + ~H""" +
+ <.page title={@title}> +

<%= @title %>

+ +
+ """ + end +end diff --git a/lib/safira_web/live/backoffice/spotlights_live/index.ex b/lib/safira_web/live/backoffice/spotlights_live/index.ex new file mode 100644 index 00000000..d5d932f7 --- /dev/null +++ b/lib/safira_web/live/backoffice/spotlights_live/index.ex @@ -0,0 +1,25 @@ +defmodule SafiraWeb.Backoffice.SpotlightLive.Index do + use SafiraWeb, :backoffice_view + + @impl true + def mount(_params, _session, socket) do + {:ok, assign(socket, show_form: false, title: "Spotlights")} + end + + @impl true + def handle_params(params, _url, socket) do + {:noreply, + socket + |> apply_action(socket.assigns.live_action, params)} + end + + defp apply_action(socket, :config, _params) do + socket + |> assign(:page_title, "Config") + end + + defp apply_action(socket, :index, _params) do + socket + |> assign(:page_title, "Spotlights") + end +end diff --git a/lib/safira_web/live/backoffice/spotlights_live/index.html.heex b/lib/safira_web/live/backoffice/spotlights_live/index.html.heex new file mode 100644 index 00000000..4465228b --- /dev/null +++ b/lib/safira_web/live/backoffice/spotlights_live/index.html.heex @@ -0,0 +1,26 @@ +<.page title="Spotlights"> + <:actions> +
+ <.link patch={~p"/dashboard/spotlights/config"}> + <.button> + <.icon name="hero-cog-6-tooth" class="w-5 h-5" /> + + +
+ + + +<.modal + :if={@live_action in [:config]} + id="spotlight-config" + show + on_cancel={JS.patch(~p"/dashboard/spotlights")} +> + <.live_component + id="spotlight-config" + show + module={SafiraWeb.Backoffice.SpotlightLive.FormComponent} + title={@page_title} + patch={~p"/dashboard/spotlights"} + /> + diff --git a/lib/safira_web/router.ex b/lib/safira_web/router.ex index cf3a31ce..3faf4f1b 100644 --- a/lib/safira_web/router.ex +++ b/lib/safira_web/router.ex @@ -95,6 +95,11 @@ defmodule SafiraWeb.Router do scope "/dashboard", Backoffice do pipe_through :require_staff_user + scope "/spotlights", SpotlightLive do + live "/", Index, :index + live "/config", Index, :config + end + scope "/attendees", AttendeeLive do live "/", Index, :index live "/:id", Show, :show