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

[DEV-3365] update getCountries hook #79

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/src/contexts/user.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function UserContextProvider(props: PropsWithChildren): JSX.Element {
if (isLoggedIn) {
reloadUser();

getCountries().then((c) => setCountries(c.sort((a, b) => (a.name > b.name ? 1 : -1))));
getCountries().then(setCountries);
} else {
setUser(undefined);
setCountries([]);
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/definitions/country.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export const CountryUrl = { get: 'kyc/countries' };
export const CountryUrl = { get: 'country' };

export interface Country {
id: number;
symbol: string;
name: string;
locationAllowed: boolean;
kycAllowed: boolean;
nationalityAllowed: boolean;
bankAllowed: boolean;
cardAllowed: boolean;
}
7 changes: 0 additions & 7 deletions packages/react/src/hooks/kyc.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
KycFile,
} from '../definitions/kyc';
import { useApi } from './api.hook';
import { Country } from '../definitions/country';

export interface CallConfig {
url: string;
Expand All @@ -42,7 +41,6 @@ export interface KycInterface {
getKycInfo: (code: string) => Promise<KycInfo>;
continueKyc: (code: string, autoStep?: boolean) => Promise<KycSession>;
startStep: (code: string, name: KycStepName, type?: KycStepType, sequence?: number) => Promise<KycSession>;
getCountries: (code: string) => Promise<Country[]>;

// updates
setContactData: (code: string, url: string, data: KycContactData) => Promise<KycResult>;
Expand Down Expand Up @@ -111,10 +109,6 @@ export function useKyc(): KycInterface {
return call({ url, code, method: 'GET' });
}

async function getCountries(code: string): Promise<Country[]> {
return call({ url: `${KycUrl.base}/countries`, code, method: 'GET' });
}

async function setContactData(code: string, url: string, data: KycContactData): Promise<KycResult> {
return call({ url, code, method: 'PUT', data });
}
Expand Down Expand Up @@ -211,7 +205,6 @@ export function useKyc(): KycInterface {
getKycInfo,
continueKyc,
startStep,
getCountries,
setContactData,
setPersonalData,
setManualIdentData,
Expand Down
Loading