diff --git a/lib/decentralised_book_index_web/components/my_components/author_card.ex b/lib/decentralised_book_index_web/components/my_components/author_card.ex index 7369e52..0774e8c 100644 --- a/lib/decentralised_book_index_web/components/my_components/author_card.ex +++ b/lib/decentralised_book_index_web/components/my_components/author_card.ex @@ -34,7 +34,7 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.AuthorCard do
<.link navigate={~p"/authors/#{@author.id}"}> <%= if @author.avatar_url != nil do %> - Bonnie image + {"#{@author.name} <% else %>
diff --git a/lib/decentralised_book_index_web/live/author_live/show.ex b/lib/decentralised_book_index_web/live/author_live/show.ex index bcbcf37..6d06f14 100644 --- a/lib/decentralised_book_index_web/live/author_live/show.ex +++ b/lib/decentralised_book_index_web/live/author_live/show.ex @@ -5,8 +5,7 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do def render(assigns) do ~H""" <.header> - Author {@author.id} - <:subtitle>This is a author record from your database. + {@author.name} <:actions> <.link navigate={~p"/authors/#{@author}/edit"}> @@ -17,15 +16,38 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do - <.list> - <:item title="Id">{@author.id} +
+ <%= if @author.avatar_url != nil do %> + {"#{@author.name} + <% else %> +
+ +
+ <% end %> - <:item title="Name">{@author.name} + <.list class="mt-5"> + <:item title="Id">{@author.id} - <:item title="Description">{@author.description} + <:item title="Name">{@author.name} - <:item title="Avatar url">{@author.avatar_url} - + <:item title="Description">{@author.description} + +
+ + <%= if @alternative_names != [] do %> +

Alternatives names

+ + <% end %> <.back navigate={~p"/authors"}>Back to authors """ @@ -38,13 +60,15 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.Show do @impl true def handle_params(%{"id" => id}, _, socket) do + author = Ash.get!(DecentralisedBookIndex.Metadata.Author, id, actor: socket.assigns.current_user) + alternative_names = DecentralisedBookIndex.Metadata.get_author_alternative_names!(author) + {:noreply, socket |> assign(:page_title, page_title(socket.assigns.live_action)) - |> assign( - :author, - Ash.get!(DecentralisedBookIndex.Metadata.Author, id, actor: socket.assigns.current_user) - )} + |> assign(:author, author) + |> assign(:alternative_names, alternative_names) + } end defp page_title(:show), do: "Show Author"