From a95b13b9dd6c7b8b93aaea3d39554f4b740f6d04 Mon Sep 17 00:00:00 2001 From: feliciofilipe Date: Sat, 18 Jun 2022 18:54:13 +0100 Subject: [PATCH] Add vault empty state --- .../live/app/vault/order_live/index.ex | 16 +++ .../live/app/vault/order_live/index.html.heex | 132 +++++++++++++----- .../templates/layout/live.html.heex | 5 + 3 files changed, 116 insertions(+), 37 deletions(-) diff --git a/lib/parzival_web/live/app/vault/order_live/index.ex b/lib/parzival_web/live/app/vault/order_live/index.ex index 3dd2dce8..11571b36 100644 --- a/lib/parzival_web/live/app/vault/order_live/index.ex +++ b/lib/parzival_web/live/app/vault/order_live/index.ex @@ -18,9 +18,25 @@ defmodule ParzivalWeb.App.OrderLive.Index do socket |> assign(:current_page, :vault) |> assign(:params, params) + |> assign(list_products(params)) |> assign(list_orders(params, socket))} end + defp list_products(params) do + case Store.list_products(params) do + {:ok, {products, meta}} -> + products = + products + |> Enum.filter(fn product -> product.stock > 0 end) + |> Enum.take(3) + + %{products: products, meta: meta} + + {:error, flop} -> + %{products: [], meta: flop} + end + end + defp list_orders(params, socket) do params = params diff --git a/lib/parzival_web/live/app/vault/order_live/index.html.heex b/lib/parzival_web/live/app/vault/order_live/index.html.heex index 2befec50..bca71058 100644 --- a/lib/parzival_web/live/app/vault/order_live/index.html.heex +++ b/lib/parzival_web/live/app/vault/order_live/index.html.heex @@ -11,47 +11,105 @@

Items in your shopping cart

- - <.pagination items={@orders} meta={@meta} params={@params} class="flex justify-between items-center w-full" /> + + <.pagination items={@orders} meta={@meta} params={@params} class="flex justify-between items-center w-full" /> + <% else %> +
+
+
+ +

+ Buy Prizes +

+

+ You haven’t purchased any prizes from the store yet. Spen your + tokens wisely. +

+
+
+
+

+ Prizes that you can still purchase +

+
    + <%= for product <- @products do %> +
  • + <%= live_patch to: Routes.product_show_path(@socket, :show, product), class: "px-5 flex justify-between items-center py-4 space-x-3 hover:bg-gray-50" do %> +
    +
    + +
    +
    +

    + <%= product.name %> +

    +
    +
    +
    +

    + 💰 <%= product.price %> +

    +
    + <% end %> +
  • + <% end %> +
+
+
+ +
+
+
+

+

+
+
+
+

+
    +
    +
    + <% end %>
    diff --git a/lib/parzival_web/templates/layout/live.html.heex b/lib/parzival_web/templates/layout/live.html.heex index dfbd762c..c09c5cc2 100644 --- a/lib/parzival_web/templates/layout/live.html.heex +++ b/lib/parzival_web/templates/layout/live.html.heex @@ -121,6 +121,11 @@ <% end %> <% end %> +
    + <%= for i <- 1..12 do %> +
    + <% end %> +