Add price and filter homepage
This commit is contained in:
@@ -12,7 +12,14 @@ defmodule WishWeb.HomeLive.Index do
|
||||
_ -> false
|
||||
end
|
||||
|
||||
{:ok, assign(socket, :items, Wishlist.list_items()) |> assign(:grid, grid?)}
|
||||
items =
|
||||
if socket.assigns.current_user do
|
||||
Wishlist.list_items()
|
||||
else
|
||||
Wishlist.list_available_items()
|
||||
end
|
||||
|
||||
{:ok, assign(socket, :items, items) |> assign(:grid, grid?)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
||||
@@ -21,6 +21,7 @@ defmodule WishWeb.ItemLive.FormComponent do
|
||||
>
|
||||
<.input field={@form[:title]} type="text" label="Title" />
|
||||
<.input field={@form[:description]} type="text" label="Description" />
|
||||
<.input field={@form[:price]} type="number" min="0" step="any" label="Price" />
|
||||
<.input field={@form[:url]} type="text" label="Url" />
|
||||
<.input field={@form[:image_url]} type="text" label="Image URL" />
|
||||
<.input field={@form[:desire]} type="number" label="Desire" />
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
>
|
||||
<:col :let={{_id, item}} label="Title"><%= item.title %></:col>
|
||||
<:col :let={{_id, item}} label="Description"><%= item.description %></:col>
|
||||
<:col :let={{_id, item}} label="Price"><%= item.price %></:col>
|
||||
<:col :let={{_id, item}} label="Desire"><%= item.desire %></:col>
|
||||
<:action :let={{id, item}}>
|
||||
<.link
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<.simple_form for={@form} id="item-form" phx-change="validate" phx-submit="save">
|
||||
<.input field={@form[:title]} type="text" label="Title" />
|
||||
<.input field={@form[:description]} type="text" label="Description" />
|
||||
<.input field={@form[:price]} type="number" min="0" step="any" label="Price" />
|
||||
<.input field={@form[:url]} type="text" label="Url" />
|
||||
<.input field={@form[:image_url]} type="text" label="Image URL" />
|
||||
<.input field={@form[:desire]} type="number" label="Desire" />
|
||||
|
||||
Reference in New Issue
Block a user