defmodule BeetRoundServerWeb.BiddingLive.Show do use BeetRoundServerWeb, :live_view alias BeetRoundServer.Biddings @impl true def render(assigns) do ~H""" <.header> Bidding {@bidding.id} <:subtitle>This is a bidding record from your database. <:actions> <.button navigate={~p"/biddings"}> <.icon name="hero-arrow-left" /> <.button variant="primary" navigate={~p"/biddings/#{@bidding}/edit?return_to=show"}> <.icon name="hero-pencil-square" /> Edit bidding <.list> <:item title="Bidding round">{@bidding.bidding_round} <:item title="Amount">{@bidding.amount} <:item title="Depot wish one">{@bidding.depot_wish_one} <:item title="Depot wish two">{@bidding.depot_wish_two} """ end @impl true def mount(%{"id" => id}, _session, socket) do if connected?(socket) do Biddings.subscribe_biddings(socket.assigns.current_scope) end {:ok, socket |> assign(:page_title, "Show Bidding") |> assign(:bidding, Biddings.get_bidding!(socket.assigns.current_scope, id))} end @impl true def handle_info( {:updated, %BeetRoundServer.Biddings.Bidding{id: id} = bidding}, %{assigns: %{bidding: %{id: id}}} = socket ) do {:noreply, assign(socket, :bidding, bidding)} end def handle_info( {:deleted, %BeetRoundServer.Biddings.Bidding{id: id}}, %{assigns: %{bidding: %{id: id}}} = socket ) do {:noreply, socket |> put_flash(:error, "The current bidding was deleted.") |> push_navigate(to: ~p"/biddings")} end def handle_info({type, %BeetRoundServer.Biddings.Bidding{}}, socket) when type in [:created, :updated, :deleted] do {:noreply, socket} end end