From b0137736d1543c1d8ac694bbf2ed97e7fc1093b7 Mon Sep 17 00:00:00 2001 From: Martin Bavio Date: Fri, 30 Oct 2020 03:46:16 -0300 Subject: [PATCH] Make the cart page ready for skeleton --- pages/cart.tsx | 170 ++++++++++++++++++++----------------------------- 1 file changed, 69 insertions(+), 101 deletions(-) diff --git a/pages/cart.tsx b/pages/cart.tsx index 5a7b45e79..c7d7d588c 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -21,7 +21,9 @@ export async function getStaticProps({ } export default function Cart() { - const { data, isEmpty } = useCart() + const { data, error, isEmpty } = useCart() + const isLoading = data === undefined + const { price: subTotal } = usePrice( data && { amount: data.base_amount, @@ -37,112 +39,78 @@ export default function Cart() { const items = data?.line_items.physical_items ?? [] - const error = null - const success = null - - // Loading state - if (!data) { - return
Loading...
- } - return ( -
-
- {isEmpty ? ( -
- - - -

- Your cart is empty -

-

- Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake. -

-
- ) : error ? ( -
- - - -

- We couldn’t process the purchase. Please check your card - information and try again. -

-
- ) : success ? ( -
- - - -

- Thank you for your order. -

-
- ) : ( -
- My Cart - Review your Order -
    - {items.map((item) => ( - - ))} -
-
- - Before you leave, take a look at these items. We picked them - just for you - -
- {[1, 2, 3, 4, 5, 6].map((x) => ( -
+
+ My Cart + {error &&
Failed to load
} + {isLoading &&
Loading...
} + {isEmpty ? ( +
+ + + +

+ Your cart is empty +

+

+ Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake. +

+
+ ) : ( +
+
+
+ Review your Order +
    + {items.map((item) => ( + ))} +
+
+
+
+
+
+
    +
  • + Subtotal + {subTotal} +
  • +
  • + Taxes + Calculated at checkout +
  • +
  • + Estimated Shipping + FREE +
  • +
+
+ Total + {total} +
+
+
+
+ {isEmpty ? ( + + ) : ( + + )} +
- )} -
-
-
-
-
    -
  • - Subtotal - {subTotal} -
  • -
  • - Taxes - Calculated at checkout -
  • -
  • - Estimated Shipping - FREE -
  • -
-
- Total - {total} -
-
-
-
- {isEmpty ? ( - - ) : ( - - )} -
-
-
+ )}
) }