Update the Book Show to show the alternative editions.
continuous-integration/drone/push Build is passing Details

dev
KKlochko 2 months ago
parent 2ccf820f7d
commit 2275e26c88

@ -54,6 +54,17 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
</.list> </.list>
</div> </div>
<%= if not Enum.empty?(@alternative_editions) do %>
<h1 class="text-lg font-semibold leading-8 text-zinc-800 dark:text-white">Editions</h1>
<div class="flex flex-wrap flex-[3_1_auto]">
<%= for book <- @alternative_editions do %>
<.book_card
book={book}
current_user={@current_user}
/>
<% end %>
</div>
<% end %>
<.back navigate={~p"/books"}>Back to books</.back> <.back navigate={~p"/books"}>Back to books</.back>
""" """
@ -67,6 +78,7 @@ defmodule DecentralisedBookIndexWeb.BookLive.Show do
@impl true @impl true
def handle_params(%{"id" => id}, _, socket) do def handle_params(%{"id" => id}, _, socket) do
book = Ash.get!(Metadata.Book, id, actor: socket.assigns.current_user, load: [:author_roles]) book = Ash.get!(Metadata.Book, id, actor: socket.assigns.current_user, load: [:author_roles])
alternative_editions = Metadata.get_book_alternative_editions!(book)
{:noreply, {:noreply,
socket socket

Loading…
Cancel
Save