Skip to content

Commit

Permalink
fix: code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and kris-liu-smile committed Nov 22, 2022
1 parent 87b2a77 commit 796a62c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
9 changes: 4 additions & 5 deletions apps/storefront/src/pages/order/Order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ const Order = ({
setFilterData(search)
const initFilter = async () => {
const fn = isB2BUser ? getOrderStatusType : getBcOrderStatusType
const {
orderStatuses = [],
}: any = await fn()
const filterInfo = getFilterMoreData(isB2BUser, isCompanyOrder, orderStatuses)
setOrderStatuses(orderStatuses)
const orderStatusesName = isB2BUser ? 'orderStatuses' : 'bcOrderStatuses'
const orderStatuses: any = await fn()
const filterInfo = getFilterMoreData(isB2BUser, isCompanyOrder, orderStatuses[orderStatusesName])
setOrderStatuses(orderStatuses[orderStatusesName])
setFilterInfo(filterInfo)
}

Expand Down
8 changes: 3 additions & 5 deletions apps/storefront/src/pages/orderDetail/OrderDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,12 @@ const OrderDetail = () => {

const getOrderStatus = async () => {
const fn = isB2BUser ? getOrderStatusType : getBcOrderStatusType
const {
orderStatuses = [],
}: any = await fn()

const orderStatusesName = isB2BUser ? 'orderStatuses' : 'bcOrderStatuses'
const orderStatuses: any = await fn()
dispatch({
type: 'statusType',
payload: {
orderStatus: orderStatuses,
orderStatus: orderStatuses[orderStatusesName],
},
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ const DetailPagination = ({

if (listIndex === totalCount - 1) {
flag = 'toRight'
leftId = list[list.length - 2].node.orderId
leftId = list[list.length - 2]?.node.orderId || 0
} else if (listIndex === 0) {
flag = 'toLeft'
rightId = list[1].node.orderId
rightId = list[1]?.node.orderId || 0
} else {
leftId = list[0].node.orderId
rightId = list[2].node.orderId
leftId = list[0]?.node.orderId || 0
rightId = list[2]?.node.orderId || 0
}

setRightLeftSide({
Expand Down

0 comments on commit 796a62c

Please sign in to comment.