diff --git a/lib/gallium/ticketing.ex b/lib/gallium/ticketing.ex index c47e750..997ee67 100644 --- a/lib/gallium/ticketing.ex +++ b/lib/gallium/ticketing.ex @@ -20,6 +20,32 @@ defmodule Gallium.Ticketing do |> Repo.preload([:payment, :accompany, user: :ticket]) end + @doc """ + Groups attendees (and their accompanies) by `table_preference`. + """ + def list_tables_with_attendees do + Attendee + |> where([a], not is_nil(a.table_preference) and a.table_preference != "") + |> order_by([a], asc: a.table_preference, asc: a.inserted_at) + |> Repo.all() + |> Repo.preload(:accompany) + |> Enum.group_by(& &1.table_preference) + |> Enum.map(fn {table, attendees} -> {table, table_people(attendees)} end) + |> Enum.sort_by(fn {table, _} -> table end) + end + + defp table_people(attendees) do + Enum.flat_map(attendees, &attendee_and_accompany/1) + end + + defp attendee_and_accompany(%Attendee{accompany: nil} = attendee) do + [%{full_name: attendee.full_name}] + end + + defp attendee_and_accompany(%Attendee{accompany: accompany} = attendee) do + [%{full_name: attendee.full_name}, %{full_name: accompany.full_name}] + end + @doc """ Returns the list of accompanies. diff --git a/lib/gallium_web/live/backoffice/components/sidebar.ex b/lib/gallium_web/live/backoffice/components/sidebar.ex index fbc1209..801fbeb 100644 --- a/lib/gallium_web/live/backoffice/components/sidebar.ex +++ b/lib/gallium_web/live/backoffice/components/sidebar.ex @@ -7,17 +7,23 @@ defmodule GalliumWeb.BackOffice.Components.Sidebar do def sidebar(assigns) do menu_items = [ - %{ - action: :members, - icon: "hero-arrow-up-tray", - label: "Adicionar Membros", - path: ~p"/dashboard/members" - }, %{ action: :attendees, icon: "hero-users", label: "Inscrições", path: ~p"/dashboard/attendees" + }, + %{ + action: :tables, + icon: "hero-rectangle-group", + label: "Mesas", + path: ~p"/dashboard/tables" + }, + %{ + action: :members, + icon: "hero-arrow-up-tray", + label: "Sócios", + path: ~p"/dashboard/members" } ] @@ -28,8 +34,7 @@ defmodule GalliumWeb.BackOffice.Components.Sidebar do "fixed left-0 top-0 h-screen w-64 flex-shrink-0 md:relative md:h-auto md:border-r-2 md:border-gray-300 z-50 transition-transform duration-300 overflow-y-auto bg-white md:bg-transparent", if(@sidebar_open, do: "translate-x-0", else: "-translate-x-full md:translate-x-0") ]}> -
-

Menu

+