Skip to content

Commit

Permalink
fix: pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nada-deriv committed May 13, 2024
1 parent 1ecf5cb commit b4dbae7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/hooks/custom-hooks/useSendbird.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,27 @@ 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 (
code === ERROR_CODES.INVALID_VERIFICATION_TOKEN ||
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 &&
Expand Down
17 changes: 3 additions & 14 deletions src/pages/orders/screens/OrderDetails/OrderDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -71,17 +70,12 @@ const OrderDetails = () => {
<OrderDetailsProvider value={{ isErrorOrderInfo: !!error, orderDetails }}>
{showChat ? (
<OrdersChatSection
activeChatChannel={activeChatChannel}
isChatLoading={isChatLoading}
isError={isError}
isInactive={!!orderDetails?.isInactiveOrder}
messages={messages}
onReturn={onChatReturn}
otherUserDetails={orderDetails?.otherUserDetails}
refreshChat={refreshChat}
sendFile={sendFile}
sendMessage={sendMessage}
userId={userId ?? ''}
{...rest}
/>
) : (
<FullPageMobileWrapper
Expand Down Expand Up @@ -132,17 +126,12 @@ const OrderDetails = () => {
<div className='grid grid-cols-none lg:grid-cols-2 lg:gap-14'>
<OrderDetailsCard sendFile={sendFile} />
<OrdersChatSection
activeChatChannel={activeChatChannel}
isChatLoading={isChatLoading}
isError={isError}
isInactive={!!orderDetails?.isInactiveOrder}
messages={messages}
onReturn={onChatReturn}
otherUserDetails={orderDetails?.otherUserDetails}
refreshChat={refreshChat}
sendFile={sendFile}
sendMessage={sendMessage}
userId={userId ?? ''}
{...rest}
/>
</div>
</div>
Expand Down

0 comments on commit b4dbae7

Please sign in to comment.