UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

94 lines (93 loc) 3.45 kB
import type { CustomerSupportSchema } from '../../components/Shared/tasks/CustomerSupport/types'; import type { ValidationRuleResult } from '../../utils/validation/types'; import type { PayoutDetailsSchema } from '../../components/BankAccount/forms/PayoutDetails/types'; import type { BusinessDetailsSchema } from '../../components/Business/forms/BusinessDetails/types'; import type { BusinessLinesSchema } from '../../components/BusinessLines/tasks/types'; import type { BusinessFinancingSchema } from '../../components/EFP/tasks/BusinessFinancingDropin/types'; import type { SourceOfFundsSchema } from '../../components/EFP/tasks/SourceOfFundsDropin/types'; import type { TaxReportingSchema } from '../../components/EFP/tasks/TaxReportingDropin/types'; import type { IndividualSchema } from '../../components/Individual/forms/Individual.types'; import type { TrustSchema } from '../../components/Trust/forms/Trust/types'; import type { TrustMemberSchema } from '../../components/Trust/tasks/RoleAndTypeDropin/types'; export interface AddToStateAction { type: 'addToState'; value: { dataStoreId?: string; data: object; valid?: object; errors?: object; fieldProblems?: object; schema?: string[]; }; } interface RemoveFromStateAction { type: 'removeFromState'; value: { dataStoreId?: string; }; } interface ResetStateAction { type: 'resetState'; } export type SCAction = AddToStateAction | RemoveFromStateAction | ResetStateAction; interface SCCurrent { setState: null | ((action: SCAction) => void); setActiveForms?: (forms: string[]) => void; } export interface StateContextRef { current: SCCurrent; } interface StateContextBase { owner?: string; } export interface SCSetter extends StateContextBase { stateRef: StateContextRef; } export type StateModel<TLDS extends TopLevelDataSchema = TopLevelDataSchema> = { getData: () => TLDS; getState: () => State<TLDS>; dispatch: (action: SCAction) => void; setActiveForms: (forms: string[]) => void; state: { currentState: State<TLDS>; prevState?: State<TLDS>; }; }; export type TopLevelDataSchema = IndividualSchema | BusinessDetailsSchema | CustomerSupportSchema | PayoutDetailsSchema | TrustSchema | TrustMemberSchema | BusinessFinancingSchema | SourceOfFundsSchema | TaxReportingSchema | BusinessLinesSchema; export interface State<TLDS extends TopLevelDataSchema> { data: TLDS; allData: TLDS; valid: { [ActiveForm in keyof TLDS]: { [Field in keyof TLDS[ActiveForm]]: boolean; }; }; errors: { [ActiveForm in keyof TLDS]: { [Field in keyof TLDS[ActiveForm]]: ValidationRuleResult; }; }; fieldProblems: { [ActiveForm in keyof TLDS]: { [Field in keyof TLDS[ActiveForm]]: boolean; }; }; allValid: boolean; isValid: boolean; validityByForm?: Record<string, boolean>; initialData: TLDS; } export interface StateSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName]> { data?: SliceData; valid?: Partial<{ [key in keyof SliceData]: boolean; }>; errors?: Partial<{ [key in keyof SliceData]: ValidationRuleResult | null; }>; fieldProblems?: { [key in keyof SliceData]: boolean; }; schema?: ReadonlyArray<keyof SliceData>; } export {};