Skip to content

Commit

Permalink
fix: master conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nada-deriv committed Jun 11, 2024
2 parents f620365 + 6c86d94 commit 083caca
Show file tree
Hide file tree
Showing 83 changed files with 1,400 additions and 266 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ jobs:
- name: Publish to Cloudflare Pages
id: publish-to-pages
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINK_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINK_ACCOUNT_ID }}
HEAD_BRANCH: ${{ github.head_ref }}
run: |
echo "Installing Wrangler CLI"
npm i -g wrangler
echo "Deploying build to Cloudflare Pages"
directory='dist'
projectName=${{ secrets.CLOUDFLARE_PROJECT_NAME }}
projectName=${{ secrets.CLOUDFLARE_TEST_LINK_PROJECT_NAME }}
branch=$(echo "$HEAD_BRANCH" | head -c 20 | sed 's/[\/_\.]/-/g; s/[^a-zA-Z0-9]$/1/')
cf_preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?)
echo "------"
Expand Down
1 change: 1 addition & 0 deletions localstorage-sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'https://staging-app.deriv.me',
'https://staging-app.deriv.be',
'https://test-app.deriv.com',
'https://uat-app.deriv.com',
];

if (allowed_origins.includes(message.origin)) {
Expand Down
27 changes: 11 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@babel/preset-env": "^7.24.5",
"@deriv-com/api-hooks": "^0.1.24",
"@deriv-com/api-hooks": "^1.1.1",
"@deriv-com/translations": "^1.2.4",
"@deriv-com/ui": "^1.28.0",
"@deriv-com/utils": "latest",
Expand Down
6 changes: 5 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { BrowserRouter } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';
import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
import { AppFooter, AppHeader, DerivIframe } from '@/components';
import { useRedirectToOauth } from '@/hooks';
import AppContent from '@/routes/AppContent';
import { initializeI18n, TranslationProvider } from '@deriv-com/translations';
import { useDevice } from '@deriv-com/ui';
import AppContent from './routes/AppContent';

const { VITE_CROWDIN_BRANCH_NAME, VITE_PROJECT_NAME, VITE_TRANSLATIONS_CDN_URL } = import.meta.env;
const i18nInstance = initializeI18n({
Expand All @@ -13,6 +14,9 @@ const i18nInstance = initializeI18n({

const App = () => {
const { isDesktop } = useDevice();
const { redirectToOauth } = useRedirectToOauth();

redirectToOauth();

return (
<BrowserRouter>
Expand Down
183 changes: 182 additions & 1 deletion src/__mocks__/mock-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TAdvertType, TType01 } from 'types';
import { TAdvertType, TPaymentFieldType, TType01, TWalletType } from 'types';

export const mockAdvertValues = {
account_currency: 'USD',
Expand Down Expand Up @@ -93,3 +93,184 @@ export const mockAdvertValues = {
type: 'sell' as 'buy' | 'sell',
visibility_status: ['advertiser_temp_ban'] as TAdvertType['visibility_status'],
};

export const mockAdvertiserPaymentMethods = [
{
display_name: 'Other',
fields: {
account: {
display_name: 'Account ID / phone number / email',
required: 0,
type: 'text' as TPaymentFieldType,
value: 'adfg',
},
instructions: {
display_name: 'Instructions',
required: 0,
type: 'memo' as TPaymentFieldType,
value: 'rtbnrt',
},
name: {
display_name: 'Payment method name',
required: 1,
type: 'text' as TPaymentFieldType,
value: 'wrtnwrtn',
},
},
id: '89',
is_enabled: 1 as TType01,
method: 'other',
type: 'other' as TWalletType,
used_by_adverts: ['194'],
used_by_orders: null,
},
];

export const mockCountryList = {
af: {
country_name: 'Afghanistan',
cross_border_ads_enabled: 1,
fixed_rate_adverts: 'enabled',
float_rate_adverts: 'disabled',
float_rate_offset_limit: 10,
local_currency: 'AFN',
payment_methods: {
alipay: {
display_name: 'Alipay',
fields: {
account: {
display_name: 'Alipay ID',
required: 1,
type: 'text',
},
instructions: {
display_name: 'Instructions',
required: 0,
type: 'memo',
},
},
type: 'ewallet',
},
},
},
};

export const mockPaymentMethods = [
{
display_name: 'Bank Transfer',
fields: {
account: {
display_name: 'Account Number',
required: 1,
type: 'text',
value: 'Account Number',
},
bank_name: { display_name: 'Bank Transfer', required: 1, type: 'text', value: 'Bank Name' },
},
id: 'test1',
is_enabled: 0,
method: '',
type: 'bank',
used_by_adverts: null,
used_by_orders: null,
},
{
display_name: 'Ali pay',
fields: {
account: {
display_name: 'Account Number',
required: 1,
type: 'text',
value: 'Account Number',
},
bank_name: { display_name: 'Ali pay', required: 1, type: 'text', value: 'Bank Name' },
},
id: 'test2',
is_enabled: 0,
method: '',
type: 'wallet',
used_by_adverts: null,
used_by_orders: null,
},
{
display_name: 'Skrill',
fields: {
account: {
display_name: 'Account Number',
required: 1,
type: 'text',
value: 'Account Number',
},
bank_name: { display_name: 'Skrill', required: 1, type: 'text', value: 'Bank Name' },
},
id: 'test3',
is_enabled: 0,
method: '',
type: 'wallet',
used_by_adverts: null,
used_by_orders: null,
},
];

export const mockAdvertiserAdvertValues = {
account_currency: 'USD',
active_orders: 0,
advertiser_details: {
completed_orders_count: 0,
has_not_been_recommended: false,
id: '34',
is_blocked: false,
is_favourite: false,
is_online: true,
is_recommended: false,
last_online_time: 1688480346,
name: 'client CR90000212',
rating_average: null,
rating_count: 0,
recommended_average: null,
recommended_count: null,
total_completion_rate: null,
},
amount: 22,
amount_display: '22.00',
block_trade: false,
contact_info: '',
counterparty_type: 'sell' as const,
country: 'id',
created_time: new Date(1688460999),
currentRateType: 'fixed' as const,
days_until_archive: 1,
description: '',
effective_rate: 22,
effective_rate_display: '22.00',
eligible_countries: ['ID'],
id: '138',
is_active: true,
is_floating: false,
is_visible: true,
local_currency: 'IDR',
max_order_amount: 22,
max_order_amount_display: '22.00',
max_order_amount_limit: 22,
max_order_amount_limit_display: '22.00',
min_completion_rate: 22,
min_join_days: 4,
min_order_amount: 22,
min_order_amount_display: '22.00',
min_order_amount_limit: 22,
min_order_amount_limit_display: '22.00',
min_rating: 4,
order_expiry_period: 900,
payment_info: '',
payment_method: null,
payment_method_names: ['Bank Transfer'],
price: 22,
price_display: '22.00',
rate: 22,
rate_display: '22.00',
rate_type: 'fixed' as const,
remaining_amount: 22,
remaining_amount_display: '22.00',
type: 'buy' as const,
visibility_status: [],
};
31 changes: 3 additions & 28 deletions src/components/AppHeader/AppHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useEffect } from 'react';
import { getOauthUrl } from '@/constants';
import { StandaloneCircleUserRegularIcon } from '@deriv/quill-icons';
import { useAccountList, useAuthData } from '@deriv-com/api-hooks';
import { useAuthData } from '@deriv-com/api-hooks';
import { useTranslations } from '@deriv-com/translations';
import { Button, Header, Text, TooltipMenuIcon, useDevice, Wrapper } from '@deriv-com/ui';
import { LocalStorageConstants, LocalStorageUtils, URLUtils } from '@deriv-com/utils';
import { AccountSwitcher } from './AccountSwitcher';
import { AppLogo } from './AppLogo';
import { MenuItems } from './MenuItems';
Expand All @@ -14,34 +13,10 @@ import './AppHeader.scss';

// TODO: handle local storage values not updating after changing local storage values
const AppHeader = () => {
const { data: accounts } = useAccountList();
const { isDesktop } = useDevice();
const { activeLoginid, logout } = useAuthData();
const { localize } = useTranslations();
const appId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId);
const serverUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString());
const oauthUrl =
appId && serverUrl
? `https://${serverUrl}/oauth2/authorize?app_id=${appId}&l=EN&&brand=deriv`
: URLUtils.getOauthURL();

useEffect(() => {
const shouldRedirectToLogin = () => {
if (typeof accounts !== 'undefined') {
const userHasNoP2PAccount = !accounts.find(
account => account.broker === 'CR' && account.currency === 'USD'
);
const activeAccount = accounts.find(account => account.loginid === activeLoginid);
const activeAccountCurrency = activeAccount?.currency || null;

if (userHasNoP2PAccount || activeAccountCurrency !== 'USD') {
window.open(oauthUrl, '_self');
}
}
};

shouldRedirectToLogin();
}, [accounts, activeLoginid, oauthUrl]);
const oauthUrl = getOauthUrl();

return (
<Header className={!isDesktop ? 'h-[40px]' : ''}>
Expand Down
8 changes: 4 additions & 4 deletions src/components/AppHeader/HeaderConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export const MenuItems: MenuItemsConfig[] = [
label: "Trader's Hub",
},
{
as: 'button',
href: 'https://app.deriv.com/appstore/traders-hub',
as: 'a',
href: 'https://app.deriv.com/appstore/reports',
icon: <ReportsLogo iconSize='xs' />,
label: 'Reports',
},
{
as: 'button',
href: 'https://app.deriv.com/appstore/traders-hub',
as: 'a',
href: 'https://app.deriv.com/appstore/cashier',
icon: <CashierLogo iconSize='xs' />,
label: 'Cashier',
},
Expand Down
9 changes: 6 additions & 3 deletions src/components/BuySellForm/BuySellForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,14 @@ const BuySellForm = ({ advertId, isModalOpen, onRequestClose }: TBuySellFormProp
}, [isSuccess, orderCreatedInfo, history, onRequestClose]);

useEffect(() => {
if (isError && error?.error.message) {
setErrorMessage(error?.error.message);
// @ts-expect-error types are not correct from api-hooks
if (isError && error?.message) {
// @ts-expect-error types are not correct from api-hooks
setErrorMessage(error?.message);
scrollRef.current?.scrollIntoView({ behavior: 'smooth', block: 'end' });
}
}, [error?.error.message, isError]);
// @ts-expect-error types are not correct from api-hooks
}, [error?.message, isError]);

return (
<form onSubmit={handleSubmit(onSubmit)}>
Expand Down
Loading

0 comments on commit 083caca

Please sign in to comment.