From 04bddcbf3d94e25a0aff7b363aae1ab67183c34a Mon Sep 17 00:00:00 2001 From: kundan singh Date: Fri, 5 Apr 2024 13:30:28 +0530 Subject: [PATCH] fix: fixed order details data --- apps/retail/components/filter/Filter.tsx | 6 +- apps/retail/pages/orderConfirmation.tsx | 91 ++-- apps/retail/pages/orderDetails.tsx | 648 +++++++++++------------ apps/retail/pages/search.tsx | 6 +- 4 files changed, 365 insertions(+), 386 deletions(-) diff --git a/apps/retail/components/filter/Filter.tsx b/apps/retail/components/filter/Filter.tsx index 158caba25..083e38781 100644 --- a/apps/retail/components/filter/Filter.tsx +++ b/apps/retail/components/filter/Filter.tsx @@ -136,14 +136,14 @@ const Filter = ({ handleApplyFilter, handleResetFilter }) => { paddingBottom={'2px'} > - - + + - Sort By Rating + Filter By Rating diff --git a/apps/retail/pages/orderConfirmation.tsx b/apps/retail/pages/orderConfirmation.tsx index f061e6fd6..aab6d8aa9 100644 --- a/apps/retail/pages/orderConfirmation.tsx +++ b/apps/retail/pages/orderConfirmation.tsx @@ -5,7 +5,7 @@ import { useSelector, useDispatch } from 'react-redux' import { useLanguage } from '../hooks/useLanguage' import { ConfirmationPage } from '@beckn-ui/becknified-components' import { InitResponseModel } from '../types/init.types' -import { CheckoutRootState,checkoutActions } from '@store/checkout-slice' +import { CheckoutRootState, checkoutActions } from '@store/checkout-slice' import { orderActions } from '@store/order-slice' import { useConfirmMutation } from '@services/confirm' import { getPayloadForConfirm, getPayloadForOrderHistoryPost } from '@utils/confirm-utils' @@ -23,7 +23,6 @@ const OrderConfirmation = () => { const [confirm, { isLoading, data }] = useConfirmMutation() const dispatch = useDispatch() - const initResponse = useSelector((state: CheckoutRootState) => state.checkout.initResponse) const confirmResponse = useSelector((state: CheckoutRootState) => state.checkout.confirmResponse) const apiUrl = process.env.NEXT_PUBLIC_API_URL @@ -72,51 +71,53 @@ const OrderConfirmation = () => { } return ( - 0 && confirmResponse[0].message.orderId.slice(0, 8)}...`, - trackOrderMessage:`You can track your order in "My Order" section`, - - buttons: [ - { - text: 'View Details', - handleClick: () => { - const orderId = confirmResponse[0].message.orderId - const bppId = confirmResponse[0].context.bppId - const bppUri = confirmResponse[0].context.bppUri + + 0 && confirmResponse[0].message.orderId.slice(0, 8)}...`, + trackOrderMessage: `You can track your order in "My Order" section`, - dispatch(orderActions.addSelectedOrder({ orderDetails: { orderId, bppId, bppUri } })) - const orderObjectForStatusCall = { - bppId: bppId, - bppUri: bppUri, - orderId: orderId - } - localStorage.setItem('selectedOrder', JSON.stringify(orderObjectForStatusCall)) - dispatch(checkoutActions.clearState()) - router.push('/orderDetails') - }, - disabled: false, - variant: 'solid', - colorScheme: 'primary' - }, - { - text: 'Go Back Home', - handleClick: () => { - router.push('/') - dispatch(checkoutActions.clearState()) + buttons: [ + { + text: 'View Details', + handleClick: () => { + const orderId = confirmResponse[0].message.orderId + const bppId = confirmResponse[0].context.bppId + const bppUri = confirmResponse[0].context.bppUri + + dispatch(orderActions.addSelectedOrder({ orderDetails: { orderId, bppId, bppUri } })) + const orderObjectForStatusCall = { + bppId: bppId, + bppUri: bppUri, + orderId: orderId + } + localStorage.setItem('selectedOrder', JSON.stringify(orderObjectForStatusCall)) + dispatch(checkoutActions.clearState()) + router.push('/orderDetails') + }, + disabled: false, + variant: 'solid', + colorScheme: 'primary' }, - disabled: false, - variant: 'outline', - colorScheme: 'primary' - } - ] - }} - /> + { + text: 'Go Back Home', + handleClick: () => { + router.push('/') + dispatch(checkoutActions.clearState()) + }, + disabled: false, + variant: 'outline', + colorScheme: 'primary' + } + ] + }} + /> + ) } diff --git a/apps/retail/pages/orderDetails.tsx b/apps/retail/pages/orderDetails.tsx index e1282dfb6..014bf42f0 100644 --- a/apps/retail/pages/orderDetails.tsx +++ b/apps/retail/pages/orderDetails.tsx @@ -67,7 +67,7 @@ const OrderDetails = () => { const apiUrl = process.env.NEXT_PUBLIC_API_URL const { isOpen, onOpen, onClose } = useDisclosure() const [orderStatusMap, setOrderStatusMap] = useState([]) - const {isDesktop} = useResponsive() + const { isDesktop } = useResponsive() const { transactionId } = useSelector((state: DiscoveryRootState) => state.discovery) const orderMetaData = useSelector((state: OrdersRootState) => state.orders.selectedOrderDetails) const [currentStatusLabel, setCurrentStatusLabel] = useState('') @@ -555,6 +555,7 @@ const OrderDetails = () => { const ordersLength = data.statusData.length const { timestamp } = data.statusData[0].context + const productName = data.statusData[0].message.order.items.name const { order } = data.statusData[0].message const { billing, @@ -574,7 +575,7 @@ const OrderDetails = () => { } = stops[0] const filteredOrder = data.statusData.filter(res => { - const {state} = res.message.order.fulfillments[0] + const { state } = res.message.order.fulfillments[0] state && res.message.order.fulfillments[0].state.descriptor.short_desc === 'Delivered' }) @@ -583,11 +584,10 @@ const OrderDetails = () => { className="hideScroll" maxH="calc(100vh - 100px)" overflowY="scroll" - display={{base:'block',lg:'flex'}} - justifyContent='space-between' - marginTop='2rem' - gap='3rem' - + display={{ base: 'block', lg: 'flex' }} + justifyContent="space-between" + marginTop="2rem" + gap="3rem" > {processState.allOrderDelivered && ( { )} - - - - - - - + + + + + + product image + + + + + + + + + + + + + + {/* Display progress summary */} + - - - - - - - - {/* Display progress summary */} - - - + {/* DANKTODO */} + {/* Display order status details */} + + + <> + + + threeDots + - {/* DANKTODO */} - {/* Display order status details */} - - - <> - - - threeDots - + + + + {data.statusData[0]?.message?.order?.items[0]?.name} + + + +{data.statusData[0].message.order.items.length - 1} + + - - - - {data.statusData[0]?.message?.order?.items[0]?.name} - - +{data.statusData[0].message.order.items.length - 1} + pending - - - pending - - - - + + + isOpen={isOpen} + onOpen={onOpen} + onClose={onClose} + items={data.statusData[0].message.order.items} + orderId={`${orderMetaData.orderIds[0].slice(0, 5)}...`} + /> - {/* Display order status progress */} - - {orderStatusMap.map((status: OrderStatusProgressProps, index: number) => ( - - ))} - - - + {/* Display order status progress */} + + {orderStatusMap.map((status: OrderStatusProgressProps, index: number) => ( + + ))} + + + - {/* shipping and billing address */} - - { - isDesktop && ( - + {isDesktop && ( + - - - ) - - } - { - !isDesktop && ( - - - - ) - } - -{ - isDesktop && ( + name={{ text: shippingName, icon: nameIcon }} + address={{ text: shipmentAddress, icon: locationIcon }} + mobile={{ text: shippingPhone, icon: CallphoneIcon }} + /> + )} + {!isDesktop && ( + + + )} - - ) - - } - { - !isDesktop && ( - - + )} + {!isDesktop && ( + + - - ) - } - + + )} - { - isDesktop && ( - + {isDesktop && ( + - ) - } - - {!isDesktop && ( - - - - - )} - - - - - {/* Display main bottom modal */} - - {uiState.isLoadingForTrackAndSupport ? ( - - - - ) : ( - - {menuItems(data.trackUrl as string).map((menuItem, index) => ( - - - - - ))} - - {callMenuItem(data.supportData as SupportModel).map((menuItem, index) => ( - - - - - ))} - + {!isDesktop && ( + + + + + )} - - {/* Display cancellation bottom modal */} - - {uiState.isLoadingForCancel ? ( - - ) : ( - <> - - { - setProcessState(prevValue => ({ - ...prevValue, - radioValue: value - })) - setUiState(prevValue => ({ - ...prevValue, - isProceedDisabled: false - })) - }} - value={processState.radioValue} - pl="20px" + {/* Display main bottom modal */} + + {uiState.isLoadingForTrackAndSupport ? ( + - {orderCancelReason.map(reasonObj => ( - + + ) : ( + + {menuItems(data.trackUrl as string).map((menuItem, index) => ( + + + + + ))} + + {callMenuItem(data.supportData as SupportModel).map((menuItem, index) => ( + - {reasonObj.reason} - + + + ))} - -