From 39e6f36e9a513eab0c749f49259970ef71f5294c Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Tue, 28 Nov 2023 01:34:04 +0000 Subject: [PATCH] Continue improving home screen --- lib/wish_web/components/layouts/app.html.heex | 20 +-------- .../components/layouts/root.html.heex | 8 ---- lib/wish_web/live/home_live/index.ex | 31 ++++++++++++++ lib/wish_web/live/home_live/index.html.heex | 42 ++++--------------- lib/wish_web/live/item_live/form_component.ex | 1 - lib/wish_web/live/item_live/show.html.heex | 1 - lib/wish_web/router.ex | 9 ++-- 7 files changed, 46 insertions(+), 66 deletions(-) diff --git a/lib/wish_web/components/layouts/app.html.heex b/lib/wish_web/components/layouts/app.html.heex index e23bfc8..eccbbce 100644 --- a/lib/wish_web/components/layouts/app.html.heex +++ b/lib/wish_web/components/layouts/app.html.heex @@ -2,26 +2,10 @@
- - -

- v<%= Application.spec(:phoenix, :vsn) %> -

-
- +
diff --git a/lib/wish_web/components/layouts/root.html.heex b/lib/wish_web/components/layouts/root.html.heex index 8808add..aaa8431 100644 --- a/lib/wish_web/components/layouts/root.html.heex +++ b/lib/wish_web/components/layouts/root.html.heex @@ -35,14 +35,6 @@ <% else %> -
  • - <.link - href={~p"/users/register"} - class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700" - > - Register - -
  • <.link href={~p"/users/log_in"} diff --git a/lib/wish_web/live/home_live/index.ex b/lib/wish_web/live/home_live/index.ex index ac0ee07..6224d2d 100644 --- a/lib/wish_web/live/home_live/index.ex +++ b/lib/wish_web/live/home_live/index.ex @@ -2,6 +2,7 @@ defmodule WishWeb.HomeLive.Index do use WishWeb, :live_view alias Wish.Wishlist + use Phoenix.Component @impl true def mount(_params, session, socket) do @@ -33,4 +34,34 @@ defmodule WishWeb.HomeLive.Index do {:noreply, socket} end end + + attr :item, :any + + def dropdown(assigns) do + ~H""" + + """ + end end diff --git a/lib/wish_web/live/home_live/index.html.heex b/lib/wish_web/live/home_live/index.html.heex index 9dc02e2..d8bd356 100644 --- a/lib/wish_web/live/home_live/index.html.heex +++ b/lib/wish_web/live/home_live/index.html.heex @@ -16,7 +16,6 @@ :for={item <- @items} phx-click={JS.navigate(~p"/details/#{item}")} class="h-72 p-2 rounded hover:bg-zinc-100 active:bg-zinc-200" - , >
    - <%= if item.received do %> + <%= if item.received && !@current_user do %>
    <.icon name="hero-check-circle" />Received
    @@ -37,24 +36,12 @@ <%= item.title %>
    <.icon name="hero-ellipsis-vertical" class="w-7 h-7" /> - + <.dropdown item={item} />
    +
    + <%= item.description %> +
    <% else %> @@ -71,7 +58,7 @@ alt={item.title} class="max-h-full rounded" /> - <%= if item.received do %> + <%= if item.received && !@current_user do %>
    <.icon name="hero-check-circle" />Received
    @@ -82,22 +69,7 @@
    <.icon name="hero-ellipsis-vertical" class="w-7 h-7" /> - + <.dropdown item={item} />
    diff --git a/lib/wish_web/live/item_live/form_component.ex b/lib/wish_web/live/item_live/form_component.ex index 0206993..913fff4 100644 --- a/lib/wish_web/live/item_live/form_component.ex +++ b/lib/wish_web/live/item_live/form_component.ex @@ -23,7 +23,6 @@ defmodule WishWeb.ItemLive.FormComponent do <.input field={@form[:description]} type="text" label="Description" /> <.input field={@form[:url]} type="text" label="Url" /> <.input field={@form[:image_url]} type="text" label="Image URL" /> - <.input field={@form[:received]} type="checkbox" label="Received" /> <.input field={@form[:desire]} type="number" label="Desire" /> <:actions> <.button phx-disable-with="Saving...">Save Item diff --git a/lib/wish_web/live/item_live/show.html.heex b/lib/wish_web/live/item_live/show.html.heex index aeb5508..37f23dc 100644 --- a/lib/wish_web/live/item_live/show.html.heex +++ b/lib/wish_web/live/item_live/show.html.heex @@ -12,7 +12,6 @@ <:item title="Title"><%= @item.title %> <:item title="Description"><%= @item.description %> <:item title="Url"><%= @item.url %> - <:item title="Received"><%= @item.received %> <:item title="Desire"><%= @item.desire %> diff --git a/lib/wish_web/router.ex b/lib/wish_web/router.ex index 74f826c..3665ff3 100644 --- a/lib/wish_web/router.ex +++ b/lib/wish_web/router.ex @@ -24,8 +24,11 @@ defmodule WishWeb.Router do scope "/", WishWeb do pipe_through [:browser, :get_layout] - live "/", HomeLive.Index, :index - live "/details/:id", HomeLive.Details, :index + live_session :home_page, + on_mount: [{WishWeb.UserAuth, :mount_current_user}] do + live "/", HomeLive.Index, :index + live "/details/:id", HomeLive.Details, :index + end end # Other scopes may use custom stacks. @@ -57,7 +60,7 @@ defmodule WishWeb.Router do live_session :redirect_if_user_is_authenticated, on_mount: [{WishWeb.UserAuth, :redirect_if_user_is_authenticated}] do - live "/users/register", UserRegistrationLive, :new + # live "/users/register", UserRegistrationLive, :new live "/users/log_in", UserLoginLive, :new live "/users/reset_password", UserForgotPasswordLive, :new live "/users/reset_password/:token", UserResetPasswordLive, :edit