diff --git a/lib/beet_round_server_web/live/bidding_live/form.ex b/lib/beet_round_server_web/live/bidding_live/form.ex index 073c027..d267e59 100644 --- a/lib/beet_round_server_web/live/bidding_live/form.ex +++ b/lib/beet_round_server_web/live/bidding_live/form.ex @@ -3,6 +3,7 @@ defmodule BeetRoundServerWeb.BiddingLive.Form do alias BeetRoundServer.Biddings alias BeetRoundServer.Biddings.Bidding + alias BeetRoundServer.BiddingRounds.BiddingRoundFacade @impl true def render(assigns) do @@ -12,25 +13,35 @@ defmodule BeetRoundServerWeb.BiddingLive.Form do {@page_title} <:subtitle>Bitte gib hier den Betrag ein, den Du monatlich bezahlen willst. - <.form for={@form} id="bidding-form" phx-change="validate" phx-submit="save"> - <.input field={@form[:bidding_round]} type="number" label="Bidding round" /> - <.input field={@form[:amount]} type="number" label="Amount" /> - <.input field={@form[:depot_wish_one]} type="text" label="Depot wish one" /> - <.input field={@form[:depot_wish_two]} type="text" label="Depot wish two" /> + <%= if @bidding.bidding_round == 0 do %> +

Keine Bietrunde aktiv.

- + <% else %> + <.form for={@form} id="bidding-form" phx-change="validate" phx-submit="save"> + <.input field={@form[:bidding_round]} type="number" label="Bidding round" /> + <.input field={@form[:amount]} type="number" label="Amount" /> + <.input field={@form[:depot_wish_one]} type="text" label="Depot wish one" /> + <.input field={@form[:depot_wish_two]} type="text" label="Depot wish two" /> + + + <% end %> """ end @impl true def mount(params, _session, socket) do + # current_round = BiddingRoundFacade.get_current_round() + {:ok, socket |> assign(:return_to, return_to(params["return_to"])) + # |> assign(bidding_round: current_round) |> apply_action(socket.assigns.live_action, params)} end @@ -47,7 +58,12 @@ defmodule BeetRoundServerWeb.BiddingLive.Form do end defp apply_action(socket, :new, _params) do - bidding = %Bidding{user_id: socket.assigns.current_scope.user.id} + current_round = BiddingRoundFacade.get_current_round() + + bidding = %Bidding{ + user_id: socket.assigns.current_scope.user.id, + bidding_round: current_round + } socket |> assign(:page_title, "Neues Gebot")