forked from deriv-com/p2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuySell.tsx
66 lines (61 loc) · 2.07 KB
/
BuySell.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import clsx from 'clsx';
import { useHistory, useLocation } from 'react-router-dom';
import {
AwarenessBanner,
OutsideBusinessHoursHint,
PageReturn,
PNVBanner,
TemporarilyBarredHint,
Verification,
} from '@/components';
import { BUY_SELL_URL } from '@/constants';
import {
useGetBusinessHours,
useGetPhoneNumberVerification,
useIsAdvertiser,
useIsAdvertiserBarred,
} from '@/hooks/custom-hooks';
import { useTranslations } from '@deriv-com/translations';
import { Loader } from '@deriv-com/ui';
import { BuySellTable } from '../BuySellTable';
import './BuySell.scss';
const BuySell = () => {
const { localize } = useTranslations();
const isAdvertiser = useIsAdvertiser();
const { isGetSettingsLoading, shouldShowVerification } = useGetPhoneNumberVerification();
const { isScheduleAvailable } = useGetBusinessHours();
const isAdvertiserBarred = useIsAdvertiserBarred();
const history = useHistory();
const location = useLocation();
const verified = new URLSearchParams(location.search).get('verified');
if (isGetSettingsLoading) {
return <Loader />;
}
if (verified === 'false') {
return (
<div className='buy-sell--not-verified'>
<PageReturn
onClick={() => history.replace({ pathname: BUY_SELL_URL, search: '' })}
pageTitle={localize('Verification')}
weight='bold'
/>
<Verification />
</div>
);
}
return (
<div
className={clsx('buy-sell relative', {
'buy-sell--barred': isAdvertiserBarred,
'buy-sell--outside-hours': !isScheduleAvailable && !isAdvertiserBarred,
})}
>
{isAdvertiserBarred && <TemporarilyBarredHint />}
{!isScheduleAvailable && !isAdvertiserBarred && <OutsideBusinessHoursHint />}
{isAdvertiser && shouldShowVerification && <PNVBanner />}
<AwarenessBanner />
<BuySellTable />
</div>
);
};
export default BuySell;