Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuiSin/Check on mobile view #104

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a03df6b
[CFDS] Hamza/CFDS-1459/Update the content for "Verification explained…
hamza-deriv Dec 13, 2023
fbe3f3c
[FEQ] P2P Advert update hook (#12185)
adrienne-deriv Dec 13, 2023
46f5d05
[WALL] Aizad/WALL-3036/Create/Add MT5 account modal issues (#12183)
aizad-deriv Dec 13, 2023
b366572
translations: 📚 sync translations with crowdin (#12227)
github-actions[bot] Dec 13, 2023
1fea04a
[WALL] aum/WALL-3082/positive-transfer-fee-message (#12193)
aum-deriv Dec 13, 2023
81cd9e6
[WALL] Lubega / WALL-3002 / Chore: Withdrawal verification request un…
lubega-deriv Dec 13, 2023
b65bc56
[WALL] Lubega / WALL-3003 / Chore: Withdrawal verification sent unit …
lubega-deriv Dec 13, 2023
7b17ce1
refactor: [COJ] Evgeniy/COJ-000/fix track.js error Object.hasOwn is n…
yauheni-deriv Dec 13, 2023
c17ab6c
[WALL] Farhan/WALL-2911/Unit test for WalletsErrorScreen component (#…
farhan-nurzi-deriv Dec 13, 2023
346b280
fix: remove extra link tag (#12153)
kate-deriv Dec 14, 2023
22a8d91
[DTRA] / Kate / DTRA-566 / Console error while switching between DTra…
kate-deriv Dec 14, 2023
02ad5f4
[DTRA] henry/webrel-46/chore: add test cases for trading time picker …
henry-deriv Dec 14, 2023
bd62c6f
[BOT] Rupato/BOT-1137/fix learn more button (#12067)
rupato-deriv Dec 14, 2023
e15757f
fix: google drive showing connected even on abort action (#12040)
shafin-deriv Dec 14, 2023
cf4d1a2
[FEQ] Jim/FEQ-990/p2p advert information (#12213)
jim-deriv Dec 14, 2023
f3020d6
[FEQ] Ameerul / FEQ-1005 / P2P Order List (#12176)
ameerul-deriv Dec 14, 2023
d1784a7
translations: 📚 sync translations with crowdin (#12250)
github-actions[bot] Dec 14, 2023
ab9c987
fix: the thing (#12240)
rostislav-deriv Dec 14, 2023
48c3fbd
fix: the thing (#12239)
rostislav-deriv Dec 14, 2023
ccd780b
fix: the thing (#12238)
rostislav-deriv Dec 14, 2023
ebc8e2d
chore: updated the translation literals (#12269)
hamza-deriv Dec 14, 2023
b822ed8
translations: 📚 sync translations with crowdin (#12274)
github-actions[bot] Dec 14, 2023
8e2d10d
Revert "fix: google drive showing connected even on abort action (#12…
sandeep-deriv Dec 14, 2023
423bd40
Suisin/chore: update scss to not use max height for jurisdiction moda…
suisin-deriv Dec 15, 2023
c6f74f8
[FEQ] Jim/FEQ-999/p2p chat create (#12257)
jim-deriv Dec 15, 2023
7a170a0
Ameerul / P2PS-828 / Refactor My Profile Page (#10621)
ameerul-deriv Dec 15, 2023
a922a7a
feat: write unit tests (#12276)
sergei-deriv Dec 15, 2023
299392d
[P2PS] Ameerul /P2PS-2005 Refactor AdErrorTooltipModal (#11868)
ameerul-deriv Dec 15, 2023
c3bc7a7
[FEQ] Niloofar/FEQ-997/P2P Advertiser Relations custom hooks (#12260)
niloofar-deriv Dec 15, 2023
a39f3ae
[P2PS] Ameerul / P2PS-969 / Improve validation message for amount fie…
ameerul-deriv Dec 15, 2023
e3088ba
feat: added p2p_order_cancel hook (#12273)
ameerul-deriv Dec 15, 2023
1d430b6
[P2P]-refactor: order util refactor (#10115)
nada-deriv Dec 15, 2023
586b9bb
[TRAH] Thisyahlen/traders hub package (#12208)
thisyahlen-deriv Dec 15, 2023
52b9c32
fix: verify button alignment in POI accounts screen (#12259)
shahzaib-deriv Dec 15, 2023
d5d785d
translations: 📚 sync translations with crowdin (#12296)
github-actions[bot] Dec 15, 2023
93d053c
Merge branch 'amina/COJ_407_Success_message_after_upgrade' of github.…
suisin-deriv Dec 15, 2023
6402a93
chore: packagelock (#12297)
thisyahlen-deriv Dec 15, 2023
1ac393c
[P2PS] Ameerul / P2PS-2105 / The page is not responding while adding …
ameerul-deriv Dec 15, 2023
a489cfc
chore: mobile view of success modal
suisin-deriv Dec 15, 2023
3661ff0
Merge branch 'binary-com:master' into check_on_mobile_view
amina-deriv Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ jobs:
run: npx tsc --project packages/stores/tsconfig.json -noEmit
- name: Check TypeScript for @deriv/wallets
run: npx tsc --project packages/wallets/tsconfig.json -noEmit
- name: Check TypeScript for @deriv/tradershub
run: npx tsc --project packages/tradershub/tsconfig.json -noEmit
- name: Check ESLint for @deriv/wallets
run: npx eslint --fix --ignore-path packages/wallets/.eslintignore --config packages/wallets/.eslintrc.js packages/wallets
- name: Check ESLint for @deriv/tradershub
run: npx eslint --fix --ignore-path packages/tradershub/.eslintignore --config packages/tradershub/.eslintrc.js packages/tradershub
- name: Check Stylelint for @deriv/wallets
run: npx stylelint packages/wallets/**/*.scss
- name: Check tests for @deriv/hooks
Expand Down
1,292 changes: 1,035 additions & 257 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@types/react-dom": "^18.0.0",
"@types/react-router-dom": "^5.1.6",
"@types/react-virtualized": "^9.21.21",
"autoprefixer": "^10.4.16",
"babel-polyfill": "^6.26.0",
"dotenv-webpack": "^8.0.1",
"husky": "^7.0.0",
Expand All @@ -52,6 +53,7 @@
"stylelint-no-unsupported-browser-features": "^4.0.0",
"stylelint-selector-bem-pattern": "^2.1.0",
"stylelint-webpack-plugin": "^2.1.1",
"tailwindcss": "^3.3.6",
"ts-jest": "^26.4.2"
},
"scripts": {
Expand Down Expand Up @@ -94,6 +96,7 @@
"dependencies": {
"@babel/preset-typescript": "^7.16.5",
"@deriv/analytics": "^1.4.5",
"@deriv/quill-design": "^1.2.10",
"@sendbird/chat": "^4.9.7",
"@types/react-transition-group": "^4.4.4",
"babel-jest": "^27.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('<FinancialDetails />', () => {

fieldsRenderCheck();

const inputs = screen.getAllByTestId('dti_dropdown_display');
const inputs = screen.getAllByTestId('dt_dropdown_display');
expect(inputs).toHaveLength(8);

expect(screen.getByText('Next')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ScrollToFieldWithError = ({
}, [should_recollect_inputs_names]);
React.useEffect(() => {
const current_error_field_name =
all_page_inputs_names.find(input_name => Object.hasOwn(errors, input_name)) || '';
all_page_inputs_names.find(input_name => Object.prototype.hasOwnProperty.call(errors, input_name)) || '';

if (fields_to_scroll_top?.includes(current_error_field_name)) {
scrollToElement(current_error_field_name, 'start');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const runCommonFormfieldsTests = is_svg => {
name: /additional information/i,
})
).toBeInTheDocument();
expect(screen.queryByTestId('dti_dropdown_display')).toBeInTheDocument();
expect(screen.queryByTestId('dt_dropdown_display')).toBeInTheDocument();
expect(screen.queryByTestId('account_opening_reason_mobile')).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: /previous/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /next/i })).toBeInTheDocument();
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('<PersonalDetails/>', () => {
expect(screen.getByText(/tax identification number/i)).toBeInTheDocument();
expect(screen.getByLabelText(/tax identification number/i)).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /account opening reason/i })).toBeInTheDocument();
expect(screen.queryByTestId('dti_dropdown_display')).not.toBeInTheDocument();
expect(screen.queryByTestId('dt_dropdown_display')).not.toBeInTheDocument();
expect(screen.queryByTestId('account_opening_reason_mobile')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /previous/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /next/i })).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,21 @@ const IdvFailed = ({
/>
<DesktopWrapper>
{!is_from_external && (
<Button
className='proof-of-identity__submit-button'
type='submit'
has_effect
is_disabled={!dirty || isSubmitting || !isValid}
text={is_document_upload_required ? localize('Verify') : localize('Update profile')}
large
primary
/>
<div className='proof-of-identity__actions'>
<Button
className='proof-of-identity__submit-button'
type='submit'
has_effect
is_disabled={!dirty || isSubmitting || !isValid}
text={
is_document_upload_required
? localize('Verify')
: localize('Update profile')
}
large
primary
/>
</div>
)}
</DesktopWrapper>
</FormBody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React from 'react';
import useInfiniteQuery from '../useInfiniteQuery';
import { renderHook } from '@testing-library/react-hooks';
import useP2PAdvertList from '../hooks/p2p/useP2PAdvertList';
import useAdvertList from '../hooks/p2p/useAdvertList';
import APIProvider from '../APIProvider';

jest.mock('../useInfiniteQuery');

const mockUseInfiniteQuery = useInfiniteQuery as jest.MockedFunction<typeof useInfiniteQuery<'p2p_advert_list'>>;

describe('useP2PAdvertList', () => {
describe('useAdvertList', () => {
test('should return undefined if there is no response', () => {
const wrapper = ({ children }: { children: JSX.Element }) => <APIProvider>{children}</APIProvider>;
// @ts-expect-error need to come up with a way to mock the return type of useInfiniteQuery
mockUseInfiniteQuery.mockReturnValueOnce({});

const { result } = renderHook(() => useP2PAdvertList(), { wrapper });
const { result } = renderHook(() => useAdvertList(), { wrapper });
expect(result.current.data).toBeUndefined();
});

Expand Down Expand Up @@ -84,7 +84,7 @@ describe('useP2PAdvertList', () => {
},
});

const { result } = renderHook(() => useP2PAdvertList(), { wrapper });
const { result } = renderHook(() => useAdvertList(), { wrapper });
const adverts_list = result.current.data;
expect(adverts_list).toHaveLength(1);
expect(adverts_list?.[0].country).toBe('id');
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './countries';
export * from './onfido';
export * from './payment-method-icons';
5 changes: 0 additions & 5 deletions packages/api/src/constants/payment-method-icons.ts

This file was deleted.

65 changes: 65 additions & 0 deletions packages/api/src/hooks/p2p/useAdvertDelete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { useCallback, useMemo } from 'react';
import useMutation from '../../useMutation';
import useInvalidateQuery from '../../useInvalidateQuery';

type TPayload = Parameters<ReturnType<typeof useMutation<'p2p_advert_update'>>['mutate']>[0]['payload'];

/** A custom hook that deletes a P2P advert. This can only be used by an approved P2P advertiser.
*
* To delete an advert, specify the advert ID to delete, for instance:
* @example
* mutate({
"id": 1234
});
*
* Once this is mutated, the advert with ID of 1234 will be deleted.
*/
const useAdvertDelete = () => {
const invalidate = useInvalidateQuery();
const {
data,
mutate: _mutate,
...rest
} = useMutation('p2p_advert_update', {
onSuccess: () => {
invalidate('p2p_advert_list');
},
});

const mutate = useCallback(
(payload: Omit<TPayload, 'delete'>) =>
_mutate({
payload: {
...payload,
delete: 1,
},
}),
[_mutate]
);

const modified_data = useMemo(() => {
const p2p_advert_update = data?.p2p_advert_update;

if (!p2p_advert_update) return undefined;

return {
...p2p_advert_update,
/** Indicates if this is block trade advert or not. */
is_block_trade: Boolean(p2p_advert_update.block_trade),
/** The activation status of the advert. */
is_active: Boolean(p2p_advert_update.is_active),
/** Indicates that this advert will appear on the main advert list. */
is_visible: Boolean(p2p_advert_update.is_visible),
/** Indicates that the advert has been deleted. */
is_deleted: Boolean(p2p_advert_update.deleted),
};
}, [data?.p2p_advert_update]);

return {
data: modified_data,
mutate,
...rest,
};
};

export default useAdvertDelete;
45 changes: 45 additions & 0 deletions packages/api/src/hooks/p2p/useAdvertInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useMemo } from 'react';
import useQuery from '../../useQuery';

/**
* This custom hook returns the advert information about the given advert ID.
*/
const useAdvertInfo = (
payload: NonNullable<Parameters<typeof useQuery<'p2p_advert_info'>>[1]>['payload'],
options?: NonNullable<Parameters<typeof useQuery<'p2p_advert_info'>>[1]>['options']
) => {
const { data, ...rest } = useQuery('p2p_advert_info', {
payload,
options,
});

const modified_data = useMemo(() => {
const p2p_advert_info = data?.p2p_advert_info;

if (!p2p_advert_info) return undefined;

return {
...p2p_advert_info,
/** Determines whether the advert is a buy advert or not. */
is_buy: p2p_advert_info.type === 'buy',
/** Determines whether the advert is a sell advert or not. */
is_sell: p2p_advert_info.type === 'sell',
is_block_trade: Boolean(p2p_advert_info.block_trade),
is_deleted: Boolean(p2p_advert_info.deleted),
is_active: Boolean(p2p_advert_info.is_active),
is_visible: Boolean(p2p_advert_info.is_visible),
/**
* @deprecated This property was deprecated on back-end
* @see https://api.deriv.com/api-explorer#p2p_advert_info
* **/
payment_method: p2p_advert_info.payment_method,
};
}, [data?.p2p_advert_info]);

return {
data: modified_data,
...rest,
};
};

export default useAdvertInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import useAuthorize from '../useAuthorize';
/**
* This custom hook returns available adverts for use with 'p2p_order_create' by calling 'p2p_advert_list' endpoint
*/
const useP2PAdvertList = (
const useAdvertList = (
payload?: NonNullable<Parameters<typeof useInfiniteQuery<'p2p_advert_list'>>[1]>['payload'],
config?: NonNullable<Parameters<typeof useInfiniteQuery<'p2p_advert_list'>>[1]>['options']
) => {
const { isSuccess } = useAuthorize();
const { data, fetchNextPage, ...rest } = useInfiniteQuery('p2p_advert_list', {
payload: { ...payload, offset: payload?.offset || 0, limit: payload?.limit || 50 },
payload: { ...payload, offset: payload?.offset, limit: payload?.limit },
options: {
getNextPageParam: (lastPage, pages) => {
if (!lastPage?.p2p_advert_list?.list) return;
Expand Down Expand Up @@ -65,4 +65,4 @@ const useP2PAdvertList = (
};
};

export default useP2PAdvertList;
export default useAdvertList;
55 changes: 55 additions & 0 deletions packages/api/src/hooks/p2p/useAdvertUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useCallback, useMemo } from 'react';
import useMutation from '../../useMutation';
import useInvalidateQuery from '../../useInvalidateQuery';

type TPayload = Parameters<ReturnType<typeof useMutation<'p2p_advert_update'>>['mutate']>[0]['payload'];

/** A custom hook that updates a P2P advert. This can only be used by an approved P2P advertiser.
*
* To update an advert, specify the payload arguments that should be updated, for instance:
* @example
* mutate({
"id": 1234, // required
"is_active": 0 // optional
});
*
*/
const useAdvertUpdate = () => {
const invalidate = useInvalidateQuery();
const {
data,
mutate: _mutate,
...rest
} = useMutation('p2p_advert_update', {
onSuccess: () => {
invalidate('p2p_advert_list');
},
});

const mutate = useCallback((payload: TPayload) => _mutate({ payload }), [_mutate]);

const modified_data = useMemo(() => {
const p2p_advert_update = data?.p2p_advert_update;
if (!p2p_advert_update) return undefined;

return {
...p2p_advert_update,
/** Indicates if this is block trade advert or not. */
is_block_trade: Boolean(p2p_advert_update.block_trade),
/** The activation status of the advert. */
is_active: Boolean(p2p_advert_update.is_active),
/** Indicates that this advert will appear on the main advert list. */
is_visible: Boolean(p2p_advert_update.is_visible),
/** Indicates that the advert has been deleted. */
is_deleted: Boolean(p2p_advert_update.deleted),
};
}, [data?.p2p_advert_update]);

return {
data: modified_data,
mutate,
...rest,
};
};

export default useAdvertUpdate;
33 changes: 33 additions & 0 deletions packages/api/src/hooks/p2p/useAdvertiserRelations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import useInvalidateQuery from '../../useInvalidateQuery';
import useMutation from '../../useMutation';
import useQuery from '../../useQuery';
import useAuthorize from '../useAuthorize';

/** This hook returns favourite and blocked advertisers and the mutation function to update the block list of the current user. */
const useAdvertiserRelations = () => {
const { isSuccess } = useAuthorize();
const invalidate = useInvalidateQuery();
const { data, ...rest } = useQuery('p2p_advertiser_relations', { options: { enabled: isSuccess } });
const { mutate, ...mutate_rest } = useMutation('p2p_advertiser_relations', {
onSuccess: () => invalidate('p2p_advertiser_relations'),
});

const advertiser_relations = data?.p2p_advertiser_relations;

return {
/** P2P advertiser relations information. */
data: advertiser_relations,
/** Blocked advertisers by the current user. */
blocked_advertisers: advertiser_relations?.blocked_advertisers,
/** Favourite advertisers of the current user. */
favourite_advertisers: advertiser_relations?.favourite_advertisers,

/** The mutation function to update (add/remove) the currrent user's block list. */
mutate,
/** The mutation related information. */
mutation: mutate_rest,
...rest,
};
};

export default useAdvertiserRelations;
18 changes: 18 additions & 0 deletions packages/api/src/hooks/p2p/useAdvertiserRelationsAddBlocked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useCallback } from 'react';
import useAdvertiserRelations from './useAdvertiserRelations';

/** This hook blocks advertisers of the current user by passing the advertiser id. */
const useAdvertiserRelationsAddBlocked = () => {
const { mutate, data, ...rest } = useAdvertiserRelations();

const addBlockedAdvertiser = useCallback((id: number[]) => mutate({ payload: { add_blocked: id } }), [mutate]);

return {
data,
/** Sends a request to block advertiser of the current user by passing the advertiser id. */
mutate: addBlockedAdvertiser,
...rest,
};
};

export default useAdvertiserRelationsAddBlocked;
Loading