diff --git a/src/hooks/custom-hooks/useSendbird.ts b/src/hooks/custom-hooks/useSendbird.ts index 22afdc64..4650b756 100644 --- a/src/hooks/custom-hooks/useSendbird.ts +++ b/src/hooks/custom-hooks/useSendbird.ts @@ -276,6 +276,7 @@ const useSendbird = (orderId: string, isErrorOrderInfo: boolean, chatChannelUrl: } else if (sendbirdServiceToken?.app_id) { initialiseChat(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [orderId, chatChannelUrl, sendbirdServiceToken?.app_id]); return { diff --git a/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx b/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx index bdce2e41..59abac3a 100644 --- a/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx +++ b/src/pages/orders/components/OrderDetailsCard/OrderDetailsCardFooter/OrderDetailsCardFooter.tsx @@ -24,11 +24,9 @@ const OrderDetailsCardFooter = ({ sendFile }: { sendFile: (file: File) => void } const { error, isError, mutate } = api.order.useConfirm(); const textSize = isMobile ? 'md' : 'sm'; - useEffect(() => { - //TODO: handle email verification, invalid verification, and rating modals. + //TODO: handle email verification, invalid verification, and rating modals. + const handleModalDisplay = (isError: boolean, isBuyOrderForUser: boolean, code?: string) => { if (isError) { - const { code } = error?.error ?? {}; - if (code === ERROR_CODES.ORDER_EMAIL_VERIFICATION_REQUIRED) { showModal('EmailVerificationModal'); } else if ( @@ -36,13 +34,17 @@ const OrderDetailsCardFooter = ({ sendFile }: { sendFile: (file: File) => void } code === ERROR_CODES.EXCESSIVE_VERIFICATION_REQUESTS ) { showModal('InvalidVerificationLinkModal'); - } else if (code === ERROR_CODES.EXCESSIVE_VERIFICATION_FAILURES && orderDetails.isBuyOrderForUser) { + } else if (code === ERROR_CODES.EXCESSIVE_VERIFICATION_FAILURES && isBuyOrderForUser) { showModal('EmailLinkBlockedModal'); } } else if (!isBuyOrderForUser) { showModal('RatingModal'); } - }, [error?.error, isBuyOrderForUser, isError, orderDetails.isBuyOrderForUser]); + }; + + useEffect(() => { + handleModalDisplay(isError, isBuyOrderForUser, error?.error?.code); + }, [error?.error, isBuyOrderForUser, isError]); if ( !shouldShowCancelAndPaidButton && diff --git a/src/pages/orders/screens/OrderDetails/OrderDetails.tsx b/src/pages/orders/screens/OrderDetails/OrderDetails.tsx index a8719e15..7c317174 100644 --- a/src/pages/orders/screens/OrderDetails/OrderDetails.tsx +++ b/src/pages/orders/screens/OrderDetails/OrderDetails.tsx @@ -32,8 +32,7 @@ const OrderDetails = () => { }); const { isBuyOrderForUser, shouldShowLostFundsBanner } = orderDetails; const { isMobile } = useDevice(); - const { activeChatChannel, isChatLoading, isError, messages, refreshChat, sendFile, sendMessage, userId } = - useSendbird(orderDetails?.id, !!error, orderDetails?.chat_channel_url ?? ''); + const { sendFile, userId, ...rest } = useSendbird(orderDetails?.id, !!error, orderDetails?.chat_channel_url ?? ''); const headerText = `${isBuyOrderForUser ? 'Buy' : 'Sell'} USD order`; const warningMessage = 'Don’t risk your funds with cash transactions. Use bank transfers or e-wallets instead.'; @@ -71,17 +70,12 @@ const OrderDetails = () => { {showChat ? ( ) : ( {