Skip to content

Commit ed8e8df

Browse files
authored
Merge pull request #128 from nada-deriv/nada/FEQ-2341/orders
nada/fix: style issues with orders
2 parents 573d366 + f7dcbed commit ed8e8df

File tree

12 files changed

+46
-21
lines changed

12 files changed

+46
-21
lines changed

src/App.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { Suspense } from 'react';
12
import { BrowserRouter } from 'react-router-dom';
23
import { QueryParamProvider } from 'use-query-params';
34
import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
45
import { AppFooter, AppHeader, DerivIframe } from '@/components';
56
import { useRedirectToOauth } from '@/hooks';
67
import AppContent from '@/routes/AppContent';
78
import { initializeI18n, TranslationProvider } from '@deriv-com/translations';
8-
import { useDevice } from '@deriv-com/ui';
9+
import { Loader, useDevice } from '@deriv-com/ui';
910

1011
const { VITE_CROWDIN_BRANCH_NAME, VITE_PROJECT_NAME, VITE_TRANSLATIONS_CDN_URL } = import.meta.env;
1112
const i18nInstance = initializeI18n({
@@ -22,10 +23,12 @@ const App = () => {
2223
<BrowserRouter>
2324
<QueryParamProvider adapter={ReactRouter5Adapter}>
2425
<TranslationProvider defaultLang='EN' i18nInstance={i18nInstance}>
25-
<DerivIframe />
26-
<AppHeader />
27-
<AppContent />
28-
{isDesktop && <AppFooter />}
26+
<Suspense fallback={<Loader isFullScreen />}>
27+
<DerivIframe />
28+
<AppHeader />
29+
<AppContent />
30+
{isDesktop && <AppFooter />}
31+
</Suspense>
2932
</TranslationProvider>
3033
</QueryParamProvider>
3134
</BrowserRouter>

src/components/PaymentMethodForm/PaymentMethodForm.scss

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@
143143
& .deriv-input__right-content {
144144
display: flex;
145145
align-items: center;
146+
& .deriv-dropdown__button {
147+
&--active {
148+
transform: none;
149+
}
150+
}
146151
}
147152
}
148153
}

src/hooks/custom-hooks/useSendbird.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,16 @@ const useSendbird = (orderId: string | undefined, isErrorOrderInfo: boolean, cha
272272

273273
useEffect(() => {
274274
// if the user has not created a chat URL for the order yet, create one using p2p_create_chat endpoint
275-
if (orderId && !chatChannelUrl) {
275+
// chatChannelUrl is received from order details, hence check if chat url was already created using p2p_create_chat
276+
if (!chatChannel?.url && sendbirdServiceToken?.app_id && orderId) {
277+
initialiseChat();
278+
} else if (orderId && !chatChannelUrl && !chatChannel?.url) {
276279
createChat({
277280
order_id: orderId,
278281
});
279-
} else if (sendbirdServiceToken?.app_id) {
280-
initialiseChat();
281282
}
282283
// eslint-disable-next-line react-hooks/exhaustive-deps
283-
}, [orderId, chatChannelUrl, sendbirdServiceToken?.app_id]);
284+
}, [orderId, chatChannelUrl, chatChannel?.url, sendbirdServiceToken?.app_id]);
284285

285286
return {
286287
activeChatChannel: chatChannel,

src/pages/orders/components/ChatMessageReceipt/ChatMessageReceipt.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentType, SVGAttributes } from 'react';
1+
import { ComponentType, memo, SVGAttributes } from 'react';
22
import { CHAT_MESSAGE_STATUS } from '@/constants';
33
import { useSendbird } from '@/hooks/custom-hooks';
44
import { ReactComponent as MessageDeliveredIcon } from '../../../../public/ic-message-delivered.svg';
@@ -37,4 +37,4 @@ const ChatMessageReceipt = ({ chatChannel, message, userId }: TChatMessageReceip
3737
return <Icon data-testid='dt_chat_message_receipt_icon' />;
3838
};
3939

40-
export default ChatMessageReceipt;
40+
export default memo(ChatMessageReceipt);

src/pages/orders/components/ChatMessages/ChatMessages.scss

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
background-color: #ffffff;
33
margin-top: auto;
44
margin-right: 0.8rem;
5-
height: calc(60vh - 16rem);
5+
display: flex;
6+
flex-direction: column;
7+
flex-grow: 1;
68
overflow-y: auto;
79

810
@include mobile {
@@ -15,7 +17,11 @@
1517
&__item {
1618
display: flex;
1719
flex-direction: column;
18-
margin: 1.6rem 1.2rem 1.6rem 2.4rem;
20+
margin: 1.6rem 1.2rem 0 2.4rem;
21+
22+
&:last-child {
23+
margin-bottom: 1.6rem;
24+
}
1925

2026
&__file {
2127
color: inherit;

src/pages/orders/screens/OrderDetails/OrderDetails.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.order-details {
22
overflow: overlay;
3-
height: calc(100vh - 22rem);
3+
height: calc(100vh - 27rem);
44

55
@include mobile {
66
position: absolute;

src/pages/orders/screens/OrderDetails/OrderDetails.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const OrderDetails = () => {
140140
<Text size='2xs'>{warningMessage}</Text>
141141
</InlineMessage>
142142
)}
143-
<div className='grid grid-cols-none lg:grid-cols-2 lg:gap-14'>
143+
<div className='grid grid-cols-none lg:grid-cols-2 lg:gap-14 h-full'>
144144
<OrderDetailsCard sendFile={sendFile} />
145145
<OrdersChatSection
146146
isInactive={!!orderDetails?.isInactiveOrder}

src/pages/orders/screens/OrderDetails/__tests__/OrderDetails.spec.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ jest.mock('@/hooks/custom-hooks', () => ({
7070
},
7171
}),
7272
useSendbird: () => ({
73+
activeChatChannel: {
74+
isFrozen: false,
75+
},
7376
isOnline: true,
7477
lastOnlineTime: 123546789,
7578
nickname: 'John Doe',

src/pages/orders/screens/Orders/OrdersTable/OrdersTable.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
height: calc(100vh - 35rem) !important;
99

1010
@include mobile {
11-
height: calc(100vh - 17rem) !important;
11+
height: calc(100vh - 20rem) !important;
1212
}
1313

1414
&__row {

src/pages/orders/screens/Orders/OrdersTableRow/OrdersTableRow.scss

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
align-items: center;
66
grid-template-columns: 1fr 1.5fr 2fr 3fr 1.5fr 1.5fr 1.5fr;
77
cursor: pointer;
8+
min-height: 7.3rem;
89
}
910

1011
@include mobile {

src/pages/orders/screens/OrdersChatSection/OrdersChatSection.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
border-radius: 4px;
33
border: 8px solid #f2f3f4;
44
width: 44rem;
5+
display: flex;
6+
flex-direction: column;
7+
justify-content: center;
8+
align-items: center;
9+
min-height: 60vh;
10+
height: 100%;
511

612
@include mobile {
713
width: unset;
@@ -29,7 +35,7 @@
2935
}
3036

3137
&--closed {
32-
height: calc(100vh - 2rem);
38+
height: calc(100vh - 5rem);
3339

3440
& .mobile-wrapper {
3541
&__footer {

src/pages/orders/screens/OrdersChatSection/OrdersChatSection.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const OrdersChatSection = ({ isInactive, onReturn, otherUserDetails, ...sendBird
2929

3030
if (isError) {
3131
return (
32-
<div className='orders-chat-section flex flex-col justify-center items-center h-[70vh]'>
32+
<div className='orders-chat-section'>
3333
<ChatError onClickRetry={refreshChat} />
3434
</div>
3535
);
@@ -48,7 +48,7 @@ const OrdersChatSection = ({ isInactive, onReturn, otherUserDetails, ...sendBird
4848
)}
4949
renderHeader={() => <ChatHeader isOnline={isOnline} lastOnlineTime={lastOnlineTime} nickname={name} />}
5050
>
51-
{isChatLoading ? (
51+
{isChatLoading || !activeChatChannel ? (
5252
<Loader isFullScreen={false} />
5353
) : (
5454
<ChatMessages chatChannel={activeChatChannel} chatMessages={messages} userId={userId} />
@@ -57,8 +57,8 @@ const OrdersChatSection = ({ isInactive, onReturn, otherUserDetails, ...sendBird
5757
);
5858
}
5959
return (
60-
<div className='orders-chat-section flex flex-col justify-center items-center h-[60vh]'>
61-
{isChatLoading ? (
60+
<div className='orders-chat-section'>
61+
{isChatLoading || !activeChatChannel ? (
6262
<Loader isFullScreen={false} />
6363
) : (
6464
<>

0 commit comments

Comments
 (0)