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