From bc7f7b1fab4006ee393b73eb0cff896db4c7cda1 Mon Sep 17 00:00:00 2001 From: kris liu Date: Wed, 9 Nov 2022 19:01:43 +0800 Subject: [PATCH] fix: order List Function 1.https://bigc-b2b.atlassian.net/browse/BUN-391 2.https://bigc-b2b.atlassian.net/browse/BUN-393 --- apps/storefront/src/pages/order/Order.tsx | 13 +++++++------ apps/storefront/src/pages/order/OrderItemCard.tsx | 9 ++++++++- apps/storefront/src/pages/order/config.ts | 14 ++++++++++++++ .../src/pages/order/shared/getOrderStatus.ts | 8 ++++---- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/apps/storefront/src/pages/order/Order.tsx b/apps/storefront/src/pages/order/Order.tsx index 0d3ea2f2..fab9156c 100644 --- a/apps/storefront/src/pages/order/Order.tsx +++ b/apps/storefront/src/pages/order/Order.tsx @@ -42,6 +42,7 @@ import { getInitFilter, FilterSearchProps, getFilterMoreData, + currencySymbol, } from './config' import { @@ -88,11 +89,11 @@ const sortByList: Array = [ }, { name: 'Lowest Price', - id: '-totalIncTax', + id: 'totalIncTax', }, { name: 'Highest Price', - id: 'totalIncTax', + id: '-totalIncTax', }, ] @@ -106,7 +107,7 @@ const sortByConfigData = { sortByList, sortByItemName, sortByLabel: 'Sort by', - defaultValue: '', + defaultValue: 'createdAt', isFirstSelect: false, w: 150, } @@ -234,12 +235,12 @@ const Order = ({ { key: 'poNumber', title: 'PO / Reference', - render: (item: ListItem, index: number) => ( goToDetail(item, index)}>{item.poNumber ? item.poNumber : '-'}), + render: (item: ListItem) => ({item.poNumber ? item.poNumber : '-'}), }, { key: 'totalIncTax', title: 'Grand total', - render: (item: ListItem) => (`${item.totalIncTax && '$'}${item.totalIncTax}`), + render: (item: ListItem) => (`${currencySymbol(item.money)}${item.totalIncTax}`), }, { key: 'status', @@ -260,7 +261,7 @@ const Order = ({ { key: 'createdAt', title: 'Created on', - render: (item: ListItem) => format(+item.createdAt, 'dd MMM yy'), + render: (item: ListItem) => format(+item.createdAt * 1000, 'dd MMM yy'), }, ] diff --git a/apps/storefront/src/pages/order/OrderItemCard.tsx b/apps/storefront/src/pages/order/OrderItemCard.tsx index 87f06fa9..e88ae56e 100644 --- a/apps/storefront/src/pages/order/OrderItemCard.tsx +++ b/apps/storefront/src/pages/order/OrderItemCard.tsx @@ -21,6 +21,10 @@ import { OrderStatus, } from './components/OrderStatus' +import { + currencySymbol, +} from './config' + interface ListItem { [key: string]: string } @@ -54,6 +58,8 @@ export const OrderItemCard = (props: OrderItemCardProps) => { const navigate = useNavigate() + console.log(JSON.parse(item.money)) + const goToDetail = (item: ListItem) => { navigate(`/orderDetail/${item.orderId}`, { state: { @@ -111,6 +117,7 @@ export const OrderItemCard = (props: OrderItemCardProps) => { minHeight: '1.43em', }} > + {currencySymbol(item.money)} {item.totalIncTax} @@ -130,7 +137,7 @@ export const OrderItemCard = (props: OrderItemCardProps) => { {`by ${item.firstName} ${item.lastName}`} - {format(+item.createdAt, 'dd MMM yy')} + {format(+item.createdAt * 1000, 'dd MMM yy')} diff --git a/apps/storefront/src/pages/order/config.ts b/apps/storefront/src/pages/order/config.ts index 1da45263..a6ae3ac7 100644 --- a/apps/storefront/src/pages/order/config.ts +++ b/apps/storefront/src/pages/order/config.ts @@ -107,3 +107,17 @@ export const getInitFilter = (isCompanyOrder: boolean, isB2BUser: boolean): Part return isB2BUser ? b2bFilterSearch : bcFilterSearch } + +export const currencySymbol = (currencyItem: string) => { + try { + if (currencyItem) { + const currencyToken = JSON.parse(JSON.parse(currencyItem))?.currency_token || '' + + return currencyToken + } + + return '' + } catch (e) { + return '' + } +} diff --git a/apps/storefront/src/pages/order/shared/getOrderStatus.ts b/apps/storefront/src/pages/order/shared/getOrderStatus.ts index f1197871..75b47cab 100644 --- a/apps/storefront/src/pages/order/shared/getOrderStatus.ts +++ b/apps/storefront/src/pages/order/shared/getOrderStatus.ts @@ -7,7 +7,7 @@ export const orderStatusCode: OrderStatusConfig = { 2: 'Shipped', 3: 'Partially Shipped', 4: 'Refunded', - 5: 'Canceled', + 5: 'Cancelled', 6: 'Declined', 7: 'Awaiting Payment', 8: 'Awaiting Pickup', @@ -25,7 +25,7 @@ const orderStatusColor: OrderStatusConfig = { Disputed: '#916CF6', Refunded: '#F4CC46', Declined: '#7A6041', - Canceled: '#000000', + Cancelled: '#000000', Shipped: '#C4DD6C', Completed: '#C4DD6C', 'Partially Shipped': '#516FAE', @@ -43,7 +43,7 @@ const orderStatusTextColor: OrderStatusConfig = { Disputed: '#FFFFFF', Refunded: 'rgba(0, 0, 0, 0.87)', Declined: '#FFFFFF', - Canceled: '#FFFFFF', + Cancelled: '#FFFFFF', Shipped: 'rgba(0, 0, 0, 0.87)', Completed: 'rgba(0, 0, 0, 0.87)', 'Partially Shipped': '#FFFFFF', @@ -62,7 +62,7 @@ const orderStatusText: OrderStatusConfig = { Disputed: 'Disputed', Refunded: 'Refunded', Declined: 'Declined', - Canceled: 'Canceled', + Cancelled: 'Cancelled', Shipped: 'Shipped', Completed: 'Completed', 'Partially Shipped': 'Partially Shipped',