From f900442a94f256114d749253133c47fd19fa79d2 Mon Sep 17 00:00:00 2001 From: Winston Hsiao Date: Thu, 14 Nov 2024 22:14:25 -0800 Subject: [PATCH] Adjust orders and account UI --- frontend/src/components/orders/OrderCard.tsx | 22 +- frontend/src/components/pages/Orders.tsx | 2 +- frontend/src/components/pages/Profile.tsx | 10 +- frontend/src/gen/api.ts | 2 + store/app/model.py | 3 + store/app/routers/stripe.py | 208 +++++++++---------- 6 files changed, 126 insertions(+), 121 deletions(-) diff --git a/frontend/src/components/orders/OrderCard.tsx b/frontend/src/components/orders/OrderCard.tsx index 9d9e43f9..de182cb4 100644 --- a/frontend/src/components/orders/OrderCard.tsx +++ b/frontend/src/components/orders/OrderCard.tsx @@ -24,12 +24,14 @@ const orderStatuses = [ "being_assembled", "shipped", "delivered", + "preorder_placed", "cancelled", "refunded", "failed", ]; const activeStatuses = [ + "preorder_placed", "processing", "in_development", "being_assembled", @@ -67,7 +69,7 @@ const OrderCard: React.FC<{ orderWithProduct: OrderWithProduct }> = ({ return "text-gray-600"; }; - const unitPrice = order.amount / order.quantity; + const unitPrice = order.price_amount / order.quantity; const handleOrderUpdate = (updatedOrder: Order) => { setOrderWithProduct((prev) => ({ ...prev, order: updatedOrder })); @@ -87,6 +89,22 @@ const OrderCard: React.FC<{ orderWithProduct: OrderWithProduct }> = ({

+ {order.status === "preorder_placed" && order.preorder_deposit_amount && ( +
+

+ Pre-order Deposit: {formatPrice(order.preorder_deposit_amount)} +

+ {order.preorder_release_date && ( +

+ Expected Release:{" "} + {new Date( + order.preorder_release_date * 1000, + ).toLocaleDateString()} +

+ )} +
+ )} +

Order ID: {order.id}

@@ -116,7 +134,7 @@ const OrderCard: React.FC<{ orderWithProduct: OrderWithProduct }> = ({

Quantity: {order.quantity}

- {formatPrice(order.amount)} + {formatPrice(order.price_amount)} {" "} = {formatPrice(unitPrice)} x {order.quantity} diff --git a/frontend/src/components/pages/Orders.tsx b/frontend/src/components/pages/Orders.tsx index 725e7c97..d375f991 100644 --- a/frontend/src/components/pages/Orders.tsx +++ b/frontend/src/components/pages/Orders.tsx @@ -54,7 +54,7 @@ const OrdersPage: React.FC = () => {

Your Orders

- You can view the status of your past and current orders here. + You can view the status of your orders here.

{isLoading || loadingOrders ? ( diff --git a/frontend/src/components/pages/Profile.tsx b/frontend/src/components/pages/Profile.tsx index 09505a3e..82c68a02 100644 --- a/frontend/src/components/pages/Profile.tsx +++ b/frontend/src/components/pages/Profile.tsx @@ -290,7 +290,7 @@ export const RenderProfile = (props: RenderProfileProps) => { You are set up to sell robots on K-Scale.

) : ( -

You must complete seller onboarding to sell robots

+

Complete seller onboarding to sell robots on K-Scale

)}
@@ -345,11 +345,11 @@ export const RenderProfile = (props: RenderProfileProps) => {