Only showing the current bidding to the user.

This commit is contained in:
2026-02-14 15:30:38 +01:00
parent f6d5f8d2ca
commit 1a4a05ff18

View File

@ -9,7 +9,7 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
~H""" ~H"""
<Layouts.app flash={@flash} current_scope={@current_scope}> <Layouts.app flash={@flash} current_scope={@current_scope}>
<.header> <.header>
{@page_title} {@current_scope.user.email}
<:actions> <:actions>
<.button variant="primary" navigate={~p"/biddings/new"}> <.button variant="primary" navigate={~p"/biddings/new"}>
<.icon name="hero-plus" /> Neues Gebot <.icon name="hero-plus" /> Neues Gebot
@ -18,35 +18,24 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
</.header> </.header>
<%= if @bidding_round == 0 do %> <%= if @bidding_round == 0 do %>
<p>Keine Bietrunde aktiv.</p> <p>Keine Bietrunde aktiv. Aktuell kein Bieten möglich!</p>
<% else %> <% else %>
<p>Aktive Bietrunde: {@bidding_round}</p> <p>Aktive Bietrunde: {@bidding_round} - Es kann geboten werden!</p>
<% end %> <% end %>
<.table <br />
id="biddings"
rows={@streams.biddings} <%= if @current_bidding do %>
row_click={fn {_id, bidding} -> JS.navigate(~p"/biddings/#{bidding}") end} <p><b>Aktuelles Gebot:</b></p>
> <.list>
<:col :let={{_id, bidding}} label="Bidding round">{bidding.bidding_round}</:col> <:item title="Bietrunde">{@current_bidding.bidding_round}</:item>
<:col :let={{_id, bidding}} label="Amount">{bidding.amount}</:col> <:item title="monatl. Betrag">{@current_bidding.amount}</:item>
<:col :let={{_id, bidding}} label="Depot wish one">{bidding.depot_wish_one}</:col> <:item title="Depot Wunsch 1">{@current_bidding.depot_wish_one}</:item>
<:col :let={{_id, bidding}} label="Depot wish two">{bidding.depot_wish_two}</:col> <:item title="Depot Wunsch 2">{@current_bidding.depot_wish_two}</:item>
<:action :let={{_id, bidding}}> </.list>
<div class="sr-only"> <% else %>
<.link navigate={~p"/biddings/#{bidding}"}>Show</.link> <p>Noch kein Gebot abgegeben</p>
</div> <% end %>
<.link navigate={~p"/biddings/#{bidding}/edit"}>Edit</.link>
</:action>
<:action :let={{id, bidding}}>
<.link
phx-click={JS.push("delete", value: %{id: bidding.id}) |> hide("##{id}")}
data-confirm="Gebot wirklich löschen?"
>
Delete
</.link>
</:action>
</.table>
</Layouts.app> </Layouts.app>
""" """
end end
@ -58,11 +47,13 @@ defmodule BeetRoundServerWeb.BiddingLive.Index do
end end
current_round = BiddingRoundFacade.get_current_round() current_round = BiddingRoundFacade.get_current_round()
current_bidding = Biddings.get_most_recent_bidding(socket.assigns.current_scope)
{:ok, {:ok,
socket socket
|> assign(:page_title, "Aktuelles Gebot") |> assign(:page_title, "Aktuelles Gebot")
|> assign(bidding_round: current_round) |> assign(bidding_round: current_round)
|> assign(current_bidding: current_bidding)
|> stream(:biddings, list_biddings(socket.assigns.current_scope))} |> stream(:biddings, list_biddings(socket.assigns.current_scope))}
end end