@adyen/kyc-components 3.23.1 → 3.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/adyen-kyc-components.es.js +1711 -1696
- package/dist/style.css +7 -4
- package/dist/types/components/AdditionalInformation/types.d.ts +1 -1
- package/dist/types/components/BasicInformation/types.d.ts +1 -1
- package/dist/types/components/BusinessDetails/forms.d.ts +1 -1
- package/dist/types/components/Company/component/CompanyComponent.d.ts +1 -2
- package/dist/types/components/CompanyRegistrationDetails/types.d.ts +9 -11
- package/dist/types/components/SoleProp/component/SolePropComponent.d.ts +1 -1
- package/dist/types/components/internal/DateOfIncorporationField/fieldConfig.d.ts +3 -0
- package/dist/types/components/internal/TaxInformationField/index.d.ts +0 -1
- package/dist/types/components/internal/TradingNameField/fieldConfig.d.ts +3 -0
- package/dist/types/core/models/company.d.ts +0 -3
- package/dist/types/utils/mapping/componentApiMapping.d.ts +2 -0
- package/package.json +1 -1
- package/dist/types/components/CompanyRegistrationDetails/validate.d.ts +0 -16
- package/dist/types/components/internal/DateOfIncorporationField/validate.d.ts +0 -3
- package/dist/types/components/internal/TradingNameField/validate.d.ts +0 -3
|
@@ -2,7 +2,7 @@ import { useContext, useState, useCallback, useEffect, useMemo, useReducer, useR
|
|
|
2
2
|
import { createContext, isValidElement, createElement, render } from "preact";
|
|
3
3
|
import { sanitize } from "isomorphic-dompurify";
|
|
4
4
|
import cx from "classnames";
|
|
5
|
-
import { lazy, Suspense, useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1 } from "preact/compat";
|
|
5
|
+
import { lazy, Suspense, useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1, useCallback as useCallback$1 } from "preact/compat";
|
|
6
6
|
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
7
7
|
import debounce from "lodash-es/debounce";
|
|
8
8
|
import isISIN from "validator/es/lib/isISIN.js";
|
|
@@ -7409,27 +7409,6 @@ const CompanyNameAndCountryComponent = memo(CompanyNameAndCountry, (prevProps, n
|
|
|
7409
7409
|
var _a, _b;
|
|
7410
7410
|
return objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && ((_a = prevProps.data) == null ? void 0 : _a.country) === ((_b = nextProps.data) == null ? void 0 : _b.country) && prevProps.shouldValidate === nextProps.shouldValidate;
|
|
7411
7411
|
});
|
|
7412
|
-
function StateContextSetter({
|
|
7413
|
-
stateRef
|
|
7414
|
-
}) {
|
|
7415
|
-
if (stateRef.current.setState) {
|
|
7416
|
-
return null;
|
|
7417
|
-
}
|
|
7418
|
-
return jsx(StateContext.Consumer, {
|
|
7419
|
-
children: (stateContextValue) => {
|
|
7420
|
-
if (!stateContextValue) {
|
|
7421
|
-
throw new Error("<StateContextSetter> needs to be mounted inside a <StateProvider>");
|
|
7422
|
-
}
|
|
7423
|
-
const {
|
|
7424
|
-
dispatch,
|
|
7425
|
-
setActiveForms
|
|
7426
|
-
} = stateContextValue;
|
|
7427
|
-
stateRef.current.setState = dispatch;
|
|
7428
|
-
stateRef.current.setActiveForms = setActiveForms;
|
|
7429
|
-
return null;
|
|
7430
|
-
}
|
|
7431
|
-
});
|
|
7432
|
-
}
|
|
7433
7412
|
var CompanyTypesValue = /* @__PURE__ */ ((CompanyTypesValue2) => {
|
|
7434
7413
|
CompanyTypesValue2["PRIVATE_COMPANY"] = "privateCompany";
|
|
7435
7414
|
CompanyTypesValue2["PUBLIC_COMPANY"] = "listedPublicCompany";
|
|
@@ -7441,22 +7420,12 @@ var CompanyTypesValue = /* @__PURE__ */ ((CompanyTypesValue2) => {
|
|
|
7441
7420
|
CompanyTypesValue2["SOLE_PROPRIETORSHIP"] = "soleProprietorship";
|
|
7442
7421
|
return CompanyTypesValue2;
|
|
7443
7422
|
})(CompanyTypesValue || {});
|
|
7444
|
-
const
|
|
7445
|
-
const
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
cachedStripPatterns.set(mask, stripPattern);
|
|
7451
|
-
return stripPattern;
|
|
7452
|
-
};
|
|
7453
|
-
const displayValueToPureValue = (displayValue, mask) => {
|
|
7454
|
-
const stripPattern = cachedStripPatterns.get(mask) ?? makeStripPattern(mask);
|
|
7455
|
-
return displayValue.replaceAll(stripPattern, "");
|
|
7456
|
-
};
|
|
7457
|
-
const isValueObscured = (value) => {
|
|
7458
|
-
var _a;
|
|
7459
|
-
return typeof value === "string" && !!((_a = value.match(/[*]{1,}/)) == null ? void 0 : _a.length);
|
|
7423
|
+
const makeArrayOfRepeatedObjects = (length, obj) => {
|
|
7424
|
+
const array = [];
|
|
7425
|
+
for (let i = 0; i < length; i += 1) {
|
|
7426
|
+
array.push(cloneObject(obj));
|
|
7427
|
+
}
|
|
7428
|
+
return array;
|
|
7460
7429
|
};
|
|
7461
7430
|
const shiftRight = (possibleShifts, matchedTokens, remainingTokens) => {
|
|
7462
7431
|
let shiftsToTry = [...possibleShifts];
|
|
@@ -7553,583 +7522,6 @@ const tryShift = (matchedTokens, remainingTokens, fromIndex, shiftDistance) => {
|
|
|
7553
7522
|
remainingTokens: newRemainingTokens
|
|
7554
7523
|
};
|
|
7555
7524
|
};
|
|
7556
|
-
const getAvailableInputTokens = (tokens) => {
|
|
7557
|
-
const availableTokens = [];
|
|
7558
|
-
for (const token of tokens) {
|
|
7559
|
-
if (token.type === "nonInput") {
|
|
7560
|
-
if (token.includeInValue) {
|
|
7561
|
-
availableTokens.push({
|
|
7562
|
-
...token,
|
|
7563
|
-
offset: tokens.indexOf(token)
|
|
7564
|
-
});
|
|
7565
|
-
}
|
|
7566
|
-
continue;
|
|
7567
|
-
}
|
|
7568
|
-
availableTokens.push({
|
|
7569
|
-
...token,
|
|
7570
|
-
offset: tokens.indexOf(token)
|
|
7571
|
-
});
|
|
7572
|
-
if (token.type !== "input" || !token.optional) break;
|
|
7573
|
-
}
|
|
7574
|
-
return availableTokens;
|
|
7575
|
-
};
|
|
7576
|
-
const findMatchingToken = (tokensWithOffset, char) => tokensWithOffset.find((token) => token.type === "nonInput" || !token.allow || token.allow.test(char)) ?? null;
|
|
7577
|
-
const getEagerSuffix = (tokens) => {
|
|
7578
|
-
let suffix = "";
|
|
7579
|
-
for (const token of tokens) {
|
|
7580
|
-
if (token.type === "input") {
|
|
7581
|
-
if (token.optional) continue;
|
|
7582
|
-
else break;
|
|
7583
|
-
}
|
|
7584
|
-
if (!token.displayEagerly) break;
|
|
7585
|
-
suffix += token.char;
|
|
7586
|
-
}
|
|
7587
|
-
return suffix;
|
|
7588
|
-
};
|
|
7589
|
-
const getPotentialForMoreOptionalInput = (tokens) => tokens.some((token) => token.type === "input" && token.optional);
|
|
7590
|
-
const matchAgainstMask = (pureValue, mask, acceptObscuredValue = false) => {
|
|
7591
|
-
let tokensToProcess = [...mask.tokens];
|
|
7592
|
-
let charsToProcess = pureValue;
|
|
7593
|
-
let charIndex = 0;
|
|
7594
|
-
let matchedTokens = [];
|
|
7595
|
-
if (acceptObscuredValue && isValueObscured(pureValue)) {
|
|
7596
|
-
return {
|
|
7597
|
-
outcome: "obscureCorrect",
|
|
7598
|
-
displayValue: pureValue
|
|
7599
|
-
};
|
|
7600
|
-
}
|
|
7601
|
-
const shiftChars = (increment) => {
|
|
7602
|
-
charIndex += increment;
|
|
7603
|
-
charsToProcess = charsToProcess.slice(increment);
|
|
7604
|
-
};
|
|
7605
|
-
const shiftTokens = (increment) => {
|
|
7606
|
-
tokensToProcess = tokensToProcess.slice(increment);
|
|
7607
|
-
};
|
|
7608
|
-
const displayValue = () => matchedTokens.map((token) => token.char).join("");
|
|
7609
|
-
while (true) {
|
|
7610
|
-
const char = charsToProcess[0];
|
|
7611
|
-
const token = tokensToProcess[0];
|
|
7612
|
-
if (!char && !tokensToProcess.some((t) => t.type === "input" && !t.optional)) return {
|
|
7613
|
-
outcome: "correct",
|
|
7614
|
-
displayValue: displayValue() + getEagerSuffix(tokensToProcess),
|
|
7615
|
-
potentialForMoreOptionalInput: getPotentialForMoreOptionalInput(tokensToProcess)
|
|
7616
|
-
};
|
|
7617
|
-
if (!char) {
|
|
7618
|
-
const output = shiftRight(mask.possibleShifts, matchedTokens, tokensToProcess);
|
|
7619
|
-
matchedTokens = output.matchedTokens;
|
|
7620
|
-
tokensToProcess = output.remainingTokens;
|
|
7621
|
-
return {
|
|
7622
|
-
outcome: "partialCorrect",
|
|
7623
|
-
displayValue: displayValue() + getEagerSuffix(tokensToProcess)
|
|
7624
|
-
};
|
|
7625
|
-
}
|
|
7626
|
-
if (!token) return {
|
|
7627
|
-
outcome: "mismatch",
|
|
7628
|
-
badChar: char,
|
|
7629
|
-
mismatchAtChar: charIndex,
|
|
7630
|
-
mismatchedToken: "inputTooLong",
|
|
7631
|
-
partialDisplayValue: displayValue()
|
|
7632
|
-
};
|
|
7633
|
-
if (token.type === "nonInput") {
|
|
7634
|
-
if (token.includeInValue) {
|
|
7635
|
-
if (char !== token.char) return {
|
|
7636
|
-
outcome: "mismatch",
|
|
7637
|
-
badChar: char,
|
|
7638
|
-
mismatchAtChar: charIndex,
|
|
7639
|
-
mismatchedToken: token,
|
|
7640
|
-
partialDisplayValue: displayValue()
|
|
7641
|
-
};
|
|
7642
|
-
shiftChars(1);
|
|
7643
|
-
}
|
|
7644
|
-
matchedTokens.push(token);
|
|
7645
|
-
shiftTokens(1);
|
|
7646
|
-
}
|
|
7647
|
-
if (token.type === "input") {
|
|
7648
|
-
const availableTokens = getAvailableInputTokens(tokensToProcess);
|
|
7649
|
-
const matchingToken = findMatchingToken(availableTokens, char);
|
|
7650
|
-
if (!matchingToken) return {
|
|
7651
|
-
outcome: "mismatch",
|
|
7652
|
-
badChar: char,
|
|
7653
|
-
mismatchAtChar: charIndex,
|
|
7654
|
-
mismatchedToken: token,
|
|
7655
|
-
partialDisplayValue: displayValue()
|
|
7656
|
-
};
|
|
7657
|
-
matchedTokens.push({
|
|
7658
|
-
...matchingToken,
|
|
7659
|
-
char
|
|
7660
|
-
});
|
|
7661
|
-
shiftTokens(matchingToken.offset + 1);
|
|
7662
|
-
shiftChars(1);
|
|
7663
|
-
}
|
|
7664
|
-
}
|
|
7665
|
-
};
|
|
7666
|
-
const deriveInputState = (isValid, isFocused, isDisabled, isOptional, hasNullishValue, hasBlurred, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
|
|
7667
|
-
if (isDisabled) return {
|
|
7668
|
-
isError: false
|
|
7669
|
-
};
|
|
7670
|
-
if (isOptional && hasNullishValue) {
|
|
7671
|
-
return {
|
|
7672
|
-
isError: false
|
|
7673
|
-
};
|
|
7674
|
-
}
|
|
7675
|
-
if (isValid && (!potentiallyMoreOptionalCharacters || !isFocused)) return {
|
|
7676
|
-
isError: false,
|
|
7677
|
-
text: jsxs(Fragment, {
|
|
7678
|
-
children: [jsx(Icon, {
|
|
7679
|
-
name: "checkmark-small",
|
|
7680
|
-
className: "adyen-kyc-helper-text__valid-format-check"
|
|
7681
|
-
}), i18n.get("formatIsCorrect")]
|
|
7682
|
-
})
|
|
7683
|
-
};
|
|
7684
|
-
if (isFocused && formatGuidance) return {
|
|
7685
|
-
isError: false,
|
|
7686
|
-
text: formatGuidance
|
|
7687
|
-
};
|
|
7688
|
-
if (!isValid && (shouldValidate || hasBlurred)) return {
|
|
7689
|
-
isError: true,
|
|
7690
|
-
text: typeof errorMessage === "string" && errorMessage ? errorMessage : formatGuidance
|
|
7691
|
-
};
|
|
7692
|
-
return {
|
|
7693
|
-
isError: false
|
|
7694
|
-
};
|
|
7695
|
-
};
|
|
7696
|
-
const MISMATCH_ANIMATION_NAME = "mismatchShake";
|
|
7697
|
-
const logger$C = createLogger("MaskedInputText");
|
|
7698
|
-
const MaskedInputText = ({
|
|
7699
|
-
value,
|
|
7700
|
-
onInput,
|
|
7701
|
-
onBlur,
|
|
7702
|
-
onMismatch: onMismatchExternal,
|
|
7703
|
-
isValid: validationIsValid,
|
|
7704
|
-
errorMessage,
|
|
7705
|
-
shouldValidate,
|
|
7706
|
-
mask,
|
|
7707
|
-
name,
|
|
7708
|
-
label,
|
|
7709
|
-
placeholder,
|
|
7710
|
-
transformOnType,
|
|
7711
|
-
readonly = false,
|
|
7712
|
-
disabled = false,
|
|
7713
|
-
optional: optional2 = false,
|
|
7714
|
-
formatGuidance,
|
|
7715
|
-
classNameModifiers,
|
|
7716
|
-
acceptObscuredValue = false
|
|
7717
|
-
}) => {
|
|
7718
|
-
const hasExistingData = !isEmpty(value);
|
|
7719
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
7720
|
-
const [hasBlurred, setHasBlurred] = useState(hasExistingData);
|
|
7721
|
-
const [caretReturnPosition, setCaretReturnPosition] = useState(null);
|
|
7722
|
-
const inputRef = useRef(null);
|
|
7723
|
-
const [showingMismatch, setShowingMismatch] = useState(false);
|
|
7724
|
-
const {
|
|
7725
|
-
i18n
|
|
7726
|
-
} = useI18nContext();
|
|
7727
|
-
const onMismatch = (mismatch) => {
|
|
7728
|
-
if (!inputRef.current) return;
|
|
7729
|
-
setShowingMismatch(true);
|
|
7730
|
-
inputRef.current.addEventListener("animationend", (event) => {
|
|
7731
|
-
if (event.animationName !== MISMATCH_ANIMATION_NAME) return;
|
|
7732
|
-
setShowingMismatch(false);
|
|
7733
|
-
});
|
|
7734
|
-
onMismatchExternal == null ? void 0 : onMismatchExternal(mismatch);
|
|
7735
|
-
};
|
|
7736
|
-
useEffect(() => {
|
|
7737
|
-
if (!mask) {
|
|
7738
|
-
logger$C.warn("`mask` is undefined. No masking of input will take place.");
|
|
7739
|
-
}
|
|
7740
|
-
}, [mask]);
|
|
7741
|
-
const getMaskResult = useCallback((pureValue) => {
|
|
7742
|
-
if (!mask) return {
|
|
7743
|
-
outcome: "partialCorrect",
|
|
7744
|
-
displayValue: pureValue
|
|
7745
|
-
};
|
|
7746
|
-
return matchAgainstMask(transformOnType ? transformOnType(pureValue) : pureValue, mask, acceptObscuredValue);
|
|
7747
|
-
}, [mask, transformOnType, acceptObscuredValue]);
|
|
7748
|
-
const displayValueToPure = useCallback((displayValue2) => {
|
|
7749
|
-
if (!mask) return displayValue2;
|
|
7750
|
-
return displayValueToPureValue(displayValue2, mask);
|
|
7751
|
-
}, [mask]);
|
|
7752
|
-
const maskResult = useMemo(() => getMaskResult(value), [getMaskResult, value]);
|
|
7753
|
-
const displayValue = maskResult.outcome === "mismatch" ? maskResult.partialDisplayValue : maskResult.displayValue;
|
|
7754
|
-
const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, disabled, optional2, !displayValue, hasBlurred, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
|
|
7755
|
-
useEffect(() => {
|
|
7756
|
-
if (mask && maskResult.outcome === "mismatch") {
|
|
7757
|
-
const strippedValue = displayValueToPure(value);
|
|
7758
|
-
if (getMaskResult(strippedValue).outcome !== "mismatch") {
|
|
7759
|
-
onInput(strippedValue);
|
|
7760
|
-
return;
|
|
7761
|
-
}
|
|
7762
|
-
const fallback = displayValueToPure(maskResult.partialDisplayValue);
|
|
7763
|
-
logger$C.warn(`Value received "${value}" does not match mask`, maskResult, `
|
|
7764
|
-
Falling back to partially valid value "${fallback}"`);
|
|
7765
|
-
onInput(fallback);
|
|
7766
|
-
}
|
|
7767
|
-
}, [mask, maskResult, value, onInput, displayValueToPure, getMaskResult]);
|
|
7768
|
-
useLayoutEffect(() => {
|
|
7769
|
-
if (caretReturnPosition && inputRef.current && caretReturnPosition !== inputRef.current.selectionStart) {
|
|
7770
|
-
inputRef.current.setSelectionRange(caretReturnPosition, caretReturnPosition, "none");
|
|
7771
|
-
setCaretReturnPosition(null);
|
|
7772
|
-
}
|
|
7773
|
-
}, [caretReturnPosition]);
|
|
7774
|
-
const handleInput = (event) => {
|
|
7775
|
-
const inputEl = event.target;
|
|
7776
|
-
const newPureValue = displayValueToPure(inputEl.value);
|
|
7777
|
-
const newMaskResult = getMaskResult(newPureValue);
|
|
7778
|
-
const returnCaretLater = (offset = 0) => {
|
|
7779
|
-
if (!inputEl.selectionStart) return;
|
|
7780
|
-
setCaretReturnPosition(inputEl.selectionStart + offset);
|
|
7781
|
-
};
|
|
7782
|
-
const cancelInput = () => {
|
|
7783
|
-
returnCaretLater(-1);
|
|
7784
|
-
inputEl.value = displayValue;
|
|
7785
|
-
event.preventDefault();
|
|
7786
|
-
event.stopPropagation();
|
|
7787
|
-
};
|
|
7788
|
-
if (newMaskResult.outcome === "mismatch") {
|
|
7789
|
-
cancelInput();
|
|
7790
|
-
onMismatch(newMaskResult);
|
|
7791
|
-
return;
|
|
7792
|
-
}
|
|
7793
|
-
if (inputEl.selectionStart && inputEl.selectionStart < inputEl.value.length) {
|
|
7794
|
-
returnCaretLater();
|
|
7795
|
-
}
|
|
7796
|
-
inputEl.value = newMaskResult.displayValue;
|
|
7797
|
-
onInput(newPureValue);
|
|
7798
|
-
};
|
|
7799
|
-
return jsx(Field, {
|
|
7800
|
-
name,
|
|
7801
|
-
label,
|
|
7802
|
-
isValid: !inputState.isError,
|
|
7803
|
-
errorMessage: inputState.isError ? inputState.text ?? true : void 0,
|
|
7804
|
-
helper: inputState.isError ? void 0 : inputState.text,
|
|
7805
|
-
helperPosition: "below",
|
|
7806
|
-
classNameModifiers: classNameModifiers == null ? void 0 : classNameModifiers.field,
|
|
7807
|
-
disabled,
|
|
7808
|
-
optional: optional2,
|
|
7809
|
-
children: ({
|
|
7810
|
-
onBlurHandler: fieldOnBlur,
|
|
7811
|
-
onFocusHandler: fieldOnFocus,
|
|
7812
|
-
...childProps
|
|
7813
|
-
}) => jsx(InputText, {
|
|
7814
|
-
...childProps,
|
|
7815
|
-
value: displayValue,
|
|
7816
|
-
onInput: handleInput,
|
|
7817
|
-
onPaste: (event) => {
|
|
7818
|
-
var _a;
|
|
7819
|
-
const pasteValue = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
|
|
7820
|
-
const inputEl = event.target;
|
|
7821
|
-
const {
|
|
7822
|
-
selectionStart,
|
|
7823
|
-
selectionEnd
|
|
7824
|
-
} = inputEl;
|
|
7825
|
-
if (!pasteValue || !selectionStart || selectionStart !== selectionEnd) return;
|
|
7826
|
-
const pureDisplayValue = displayValueToPure(displayValue);
|
|
7827
|
-
const purePasteValue = displayValueToPure(pasteValue);
|
|
7828
|
-
const newPureValue = pureDisplayValue.slice(0, selectionStart) + purePasteValue + pureDisplayValue.slice(selectionStart);
|
|
7829
|
-
if (newPureValue.startsWith(pureDisplayValue + pureDisplayValue)) {
|
|
7830
|
-
const withPrefixRemoved = newPureValue.replace(pureDisplayValue, "");
|
|
7831
|
-
event.preventDefault();
|
|
7832
|
-
handleInput({
|
|
7833
|
-
...event,
|
|
7834
|
-
target: {
|
|
7835
|
-
...event.target,
|
|
7836
|
-
value: withPrefixRemoved
|
|
7837
|
-
}
|
|
7838
|
-
});
|
|
7839
|
-
}
|
|
7840
|
-
},
|
|
7841
|
-
onKeyDown: (event) => {
|
|
7842
|
-
const inputEl = event.target;
|
|
7843
|
-
const isCaretAtEndWithNoSelection = inputEl.selectionStart === inputEl.value.length && inputEl.selectionStart === inputEl.selectionEnd;
|
|
7844
|
-
if (event.key !== KEYBOARD_KEYS.backspace || !isCaretAtEndWithNoSelection) return;
|
|
7845
|
-
event.preventDefault();
|
|
7846
|
-
const withLastCharRemoved = value.slice(0, value.length - 1);
|
|
7847
|
-
const newMaskResult = getMaskResult(withLastCharRemoved);
|
|
7848
|
-
if (newMaskResult.outcome === "mismatch") {
|
|
7849
|
-
inputEl.value = newMaskResult.partialDisplayValue;
|
|
7850
|
-
onMismatch(newMaskResult);
|
|
7851
|
-
} else {
|
|
7852
|
-
inputEl.value = newMaskResult.displayValue;
|
|
7853
|
-
onInput(withLastCharRemoved);
|
|
7854
|
-
}
|
|
7855
|
-
},
|
|
7856
|
-
onFocusHandler: (event) => {
|
|
7857
|
-
fieldOnFocus(event);
|
|
7858
|
-
setIsFocused(true);
|
|
7859
|
-
},
|
|
7860
|
-
onBlurHandler: (event) => {
|
|
7861
|
-
fieldOnBlur(event);
|
|
7862
|
-
const eventWithProcessedValue = {
|
|
7863
|
-
...event,
|
|
7864
|
-
target: {
|
|
7865
|
-
...event.target,
|
|
7866
|
-
value: displayValueToPure(event.target.value)
|
|
7867
|
-
}
|
|
7868
|
-
};
|
|
7869
|
-
onBlur == null ? void 0 : onBlur(eventWithProcessedValue);
|
|
7870
|
-
setIsFocused(false);
|
|
7871
|
-
setHasBlurred(true);
|
|
7872
|
-
},
|
|
7873
|
-
name,
|
|
7874
|
-
readonly,
|
|
7875
|
-
disabled,
|
|
7876
|
-
placeholder,
|
|
7877
|
-
classNameModifiers: [...(classNameModifiers == null ? void 0 : classNameModifiers.input) ?? [], ...showingMismatch ? ["mismatch"] : []],
|
|
7878
|
-
"aria-required": true,
|
|
7879
|
-
"aria-label": label,
|
|
7880
|
-
"aria-invalid": inputState.isError,
|
|
7881
|
-
"aria-placeholder": placeholder,
|
|
7882
|
-
ref: inputRef
|
|
7883
|
-
})
|
|
7884
|
-
});
|
|
7885
|
-
};
|
|
7886
|
-
let idCounter = Date.now();
|
|
7887
|
-
const getUniqueId = (prefix = "id") => {
|
|
7888
|
-
idCounter += 1;
|
|
7889
|
-
return `${prefix}-${idCounter}`;
|
|
7890
|
-
};
|
|
7891
|
-
const InputRadio = ({
|
|
7892
|
-
className,
|
|
7893
|
-
...props
|
|
7894
|
-
}) => jsx("input", {
|
|
7895
|
-
...props,
|
|
7896
|
-
className: cx("adyen-kyc-input-radio__input", className)
|
|
7897
|
-
});
|
|
7898
|
-
function RadioGroup({
|
|
7899
|
-
items = [],
|
|
7900
|
-
name,
|
|
7901
|
-
onChange = noop,
|
|
7902
|
-
value,
|
|
7903
|
-
isInvalid,
|
|
7904
|
-
uniqueId,
|
|
7905
|
-
className,
|
|
7906
|
-
disabled = false,
|
|
7907
|
-
horizontal = false
|
|
7908
|
-
}) {
|
|
7909
|
-
const {
|
|
7910
|
-
i18n
|
|
7911
|
-
} = useI18nContext();
|
|
7912
|
-
const uniqueIdBase = uniqueId == null ? void 0 : uniqueId.replace(/[0-9]/g, "").substring(0, uniqueId.lastIndexOf("-"));
|
|
7913
|
-
const classes = horizontal ? "adyen-kyc-radio-group adyen-kyc-radio-group--horizontal" : "adyen-kyc-radio-group";
|
|
7914
|
-
return jsx("div", {
|
|
7915
|
-
className: classes,
|
|
7916
|
-
children: items.map((item) => {
|
|
7917
|
-
const uniqueId2 = getUniqueId(uniqueIdBase);
|
|
7918
|
-
return jsxs("label", {
|
|
7919
|
-
htmlFor: uniqueId2,
|
|
7920
|
-
className: "adyen-kyc-input-radio",
|
|
7921
|
-
children: [jsx(InputRadio, {
|
|
7922
|
-
id: uniqueId2,
|
|
7923
|
-
type: "radio",
|
|
7924
|
-
checked: value === item.id,
|
|
7925
|
-
"aria-checked": value === item.id,
|
|
7926
|
-
name,
|
|
7927
|
-
onChange,
|
|
7928
|
-
onClick: onChange,
|
|
7929
|
-
value: item.id,
|
|
7930
|
-
disabled
|
|
7931
|
-
}), jsx("span", {
|
|
7932
|
-
className: cx(["adyen-kyc-input-radio__label", "adyen-kyc-label__text", className, {
|
|
7933
|
-
"adyen-kyc-radio-group__label--invalid": isInvalid
|
|
7934
|
-
}]),
|
|
7935
|
-
children: i18n.get(item.name)
|
|
7936
|
-
})]
|
|
7937
|
-
}, item.name || item.id);
|
|
7938
|
-
})
|
|
7939
|
-
});
|
|
7940
|
-
}
|
|
7941
|
-
const companyRegistrationNumberOptions = {
|
|
7942
|
-
[CountryCodes.Poland]: [{
|
|
7943
|
-
id: "regon",
|
|
7944
|
-
name: "regon"
|
|
7945
|
-
}, {
|
|
7946
|
-
id: "krsNumber",
|
|
7947
|
-
name: "krsNumber"
|
|
7948
|
-
}],
|
|
7949
|
-
[CountryCodes.Italy]: [{
|
|
7950
|
-
id: "partitaIVA",
|
|
7951
|
-
name: "partitaIVA"
|
|
7952
|
-
}, {
|
|
7953
|
-
id: "CCIAA",
|
|
7954
|
-
name: "CCIAA"
|
|
7955
|
-
}],
|
|
7956
|
-
[CountryCodes.Austria]: [{
|
|
7957
|
-
id: "firmenbuchnummer",
|
|
7958
|
-
name: "firmenbuchnummer"
|
|
7959
|
-
}, {
|
|
7960
|
-
id: "ZVR",
|
|
7961
|
-
name: "zentralesVereinsregisterId",
|
|
7962
|
-
applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
|
|
7963
|
-
}],
|
|
7964
|
-
[CountryCodes.France]: [{
|
|
7965
|
-
id: "SIRET",
|
|
7966
|
-
name: "siret"
|
|
7967
|
-
}, {
|
|
7968
|
-
id: "RNA",
|
|
7969
|
-
name: "rnaNumber",
|
|
7970
|
-
applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
|
|
7971
|
-
}],
|
|
7972
|
-
[CountryCodes.NewZealand]: [{
|
|
7973
|
-
id: "NZBN",
|
|
7974
|
-
name: "NZBN"
|
|
7975
|
-
}, {
|
|
7976
|
-
id: "companyNumberNZ",
|
|
7977
|
-
name: "companyNumberNZ",
|
|
7978
|
-
applicableOnlyFor: [CompanyTypesValue.PRIVATE_COMPANY, CompanyTypesValue.PUBLIC_COMPANY, CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]
|
|
7979
|
-
}]
|
|
7980
|
-
};
|
|
7981
|
-
const getCompanyRegistrationNumberOptions = (country2, companyType2) => {
|
|
7982
|
-
const optionsForCountry = companyRegistrationNumberOptions[country2];
|
|
7983
|
-
if (!companyType2 || !optionsForCountry) return optionsForCountry;
|
|
7984
|
-
return optionsForCountry.filter((option) => {
|
|
7985
|
-
var _a;
|
|
7986
|
-
return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
|
|
7987
|
-
});
|
|
7988
|
-
};
|
|
7989
|
-
const individualIdNumberOptions = {
|
|
7990
|
-
[CountryCodes.Spain]: [{
|
|
7991
|
-
id: "dni",
|
|
7992
|
-
name: "dni"
|
|
7993
|
-
}, {
|
|
7994
|
-
id: "nie",
|
|
7995
|
-
name: "nie"
|
|
7996
|
-
}]
|
|
7997
|
-
};
|
|
7998
|
-
const additionallIdNumberOptions = {
|
|
7999
|
-
[CountryCodes.NewZealand]: [{
|
|
8000
|
-
id: "driversLicense",
|
|
8001
|
-
name: "driversLicense"
|
|
8002
|
-
}, {
|
|
8003
|
-
id: "passport",
|
|
8004
|
-
name: "passportNumber"
|
|
8005
|
-
}],
|
|
8006
|
-
[CountryCodes.HongKong]: [{
|
|
8007
|
-
id: "proofOfIdentityCard",
|
|
8008
|
-
name: "stateIssuedProofOfIdentityCard"
|
|
8009
|
-
}, {
|
|
8010
|
-
id: "driversLicense",
|
|
8011
|
-
name: "driversLicense"
|
|
8012
|
-
}, {
|
|
8013
|
-
id: "passport",
|
|
8014
|
-
name: "passportNumber"
|
|
8015
|
-
}],
|
|
8016
|
-
[CountryCodes.Australia]: [{
|
|
8017
|
-
id: "driversLicense",
|
|
8018
|
-
name: "driversLicense"
|
|
8019
|
-
}, {
|
|
8020
|
-
id: "passport",
|
|
8021
|
-
name: "passportNumber"
|
|
8022
|
-
}]
|
|
8023
|
-
};
|
|
8024
|
-
const taxIdNumberOptions = {
|
|
8025
|
-
[CountryCodes.Denmark]: [{
|
|
8026
|
-
id: "momsregistreringsnummerCVR",
|
|
8027
|
-
name: "momsregistreringsnummerCVR"
|
|
8028
|
-
}, {
|
|
8029
|
-
id: "stamregister",
|
|
8030
|
-
name: "stamregister"
|
|
8031
|
-
}],
|
|
8032
|
-
[CountryCodes.France]: [{
|
|
8033
|
-
id: "numeroDIdentificationALATaxe",
|
|
8034
|
-
name: "numeroDIdentificationALATaxe"
|
|
8035
|
-
}, {
|
|
8036
|
-
id: "NumeroDeTVA",
|
|
8037
|
-
name: "NumeroDeTVA"
|
|
8038
|
-
}],
|
|
8039
|
-
[CountryCodes.Singapore]: [{
|
|
8040
|
-
id: "GST",
|
|
8041
|
-
name: "gst"
|
|
8042
|
-
}, {
|
|
8043
|
-
id: "UEN",
|
|
8044
|
-
name: "uen"
|
|
8045
|
-
}],
|
|
8046
|
-
[CountryCodes.Jersey]: [{
|
|
8047
|
-
id: "taxIdentificationNumber",
|
|
8048
|
-
name: "taxIdentificationNumber"
|
|
8049
|
-
}, {
|
|
8050
|
-
id: "socialSecurityNumber",
|
|
8051
|
-
name: "socialSecurityNumber",
|
|
8052
|
-
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
8053
|
-
}],
|
|
8054
|
-
[CountryCodes.PuertoRico]: [{
|
|
8055
|
-
id: "EIN",
|
|
8056
|
-
name: "ein"
|
|
8057
|
-
}, {
|
|
8058
|
-
id: "SSN",
|
|
8059
|
-
name: "ssn",
|
|
8060
|
-
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
8061
|
-
}],
|
|
8062
|
-
[CountryCodes.UnitedStates]: [{
|
|
8063
|
-
id: "EIN",
|
|
8064
|
-
name: "ein"
|
|
8065
|
-
}, {
|
|
8066
|
-
id: "SSN",
|
|
8067
|
-
name: "ssn",
|
|
8068
|
-
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
8069
|
-
}]
|
|
8070
|
-
};
|
|
8071
|
-
const getTaxIdNumberOptions = (country2, companyType2) => {
|
|
8072
|
-
const optionsForCountry = taxIdNumberOptions[country2];
|
|
8073
|
-
if (!companyType2 || !optionsForCountry) return optionsForCountry;
|
|
8074
|
-
if (country2 === "US" || country2 === "PR") return optionsForCountry.filter((option) => option.id === "EIN");
|
|
8075
|
-
return optionsForCountry.filter((option) => {
|
|
8076
|
-
var _a;
|
|
8077
|
-
return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
|
|
8078
|
-
});
|
|
8079
|
-
};
|
|
8080
|
-
function CompanyRegistrationNumberTypeSelector({
|
|
8081
|
-
country: country2,
|
|
8082
|
-
companyType: companyType2,
|
|
8083
|
-
selected,
|
|
8084
|
-
setSelected,
|
|
8085
|
-
exemptedOption
|
|
8086
|
-
}) {
|
|
8087
|
-
const {
|
|
8088
|
-
i18n
|
|
8089
|
-
} = useI18nContext();
|
|
8090
|
-
const handleSelect = useCallback((selectedStr) => {
|
|
8091
|
-
const newSelected = selectedStr;
|
|
8092
|
-
if (newSelected === "exempted") {
|
|
8093
|
-
if (exemptedOption) {
|
|
8094
|
-
setSelected(newSelected);
|
|
8095
|
-
}
|
|
8096
|
-
return;
|
|
8097
|
-
}
|
|
8098
|
-
setSelected(newSelected);
|
|
8099
|
-
}, [exemptedOption, setSelected]);
|
|
8100
|
-
const options = useMemo(() => {
|
|
8101
|
-
const availableOptions = getCompanyRegistrationNumberOptions(country2, companyType2) ?? [];
|
|
8102
|
-
if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
|
|
8103
|
-
return [...availableOptions, {
|
|
8104
|
-
id: "exempted",
|
|
8105
|
-
name: exemptedOption
|
|
8106
|
-
}];
|
|
8107
|
-
}, [companyType2, country2, exemptedOption]);
|
|
8108
|
-
useEffect(() => {
|
|
8109
|
-
if (!selected && options.length > 0) {
|
|
8110
|
-
setSelected(options[0].id);
|
|
8111
|
-
}
|
|
8112
|
-
}, [options, selected, setSelected]);
|
|
8113
|
-
if (options.length <= 1) return null;
|
|
8114
|
-
return jsx(Field, {
|
|
8115
|
-
name: "companyRegistrationNumberType",
|
|
8116
|
-
label: i18n.get("whichTypeOfRegistrationNumberDoYouHave"),
|
|
8117
|
-
children: (childProps) => jsx(RadioGroup, {
|
|
8118
|
-
...childProps,
|
|
8119
|
-
name: "companyRegistrationNumberType",
|
|
8120
|
-
items: options,
|
|
8121
|
-
value: selected,
|
|
8122
|
-
onChange: (e) => handleSelect(e.target.value)
|
|
8123
|
-
})
|
|
8124
|
-
});
|
|
8125
|
-
}
|
|
8126
|
-
const makeArrayOfRepeatedObjects = (length, obj) => {
|
|
8127
|
-
const array = [];
|
|
8128
|
-
for (let i = 0; i < length; i += 1) {
|
|
8129
|
-
array.push(cloneObject(obj));
|
|
8130
|
-
}
|
|
8131
|
-
return array;
|
|
8132
|
-
};
|
|
8133
7525
|
const nonInputs = (str, options) => Array.from(str).map((char) => ({
|
|
8134
7526
|
type: "nonInput",
|
|
8135
7527
|
char,
|
|
@@ -10000,154 +9392,685 @@ const defaultFieldConfig$9 = {
|
|
|
10000
9392
|
}
|
|
10001
9393
|
}
|
|
10002
9394
|
};
|
|
10003
|
-
}
|
|
10004
|
-
},
|
|
10005
|
-
[CountryCodes.UnitedStates]: ({
|
|
10006
|
-
state: state2
|
|
10007
|
-
}) => ({
|
|
10008
|
-
label: "registrationNumber__US",
|
|
10009
|
-
helperText: "registrationNumber__helperText__US",
|
|
10010
|
-
mask: state2 ? businessRegistrationNumberMasks[CountryCodes.UnitedStates][state2] : businessRegistrationNumberMasks[CountryCodes.UnitedStates].default,
|
|
10011
|
-
validators: state2 ? validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates][state2]) : validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates].default),
|
|
10012
|
-
guidanceText: state2 ? stateFormatGuidanceText[state2] : stateFormatGuidanceText.default
|
|
10013
|
-
})
|
|
9395
|
+
}
|
|
9396
|
+
},
|
|
9397
|
+
[CountryCodes.UnitedStates]: ({
|
|
9398
|
+
state: state2
|
|
9399
|
+
}) => ({
|
|
9400
|
+
label: "registrationNumber__US",
|
|
9401
|
+
helperText: "registrationNumber__helperText__US",
|
|
9402
|
+
mask: state2 ? businessRegistrationNumberMasks[CountryCodes.UnitedStates][state2] : businessRegistrationNumberMasks[CountryCodes.UnitedStates].default,
|
|
9403
|
+
validators: state2 ? validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates][state2]) : validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates].default),
|
|
9404
|
+
guidanceText: state2 ? stateFormatGuidanceText[state2] : stateFormatGuidanceText.default
|
|
9405
|
+
})
|
|
9406
|
+
};
|
|
9407
|
+
const cachedStripPatterns = /* @__PURE__ */ new Map();
|
|
9408
|
+
const makeStripPattern = (mask) => {
|
|
9409
|
+
const inputPatterns = mask.tokens.filter((token) => token.type === "input" && !!token.allow).map((token) => token.allow);
|
|
9410
|
+
const nonInputChars = mask.tokens.filter((token) => token.type === "nonInput" && !token.includeInValue).map((token) => token.char);
|
|
9411
|
+
const strippedChars = [...new Set(nonInputChars.filter((char) => !inputPatterns.some((pattern) => pattern.test(char))))];
|
|
9412
|
+
const stripPattern = new RegExp(`[${strippedChars.join("")}]`, "g");
|
|
9413
|
+
cachedStripPatterns.set(mask, stripPattern);
|
|
9414
|
+
return stripPattern;
|
|
9415
|
+
};
|
|
9416
|
+
const displayValueToPureValue = (displayValue, mask) => {
|
|
9417
|
+
const stripPattern = cachedStripPatterns.get(mask) ?? makeStripPattern(mask);
|
|
9418
|
+
return displayValue.replaceAll(stripPattern, "");
|
|
9419
|
+
};
|
|
9420
|
+
const isValueObscured = (value) => {
|
|
9421
|
+
var _a;
|
|
9422
|
+
return typeof value === "string" && !!((_a = value.match(/[*]{1,}/)) == null ? void 0 : _a.length);
|
|
9423
|
+
};
|
|
9424
|
+
const getAvailableInputTokens = (tokens) => {
|
|
9425
|
+
const availableTokens = [];
|
|
9426
|
+
for (const token of tokens) {
|
|
9427
|
+
if (token.type === "nonInput") {
|
|
9428
|
+
if (token.includeInValue) {
|
|
9429
|
+
availableTokens.push({
|
|
9430
|
+
...token,
|
|
9431
|
+
offset: tokens.indexOf(token)
|
|
9432
|
+
});
|
|
9433
|
+
}
|
|
9434
|
+
continue;
|
|
9435
|
+
}
|
|
9436
|
+
availableTokens.push({
|
|
9437
|
+
...token,
|
|
9438
|
+
offset: tokens.indexOf(token)
|
|
9439
|
+
});
|
|
9440
|
+
if (token.type !== "input" || !token.optional) break;
|
|
9441
|
+
}
|
|
9442
|
+
return availableTokens;
|
|
9443
|
+
};
|
|
9444
|
+
const findMatchingToken = (tokensWithOffset, char) => tokensWithOffset.find((token) => token.type === "nonInput" || !token.allow || token.allow.test(char)) ?? null;
|
|
9445
|
+
const getEagerSuffix = (tokens) => {
|
|
9446
|
+
let suffix = "";
|
|
9447
|
+
for (const token of tokens) {
|
|
9448
|
+
if (token.type === "input") {
|
|
9449
|
+
if (token.optional) continue;
|
|
9450
|
+
else break;
|
|
9451
|
+
}
|
|
9452
|
+
if (!token.displayEagerly) break;
|
|
9453
|
+
suffix += token.char;
|
|
9454
|
+
}
|
|
9455
|
+
return suffix;
|
|
9456
|
+
};
|
|
9457
|
+
const getPotentialForMoreOptionalInput = (tokens) => tokens.some((token) => token.type === "input" && token.optional);
|
|
9458
|
+
const matchAgainstMask = (pureValue, mask, acceptObscuredValue = false) => {
|
|
9459
|
+
let tokensToProcess = [...mask.tokens];
|
|
9460
|
+
let charsToProcess = pureValue;
|
|
9461
|
+
let charIndex = 0;
|
|
9462
|
+
let matchedTokens = [];
|
|
9463
|
+
if (acceptObscuredValue && isValueObscured(pureValue)) {
|
|
9464
|
+
return {
|
|
9465
|
+
outcome: "obscureCorrect",
|
|
9466
|
+
displayValue: pureValue
|
|
9467
|
+
};
|
|
9468
|
+
}
|
|
9469
|
+
const shiftChars = (increment) => {
|
|
9470
|
+
charIndex += increment;
|
|
9471
|
+
charsToProcess = charsToProcess.slice(increment);
|
|
9472
|
+
};
|
|
9473
|
+
const shiftTokens = (increment) => {
|
|
9474
|
+
tokensToProcess = tokensToProcess.slice(increment);
|
|
9475
|
+
};
|
|
9476
|
+
const displayValue = () => matchedTokens.map((token) => token.char).join("");
|
|
9477
|
+
while (true) {
|
|
9478
|
+
const char = charsToProcess[0];
|
|
9479
|
+
const token = tokensToProcess[0];
|
|
9480
|
+
if (!char && !tokensToProcess.some((t) => t.type === "input" && !t.optional)) return {
|
|
9481
|
+
outcome: "correct",
|
|
9482
|
+
displayValue: displayValue() + getEagerSuffix(tokensToProcess),
|
|
9483
|
+
potentialForMoreOptionalInput: getPotentialForMoreOptionalInput(tokensToProcess)
|
|
9484
|
+
};
|
|
9485
|
+
if (!char) {
|
|
9486
|
+
const output = shiftRight(mask.possibleShifts, matchedTokens, tokensToProcess);
|
|
9487
|
+
matchedTokens = output.matchedTokens;
|
|
9488
|
+
tokensToProcess = output.remainingTokens;
|
|
9489
|
+
return {
|
|
9490
|
+
outcome: "partialCorrect",
|
|
9491
|
+
displayValue: displayValue() + getEagerSuffix(tokensToProcess)
|
|
9492
|
+
};
|
|
9493
|
+
}
|
|
9494
|
+
if (!token) return {
|
|
9495
|
+
outcome: "mismatch",
|
|
9496
|
+
badChar: char,
|
|
9497
|
+
mismatchAtChar: charIndex,
|
|
9498
|
+
mismatchedToken: "inputTooLong",
|
|
9499
|
+
partialDisplayValue: displayValue()
|
|
9500
|
+
};
|
|
9501
|
+
if (token.type === "nonInput") {
|
|
9502
|
+
if (token.includeInValue) {
|
|
9503
|
+
if (char !== token.char) return {
|
|
9504
|
+
outcome: "mismatch",
|
|
9505
|
+
badChar: char,
|
|
9506
|
+
mismatchAtChar: charIndex,
|
|
9507
|
+
mismatchedToken: token,
|
|
9508
|
+
partialDisplayValue: displayValue()
|
|
9509
|
+
};
|
|
9510
|
+
shiftChars(1);
|
|
9511
|
+
}
|
|
9512
|
+
matchedTokens.push(token);
|
|
9513
|
+
shiftTokens(1);
|
|
9514
|
+
}
|
|
9515
|
+
if (token.type === "input") {
|
|
9516
|
+
const availableTokens = getAvailableInputTokens(tokensToProcess);
|
|
9517
|
+
const matchingToken = findMatchingToken(availableTokens, char);
|
|
9518
|
+
if (!matchingToken) return {
|
|
9519
|
+
outcome: "mismatch",
|
|
9520
|
+
badChar: char,
|
|
9521
|
+
mismatchAtChar: charIndex,
|
|
9522
|
+
mismatchedToken: token,
|
|
9523
|
+
partialDisplayValue: displayValue()
|
|
9524
|
+
};
|
|
9525
|
+
matchedTokens.push({
|
|
9526
|
+
...matchingToken,
|
|
9527
|
+
char
|
|
9528
|
+
});
|
|
9529
|
+
shiftTokens(matchingToken.offset + 1);
|
|
9530
|
+
shiftChars(1);
|
|
9531
|
+
}
|
|
9532
|
+
}
|
|
9533
|
+
};
|
|
9534
|
+
const deriveInputState = (isValid, isFocused, isDisabled, isOptional, hasNullishValue, hasBlurred, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
|
|
9535
|
+
if (isDisabled) return {
|
|
9536
|
+
isError: false
|
|
9537
|
+
};
|
|
9538
|
+
if (isOptional && hasNullishValue) {
|
|
9539
|
+
return {
|
|
9540
|
+
isError: false
|
|
9541
|
+
};
|
|
9542
|
+
}
|
|
9543
|
+
if (isValid && (!potentiallyMoreOptionalCharacters || !isFocused)) return {
|
|
9544
|
+
isError: false,
|
|
9545
|
+
text: jsxs(Fragment, {
|
|
9546
|
+
children: [jsx(Icon, {
|
|
9547
|
+
name: "checkmark-small",
|
|
9548
|
+
className: "adyen-kyc-helper-text__valid-format-check"
|
|
9549
|
+
}), i18n.get("formatIsCorrect")]
|
|
9550
|
+
})
|
|
9551
|
+
};
|
|
9552
|
+
if (isFocused && formatGuidance) return {
|
|
9553
|
+
isError: false,
|
|
9554
|
+
text: formatGuidance
|
|
9555
|
+
};
|
|
9556
|
+
if (!isValid && (shouldValidate || hasBlurred)) return {
|
|
9557
|
+
isError: true,
|
|
9558
|
+
text: typeof errorMessage === "string" && errorMessage ? errorMessage : formatGuidance
|
|
9559
|
+
};
|
|
9560
|
+
return {
|
|
9561
|
+
isError: false
|
|
9562
|
+
};
|
|
9563
|
+
};
|
|
9564
|
+
const MISMATCH_ANIMATION_NAME = "mismatchShake";
|
|
9565
|
+
const logger$C = createLogger("MaskedInputText");
|
|
9566
|
+
const MaskedInputText = ({
|
|
9567
|
+
value,
|
|
9568
|
+
onInput,
|
|
9569
|
+
onBlur,
|
|
9570
|
+
onMismatch: onMismatchExternal,
|
|
9571
|
+
isValid: validationIsValid,
|
|
9572
|
+
errorMessage,
|
|
9573
|
+
shouldValidate,
|
|
9574
|
+
mask,
|
|
9575
|
+
name,
|
|
9576
|
+
label,
|
|
9577
|
+
placeholder,
|
|
9578
|
+
transformOnType,
|
|
9579
|
+
readonly = false,
|
|
9580
|
+
disabled = false,
|
|
9581
|
+
optional: optional2 = false,
|
|
9582
|
+
formatGuidance,
|
|
9583
|
+
classNameModifiers,
|
|
9584
|
+
acceptObscuredValue = false
|
|
9585
|
+
}) => {
|
|
9586
|
+
const hasExistingData = !isEmpty(value);
|
|
9587
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
9588
|
+
const [hasBlurred, setHasBlurred] = useState(hasExistingData);
|
|
9589
|
+
const [caretReturnPosition, setCaretReturnPosition] = useState(null);
|
|
9590
|
+
const inputRef = useRef(null);
|
|
9591
|
+
const [showingMismatch, setShowingMismatch] = useState(false);
|
|
9592
|
+
const {
|
|
9593
|
+
i18n
|
|
9594
|
+
} = useI18nContext();
|
|
9595
|
+
const onMismatch = (mismatch) => {
|
|
9596
|
+
if (!inputRef.current) return;
|
|
9597
|
+
setShowingMismatch(true);
|
|
9598
|
+
inputRef.current.addEventListener("animationend", (event) => {
|
|
9599
|
+
if (event.animationName !== MISMATCH_ANIMATION_NAME) return;
|
|
9600
|
+
setShowingMismatch(false);
|
|
9601
|
+
});
|
|
9602
|
+
onMismatchExternal == null ? void 0 : onMismatchExternal(mismatch);
|
|
9603
|
+
};
|
|
9604
|
+
useEffect(() => {
|
|
9605
|
+
if (!mask) {
|
|
9606
|
+
logger$C.warn("`mask` is undefined. No masking of input will take place.");
|
|
9607
|
+
}
|
|
9608
|
+
}, [mask]);
|
|
9609
|
+
const getMaskResult = useCallback((pureValue) => {
|
|
9610
|
+
if (!mask) return {
|
|
9611
|
+
outcome: "partialCorrect",
|
|
9612
|
+
displayValue: pureValue
|
|
9613
|
+
};
|
|
9614
|
+
return matchAgainstMask(transformOnType ? transformOnType(pureValue) : pureValue, mask, acceptObscuredValue);
|
|
9615
|
+
}, [mask, transformOnType, acceptObscuredValue]);
|
|
9616
|
+
const displayValueToPure = useCallback((displayValue2) => {
|
|
9617
|
+
if (!mask) return displayValue2;
|
|
9618
|
+
return displayValueToPureValue(displayValue2, mask);
|
|
9619
|
+
}, [mask]);
|
|
9620
|
+
const maskResult = useMemo(() => getMaskResult(value), [getMaskResult, value]);
|
|
9621
|
+
const displayValue = maskResult.outcome === "mismatch" ? maskResult.partialDisplayValue : maskResult.displayValue;
|
|
9622
|
+
const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, disabled, optional2, !displayValue, hasBlurred, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
|
|
9623
|
+
useEffect(() => {
|
|
9624
|
+
if (mask && maskResult.outcome === "mismatch") {
|
|
9625
|
+
const strippedValue = displayValueToPure(value);
|
|
9626
|
+
if (getMaskResult(strippedValue).outcome !== "mismatch") {
|
|
9627
|
+
onInput(strippedValue);
|
|
9628
|
+
return;
|
|
9629
|
+
}
|
|
9630
|
+
const fallback = displayValueToPure(maskResult.partialDisplayValue);
|
|
9631
|
+
logger$C.warn(`Value received "${value}" does not match mask`, maskResult, `
|
|
9632
|
+
Falling back to partially valid value "${fallback}"`);
|
|
9633
|
+
onInput(fallback);
|
|
9634
|
+
}
|
|
9635
|
+
}, [mask, maskResult, value, onInput, displayValueToPure, getMaskResult]);
|
|
9636
|
+
useLayoutEffect(() => {
|
|
9637
|
+
if (caretReturnPosition && inputRef.current && caretReturnPosition !== inputRef.current.selectionStart) {
|
|
9638
|
+
inputRef.current.setSelectionRange(caretReturnPosition, caretReturnPosition, "none");
|
|
9639
|
+
setCaretReturnPosition(null);
|
|
9640
|
+
}
|
|
9641
|
+
}, [caretReturnPosition]);
|
|
9642
|
+
const handleInput = (event) => {
|
|
9643
|
+
const inputEl = event.target;
|
|
9644
|
+
const newPureValue = displayValueToPure(inputEl.value);
|
|
9645
|
+
const newMaskResult = getMaskResult(newPureValue);
|
|
9646
|
+
const returnCaretLater = (offset = 0) => {
|
|
9647
|
+
if (!inputEl.selectionStart) return;
|
|
9648
|
+
setCaretReturnPosition(inputEl.selectionStart + offset);
|
|
9649
|
+
};
|
|
9650
|
+
const cancelInput = () => {
|
|
9651
|
+
returnCaretLater(-1);
|
|
9652
|
+
inputEl.value = displayValue;
|
|
9653
|
+
event.preventDefault();
|
|
9654
|
+
event.stopPropagation();
|
|
9655
|
+
};
|
|
9656
|
+
if (newMaskResult.outcome === "mismatch") {
|
|
9657
|
+
cancelInput();
|
|
9658
|
+
onMismatch(newMaskResult);
|
|
9659
|
+
return;
|
|
9660
|
+
}
|
|
9661
|
+
if (inputEl.selectionStart && inputEl.selectionStart < inputEl.value.length) {
|
|
9662
|
+
returnCaretLater();
|
|
9663
|
+
}
|
|
9664
|
+
inputEl.value = newMaskResult.displayValue;
|
|
9665
|
+
onInput(newPureValue);
|
|
9666
|
+
};
|
|
9667
|
+
return jsx(Field, {
|
|
9668
|
+
name,
|
|
9669
|
+
label,
|
|
9670
|
+
isValid: !inputState.isError,
|
|
9671
|
+
errorMessage: inputState.isError ? inputState.text ?? true : void 0,
|
|
9672
|
+
helper: inputState.isError ? void 0 : inputState.text,
|
|
9673
|
+
helperPosition: "below",
|
|
9674
|
+
classNameModifiers: classNameModifiers == null ? void 0 : classNameModifiers.field,
|
|
9675
|
+
disabled,
|
|
9676
|
+
optional: optional2,
|
|
9677
|
+
children: ({
|
|
9678
|
+
onBlurHandler: fieldOnBlur,
|
|
9679
|
+
onFocusHandler: fieldOnFocus,
|
|
9680
|
+
...childProps
|
|
9681
|
+
}) => jsx(InputText, {
|
|
9682
|
+
...childProps,
|
|
9683
|
+
value: displayValue,
|
|
9684
|
+
onInput: handleInput,
|
|
9685
|
+
onPaste: (event) => {
|
|
9686
|
+
var _a;
|
|
9687
|
+
const pasteValue = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
|
|
9688
|
+
const inputEl = event.target;
|
|
9689
|
+
const {
|
|
9690
|
+
selectionStart,
|
|
9691
|
+
selectionEnd
|
|
9692
|
+
} = inputEl;
|
|
9693
|
+
if (!pasteValue || !selectionStart || selectionStart !== selectionEnd) return;
|
|
9694
|
+
const pureDisplayValue = displayValueToPure(displayValue);
|
|
9695
|
+
const purePasteValue = displayValueToPure(pasteValue);
|
|
9696
|
+
const newPureValue = pureDisplayValue.slice(0, selectionStart) + purePasteValue + pureDisplayValue.slice(selectionStart);
|
|
9697
|
+
if (newPureValue.startsWith(pureDisplayValue + pureDisplayValue)) {
|
|
9698
|
+
const withPrefixRemoved = newPureValue.replace(pureDisplayValue, "");
|
|
9699
|
+
event.preventDefault();
|
|
9700
|
+
handleInput({
|
|
9701
|
+
...event,
|
|
9702
|
+
target: {
|
|
9703
|
+
...event.target,
|
|
9704
|
+
value: withPrefixRemoved
|
|
9705
|
+
}
|
|
9706
|
+
});
|
|
9707
|
+
}
|
|
9708
|
+
},
|
|
9709
|
+
onKeyDown: (event) => {
|
|
9710
|
+
const inputEl = event.target;
|
|
9711
|
+
const isCaretAtEndWithNoSelection = inputEl.selectionStart === inputEl.value.length && inputEl.selectionStart === inputEl.selectionEnd;
|
|
9712
|
+
if (event.key !== KEYBOARD_KEYS.backspace || !isCaretAtEndWithNoSelection) return;
|
|
9713
|
+
event.preventDefault();
|
|
9714
|
+
const withLastCharRemoved = value.slice(0, value.length - 1);
|
|
9715
|
+
const newMaskResult = getMaskResult(withLastCharRemoved);
|
|
9716
|
+
if (newMaskResult.outcome === "mismatch") {
|
|
9717
|
+
inputEl.value = newMaskResult.partialDisplayValue;
|
|
9718
|
+
onMismatch(newMaskResult);
|
|
9719
|
+
} else {
|
|
9720
|
+
inputEl.value = newMaskResult.displayValue;
|
|
9721
|
+
onInput(withLastCharRemoved);
|
|
9722
|
+
}
|
|
9723
|
+
},
|
|
9724
|
+
onFocusHandler: (event) => {
|
|
9725
|
+
fieldOnFocus(event);
|
|
9726
|
+
setIsFocused(true);
|
|
9727
|
+
},
|
|
9728
|
+
onBlurHandler: (event) => {
|
|
9729
|
+
fieldOnBlur(event);
|
|
9730
|
+
const eventWithProcessedValue = {
|
|
9731
|
+
...event,
|
|
9732
|
+
target: {
|
|
9733
|
+
...event.target,
|
|
9734
|
+
value: displayValueToPure(event.target.value)
|
|
9735
|
+
}
|
|
9736
|
+
};
|
|
9737
|
+
onBlur == null ? void 0 : onBlur(eventWithProcessedValue);
|
|
9738
|
+
setIsFocused(false);
|
|
9739
|
+
setHasBlurred(true);
|
|
9740
|
+
},
|
|
9741
|
+
name,
|
|
9742
|
+
readonly,
|
|
9743
|
+
disabled,
|
|
9744
|
+
placeholder,
|
|
9745
|
+
classNameModifiers: [...(classNameModifiers == null ? void 0 : classNameModifiers.input) ?? [], ...showingMismatch ? ["mismatch"] : []],
|
|
9746
|
+
"aria-required": true,
|
|
9747
|
+
"aria-label": label,
|
|
9748
|
+
"aria-invalid": inputState.isError,
|
|
9749
|
+
"aria-placeholder": placeholder,
|
|
9750
|
+
ref: inputRef
|
|
9751
|
+
})
|
|
9752
|
+
});
|
|
10014
9753
|
};
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
for (const option of optionsForCountry) {
|
|
10020
|
-
const fieldMetadata = metadataFn({
|
|
10021
|
-
companyType: companyType2,
|
|
10022
|
-
registrationNumberType: option.id
|
|
10023
|
-
});
|
|
10024
|
-
if (!fieldMetadata.validators) continue;
|
|
10025
|
-
const validators2 = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
|
|
10026
|
-
if (validators2.every((validator) => validator.validate(registrationNumber2))) {
|
|
10027
|
-
return option.id;
|
|
10028
|
-
}
|
|
10029
|
-
}
|
|
9754
|
+
let idCounter = Date.now();
|
|
9755
|
+
const getUniqueId = (prefix = "id") => {
|
|
9756
|
+
idCounter += 1;
|
|
9757
|
+
return `${prefix}-${idCounter}`;
|
|
10030
9758
|
};
|
|
10031
|
-
const
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
9759
|
+
const InputRadio = ({
|
|
9760
|
+
className,
|
|
9761
|
+
...props
|
|
9762
|
+
}) => jsx("input", {
|
|
9763
|
+
...props,
|
|
9764
|
+
className: cx("adyen-kyc-input-radio__input", className)
|
|
9765
|
+
});
|
|
9766
|
+
function RadioGroup({
|
|
9767
|
+
items = [],
|
|
9768
|
+
name,
|
|
9769
|
+
onChange = noop,
|
|
9770
|
+
value,
|
|
9771
|
+
isInvalid,
|
|
9772
|
+
uniqueId,
|
|
9773
|
+
className,
|
|
9774
|
+
disabled = false,
|
|
9775
|
+
horizontal = false
|
|
9776
|
+
}) {
|
|
10035
9777
|
const {
|
|
10036
9778
|
i18n
|
|
10037
9779
|
} = useI18nContext();
|
|
10038
|
-
const
|
|
10039
|
-
|
|
9780
|
+
const uniqueIdBase = uniqueId == null ? void 0 : uniqueId.replace(/[0-9]/g, "").substring(0, uniqueId.lastIndexOf("-"));
|
|
9781
|
+
const classes = horizontal ? "adyen-kyc-radio-group adyen-kyc-radio-group--horizontal" : "adyen-kyc-radio-group";
|
|
9782
|
+
return jsx("div", {
|
|
9783
|
+
className: classes,
|
|
9784
|
+
children: items.map((item) => {
|
|
9785
|
+
const uniqueId2 = getUniqueId(uniqueIdBase);
|
|
9786
|
+
return jsxs("label", {
|
|
9787
|
+
htmlFor: uniqueId2,
|
|
9788
|
+
className: "adyen-kyc-input-radio",
|
|
9789
|
+
children: [jsx(InputRadio, {
|
|
9790
|
+
id: uniqueId2,
|
|
9791
|
+
type: "radio",
|
|
9792
|
+
checked: value === item.id,
|
|
9793
|
+
"aria-checked": value === item.id,
|
|
9794
|
+
name,
|
|
9795
|
+
onChange,
|
|
9796
|
+
onClick: onChange,
|
|
9797
|
+
value: item.id,
|
|
9798
|
+
disabled
|
|
9799
|
+
}), jsx("span", {
|
|
9800
|
+
className: cx(["adyen-kyc-input-radio__label", "adyen-kyc-label__text", className, {
|
|
9801
|
+
"adyen-kyc-radio-group__label--invalid": isInvalid
|
|
9802
|
+
}]),
|
|
9803
|
+
children: i18n.get(item.name)
|
|
9804
|
+
})]
|
|
9805
|
+
}, item.name || item.id);
|
|
9806
|
+
})
|
|
10040
9807
|
});
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
9808
|
+
}
|
|
9809
|
+
const companyRegistrationNumberOptions = {
|
|
9810
|
+
[CountryCodes.Poland]: [{
|
|
9811
|
+
id: "regon",
|
|
9812
|
+
name: "regon"
|
|
9813
|
+
}, {
|
|
9814
|
+
id: "krsNumber",
|
|
9815
|
+
name: "krsNumber"
|
|
9816
|
+
}],
|
|
9817
|
+
[CountryCodes.Italy]: [{
|
|
9818
|
+
id: "partitaIVA",
|
|
9819
|
+
name: "partitaIVA"
|
|
9820
|
+
}, {
|
|
9821
|
+
id: "CCIAA",
|
|
9822
|
+
name: "CCIAA"
|
|
9823
|
+
}],
|
|
9824
|
+
[CountryCodes.Austria]: [{
|
|
9825
|
+
id: "firmenbuchnummer",
|
|
9826
|
+
name: "firmenbuchnummer"
|
|
9827
|
+
}, {
|
|
9828
|
+
id: "ZVR",
|
|
9829
|
+
name: "zentralesVereinsregisterId",
|
|
9830
|
+
applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
|
|
9831
|
+
}],
|
|
9832
|
+
[CountryCodes.France]: [{
|
|
9833
|
+
id: "SIRET",
|
|
9834
|
+
name: "siret"
|
|
9835
|
+
}, {
|
|
9836
|
+
id: "RNA",
|
|
9837
|
+
name: "rnaNumber",
|
|
9838
|
+
applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
|
|
9839
|
+
}],
|
|
9840
|
+
[CountryCodes.NewZealand]: [{
|
|
9841
|
+
id: "NZBN",
|
|
9842
|
+
name: "NZBN"
|
|
9843
|
+
}, {
|
|
9844
|
+
id: "companyNumberNZ",
|
|
9845
|
+
name: "companyNumberNZ",
|
|
9846
|
+
applicableOnlyFor: [CompanyTypesValue.PRIVATE_COMPANY, CompanyTypesValue.PUBLIC_COMPANY, CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]
|
|
9847
|
+
}]
|
|
9848
|
+
};
|
|
9849
|
+
const getCompanyRegistrationNumberOptions = (country2, companyType2) => {
|
|
9850
|
+
const optionsForCountry = companyRegistrationNumberOptions[country2];
|
|
9851
|
+
if (!companyType2 || !optionsForCountry) return optionsForCountry;
|
|
9852
|
+
return optionsForCountry.filter((option) => {
|
|
9853
|
+
var _a;
|
|
9854
|
+
return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
|
|
10056
9855
|
});
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
9856
|
+
};
|
|
9857
|
+
const individualIdNumberOptions = {
|
|
9858
|
+
[CountryCodes.Spain]: [{
|
|
9859
|
+
id: "dni",
|
|
9860
|
+
name: "dni"
|
|
9861
|
+
}, {
|
|
9862
|
+
id: "nie",
|
|
9863
|
+
name: "nie"
|
|
9864
|
+
}]
|
|
9865
|
+
};
|
|
9866
|
+
const additionallIdNumberOptions = {
|
|
9867
|
+
[CountryCodes.NewZealand]: [{
|
|
9868
|
+
id: "driversLicense",
|
|
9869
|
+
name: "driversLicense"
|
|
9870
|
+
}, {
|
|
9871
|
+
id: "passport",
|
|
9872
|
+
name: "passportNumber"
|
|
9873
|
+
}],
|
|
9874
|
+
[CountryCodes.HongKong]: [{
|
|
9875
|
+
id: "proofOfIdentityCard",
|
|
9876
|
+
name: "stateIssuedProofOfIdentityCard"
|
|
9877
|
+
}, {
|
|
9878
|
+
id: "driversLicense",
|
|
9879
|
+
name: "driversLicense"
|
|
9880
|
+
}, {
|
|
9881
|
+
id: "passport",
|
|
9882
|
+
name: "passportNumber"
|
|
9883
|
+
}],
|
|
9884
|
+
[CountryCodes.Australia]: [{
|
|
9885
|
+
id: "driversLicense",
|
|
9886
|
+
name: "driversLicense"
|
|
9887
|
+
}, {
|
|
9888
|
+
id: "passport",
|
|
9889
|
+
name: "passportNumber"
|
|
9890
|
+
}]
|
|
9891
|
+
};
|
|
9892
|
+
const taxIdNumberOptions = {
|
|
9893
|
+
[CountryCodes.Denmark]: [{
|
|
9894
|
+
id: "momsregistreringsnummerCVR",
|
|
9895
|
+
name: "momsregistreringsnummerCVR"
|
|
9896
|
+
}, {
|
|
9897
|
+
id: "stamregister",
|
|
9898
|
+
name: "stamregister"
|
|
9899
|
+
}],
|
|
9900
|
+
[CountryCodes.France]: [{
|
|
9901
|
+
id: "numeroDIdentificationALATaxe",
|
|
9902
|
+
name: "numeroDIdentificationALATaxe"
|
|
9903
|
+
}, {
|
|
9904
|
+
id: "NumeroDeTVA",
|
|
9905
|
+
name: "NumeroDeTVA"
|
|
9906
|
+
}],
|
|
9907
|
+
[CountryCodes.Singapore]: [{
|
|
9908
|
+
id: "GST",
|
|
9909
|
+
name: "gst"
|
|
9910
|
+
}, {
|
|
9911
|
+
id: "UEN",
|
|
9912
|
+
name: "uen"
|
|
9913
|
+
}],
|
|
9914
|
+
[CountryCodes.Jersey]: [{
|
|
9915
|
+
id: "taxIdentificationNumber",
|
|
9916
|
+
name: "taxIdentificationNumber"
|
|
9917
|
+
}, {
|
|
9918
|
+
id: "socialSecurityNumber",
|
|
9919
|
+
name: "socialSecurityNumber",
|
|
9920
|
+
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
9921
|
+
}],
|
|
9922
|
+
[CountryCodes.PuertoRico]: [{
|
|
9923
|
+
id: "EIN",
|
|
9924
|
+
name: "ein"
|
|
9925
|
+
}, {
|
|
9926
|
+
id: "SSN",
|
|
9927
|
+
name: "ssn",
|
|
9928
|
+
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
9929
|
+
}],
|
|
9930
|
+
[CountryCodes.UnitedStates]: [{
|
|
9931
|
+
id: "EIN",
|
|
9932
|
+
name: "ein"
|
|
9933
|
+
}, {
|
|
9934
|
+
id: "SSN",
|
|
9935
|
+
name: "ssn",
|
|
9936
|
+
applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
|
|
9937
|
+
}]
|
|
9938
|
+
};
|
|
9939
|
+
const getTaxIdNumberOptions = (country2, companyType2) => {
|
|
9940
|
+
const optionsForCountry = taxIdNumberOptions[country2];
|
|
9941
|
+
if (!companyType2 || !optionsForCountry) return optionsForCountry;
|
|
9942
|
+
if (country2 === "US" || country2 === "PR") return optionsForCountry.filter((option) => option.id === "EIN");
|
|
9943
|
+
return optionsForCountry.filter((option) => {
|
|
9944
|
+
var _a;
|
|
9945
|
+
return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
|
|
10074
9946
|
});
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
9947
|
+
};
|
|
9948
|
+
function CompanyRegistrationNumberTypeSelector({
|
|
9949
|
+
country: country2,
|
|
9950
|
+
companyType: companyType2,
|
|
9951
|
+
selected,
|
|
9952
|
+
setSelected,
|
|
9953
|
+
exemptedOption
|
|
9954
|
+
}) {
|
|
9955
|
+
const {
|
|
9956
|
+
i18n
|
|
9957
|
+
} = useI18nContext();
|
|
9958
|
+
const handleSelect = useCallback((selectedStr) => {
|
|
9959
|
+
const newSelected = selectedStr;
|
|
9960
|
+
if (newSelected === "exempted") {
|
|
9961
|
+
if (exemptedOption) {
|
|
9962
|
+
setSelected(newSelected);
|
|
10085
9963
|
}
|
|
10086
|
-
|
|
10087
|
-
|
|
9964
|
+
return;
|
|
9965
|
+
}
|
|
9966
|
+
setSelected(newSelected);
|
|
9967
|
+
}, [exemptedOption, setSelected]);
|
|
9968
|
+
const options = useMemo(() => {
|
|
9969
|
+
const availableOptions = getCompanyRegistrationNumberOptions(country2, companyType2) ?? [];
|
|
9970
|
+
if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
|
|
9971
|
+
return [...availableOptions, {
|
|
9972
|
+
id: "exempted",
|
|
9973
|
+
name: exemptedOption
|
|
9974
|
+
}];
|
|
9975
|
+
}, [companyType2, country2, exemptedOption]);
|
|
10088
9976
|
useEffect(() => {
|
|
10089
|
-
if (
|
|
10090
|
-
|
|
9977
|
+
if (!selected && options.length > 0) {
|
|
9978
|
+
setSelected(options[0].id);
|
|
10091
9979
|
}
|
|
10092
|
-
}, [
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
9980
|
+
}, [options, selected, setSelected]);
|
|
9981
|
+
if (options.length <= 1) return null;
|
|
9982
|
+
return jsx(Field, {
|
|
9983
|
+
name: "companyRegistrationNumberType",
|
|
9984
|
+
label: i18n.get("whichTypeOfRegistrationNumberDoYouHave"),
|
|
9985
|
+
children: (childProps) => jsx(RadioGroup, {
|
|
9986
|
+
...childProps,
|
|
9987
|
+
name: "companyRegistrationNumberType",
|
|
9988
|
+
items: options,
|
|
9989
|
+
value: selected,
|
|
9990
|
+
onChange: (e) => handleSelect(e.target.value)
|
|
9991
|
+
})
|
|
9992
|
+
});
|
|
9993
|
+
}
|
|
9994
|
+
const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
|
|
9995
|
+
function BusinessRegistrationNumberField({
|
|
9996
|
+
data,
|
|
9997
|
+
valid,
|
|
9998
|
+
errors,
|
|
9999
|
+
labels: labels2,
|
|
10000
|
+
mask,
|
|
10001
|
+
guidanceText,
|
|
10002
|
+
placeholders,
|
|
10003
|
+
readonly,
|
|
10004
|
+
shouldValidate,
|
|
10005
|
+
optional: optional2,
|
|
10006
|
+
handleChangeFor,
|
|
10007
|
+
country: country2,
|
|
10008
|
+
canExempt,
|
|
10009
|
+
companyType: companyType2,
|
|
10010
|
+
registrationNumberOptions,
|
|
10011
|
+
registrationNumberType,
|
|
10012
|
+
setRegistrationNumberType
|
|
10013
|
+
}) {
|
|
10014
|
+
const showExemptedOption = canExempt && !!registrationNumberOptions && registrationNumberOptions.length > 1;
|
|
10096
10015
|
const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
|
|
10097
10016
|
if (regNumberType === "exempted") {
|
|
10098
|
-
if (!
|
|
10017
|
+
if (!canExempt) {
|
|
10099
10018
|
throw Error(`${country2} does not allow tax exemptions`);
|
|
10100
10019
|
}
|
|
10101
10020
|
handleChangeFor("exemptedFromRegistrationNumber")(true);
|
|
10102
10021
|
setRegistrationNumberType(void 0);
|
|
10103
10022
|
return;
|
|
10104
10023
|
}
|
|
10105
|
-
if (
|
|
10024
|
+
if (canExempt && data.exemptedFromRegistrationNumber === true) {
|
|
10106
10025
|
handleChangeFor("exemptedFromRegistrationNumber")(false);
|
|
10107
10026
|
}
|
|
10108
10027
|
setRegistrationNumberType(regNumberType);
|
|
10109
10028
|
};
|
|
10110
10029
|
return jsxs("div", {
|
|
10111
|
-
className: "adyen-kyc-field__business-registration
|
|
10112
|
-
children: [jsx(
|
|
10113
|
-
stateRef
|
|
10114
|
-
}), jsx(CompanyRegistrationNumberTypeSelector, {
|
|
10030
|
+
className: "adyen-kyc-field__business-registration",
|
|
10031
|
+
children: [jsx(CompanyRegistrationNumberTypeSelector, {
|
|
10115
10032
|
companyType: companyType2,
|
|
10116
10033
|
country: country2,
|
|
10117
10034
|
setSelected: handleCompanyRegistrationNumberTypeChange,
|
|
10118
10035
|
selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
|
|
10119
|
-
exemptedOption: showExemptedOption ?
|
|
10036
|
+
exemptedOption: showExemptedOption ? labels2.exemptedFromRegistrationNumber : false
|
|
10120
10037
|
}), jsx(MaskedInputText, {
|
|
10121
|
-
|
|
10122
|
-
label:
|
|
10123
|
-
|
|
10038
|
+
"aria-required": true,
|
|
10039
|
+
"aria-label": labels2.registrationNumber,
|
|
10040
|
+
"aria-invalid": !valid.registrationNumber,
|
|
10124
10041
|
classNameModifiers: {
|
|
10125
10042
|
field: ["registrationNumber"],
|
|
10126
|
-
input: ["
|
|
10043
|
+
input: ["registrationNumberInput"]
|
|
10127
10044
|
},
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
onBlur: handleChangeFor("registrationNumber", "blur"),
|
|
10136
|
-
readonly: formUtils.isReadOnly("registrationNumber"),
|
|
10137
|
-
value: data.registrationNumber ?? "",
|
|
10045
|
+
name: "registrationNumber",
|
|
10046
|
+
value: (data == null ? void 0 : data.registrationNumber) ?? "",
|
|
10047
|
+
label: labels2.registrationNumber ?? "",
|
|
10048
|
+
formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
|
|
10049
|
+
placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
|
|
10050
|
+
errorMessage: errors.registrationNumber,
|
|
10051
|
+
isValid: Boolean(valid.registrationNumber),
|
|
10138
10052
|
onInput: handleChangeFor("registrationNumber", "input"),
|
|
10139
|
-
|
|
10140
|
-
|
|
10053
|
+
onBlur: handleChangeFor("registrationNumber", "blur"),
|
|
10054
|
+
disabled: data.exemptedFromRegistrationNumber,
|
|
10055
|
+
optional: optional2,
|
|
10056
|
+
readonly,
|
|
10057
|
+
shouldValidate: !optional2 && shouldValidate,
|
|
10058
|
+
...mask
|
|
10059
|
+
}), canExempt && jsx(Field, {
|
|
10141
10060
|
name: "exemptedFromRegistrationNumber",
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10061
|
+
classNameModifiers: ["exemptedFromRegistrationNumber"],
|
|
10062
|
+
children: (childProps) => jsx(Checkbox, {
|
|
10063
|
+
...childProps,
|
|
10064
|
+
"aria-required": false,
|
|
10065
|
+
"aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
|
|
10066
|
+
"aria-invalid": false,
|
|
10067
|
+
name: "exemptedFromRegistrationNumber",
|
|
10068
|
+
value: "exemptedFromRegistrationNumber",
|
|
10069
|
+
checked: Boolean(data.exemptedFromRegistrationNumber),
|
|
10070
|
+
label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
|
|
10071
|
+
readonly,
|
|
10072
|
+
onChange: handleChangeFor("exemptedFromRegistrationNumber")
|
|
10073
|
+
})
|
|
10151
10074
|
})]
|
|
10152
10075
|
});
|
|
10153
10076
|
}
|
|
@@ -10321,6 +10244,61 @@ function InputDate(props) {
|
|
|
10321
10244
|
maxLength: 10
|
|
10322
10245
|
});
|
|
10323
10246
|
}
|
|
10247
|
+
const DATE_OF_INCORPORATION_FIELD = ["dateOfIncorporation"];
|
|
10248
|
+
function DateOfIncorporationField({
|
|
10249
|
+
data,
|
|
10250
|
+
valid,
|
|
10251
|
+
errors,
|
|
10252
|
+
labels: labels2,
|
|
10253
|
+
placeholders,
|
|
10254
|
+
readonly,
|
|
10255
|
+
handleChangeFor
|
|
10256
|
+
}) {
|
|
10257
|
+
return jsx(Field, {
|
|
10258
|
+
name: "dateOfIncorporation",
|
|
10259
|
+
label: labels2.dateOfIncorporation,
|
|
10260
|
+
classNameModifiers: ["dateOfIncorporation"],
|
|
10261
|
+
errorMessage: errors.dateOfIncorporation,
|
|
10262
|
+
isValid: valid.dateOfIncorporation,
|
|
10263
|
+
children: (childProps) => jsx(InputDate, {
|
|
10264
|
+
...childProps,
|
|
10265
|
+
"aria-required": true,
|
|
10266
|
+
"aria-label": labels2.dateOfIncorporation,
|
|
10267
|
+
"aria-invalid": !valid.dateOfIncorporation,
|
|
10268
|
+
name: "dateOfIncorporation",
|
|
10269
|
+
value: data.dateOfIncorporation,
|
|
10270
|
+
placeholder: placeholders == null ? void 0 : placeholders.dateOfIncorporation,
|
|
10271
|
+
readonly,
|
|
10272
|
+
onInput: handleChangeFor("dateOfIncorporation", "input"),
|
|
10273
|
+
onBlur: handleChangeFor("dateOfIncorporation", "blur"),
|
|
10274
|
+
max: formatDateObj(/* @__PURE__ */ new Date())
|
|
10275
|
+
})
|
|
10276
|
+
});
|
|
10277
|
+
}
|
|
10278
|
+
const dateOfIncorporationFieldMetadata = {
|
|
10279
|
+
label: "dateOfIncorporation",
|
|
10280
|
+
validators: [validateNotEmptyOnBlur, {
|
|
10281
|
+
modes: ["blur"],
|
|
10282
|
+
validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
|
|
10283
|
+
errorMessage: "invalidDateOfIncorporation"
|
|
10284
|
+
}]
|
|
10285
|
+
};
|
|
10286
|
+
const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
|
|
10287
|
+
const optionsForCountry = companyRegistrationNumberOptions[country2];
|
|
10288
|
+
const metadataFn = defaultFieldConfig$9[country2];
|
|
10289
|
+
if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function") return void 0;
|
|
10290
|
+
for (const option of optionsForCountry) {
|
|
10291
|
+
const fieldMetadata = metadataFn({
|
|
10292
|
+
companyType: companyType2,
|
|
10293
|
+
registrationNumberType: option.id
|
|
10294
|
+
});
|
|
10295
|
+
if (!fieldMetadata.validators) continue;
|
|
10296
|
+
const validators2 = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
|
|
10297
|
+
if (validators2.every((validator) => validator.validate(registrationNumber2))) {
|
|
10298
|
+
return option.id;
|
|
10299
|
+
}
|
|
10300
|
+
}
|
|
10301
|
+
};
|
|
10324
10302
|
const defaultFieldMetadata$8 = {
|
|
10325
10303
|
label: "taxId"
|
|
10326
10304
|
};
|
|
@@ -10498,7 +10476,7 @@ const defaultFieldConfig$8 = {
|
|
|
10498
10476
|
};
|
|
10499
10477
|
default:
|
|
10500
10478
|
return {
|
|
10501
|
-
label: "
|
|
10479
|
+
label: "taxInformationNumber",
|
|
10502
10480
|
mask: businessRegistrationNumberMasks[CountryCodes.Guernsey].default,
|
|
10503
10481
|
validators: validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.Guernsey].default),
|
|
10504
10482
|
guidanceText: {
|
|
@@ -11423,6 +11401,80 @@ const stockTickerSymbolFieldMetadata = {
|
|
|
11423
11401
|
}
|
|
11424
11402
|
}
|
|
11425
11403
|
};
|
|
11404
|
+
const countryToTaxInfoTypeMap = {
|
|
11405
|
+
US: "EIN",
|
|
11406
|
+
AU: "ABN",
|
|
11407
|
+
NZ: "IRD",
|
|
11408
|
+
HK: "BRN",
|
|
11409
|
+
SG: "GST"
|
|
11410
|
+
};
|
|
11411
|
+
const updateTaxInformation = ({
|
|
11412
|
+
taxId: taxId2,
|
|
11413
|
+
country: country2,
|
|
11414
|
+
exemptedFromTax: exemptedFromTax2 = false,
|
|
11415
|
+
isUen,
|
|
11416
|
+
entity
|
|
11417
|
+
}) => {
|
|
11418
|
+
var _a;
|
|
11419
|
+
const updatedEntity = cloneObject(entity);
|
|
11420
|
+
const taxInformation = ((_a = entity.taxInformation) == null ? void 0 : _a.reduce((acc, info) => {
|
|
11421
|
+
acc[info.country] = info;
|
|
11422
|
+
return acc;
|
|
11423
|
+
}, {})) ?? {};
|
|
11424
|
+
if (exemptedFromTax2) {
|
|
11425
|
+
delete taxInformation[country2];
|
|
11426
|
+
} else if (isUen !== void 0) {
|
|
11427
|
+
taxInformation[country2] = {
|
|
11428
|
+
country: country2,
|
|
11429
|
+
type: isUen ? "UEN" : "GST",
|
|
11430
|
+
number: taxId2
|
|
11431
|
+
};
|
|
11432
|
+
} else {
|
|
11433
|
+
taxInformation[country2] = {
|
|
11434
|
+
country: country2,
|
|
11435
|
+
type: countryToTaxInfoTypeMap[country2],
|
|
11436
|
+
number: taxId2
|
|
11437
|
+
};
|
|
11438
|
+
}
|
|
11439
|
+
updatedEntity.taxInformation = Object.values(taxInformation);
|
|
11440
|
+
if (country2 === "US") {
|
|
11441
|
+
delete updatedEntity.vatNumber;
|
|
11442
|
+
delete updatedEntity.registrationNumber;
|
|
11443
|
+
}
|
|
11444
|
+
return updatedEntity;
|
|
11445
|
+
};
|
|
11446
|
+
const getUpdatedCountryOfGoverningLaw = (nameAndCountry) => {
|
|
11447
|
+
if (!nameAndCountry) {
|
|
11448
|
+
return nameAndCountry;
|
|
11449
|
+
}
|
|
11450
|
+
const updatedNameAndCountry = cloneObject(nameAndCountry);
|
|
11451
|
+
if (updatedNameAndCountry.country === "GB" && !updatedNameAndCountry.differentCountryOfGoverningLaw) {
|
|
11452
|
+
updatedNameAndCountry.countryOfGoverningLaw = "GB";
|
|
11453
|
+
} else if (updatedNameAndCountry.country !== "GB") {
|
|
11454
|
+
delete updatedNameAndCountry.countryOfGoverningLaw;
|
|
11455
|
+
}
|
|
11456
|
+
return updatedNameAndCountry;
|
|
11457
|
+
};
|
|
11458
|
+
const transformCountryOfGoverningLawToLegalEntity = (nameAndCountry, organization) => {
|
|
11459
|
+
const updatedOrganization = cloneObject(organization);
|
|
11460
|
+
if (nameAndCountry.country === "GB") {
|
|
11461
|
+
if (!nameAndCountry.differentCountryOfGoverningLaw) {
|
|
11462
|
+
updatedOrganization.countryOfGoverningLaw = CountryCodes.UnitedKingdom;
|
|
11463
|
+
} else {
|
|
11464
|
+
updatedOrganization.countryOfGoverningLaw = nameAndCountry.countryOfGoverningLaw;
|
|
11465
|
+
}
|
|
11466
|
+
} else {
|
|
11467
|
+
delete updatedOrganization.countryOfGoverningLaw;
|
|
11468
|
+
}
|
|
11469
|
+
return updatedOrganization;
|
|
11470
|
+
};
|
|
11471
|
+
const transformCountryOfGoverningLawToSchema = (nameAndCountry, organization) => {
|
|
11472
|
+
const updatedNameAndCountry = cloneObject(nameAndCountry);
|
|
11473
|
+
if (organization.registeredAddress.country === CountryCodes.UnitedKingdom && organization.countryOfGoverningLaw !== CountryCodes.UnitedKingdom) {
|
|
11474
|
+
updatedNameAndCountry.differentCountryOfGoverningLaw = true;
|
|
11475
|
+
}
|
|
11476
|
+
return updatedNameAndCountry;
|
|
11477
|
+
};
|
|
11426
11478
|
function TaxIdNumberTypeSelector({
|
|
11427
11479
|
country: country2,
|
|
11428
11480
|
companyType: companyType2,
|
|
@@ -11470,155 +11522,278 @@ function TaxIdNumberTypeSelector({
|
|
|
11470
11522
|
})
|
|
11471
11523
|
});
|
|
11472
11524
|
}
|
|
11473
|
-
const
|
|
11474
|
-
function
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
const formUtils = formUtilities(mergedProps, i18n);
|
|
11496
|
-
const stateRef = useRef({
|
|
11497
|
-
setState: null
|
|
11498
|
-
});
|
|
11499
|
-
const {
|
|
11500
|
-
handleChangeFor,
|
|
11501
|
-
data,
|
|
11502
|
-
valid,
|
|
11503
|
-
errors,
|
|
11504
|
-
isValid,
|
|
11505
|
-
fieldProblems
|
|
11506
|
-
} = useForm({
|
|
11507
|
-
...mergedProps,
|
|
11508
|
-
schema: (data2) => formUtils.isRequiredField("isUen") ? ["taxId", "isUen"] : data2.exemptedFromTax ? ["exemptedFromTax"] : ["taxId", "exemptedFromTax"],
|
|
11509
|
-
rules: mergedProps.validators,
|
|
11510
|
-
defaultData: {
|
|
11511
|
-
...propData,
|
|
11512
|
-
exemptedFromTax: Boolean(propData == null ? void 0 : propData.exemptedFromTax),
|
|
11513
|
-
// exemptedFromTax should be a boolean
|
|
11514
|
-
isUen: formUtils.isRequiredField("isUen") ? Boolean(propData == null ? void 0 : propData.isUen) : void 0
|
|
11515
|
-
},
|
|
11516
|
-
fieldProblems: fieldValidationErrors
|
|
11517
|
-
});
|
|
11525
|
+
const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
|
|
11526
|
+
function TaxInformationField({
|
|
11527
|
+
data,
|
|
11528
|
+
valid,
|
|
11529
|
+
errors,
|
|
11530
|
+
labels: labels2,
|
|
11531
|
+
mask,
|
|
11532
|
+
guidanceText,
|
|
11533
|
+
placeholders,
|
|
11534
|
+
readonly,
|
|
11535
|
+
shouldValidate,
|
|
11536
|
+
handleChangeFor,
|
|
11537
|
+
country: country2,
|
|
11538
|
+
canExempt,
|
|
11539
|
+
registrationNumber: registrationNumber2,
|
|
11540
|
+
isUen,
|
|
11541
|
+
companyType: companyType2,
|
|
11542
|
+
taxIdNumberType,
|
|
11543
|
+
setTaxIdNumberType,
|
|
11544
|
+
defaultData
|
|
11545
|
+
}) {
|
|
11546
|
+
var _a;
|
|
11518
11547
|
useEffect(() => {
|
|
11519
|
-
|
|
11520
|
-
|
|
11548
|
+
handleChangeFor("taxInformation", "input")(defaultData);
|
|
11549
|
+
}, [country2]);
|
|
11550
|
+
const showTaxIdExemptedOptions = canExempt && (((_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a.length) ?? 0) > 1;
|
|
11551
|
+
const currentCountryTaxInformation = useMemo(() => {
|
|
11552
|
+
var _a2;
|
|
11553
|
+
return (_a2 = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a2.find((taxInfo) => taxInfo.country === country2);
|
|
11554
|
+
}, [data, country2]);
|
|
11555
|
+
const removeCurrentCountryTaxInformation = () => {
|
|
11556
|
+
var _a2;
|
|
11557
|
+
const filterdTaxInformation = (_a2 = data.taxInformation) == null ? void 0 : _a2.filter((taxId2) => taxId2.country !== country2);
|
|
11558
|
+
handleChangeFor("taxInformation", "input")(filterdTaxInformation);
|
|
11559
|
+
};
|
|
11560
|
+
const setUenAsTaxId = (uen2) => {
|
|
11561
|
+
if (!data.taxInformation) {
|
|
11562
|
+
return handleChangeFor("taxInformation", "blur")([{
|
|
11563
|
+
country: country2,
|
|
11564
|
+
number: uen2 ?? "",
|
|
11565
|
+
type: "UEN"
|
|
11566
|
+
}]);
|
|
11521
11567
|
}
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
}
|
|
11568
|
+
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
11569
|
+
country: country2,
|
|
11570
|
+
number: uen2 ?? "",
|
|
11571
|
+
type: "UEN"
|
|
11572
|
+
}];
|
|
11573
|
+
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
11574
|
+
if (taxInfo.country !== country2) return taxInfo;
|
|
11575
|
+
return {
|
|
11576
|
+
country: country2,
|
|
11577
|
+
number: uen2 ?? "",
|
|
11578
|
+
type: "UEN"
|
|
11579
|
+
};
|
|
11534
11580
|
});
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
return;
|
|
11581
|
+
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
|
|
11582
|
+
};
|
|
11583
|
+
const handleTaxInformationInput = (value) => {
|
|
11584
|
+
if (!data.taxInformation) {
|
|
11585
|
+
const updatedTaxInformation2 = [{
|
|
11586
|
+
country: country2,
|
|
11587
|
+
number: value,
|
|
11588
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11589
|
+
}];
|
|
11590
|
+
return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
|
|
11545
11591
|
}
|
|
11546
|
-
|
|
11592
|
+
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
11593
|
+
country: country2,
|
|
11594
|
+
number: value,
|
|
11595
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11596
|
+
}];
|
|
11597
|
+
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
11598
|
+
if (taxInfo.country !== country2) return taxInfo;
|
|
11599
|
+
return {
|
|
11600
|
+
country: country2,
|
|
11601
|
+
number: value,
|
|
11602
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11603
|
+
};
|
|
11604
|
+
});
|
|
11605
|
+
return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
|
|
11547
11606
|
};
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11607
|
+
const handleTaxInformationBlur = (e) => {
|
|
11608
|
+
const {
|
|
11609
|
+
value
|
|
11610
|
+
} = e.target;
|
|
11611
|
+
if (!data.taxInformation) {
|
|
11612
|
+
const updatedTaxInformation2 = [{
|
|
11613
|
+
country: country2,
|
|
11614
|
+
number: value,
|
|
11615
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11616
|
+
}];
|
|
11617
|
+
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
|
|
11551
11618
|
}
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11619
|
+
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
11620
|
+
country: country2,
|
|
11621
|
+
number: value,
|
|
11622
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11623
|
+
}];
|
|
11624
|
+
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
11625
|
+
if (taxInfo.country !== country2) return taxInfo;
|
|
11626
|
+
return {
|
|
11627
|
+
country: country2,
|
|
11628
|
+
number: value,
|
|
11629
|
+
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
11630
|
+
};
|
|
11631
|
+
});
|
|
11632
|
+
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
|
|
11633
|
+
};
|
|
11558
11634
|
const handleTaxIdNumberTypeChange = (taxIdType) => {
|
|
11559
11635
|
if (taxIdType === "exempted") {
|
|
11560
|
-
if (!
|
|
11636
|
+
if (!canExempt) {
|
|
11561
11637
|
throw Error(`${country2} does not allow tax exemptions`);
|
|
11562
11638
|
}
|
|
11563
11639
|
handleChangeFor("exemptedFromTax")(true);
|
|
11640
|
+
removeCurrentCountryTaxInformation();
|
|
11564
11641
|
setTaxIdNumberType(void 0);
|
|
11565
11642
|
return;
|
|
11566
11643
|
}
|
|
11567
|
-
if (
|
|
11644
|
+
if (isUen) {
|
|
11645
|
+
if (taxIdType === "UEN") {
|
|
11646
|
+
handleChangeFor("isUen")(true);
|
|
11647
|
+
setUenAsTaxId(registrationNumber2);
|
|
11648
|
+
} else {
|
|
11649
|
+
handleChangeFor("isUen")(false);
|
|
11650
|
+
removeCurrentCountryTaxInformation();
|
|
11651
|
+
}
|
|
11652
|
+
}
|
|
11653
|
+
if (canExempt && data.exemptedFromTax === true) {
|
|
11568
11654
|
handleChangeFor("exemptedFromTax")(false);
|
|
11569
11655
|
}
|
|
11570
11656
|
setTaxIdNumberType(taxIdType);
|
|
11571
11657
|
};
|
|
11658
|
+
const handleExemptedFromTaxChange = (exempted) => {
|
|
11659
|
+
handleChangeFor("exemptedFromTax")(exempted);
|
|
11660
|
+
removeCurrentCountryTaxInformation();
|
|
11661
|
+
};
|
|
11572
11662
|
return jsxs("div", {
|
|
11573
|
-
className: "adyen-kyc-
|
|
11574
|
-
children: [jsx(
|
|
11575
|
-
stateRef
|
|
11576
|
-
}), jsx(TaxIdNumberTypeSelector, {
|
|
11663
|
+
className: "adyen-kyc-field__tax-information",
|
|
11664
|
+
children: [jsx(TaxIdNumberTypeSelector, {
|
|
11577
11665
|
country: country2,
|
|
11578
11666
|
companyType: companyType2,
|
|
11579
11667
|
setSelected: handleTaxIdNumberTypeChange,
|
|
11580
11668
|
selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
|
|
11581
|
-
exemptedOption:
|
|
11669
|
+
exemptedOption: showTaxIdExemptedOptions ? labels2.exemptedFromTax : false
|
|
11582
11670
|
}), !data.isUen && jsx(MaskedInputText, {
|
|
11583
|
-
|
|
11584
|
-
label:
|
|
11585
|
-
|
|
11586
|
-
|
|
11671
|
+
"aria-required": true,
|
|
11672
|
+
"aria-label": labels2.taxInformation,
|
|
11673
|
+
"aria-invalid": !valid.taxInformation,
|
|
11674
|
+
name: "taxInformation",
|
|
11587
11675
|
classNameModifiers: {
|
|
11588
|
-
field: ["
|
|
11589
|
-
input: ["
|
|
11676
|
+
field: ["taxInformation"],
|
|
11677
|
+
input: ["taxInformationInput"]
|
|
11590
11678
|
},
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
onChange: handleUenOrGstChange,
|
|
11605
|
-
"aria-required": false,
|
|
11606
|
-
"aria-label": formUtils.getLabel("iDoNotHaveGst"),
|
|
11607
|
-
"aria-invalid": false
|
|
11608
|
-
}), formUtils.isRequiredField("exemptedFromTax") && !showTaxIdExemptedOption && jsx(Checkbox, {
|
|
11679
|
+
label: labels2.taxInformation ?? "",
|
|
11680
|
+
formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
|
|
11681
|
+
value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
|
|
11682
|
+
errorMessage: errors.taxInformation,
|
|
11683
|
+
placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
|
|
11684
|
+
isValid: Boolean(valid.taxInformation) && !!currentCountryTaxInformation,
|
|
11685
|
+
onInput: handleTaxInformationInput,
|
|
11686
|
+
onBlur: handleTaxInformationBlur,
|
|
11687
|
+
disabled: data.exemptedFromTax || data.isUen,
|
|
11688
|
+
readonly,
|
|
11689
|
+
shouldValidate,
|
|
11690
|
+
...mask
|
|
11691
|
+
}), canExempt && !showTaxIdExemptedOptions && jsx(Field, {
|
|
11609
11692
|
name: "exemptedFromTax",
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11693
|
+
classNameModifiers: ["exemptedFromTax"],
|
|
11694
|
+
children: (childProps) => jsx(Checkbox, {
|
|
11695
|
+
...childProps,
|
|
11696
|
+
"aria-required": false,
|
|
11697
|
+
"aria-label": labels2.exemptedFromTax,
|
|
11698
|
+
"aria-invalid": false,
|
|
11699
|
+
name: "exemptedFromTax",
|
|
11700
|
+
label: labels2.exemptedFromTax,
|
|
11701
|
+
value: "exemptedFromTax",
|
|
11702
|
+
checked: Boolean(data.exemptedFromTax),
|
|
11703
|
+
onChange: handleExemptedFromTaxChange
|
|
11704
|
+
})
|
|
11705
|
+
})]
|
|
11706
|
+
});
|
|
11707
|
+
}
|
|
11708
|
+
const defaultFieldMetadata$6 = defaultFieldMetadata$8;
|
|
11709
|
+
const defaultFieldConfig$6 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig, [country2, countryEntry]) => ({
|
|
11710
|
+
...fieldConfig,
|
|
11711
|
+
[country2]: ({
|
|
11712
|
+
taxIdNumberType,
|
|
11713
|
+
companyType: companyType2
|
|
11714
|
+
}) => {
|
|
11715
|
+
const fieldMetadata = resolveFieldMetadata(countryEntry, {
|
|
11716
|
+
taxIdNumberType,
|
|
11717
|
+
companyType: companyType2
|
|
11718
|
+
}, defaultFieldMetadata$8);
|
|
11719
|
+
const taxIdValidators = fieldMetadata.validators ? Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators] : [];
|
|
11720
|
+
const mappedValidators = taxIdValidators.map((validator) => ({
|
|
11721
|
+
...validator,
|
|
11722
|
+
validate: (taxInformation) => {
|
|
11723
|
+
var _a;
|
|
11724
|
+
const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
|
|
11725
|
+
return taxIdNumber2 ? validator.validate(taxIdNumber2) : false;
|
|
11726
|
+
}
|
|
11727
|
+
}));
|
|
11728
|
+
return {
|
|
11729
|
+
...fieldMetadata,
|
|
11730
|
+
validators: mappedValidators
|
|
11731
|
+
};
|
|
11732
|
+
}
|
|
11733
|
+
}), {});
|
|
11734
|
+
const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
|
|
11735
|
+
function TradingNameField({
|
|
11736
|
+
data,
|
|
11737
|
+
valid,
|
|
11738
|
+
errors,
|
|
11739
|
+
labels: labels2,
|
|
11740
|
+
readonly,
|
|
11741
|
+
handleChangeFor,
|
|
11742
|
+
legalCompanyName: legalCompanyName2
|
|
11743
|
+
}) {
|
|
11744
|
+
const handleSameAsLegalName = useCallback((isChecked) => {
|
|
11745
|
+
handleChangeFor("sameNameAsLegalName", "input")(isChecked);
|
|
11746
|
+
if (isChecked) {
|
|
11747
|
+
handleChangeFor("tradingName")(legalCompanyName2);
|
|
11748
|
+
}
|
|
11749
|
+
}, [handleChangeFor, legalCompanyName2]);
|
|
11750
|
+
useEffect(() => {
|
|
11751
|
+
if (data.sameNameAsLegalName && data.tradingName !== legalCompanyName2) {
|
|
11752
|
+
handleChangeFor("tradingName")(legalCompanyName2);
|
|
11753
|
+
}
|
|
11754
|
+
}, [legalCompanyName2, data.sameNameAsLegalName, data.tradingName]);
|
|
11755
|
+
return jsxs("div", {
|
|
11756
|
+
className: "adyen-kyc-field__tradingName",
|
|
11757
|
+
children: [jsx(Field, {
|
|
11758
|
+
name: "tradingName",
|
|
11759
|
+
label: labels2.tradingName,
|
|
11760
|
+
classNameModifiers: ["tradingName"],
|
|
11761
|
+
errorMessage: errors.tradingName,
|
|
11762
|
+
isValid: valid.tradingName,
|
|
11763
|
+
disabled: readonly || data.sameNameAsLegalName,
|
|
11764
|
+
children: (childProps) => jsx(InputText, {
|
|
11765
|
+
...childProps,
|
|
11766
|
+
"aria-required": true,
|
|
11767
|
+
"aria-label": labels2.tradingName,
|
|
11768
|
+
"aria-invalid": !valid.tradingName,
|
|
11769
|
+
name: "tradingName",
|
|
11770
|
+
value: data.tradingName,
|
|
11771
|
+
readonly: readonly || data.sameNameAsLegalName,
|
|
11772
|
+
onInput: handleChangeFor("tradingName", "input"),
|
|
11773
|
+
onBlur: handleChangeFor("tradingName", "blur")
|
|
11774
|
+
})
|
|
11775
|
+
}), jsx(Field, {
|
|
11776
|
+
name: "sameNameAsLegalName",
|
|
11777
|
+
classNameModifiers: ["sameNameAsLegalName"],
|
|
11778
|
+
errorMessage: errors.sameNameAsLegalName,
|
|
11779
|
+
isValid: valid.sameNameAsLegalName,
|
|
11780
|
+
children: (childProps) => jsx(Checkbox, {
|
|
11781
|
+
...childProps,
|
|
11782
|
+
"aria-required": false,
|
|
11783
|
+
"aria-label": labels2.sameNameAsLegalName,
|
|
11784
|
+
"aria-invalid": false,
|
|
11785
|
+
name: "sameNameAsLegalName",
|
|
11786
|
+
label: labels2.sameNameAsLegalName,
|
|
11787
|
+
checked: Boolean(data.sameNameAsLegalName),
|
|
11788
|
+
onChange: handleSameAsLegalName
|
|
11789
|
+
})
|
|
11619
11790
|
})]
|
|
11620
11791
|
});
|
|
11621
11792
|
}
|
|
11793
|
+
const tradingNameFieldMetadata = {
|
|
11794
|
+
label: "tradingName",
|
|
11795
|
+
validators: [validateNotEmptyOnBlur]
|
|
11796
|
+
};
|
|
11622
11797
|
var ExperimentNames = /* @__PURE__ */ ((ExperimentNames2) => {
|
|
11623
11798
|
ExperimentNames2["EnableCompanySearchFlow"] = "EnableCompanySearchFlow";
|
|
11624
11799
|
ExperimentNames2["EnableNewBusinessDetailsFlow"] = "EnableNewBusinessDetailsFlow";
|
|
@@ -11675,7 +11850,7 @@ function VatNumberField({
|
|
|
11675
11850
|
id: VatAbsenceReason.CountryWithoutVatOrGstSystem,
|
|
11676
11851
|
name: VatAbsenceReason.CountryWithoutVatOrGstSystem
|
|
11677
11852
|
}]);
|
|
11678
|
-
const
|
|
11853
|
+
const showVatExemptedOptions = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
|
|
11679
11854
|
const handleVatNumberTypeChange = (vatType) => {
|
|
11680
11855
|
if (vatType === "exempted") {
|
|
11681
11856
|
if (!canExempt) {
|
|
@@ -11696,13 +11871,13 @@ function VatNumberField({
|
|
|
11696
11871
|
country: country2,
|
|
11697
11872
|
setSelected: handleVatNumberTypeChange,
|
|
11698
11873
|
selected: data.exemptedFromVat ? "exempted" : vatNumberType,
|
|
11699
|
-
exemptedOption:
|
|
11874
|
+
exemptedOption: showVatExemptedOptions ? labels2.exemptedFromVat : false
|
|
11700
11875
|
}), jsx(MaskedInputText, {
|
|
11701
11876
|
"aria-required": true,
|
|
11702
11877
|
"aria-label": labels2.vatNumber,
|
|
11703
11878
|
"aria-invalid": !valid.vatNumber,
|
|
11704
11879
|
classNameModifiers: {
|
|
11705
|
-
field: ["
|
|
11880
|
+
field: ["vatNumber"],
|
|
11706
11881
|
input: ["vatNumber"]
|
|
11707
11882
|
},
|
|
11708
11883
|
name: "vatNumber",
|
|
@@ -11718,19 +11893,23 @@ function VatNumberField({
|
|
|
11718
11893
|
readonly,
|
|
11719
11894
|
shouldValidate,
|
|
11720
11895
|
...mask
|
|
11721
|
-
}), canExempt && !
|
|
11722
|
-
"aria-required": false,
|
|
11723
|
-
"aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
|
|
11724
|
-
"aria-invalid": false,
|
|
11896
|
+
}), canExempt && !showVatExemptedOptions && jsx(Field, {
|
|
11725
11897
|
name: "exemptedFromVat",
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11898
|
+
classNameModifiers: ["exemptedFromVat"],
|
|
11899
|
+
children: (childProps) => jsx(Checkbox, {
|
|
11900
|
+
...childProps,
|
|
11901
|
+
"aria-required": false,
|
|
11902
|
+
"aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
|
|
11903
|
+
"aria-invalid": false,
|
|
11904
|
+
name: "exemptedFromVat",
|
|
11905
|
+
label: labels2 == null ? void 0 : labels2.exemptedFromVat,
|
|
11906
|
+
value: "exemptedFromVat",
|
|
11907
|
+
checked: data.exemptedFromVat ?? false,
|
|
11908
|
+
onChange: handleChangeFor("exemptedFromVat")
|
|
11909
|
+
})
|
|
11731
11910
|
}), data.exemptedFromVat && jsx(Field, {
|
|
11732
11911
|
name: "vatAbsenceReason",
|
|
11733
|
-
classNameModifiers: ["
|
|
11912
|
+
classNameModifiers: ["vatAbsenceReason"],
|
|
11734
11913
|
label: labels2 == null ? void 0 : labels2.vatAbsenceReason,
|
|
11735
11914
|
errorMessage: errors.vatAbsenceReason,
|
|
11736
11915
|
isValid: valid.vatAbsenceReason,
|
|
@@ -11747,22 +11926,6 @@ function VatNumberField({
|
|
|
11747
11926
|
})]
|
|
11748
11927
|
});
|
|
11749
11928
|
}
|
|
11750
|
-
const companyRegistrationDetailsValidationRules = {
|
|
11751
|
-
tradingName: {
|
|
11752
|
-
modes: ["blur"],
|
|
11753
|
-
validate: (tradingName2) => !isEmpty(tradingName2),
|
|
11754
|
-
errorMessage: "fieldIsRequired"
|
|
11755
|
-
},
|
|
11756
|
-
dateOfIncorporation: [{
|
|
11757
|
-
modes: ["blur"],
|
|
11758
|
-
validate: (dateOfIncorporation2) => !!dateOfIncorporation2,
|
|
11759
|
-
errorMessage: "fieldIsRequired"
|
|
11760
|
-
}, {
|
|
11761
|
-
modes: ["blur"],
|
|
11762
|
-
validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2) && new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date(),
|
|
11763
|
-
errorMessage: "invalidDateOfIncorporation"
|
|
11764
|
-
}]
|
|
11765
|
-
};
|
|
11766
11929
|
const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
|
|
11767
11930
|
companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
|
|
11768
11931
|
country: CountryCodes.Gibraltar
|
|
@@ -11782,256 +11945,269 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
|
|
|
11782
11945
|
companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
|
|
11783
11946
|
country: CountryCodes.PuertoRico
|
|
11784
11947
|
}];
|
|
11785
|
-
const companyRegistrationDetailsFields = [
|
|
11948
|
+
const companyRegistrationDetailsFields = [...TRADING_NAME_FIELD, ...BUSINESS_REGISTRATION_NUMBER_FIELD, ...STOCK_EXCHANGE_MIC_FIELD, ...STOCK_ISIN_FIELD, ...STOCK_TICKER_SYMBOL_FIELD, ...VAT_NUMBER_FIELD, ...TAX_INFORMATION_FIELD, ...DATE_OF_INCORPORATION_FIELD];
|
|
11786
11949
|
function CompanyRegistrationDetailsComponent(props) {
|
|
11787
|
-
var _a, _b, _c;
|
|
11950
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11951
|
+
let mergedProps = props;
|
|
11952
|
+
const COMPANY_REGISTRATION_DETAILS = mergedProps.id ?? "companyRegistrationDetails";
|
|
11788
11953
|
const {
|
|
11789
11954
|
i18n
|
|
11790
11955
|
} = useI18nContext();
|
|
11791
11956
|
const {
|
|
11792
11957
|
companyNameAndCountry
|
|
11793
11958
|
} = useGlobalData();
|
|
11794
|
-
|
|
11795
|
-
|
|
11959
|
+
const {
|
|
11960
|
+
updateStateSlice
|
|
11961
|
+
} = useGlobalDataSlice(COMPANY_REGISTRATION_DETAILS);
|
|
11962
|
+
const country2 = (companyNameAndCountry == null ? void 0 : companyNameAndCountry.country) ?? mergedProps.country;
|
|
11963
|
+
const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === country2 && mergedProps.companyType && f.companyType.includes(mergedProps.companyType));
|
|
11964
|
+
const requiredFields = mergedProps.requiredFields || companyRegistrationDetailsFields;
|
|
11965
|
+
const legalCompanyName2 = companyNameAndCountry == null ? void 0 : companyNameAndCountry.legalCompanyName;
|
|
11966
|
+
const defaultVatNumberType = ((_a = mergedProps.data) == null ? void 0 : _a.vatNumber) ? inferTaxIdNumberType((_b = mergedProps.data) == null ? void 0 : _b.vatNumber, country2) : (_c = taxIdNumberOptions[country2]) == null ? void 0 : _c[0].id;
|
|
11796
11967
|
const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
|
|
11968
|
+
const registrationNumberOptions = useMemo(() => getCompanyRegistrationNumberOptions(country2, mergedProps.companyType), [country2, mergedProps.companyType]);
|
|
11969
|
+
const defaultRegistrationNumberType = ((_d = mergedProps.data) == null ? void 0 : _d.registrationNumber) ? inferCompanyRegistrationNumberType((_e = mergedProps.data) == null ? void 0 : _e.registrationNumber, country2, mergedProps.companyType) : registrationNumberOptions == null ? void 0 : registrationNumberOptions[0].id;
|
|
11970
|
+
const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
|
|
11971
|
+
const existingTaxId = (_h = (_g = (_f = mergedProps.data) == null ? void 0 : _f.taxInformation) == null ? void 0 : _g.find((taxId2) => taxId2.country === country2)) == null ? void 0 : _h.number;
|
|
11972
|
+
const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2) : (_i = getTaxIdNumberOptions(country2, mergedProps.companyType)) == null ? void 0 : _i[0].id;
|
|
11973
|
+
const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
|
|
11974
|
+
mergedProps = mergeFieldMetadataIntoProps("tradingName", tradingNameFieldMetadata, mergedProps);
|
|
11797
11975
|
mergedProps = mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, mergedProps);
|
|
11798
11976
|
mergedProps = mergeFieldMetadataIntoProps("stockISIN", stockISINFieldMetadata, mergedProps);
|
|
11799
11977
|
mergedProps = mergeFieldMetadataIntoProps("stockTickerSymbol", stockTickerSymbolFieldMetadata, mergedProps);
|
|
11800
|
-
mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[
|
|
11978
|
+
mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[country2], {
|
|
11801
11979
|
vatNumberType
|
|
11802
11980
|
}, defaultFieldMetadata$7), mergedProps);
|
|
11803
11981
|
mergedProps = mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, mergedProps);
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
});
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
const
|
|
11982
|
+
mergedProps = mergeFieldMetadataIntoProps("registrationNumber", resolveFieldMetadata(defaultFieldConfig$9[country2], {
|
|
11983
|
+
companyType: mergedProps.companyType,
|
|
11984
|
+
registrationNumberType
|
|
11985
|
+
}, defaultFieldMetadata$9), mergedProps);
|
|
11986
|
+
mergedProps = mergeFieldMetadataIntoProps("taxInformation", resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
11987
|
+
taxIdNumberType
|
|
11988
|
+
}, defaultFieldMetadata$6), mergedProps);
|
|
11989
|
+
mergedProps = mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, mergedProps);
|
|
11990
|
+
const getFormSchema2 = useCallback((currentData) => {
|
|
11991
|
+
const fieldsToRemove = [];
|
|
11992
|
+
if (currentData.sameNameAsLegalName) {
|
|
11993
|
+
fieldsToRemove.push("tradingName");
|
|
11994
|
+
}
|
|
11995
|
+
if (currentData.exemptedFromVat) {
|
|
11996
|
+
fieldsToRemove.push("vatNumber");
|
|
11997
|
+
} else {
|
|
11998
|
+
fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
|
|
11999
|
+
}
|
|
12000
|
+
if (currentData.exemptedFromTax) {
|
|
12001
|
+
fieldsToRemove.push("taxInformation");
|
|
12002
|
+
} else {
|
|
12003
|
+
fieldsToRemove.push("exemptedFromTax");
|
|
12004
|
+
}
|
|
12005
|
+
if (currentData.isUen) {
|
|
12006
|
+
fieldsToRemove.push("taxInformation", "exemptedFromTax");
|
|
12007
|
+
}
|
|
12008
|
+
if (currentData.exemptedFromRegistrationNumber) {
|
|
12009
|
+
fieldsToRemove.push("registrationNumber");
|
|
12010
|
+
} else {
|
|
12011
|
+
fieldsToRemove.push("exemptedFromRegistrationNumber");
|
|
12012
|
+
}
|
|
12013
|
+
return requiredFields.filter((field) => !fieldsToRemove.includes(field));
|
|
12014
|
+
}, [requiredFields]);
|
|
11813
12015
|
const {
|
|
11814
|
-
|
|
12016
|
+
schema,
|
|
11815
12017
|
data,
|
|
11816
12018
|
valid,
|
|
11817
|
-
fieldProblems,
|
|
11818
12019
|
errors,
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
setData
|
|
12020
|
+
fieldProblems,
|
|
12021
|
+
handleChangeFor
|
|
11822
12022
|
} = useForm({
|
|
11823
12023
|
...mergedProps,
|
|
11824
|
-
schema:
|
|
11825
|
-
defaultData:
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
tradingName: isSameNameAsLegalName ? legalCompanyName2 : mergedProps.data.tradingName
|
|
11829
|
-
},
|
|
11830
|
-
rules: {
|
|
11831
|
-
...mergedProps.validators,
|
|
11832
|
-
...companyRegistrationDetailsValidationRules
|
|
11833
|
-
},
|
|
11834
|
-
fieldProblems: mergedProps == null ? void 0 : mergedProps.fieldValidationErrors
|
|
12024
|
+
schema: getFormSchema2,
|
|
12025
|
+
defaultData: mergedProps.data,
|
|
12026
|
+
rules: mergedProps.validators,
|
|
12027
|
+
fieldProblems: mergedProps.fieldValidationErrors
|
|
11835
12028
|
});
|
|
11836
12029
|
useEffect(() => {
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
useEffect(() => {
|
|
11844
|
-
stateRef.current.setState({
|
|
11845
|
-
type: "addToState",
|
|
11846
|
-
value: {
|
|
11847
|
-
data,
|
|
11848
|
-
valid,
|
|
11849
|
-
errors,
|
|
11850
|
-
caller: COMPANY_REGISTRATION_DETAILS,
|
|
11851
|
-
dataStoreId: COMPANY_REGISTRATION_DETAILS,
|
|
11852
|
-
schema: requiredFields
|
|
11853
|
-
}
|
|
12030
|
+
updateStateSlice({
|
|
12031
|
+
schema,
|
|
12032
|
+
data,
|
|
12033
|
+
errors,
|
|
12034
|
+
valid,
|
|
12035
|
+
fieldProblems
|
|
11854
12036
|
});
|
|
11855
|
-
}, [
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
}), formUtils.isRequiredField("
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
}), formUtils.isRequiredField("
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
readonly: formUtils.isReadOnly("vatNumber"),
|
|
12002
|
-
handleChangeFor,
|
|
12003
|
-
country: mergedProps.country,
|
|
12004
|
-
canExempt: formUtils.isRequiredField("exemptedFromVat"),
|
|
12005
|
-
vatNumberType,
|
|
12006
|
-
setVatNumberType
|
|
12007
|
-
}), formUtils.isRequiredField("taxId") && jsx(TaxId, {
|
|
12008
|
-
...taxIdProps,
|
|
12009
|
-
dataStoreId: COMPANY_REGISTRATION_DETAILS,
|
|
12010
|
-
country: mergedProps.country,
|
|
12011
|
-
companyType: mergedProps.companyType
|
|
12012
|
-
}), formUtils.isRequiredField("dateOfIncorporation") && jsx(Field, {
|
|
12013
|
-
name: "dateOfIncorporation",
|
|
12014
|
-
label: formUtils.getLabel("dateOfIncorporation"),
|
|
12015
|
-
classNameModifiers: ["dateOfIncorporation"],
|
|
12016
|
-
errorMessage: formUtils.getErrorMessage("dateOfIncorporation", errors, fieldProblems),
|
|
12017
|
-
isValid: valid.dateOfIncorporation,
|
|
12018
|
-
children: (childProps) => jsx(InputDate, {
|
|
12019
|
-
...childProps,
|
|
12020
|
-
name: "dateOfIncorporation",
|
|
12021
|
-
value: data.dateOfIncorporation,
|
|
12022
|
-
placeholder: i18n.get("datePlaceholder"),
|
|
12037
|
+
}, [updateStateSlice, schema, data, errors, valid, fieldProblems]);
|
|
12038
|
+
const formUtils = formUtilities(mergedProps, i18n);
|
|
12039
|
+
return jsxs("form", {
|
|
12040
|
+
id: COMPANY_REGISTRATION_DETAILS,
|
|
12041
|
+
className: "adyen-kyc-company-registration-details",
|
|
12042
|
+
children: [jsx(FormHeader, {
|
|
12043
|
+
heading: mergedProps.heading
|
|
12044
|
+
}), jsx(ErrorPanel, {
|
|
12045
|
+
verificationErrors: mergedProps == null ? void 0 : mergedProps.formVerificationErrors,
|
|
12046
|
+
validationErrors: mergedProps == null ? void 0 : mergedProps.fieldValidationErrors,
|
|
12047
|
+
formUtils,
|
|
12048
|
+
id: "ariaErrorField"
|
|
12049
|
+
}), jsx(ContextGuidance, {
|
|
12050
|
+
page: "Company registration details",
|
|
12051
|
+
title: i18n.get("whyDoINeedToFillInThisInformation"),
|
|
12052
|
+
content: i18n.get("reasonForFillingCompanyRegistrationDetails"),
|
|
12053
|
+
titleId: "whyDoINeedToFillInThisInformation",
|
|
12054
|
+
contentId: "reasonForFillingCompanyRegistrationDetails"
|
|
12055
|
+
}), jsxs("fieldset", {
|
|
12056
|
+
form: COMPANY_REGISTRATION_DETAILS,
|
|
12057
|
+
children: [formUtils.isRequiredField("tradingName") && jsx("div", {
|
|
12058
|
+
className: "adyen-kyc-field-wrapper",
|
|
12059
|
+
children: jsx(TradingNameField, {
|
|
12060
|
+
data: formUtils.getFieldData(data, TRADING_NAME_FIELD),
|
|
12061
|
+
valid: formUtils.getFieldValid(valid, TRADING_NAME_FIELD),
|
|
12062
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, TRADING_NAME_FIELD),
|
|
12063
|
+
labels: formUtils.getFieldLabels(TRADING_NAME_FIELD),
|
|
12064
|
+
readonly: formUtils.isReadOnly("tradingName"),
|
|
12065
|
+
handleChangeFor,
|
|
12066
|
+
legalCompanyName: legalCompanyName2
|
|
12067
|
+
})
|
|
12068
|
+
}), formUtils.isRequiredField("stockExchangeMIC") && jsx("div", {
|
|
12069
|
+
className: "adyen-kyc-field-wrapper",
|
|
12070
|
+
children: jsx(StockExchangeMICField, {
|
|
12071
|
+
data: formUtils.getFieldData(data, STOCK_EXCHANGE_MIC_FIELD),
|
|
12072
|
+
valid: formUtils.getFieldValid(valid, STOCK_EXCHANGE_MIC_FIELD),
|
|
12073
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_EXCHANGE_MIC_FIELD),
|
|
12074
|
+
labels: formUtils.getFieldLabels(STOCK_EXCHANGE_MIC_FIELD),
|
|
12075
|
+
placeholders: formUtils.getFieldPlaceholders(STOCK_EXCHANGE_MIC_FIELD),
|
|
12076
|
+
mask: formUtils.getMask("stockExchangeMIC"),
|
|
12077
|
+
guidanceText: formUtils.getFieldGuidanceText(STOCK_EXCHANGE_MIC_FIELD),
|
|
12078
|
+
readonly: formUtils.isReadOnly("stockExchangeMIC"),
|
|
12079
|
+
handleChangeFor
|
|
12080
|
+
})
|
|
12081
|
+
}), formUtils.isRequiredField("stockISIN") && jsx("div", {
|
|
12082
|
+
className: "adyen-kyc-field-wrapper",
|
|
12083
|
+
children: jsx(StockISINField, {
|
|
12084
|
+
data: formUtils.getFieldData(data, STOCK_ISIN_FIELD),
|
|
12085
|
+
valid: formUtils.getFieldValid(valid, STOCK_ISIN_FIELD),
|
|
12086
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_ISIN_FIELD),
|
|
12087
|
+
labels: formUtils.getFieldLabels(STOCK_ISIN_FIELD),
|
|
12088
|
+
placeholders: formUtils.getFieldPlaceholders(STOCK_ISIN_FIELD),
|
|
12089
|
+
mask: formUtils.getMask("stockISIN"),
|
|
12090
|
+
guidanceText: formUtils.getFieldGuidanceText(STOCK_ISIN_FIELD),
|
|
12091
|
+
readonly: formUtils.isReadOnly("stockISIN"),
|
|
12092
|
+
handleChangeFor
|
|
12093
|
+
})
|
|
12094
|
+
}), formUtils.isRequiredField("stockTickerSymbol") && jsx("div", {
|
|
12095
|
+
className: "adyen-kyc-field-wrapper",
|
|
12096
|
+
children: jsx(StockTickerSymbolField, {
|
|
12097
|
+
data: formUtils.getFieldData(data, STOCK_TICKER_SYMBOL_FIELD),
|
|
12098
|
+
valid: formUtils.getFieldValid(valid, STOCK_TICKER_SYMBOL_FIELD),
|
|
12099
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_TICKER_SYMBOL_FIELD),
|
|
12100
|
+
labels: formUtils.getFieldLabels(STOCK_TICKER_SYMBOL_FIELD),
|
|
12101
|
+
placeholders: formUtils.getFieldPlaceholders(STOCK_TICKER_SYMBOL_FIELD),
|
|
12102
|
+
mask: formUtils.getMask("stockTickerSymbol"),
|
|
12103
|
+
guidanceText: formUtils.getFieldGuidanceText(STOCK_TICKER_SYMBOL_FIELD),
|
|
12104
|
+
readonly: formUtils.isReadOnly("stockTickerSymbol"),
|
|
12105
|
+
handleChangeFor
|
|
12106
|
+
})
|
|
12107
|
+
}), formUtils.isRequiredField("registrationNumber", !hideOptionalRegistrationNumberField) && jsx("div", {
|
|
12108
|
+
className: "adyen-kyc-field-wrapper",
|
|
12109
|
+
children: jsx(BusinessRegistrationNumberField, {
|
|
12110
|
+
data: formUtils.getFieldData(data, BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12111
|
+
valid: formUtils.getFieldValid(valid, BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12112
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12113
|
+
labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD, {
|
|
12114
|
+
exemptedFromRegistrationNumber: "iDontHaveARegistrationNumber"
|
|
12115
|
+
}),
|
|
12116
|
+
mask: formUtils.getMask("registrationNumber"),
|
|
12117
|
+
guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12118
|
+
placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12119
|
+
helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
|
|
12120
|
+
readonly: formUtils.isReadOnly("registrationNumber"),
|
|
12121
|
+
optional: formUtils.isOptionalField("registrationNumber"),
|
|
12122
|
+
shouldValidate: mergedProps.shouldValidate,
|
|
12123
|
+
handleChangeFor,
|
|
12124
|
+
country: country2,
|
|
12125
|
+
canExempt: formUtils.isRequiredField("exemptedFromRegistrationNumber"),
|
|
12126
|
+
companyType: mergedProps.companyType,
|
|
12127
|
+
registrationNumberOptions,
|
|
12128
|
+
registrationNumberType,
|
|
12129
|
+
setRegistrationNumberType
|
|
12130
|
+
})
|
|
12131
|
+
}), formUtils.isRequiredField("vatNumber") && jsx("div", {
|
|
12132
|
+
className: "adyen-kyc-field-wrapper",
|
|
12133
|
+
children: jsx(VatNumberField, {
|
|
12134
|
+
data: formUtils.getFieldData(data, VAT_NUMBER_FIELD),
|
|
12135
|
+
valid: formUtils.getFieldValid(valid, VAT_NUMBER_FIELD),
|
|
12136
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, VAT_NUMBER_FIELD),
|
|
12137
|
+
labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
|
|
12138
|
+
exemptedFromVat: "iDontHaveAVatNumber"
|
|
12139
|
+
}),
|
|
12140
|
+
mask: formUtils.getMask("vatNumber"),
|
|
12141
|
+
guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
|
|
12142
|
+
placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
|
|
12143
|
+
readonly: formUtils.isReadOnly("vatNumber"),
|
|
12144
|
+
handleChangeFor,
|
|
12145
|
+
country: country2,
|
|
12146
|
+
canExempt: formUtils.isRequiredField("exemptedFromVat"),
|
|
12147
|
+
vatNumberType,
|
|
12148
|
+
setVatNumberType
|
|
12149
|
+
})
|
|
12150
|
+
}), formUtils.isRequiredField("taxInformation") && jsx("div", {
|
|
12151
|
+
className: "adyen-kyc-field-wrapper",
|
|
12152
|
+
children: jsx(TaxInformationField, {
|
|
12153
|
+
data: formUtils.getFieldData(data, TAX_INFORMATION_FIELD),
|
|
12154
|
+
valid: formUtils.getFieldValid(valid, TAX_INFORMATION_FIELD),
|
|
12155
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, TAX_INFORMATION_FIELD),
|
|
12156
|
+
labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD, {
|
|
12157
|
+
exemptedFromTax: "iDontHaveATaxId"
|
|
12158
|
+
}),
|
|
12159
|
+
mask: formUtils.getMask("taxInformation"),
|
|
12160
|
+
helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
|
|
12161
|
+
guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
|
|
12162
|
+
readonly: formUtils.isReadOnly("taxInformation"),
|
|
12163
|
+
shouldValidate: mergedProps.shouldValidate,
|
|
12164
|
+
handleChangeFor,
|
|
12165
|
+
canExempt: formUtils.isRequiredField("exemptedFromTax"),
|
|
12166
|
+
isUen: formUtils.isRequiredField("isUen"),
|
|
12167
|
+
country: country2,
|
|
12168
|
+
companyType: mergedProps.companyType,
|
|
12169
|
+
taxIdNumberType,
|
|
12170
|
+
setTaxIdNumberType,
|
|
12171
|
+
defaultData: (_j = mergedProps.data) == null ? void 0 : _j.taxInformation
|
|
12172
|
+
})
|
|
12173
|
+
}), formUtils.isRequiredField("dateOfIncorporation") && jsx("div", {
|
|
12174
|
+
className: "adyen-kyc-field-wrapper",
|
|
12175
|
+
children: jsx(DateOfIncorporationField, {
|
|
12176
|
+
data: formUtils.getFieldData(data, DATE_OF_INCORPORATION_FIELD),
|
|
12177
|
+
valid: formUtils.getFieldValid(valid, DATE_OF_INCORPORATION_FIELD),
|
|
12178
|
+
errors: formUtils.getFieldErrors(errors, fieldProblems, DATE_OF_INCORPORATION_FIELD),
|
|
12179
|
+
labels: formUtils.getFieldLabels(DATE_OF_INCORPORATION_FIELD),
|
|
12180
|
+
placeholders: formUtils.getFieldPlaceholders(DATE_OF_INCORPORATION_FIELD, {
|
|
12181
|
+
dateOfIncorporation: "datePlaceholder"
|
|
12182
|
+
}),
|
|
12023
12183
|
readonly: formUtils.isReadOnly("dateOfIncorporation"),
|
|
12024
|
-
|
|
12025
|
-
onBlur: handleChangeFor("dateOfIncorporation", "blur"),
|
|
12026
|
-
"aria-required": true,
|
|
12027
|
-
"aria-label": formUtils.getLabel("dateOfIncorporation"),
|
|
12028
|
-
"aria-invalid": !valid.dateOfIncorporation,
|
|
12029
|
-
max: formatDateObj(/* @__PURE__ */ new Date())
|
|
12184
|
+
handleChangeFor
|
|
12030
12185
|
})
|
|
12031
12186
|
})]
|
|
12032
12187
|
})]
|
|
12033
12188
|
});
|
|
12034
12189
|
}
|
|
12190
|
+
function StateContextSetter({
|
|
12191
|
+
stateRef
|
|
12192
|
+
}) {
|
|
12193
|
+
if (stateRef.current.setState) {
|
|
12194
|
+
return null;
|
|
12195
|
+
}
|
|
12196
|
+
return jsx(StateContext.Consumer, {
|
|
12197
|
+
children: (stateContextValue) => {
|
|
12198
|
+
if (!stateContextValue) {
|
|
12199
|
+
throw new Error("<StateContextSetter> needs to be mounted inside a <StateProvider>");
|
|
12200
|
+
}
|
|
12201
|
+
const {
|
|
12202
|
+
dispatch,
|
|
12203
|
+
setActiveForms
|
|
12204
|
+
} = stateContextValue;
|
|
12205
|
+
stateRef.current.setState = dispatch;
|
|
12206
|
+
stateRef.current.setActiveForms = setActiveForms;
|
|
12207
|
+
return null;
|
|
12208
|
+
}
|
|
12209
|
+
});
|
|
12210
|
+
}
|
|
12035
12211
|
const companyBase = {
|
|
12036
12212
|
accountHolder: {
|
|
12037
12213
|
rule: "accountHolderIfCustomer"
|
|
@@ -12176,26 +12352,6 @@ const businessDetailsBase = {
|
|
|
12176
12352
|
rule: "countryRequiresRegistrationNumberForCompanies"
|
|
12177
12353
|
}
|
|
12178
12354
|
};
|
|
12179
|
-
const taxIdBase$1 = {
|
|
12180
|
-
exemptedFromTax: {
|
|
12181
|
-
rule: "countryHasTaxExemptionsForSomeCompanies"
|
|
12182
|
-
},
|
|
12183
|
-
taxId: {
|
|
12184
|
-
rule: "countryUsesTaxId"
|
|
12185
|
-
},
|
|
12186
|
-
exemptedFromVat: {
|
|
12187
|
-
rule: "countryUsesVat"
|
|
12188
|
-
},
|
|
12189
|
-
vatAbsenceReason: {
|
|
12190
|
-
rule: "countryUsesVat"
|
|
12191
|
-
},
|
|
12192
|
-
vatNumber: {
|
|
12193
|
-
rule: "countryUsesVat"
|
|
12194
|
-
},
|
|
12195
|
-
isUen: {
|
|
12196
|
-
rule: "countryUsesUenOrGst"
|
|
12197
|
-
}
|
|
12198
|
-
};
|
|
12199
12355
|
const taxInformationBase = {
|
|
12200
12356
|
vatNumber: {
|
|
12201
12357
|
rule: "countryUsesVat"
|
|
@@ -12258,7 +12414,7 @@ const fieldsPerScenario$3 = {
|
|
|
12258
12414
|
},
|
|
12259
12415
|
L: {
|
|
12260
12416
|
...companyBase,
|
|
12261
|
-
...
|
|
12417
|
+
...taxInformationBase
|
|
12262
12418
|
},
|
|
12263
12419
|
L_PROOFOFADDRESS: {
|
|
12264
12420
|
proofOfAddressDocument: {
|
|
@@ -15439,6 +15595,7 @@ function CompanyComponent(props) {
|
|
|
15439
15595
|
} = useI18nContext();
|
|
15440
15596
|
const [currentCompanyType, setCurrentCompanyType] = useState(void 0);
|
|
15441
15597
|
const [currentCountry, setCurrentCountry] = useState(props.country);
|
|
15598
|
+
const [currentLegalName, setCurrentLegalName] = useState();
|
|
15442
15599
|
const companyNameAndCountryFormProps = getFormProps(props, CompanyNameAndCountryFormID);
|
|
15443
15600
|
const companyTypeFormProps = getFormProps(props, CompanyTypeFormID);
|
|
15444
15601
|
const companyRegistrationDetailsFormProps = getFormProps(props, CompanyRegistrationDetailsFormID);
|
|
@@ -15449,13 +15606,15 @@ function CompanyComponent(props) {
|
|
|
15449
15606
|
currentState,
|
|
15450
15607
|
prevState
|
|
15451
15608
|
}) => {
|
|
15452
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15453
|
-
const
|
|
15609
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
15610
|
+
const legalCompanyName2 = (_b = (_a = currentState.data) == null ? void 0 : _a[CompanyNameAndCountryFormID]) == null ? void 0 : _b.legalCompanyName;
|
|
15611
|
+
setCurrentLegalName(legalCompanyName2);
|
|
15612
|
+
const companyType2 = (_d = (_c = currentState.data) == null ? void 0 : _c[CompanyTypeFormID]) == null ? void 0 : _d.entityType;
|
|
15454
15613
|
setCurrentCompanyType(companyType2);
|
|
15455
|
-
const companyCountryPrev = (
|
|
15456
|
-
const companyCountry = (
|
|
15614
|
+
const companyCountryPrev = (_f = (_e = prevState.data) == null ? void 0 : _e[CompanyNameAndCountryFormID]) == null ? void 0 : _f.country;
|
|
15615
|
+
const companyCountry = (_h = (_g = currentState.data) == null ? void 0 : _g[CompanyNameAndCountryFormID]) == null ? void 0 : _h.country;
|
|
15457
15616
|
setCurrentCountry(companyCountry);
|
|
15458
|
-
const accountHolder2 = (
|
|
15617
|
+
const accountHolder2 = (_j = (_i = currentState.data) == null ? void 0 : _i[CompanyTypeFormID]) == null ? void 0 : _j.accountHolder;
|
|
15459
15618
|
if (companyCountry != null && companyCountry !== companyCountryPrev) {
|
|
15460
15619
|
props.onCountryChange(companyCountry);
|
|
15461
15620
|
}
|
|
@@ -15491,8 +15650,9 @@ function CompanyComponent(props) {
|
|
|
15491
15650
|
...companyRegistrationDetailsFormProps,
|
|
15492
15651
|
heading: i18n.get("registrationDetails"),
|
|
15493
15652
|
id: CompanyRegistrationDetailsFormID,
|
|
15494
|
-
country:
|
|
15495
|
-
companyType: currentCompanyType
|
|
15653
|
+
country: currentCountry,
|
|
15654
|
+
companyType: currentCompanyType,
|
|
15655
|
+
legalName: currentLegalName
|
|
15496
15656
|
})
|
|
15497
15657
|
}), jsx("div", {
|
|
15498
15658
|
className: props.activeForm.formId !== CompanyRegistrationAddressFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
@@ -15925,80 +16085,6 @@ const getObscuredAccountNumber = ({
|
|
|
15925
16085
|
accountIdentifier,
|
|
15926
16086
|
realLastFour
|
|
15927
16087
|
}) => realLastFour ? `*******${realLastFour}` : accountIdentifier;
|
|
15928
|
-
const countryToTaxInfoTypeMap = {
|
|
15929
|
-
US: "EIN",
|
|
15930
|
-
AU: "ABN",
|
|
15931
|
-
NZ: "IRD",
|
|
15932
|
-
HK: "BRN",
|
|
15933
|
-
SG: "GST"
|
|
15934
|
-
};
|
|
15935
|
-
const updateTaxInformation = ({
|
|
15936
|
-
taxId: taxId2,
|
|
15937
|
-
country: country2,
|
|
15938
|
-
exemptedFromTax: exemptedFromTax2 = false,
|
|
15939
|
-
isUen,
|
|
15940
|
-
entity
|
|
15941
|
-
}) => {
|
|
15942
|
-
var _a;
|
|
15943
|
-
const updatedEntity = cloneObject(entity);
|
|
15944
|
-
const taxInformation = ((_a = entity.taxInformation) == null ? void 0 : _a.reduce((acc, info) => {
|
|
15945
|
-
acc[info.country] = info;
|
|
15946
|
-
return acc;
|
|
15947
|
-
}, {})) ?? {};
|
|
15948
|
-
if (exemptedFromTax2) {
|
|
15949
|
-
delete taxInformation[country2];
|
|
15950
|
-
} else if (isUen !== void 0) {
|
|
15951
|
-
taxInformation[country2] = {
|
|
15952
|
-
country: country2,
|
|
15953
|
-
type: isUen ? "UEN" : "GST",
|
|
15954
|
-
number: taxId2
|
|
15955
|
-
};
|
|
15956
|
-
} else {
|
|
15957
|
-
taxInformation[country2] = {
|
|
15958
|
-
country: country2,
|
|
15959
|
-
type: countryToTaxInfoTypeMap[country2],
|
|
15960
|
-
number: taxId2
|
|
15961
|
-
};
|
|
15962
|
-
}
|
|
15963
|
-
updatedEntity.taxInformation = Object.values(taxInformation);
|
|
15964
|
-
if (country2 === "US") {
|
|
15965
|
-
delete updatedEntity.vatNumber;
|
|
15966
|
-
delete updatedEntity.registrationNumber;
|
|
15967
|
-
}
|
|
15968
|
-
return updatedEntity;
|
|
15969
|
-
};
|
|
15970
|
-
const getUpdatedCountryOfGoverningLaw = (nameAndCountry) => {
|
|
15971
|
-
if (!nameAndCountry) {
|
|
15972
|
-
return nameAndCountry;
|
|
15973
|
-
}
|
|
15974
|
-
const updatedNameAndCountry = cloneObject(nameAndCountry);
|
|
15975
|
-
if (updatedNameAndCountry.country === "GB" && !updatedNameAndCountry.differentCountryOfGoverningLaw) {
|
|
15976
|
-
updatedNameAndCountry.countryOfGoverningLaw = "GB";
|
|
15977
|
-
} else if (updatedNameAndCountry.country !== "GB") {
|
|
15978
|
-
delete updatedNameAndCountry.countryOfGoverningLaw;
|
|
15979
|
-
}
|
|
15980
|
-
return updatedNameAndCountry;
|
|
15981
|
-
};
|
|
15982
|
-
const transformCountryOfGoverningLawToLegalEntity = (nameAndCountry, organization) => {
|
|
15983
|
-
const updatedOrganization = cloneObject(organization);
|
|
15984
|
-
if (nameAndCountry.country === "GB") {
|
|
15985
|
-
if (!nameAndCountry.differentCountryOfGoverningLaw) {
|
|
15986
|
-
updatedOrganization.countryOfGoverningLaw = CountryCodes.UnitedKingdom;
|
|
15987
|
-
} else {
|
|
15988
|
-
updatedOrganization.countryOfGoverningLaw = nameAndCountry.countryOfGoverningLaw;
|
|
15989
|
-
}
|
|
15990
|
-
} else {
|
|
15991
|
-
delete updatedOrganization.countryOfGoverningLaw;
|
|
15992
|
-
}
|
|
15993
|
-
return updatedOrganization;
|
|
15994
|
-
};
|
|
15995
|
-
const transformCountryOfGoverningLawToSchema = (nameAndCountry, organization) => {
|
|
15996
|
-
const updatedNameAndCountry = cloneObject(nameAndCountry);
|
|
15997
|
-
if (organization.registeredAddress.country === CountryCodes.UnitedKingdom && organization.countryOfGoverningLaw !== CountryCodes.UnitedKingdom) {
|
|
15998
|
-
updatedNameAndCountry.differentCountryOfGoverningLaw = true;
|
|
15999
|
-
}
|
|
16000
|
-
return updatedNameAndCountry;
|
|
16001
|
-
};
|
|
16002
16088
|
const mandatoryApiFields = {
|
|
16003
16089
|
INDIVIDUAL: ["personalDetails.firstName", "personalDetails.lastName", "personalDetails.residencyCountry"],
|
|
16004
16090
|
DECISIONMAKER: ["personalDetails.firstName", "personalDetails.lastName", "personalDetails.residencyCountry", "personalDetails.role", "personalDetails.jobTitle"],
|
|
@@ -16093,6 +16179,7 @@ const companyBaseMapping = {
|
|
|
16093
16179
|
"companyType.entityType": "organization.type",
|
|
16094
16180
|
"companyRegistrationDetails.tradingName": "organization.doingBusinessAs",
|
|
16095
16181
|
"companyRegistrationDetails.registrationNumber": "organization.registrationNumber",
|
|
16182
|
+
"companyRegistrationDetails.taxInformation": "organization.taxInformation",
|
|
16096
16183
|
"companyRegistrationDetails.vatNumber": "organization.vatNumber",
|
|
16097
16184
|
"companyRegistrationDetails.vatAbsenceReason": "organization.vatAbsenceReason",
|
|
16098
16185
|
"companyRegistrationDetails.dateOfIncorporation": "organization.dateOfIncorporation",
|
|
@@ -16168,6 +16255,7 @@ const solePropBaseMapping = {
|
|
|
16168
16255
|
"solePropRegistrationDetails.vatAbsenceReason": "soleProprietorship.vatAbsenceReason",
|
|
16169
16256
|
"solePropRegistrationDetails.exemptedFromTax": "soleProprietorship.taxAbsent",
|
|
16170
16257
|
"solePropRegistrationDetails.registrationNumber": "soleProprietorship.registrationNumber",
|
|
16258
|
+
"solePropRegistrationDetails.taxInformation": "soleProprietorship.taxInformation",
|
|
16171
16259
|
"solePropRegistrationDetails.dateOfIncorporation": "soleProprietorship.dateOfIncorporation",
|
|
16172
16260
|
"solePropRegistrationAddress.registrationAddress.city": "soleProprietorship.registeredAddress.city",
|
|
16173
16261
|
"solePropRegistrationAddress.registrationAddress.country": "soleProprietorship.registeredAddress.country",
|
|
@@ -16443,7 +16531,7 @@ const mapIndividualToLegalEntity = (data) => {
|
|
|
16443
16531
|
return requestObj;
|
|
16444
16532
|
};
|
|
16445
16533
|
const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) => {
|
|
16446
|
-
var _a, _b, _c, _d;
|
|
16534
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
16447
16535
|
let companyCompData;
|
|
16448
16536
|
if (legalEntity == null ? void 0 : legalEntity.organization) {
|
|
16449
16537
|
companyCompData = formatObject(legalEntity, companyComponentsKeyMapping);
|
|
@@ -16456,20 +16544,17 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
|
|
|
16456
16544
|
companyCompData.companyRegistrationAddress.operationalAddressIsSame = operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME;
|
|
16457
16545
|
}
|
|
16458
16546
|
companyCompData.companyNameAndCountry = transformCountryOfGoverningLawToSchema(companyCompData.companyNameAndCountry, legalEntity.organization);
|
|
16547
|
+
const sameNameAsLegalName2 = !(((_b = companyCompData.companyNameAndCountry) == null ? void 0 : _b.legalCompanyName) && ((_c = companyCompData.companyRegistrationDetails) == null ? void 0 : _c.tradingName) && companyCompData.companyNameAndCountry.legalCompanyName !== companyCompData.companyRegistrationDetails.tradingName);
|
|
16459
16548
|
companyCompData.companyRegistrationDetails = {
|
|
16460
16549
|
...companyCompData.companyRegistrationDetails,
|
|
16461
|
-
|
|
16550
|
+
tradingName: ((_d = companyCompData.companyRegistrationDetails) == null ? void 0 : _d.tradingName) ? (_e = companyCompData.companyRegistrationDetails) == null ? void 0 : _e.tradingName : (_f = companyCompData.companyNameAndCountry) == null ? void 0 : _f.legalCompanyName,
|
|
16551
|
+
sameNameAsLegalName: companyCompData.companyNameAndCountry.legalCompanyName ? sameNameAsLegalName2 : true
|
|
16462
16552
|
};
|
|
16463
|
-
|
|
16464
|
-
taxInformation = []
|
|
16465
|
-
} = legalEntity.organization;
|
|
16466
|
-
if (taxInformation.length) {
|
|
16553
|
+
if ((_h = (_g = legalEntity.organization) == null ? void 0 : _g.taxInformation) == null ? void 0 : _h.length) {
|
|
16467
16554
|
const {
|
|
16468
16555
|
country: country2
|
|
16469
16556
|
} = legalEntity.organization.registeredAddress;
|
|
16470
|
-
const countryTaxInformation = taxInformation.find((info) => info.country === country2);
|
|
16471
|
-
companyCompData.companyRegistrationDetails.taxId = countryTaxInformation == null ? void 0 : countryTaxInformation.number;
|
|
16472
|
-
companyCompData.companyRegistrationDetails.exemptedFromTax = false;
|
|
16557
|
+
const countryTaxInformation = legalEntity.organization.taxInformation.find((info) => info.country === country2);
|
|
16473
16558
|
if ((countryTaxInformation == null ? void 0 : countryTaxInformation.type) === "UEN") {
|
|
16474
16559
|
companyCompData.companyRegistrationDetails.isUen = true;
|
|
16475
16560
|
}
|
|
@@ -16477,7 +16562,7 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
|
|
|
16477
16562
|
companyCompData.companyRegistrationDetails.isUen = false;
|
|
16478
16563
|
}
|
|
16479
16564
|
}
|
|
16480
|
-
if ((
|
|
16565
|
+
if ((_i = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _i.length) {
|
|
16481
16566
|
companyCompData = {
|
|
16482
16567
|
...companyCompData,
|
|
16483
16568
|
...mapApiDocumentToCompanyDocuments(legalEntity == null ? void 0 : legalEntity.id)
|
|
@@ -16494,21 +16579,27 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
|
|
|
16494
16579
|
return companyCompData;
|
|
16495
16580
|
};
|
|
16496
16581
|
const mapCompanyToLegalEntity = (data) => {
|
|
16582
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16497
16583
|
const requestObj = {
|
|
16498
16584
|
...formatObject(data, companyApiKeyMapping)
|
|
16499
16585
|
};
|
|
16500
16586
|
if (requestObj.organization.vatAbsenceReason) {
|
|
16501
16587
|
requestObj.organization.vatNumber = "";
|
|
16502
16588
|
}
|
|
16503
|
-
|
|
16504
|
-
|
|
16589
|
+
const taxId2 = (_a = data.companyRegistrationDetails.taxInformation) == null ? void 0 : _a.find((tax) => {
|
|
16590
|
+
var _a2;
|
|
16591
|
+
return tax.country === ((_a2 = data.companyNameAndCountry) == null ? void 0 : _a2.country);
|
|
16592
|
+
}).number;
|
|
16593
|
+
if (taxId2 || ((_b = data.companyRegistrationDetails) == null ? void 0 : _b.isUen)) {
|
|
16505
16594
|
requestObj.organization = updateTaxInformation({
|
|
16506
|
-
taxId: data.companyRegistrationDetails.
|
|
16507
|
-
country: data.companyNameAndCountry.country,
|
|
16508
|
-
|
|
16595
|
+
taxId: ((_c = data.companyRegistrationDetails) == null ? void 0 : _c.isUen) ? data.companyRegistrationDetails.registrationNumber : taxId2,
|
|
16596
|
+
country: (_d = data.companyNameAndCountry) == null ? void 0 : _d.country,
|
|
16597
|
+
exemptedFromTax: (_e = data.companyRegistrationDetails) == null ? void 0 : _e.exemptedFromTax,
|
|
16598
|
+
isUen: (_f = data.companyRegistrationDetails) == null ? void 0 : _f.isUen,
|
|
16509
16599
|
entity: requestObj.organization
|
|
16510
16600
|
});
|
|
16511
16601
|
}
|
|
16602
|
+
requestObj.organization = transformCountryOfGoverningLawToLegalEntity(data.companyNameAndCountry, requestObj.organization);
|
|
16512
16603
|
requestObj.type = LegalEntityType.ORGANIZATION;
|
|
16513
16604
|
return requestObj;
|
|
16514
16605
|
};
|
|
@@ -16571,7 +16662,7 @@ const mapHighExposureToLegalEntity = (data) => ({
|
|
|
16571
16662
|
...formatObject(data, highExposureApiKeyMapping)
|
|
16572
16663
|
});
|
|
16573
16664
|
const mapLegalEntityToSoleProp = (legalEntity) => {
|
|
16574
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16665
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
16575
16666
|
let solePropCompData;
|
|
16576
16667
|
if (legalEntity == null ? void 0 : legalEntity.soleProprietorship) {
|
|
16577
16668
|
solePropCompData = formatObject(legalEntity, solePropComponentsKeyMapping);
|
|
@@ -16592,19 +16683,10 @@ const mapLegalEntityToSoleProp = (legalEntity) => {
|
|
|
16592
16683
|
solePropCompData.solePropNameAndCountry = transformCountryOfGoverningLawToSchema(solePropCompData.solePropNameAndCountry, legalEntity.soleProprietorship);
|
|
16593
16684
|
solePropCompData.solePropRegistrationDetails = {
|
|
16594
16685
|
...solePropCompData.solePropRegistrationDetails,
|
|
16595
|
-
|
|
16686
|
+
tradingName: ((_e = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _e.tradingName) ? (_f = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _f.tradingName : (_g = solePropCompData.solePropNameAndCountry) == null ? void 0 : _g.legalCompanyName,
|
|
16687
|
+
sameNameAsLegalName: !(((_h = solePropCompData.solePropNameAndCountry) == null ? void 0 : _h.legalCompanyName) && ((_i = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _i.tradingName) && solePropCompData.solePropNameAndCountry.legalCompanyName !== solePropCompData.solePropRegistrationDetails.tradingName)
|
|
16596
16688
|
};
|
|
16597
|
-
|
|
16598
|
-
taxInformation = []
|
|
16599
|
-
} = legalEntity.soleProprietorship;
|
|
16600
|
-
if (taxInformation.length) {
|
|
16601
|
-
const {
|
|
16602
|
-
country: country2
|
|
16603
|
-
} = legalEntity.soleProprietorship.registeredAddress;
|
|
16604
|
-
solePropCompData.solePropRegistrationDetails.taxId = (_g = taxInformation.find((info) => info.country === country2)) == null ? void 0 : _g.number;
|
|
16605
|
-
solePropCompData.solePropRegistrationDetails.exemptedFromTax = false;
|
|
16606
|
-
}
|
|
16607
|
-
if ((_h = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _h.length) {
|
|
16689
|
+
if ((_j = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _j.length) {
|
|
16608
16690
|
solePropCompData = {
|
|
16609
16691
|
...solePropCompData,
|
|
16610
16692
|
...mapApiDocumentToSolePropDocuments(legalEntity == null ? void 0 : legalEntity.id)
|
|
@@ -16622,20 +16704,16 @@ const mapSolePropToLegalEntity = (data) => {
|
|
|
16622
16704
|
requestObj.soleProprietorship.vatNumber = "";
|
|
16623
16705
|
}
|
|
16624
16706
|
requestObj.soleProprietorship = transformCountryOfGoverningLawToLegalEntity(data.solePropNameAndCountry, requestObj.soleProprietorship);
|
|
16625
|
-
if (data.solePropRegistrationDetails.taxId || requestObj.soleProprietorship.taxAbsent) {
|
|
16626
|
-
requestObj.soleProprietorship = updateTaxInformation({
|
|
16627
|
-
taxId: data.solePropRegistrationDetails.taxId,
|
|
16628
|
-
exemptedFromTax: data.solePropRegistrationDetails.exemptedFromTax,
|
|
16629
|
-
country: data.solePropNameAndCountry.country,
|
|
16630
|
-
entity: requestObj.soleProprietorship
|
|
16631
|
-
});
|
|
16632
|
-
}
|
|
16633
16707
|
if (data.solePropRegistrationDetails.exemptedFromRegistrationNumber) {
|
|
16634
16708
|
requestObj.soleProprietorship.registrationNumber = "";
|
|
16635
16709
|
}
|
|
16636
16710
|
if (!((_a = requestObj.soleProprietorship) == null ? void 0 : _a.countryOfGoverningLaw) && ((_b = data.solePropNameAndCountry) == null ? void 0 : _b.country)) {
|
|
16637
16711
|
requestObj.soleProprietorship.countryOfGoverningLaw = data.solePropNameAndCountry.country;
|
|
16638
16712
|
}
|
|
16713
|
+
if (data.solePropNameAndCountry.country === "US") {
|
|
16714
|
+
delete requestObj.soleProprietorship.vatNumber;
|
|
16715
|
+
delete requestObj.soleProprietorship.registrationNumber;
|
|
16716
|
+
}
|
|
16639
16717
|
requestObj.type = LegalEntityType.SOLE_PROPRIETORSHIP;
|
|
16640
16718
|
return requestObj;
|
|
16641
16719
|
};
|
|
@@ -18052,10 +18130,10 @@ const ContactDetailsComp = memo(ContactDetailsComponent, (prevProps, nextProps)
|
|
|
18052
18130
|
ContactDetailsComponent.defaultProps = {
|
|
18053
18131
|
data: {}
|
|
18054
18132
|
};
|
|
18055
|
-
const defaultFieldMetadata$
|
|
18133
|
+
const defaultFieldMetadata$5 = {
|
|
18056
18134
|
label: "idNumber"
|
|
18057
18135
|
};
|
|
18058
|
-
const defaultFieldConfig$
|
|
18136
|
+
const defaultFieldConfig$5 = {
|
|
18059
18137
|
[CountryCodes.Brazil]: {
|
|
18060
18138
|
label: "cadastroDePessoasFisicas",
|
|
18061
18139
|
mask: {
|
|
@@ -18516,10 +18594,10 @@ function IdentityNumberComponent(props) {
|
|
|
18516
18594
|
idNumberExempt: !!(propData == null ? void 0 : propData.idNumberExempt)
|
|
18517
18595
|
});
|
|
18518
18596
|
const schema = requiredFields ?? idNumberFields;
|
|
18519
|
-
const fieldConfig = propFieldConfig ?? defaultFieldConfig$
|
|
18597
|
+
const fieldConfig = propFieldConfig ?? defaultFieldConfig$5;
|
|
18520
18598
|
const metadata = resolveFieldMetadata(fieldConfig[country2], {
|
|
18521
18599
|
idNumberType
|
|
18522
|
-
}, defaultFieldMetadata$
|
|
18600
|
+
}, defaultFieldMetadata$5);
|
|
18523
18601
|
const idNumberExemptMetadata = resolveFieldMetadata(idNumberExemptDefaultConfig[country2], {}, idNumberExemptDefaultMetadata);
|
|
18524
18602
|
const mergedProps = mergeFieldMetadataIntoProps("idNumberExempt", idNumberExemptMetadata, mergeFieldMetadataIntoProps("idNumber", metadata, {
|
|
18525
18603
|
requiredFields: schema,
|
|
@@ -19181,9 +19259,9 @@ function IdentityAuComponent({
|
|
|
19181
19259
|
requiredFields
|
|
19182
19260
|
};
|
|
19183
19261
|
const mergedProps = useMemo(() => {
|
|
19184
|
-
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$
|
|
19262
|
+
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.Australia], {
|
|
19185
19263
|
idNumberType: identityType
|
|
19186
|
-
}, defaultFieldMetadata$
|
|
19264
|
+
}, defaultFieldMetadata$5);
|
|
19187
19265
|
return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, mergeFieldMetadataIntoProps("licenseCardNumber", licenseCardNumberMetaData$1, initialFormUtilProps));
|
|
19188
19266
|
}, [identityType]);
|
|
19189
19267
|
const {
|
|
@@ -19306,9 +19384,9 @@ function IdentityHKComponent({
|
|
|
19306
19384
|
requiredFields
|
|
19307
19385
|
};
|
|
19308
19386
|
const mergedProps = useMemo(() => {
|
|
19309
|
-
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$
|
|
19387
|
+
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.HongKong], {
|
|
19310
19388
|
idNumberType: identityType
|
|
19311
|
-
}, defaultFieldMetadata$
|
|
19389
|
+
}, defaultFieldMetadata$5);
|
|
19312
19390
|
return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, initialFormUtilProps);
|
|
19313
19391
|
}, [identityType]);
|
|
19314
19392
|
const {
|
|
@@ -19488,9 +19566,9 @@ function IdentityNZComponent({
|
|
|
19488
19566
|
requiredFields
|
|
19489
19567
|
};
|
|
19490
19568
|
const mergedProps = useMemo(() => {
|
|
19491
|
-
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$
|
|
19569
|
+
const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.NewZealand], {
|
|
19492
19570
|
idNumberType: identityType
|
|
19493
|
-
}, defaultFieldMetadata$
|
|
19571
|
+
}, defaultFieldMetadata$5);
|
|
19494
19572
|
return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, mergeFieldMetadataIntoProps("licenseCardNumber", licenseCardNumberMetaData, initialFormUtilProps));
|
|
19495
19573
|
}, [identityType]);
|
|
19496
19574
|
const {
|
|
@@ -21937,11 +22015,11 @@ const simpleBankAccountNumberMetadata = (example, length, maxLength) => {
|
|
|
21937
22015
|
}
|
|
21938
22016
|
};
|
|
21939
22017
|
};
|
|
21940
|
-
const defaultFieldMetadata$
|
|
22018
|
+
const defaultFieldMetadata$4 = {
|
|
21941
22019
|
label: "bankAccountNumber",
|
|
21942
22020
|
validators: isNotEmptyValidator
|
|
21943
22021
|
};
|
|
21944
|
-
const defaultFieldConfig$
|
|
22022
|
+
const defaultFieldConfig$4 = {
|
|
21945
22023
|
[CountryCodes.Denmark]: simpleBankAccountNumberMetadata("2621955959", 10),
|
|
21946
22024
|
[CountryCodes.Norway]: simpleBankAccountNumberMetadata("86011117947", 11),
|
|
21947
22025
|
[CountryCodes.UnitedKingdom]: simpleBankAccountNumberMetadata("10000003", 8),
|
|
@@ -21989,9 +22067,9 @@ function BankAccountNumber(props) {
|
|
|
21989
22067
|
} = useI18nContext();
|
|
21990
22068
|
const {
|
|
21991
22069
|
country: country2,
|
|
21992
|
-
fieldConfig = defaultFieldConfig$
|
|
22070
|
+
fieldConfig = defaultFieldConfig$4
|
|
21993
22071
|
} = props;
|
|
21994
|
-
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$
|
|
22072
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$4);
|
|
21995
22073
|
const mergedProps = mergeFieldMetadataIntoProps("bankAccountNumber", metadata, props);
|
|
21996
22074
|
const {
|
|
21997
22075
|
handleChangeFor,
|
|
@@ -22092,7 +22170,7 @@ function BankCity(props) {
|
|
|
22092
22170
|
})
|
|
22093
22171
|
});
|
|
22094
22172
|
}
|
|
22095
|
-
const defaultFieldMetadata$
|
|
22173
|
+
const defaultFieldMetadata$3 = {
|
|
22096
22174
|
label: "bankCode",
|
|
22097
22175
|
validators: isNotEmptyValidator
|
|
22098
22176
|
};
|
|
@@ -22110,7 +22188,7 @@ const simpleBankCodeMetadata = (length, example, label) => ({
|
|
|
22110
22188
|
}
|
|
22111
22189
|
}
|
|
22112
22190
|
});
|
|
22113
|
-
const defaultFieldConfig$
|
|
22191
|
+
const defaultFieldConfig$3 = {
|
|
22114
22192
|
[CountryCodes.Brazil]: simpleBankCodeMetadata(3, "123"),
|
|
22115
22193
|
[CountryCodes.Canada]: simpleBankCodeMetadata(3, "100", "institutionNumber"),
|
|
22116
22194
|
[CountryCodes.Denmark]: simpleBankCodeMetadata(4, "5051"),
|
|
@@ -22128,9 +22206,9 @@ function BankCode(props) {
|
|
|
22128
22206
|
} = useI18nContext();
|
|
22129
22207
|
const {
|
|
22130
22208
|
country: country2,
|
|
22131
|
-
fieldConfig = defaultFieldConfig$
|
|
22209
|
+
fieldConfig = defaultFieldConfig$3
|
|
22132
22210
|
} = props;
|
|
22133
|
-
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$
|
|
22211
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$3);
|
|
22134
22212
|
const mergedProps = mergeFieldMetadataIntoProps("bankCode", metadata, props);
|
|
22135
22213
|
const {
|
|
22136
22214
|
handleChangeFor,
|
|
@@ -22229,11 +22307,11 @@ function BankName(props) {
|
|
|
22229
22307
|
})
|
|
22230
22308
|
});
|
|
22231
22309
|
}
|
|
22232
|
-
const defaultFieldMetadata$
|
|
22310
|
+
const defaultFieldMetadata$2 = {
|
|
22233
22311
|
label: "branchCode",
|
|
22234
22312
|
validators: isNotEmptyValidator
|
|
22235
22313
|
};
|
|
22236
|
-
const defaultFieldConfig$
|
|
22314
|
+
const defaultFieldConfig$2 = {
|
|
22237
22315
|
[CountryCodes.UnitedKingdom]: {
|
|
22238
22316
|
label: "sortCode",
|
|
22239
22317
|
validators: validatePatternOnBlur(/^\d{6}$/),
|
|
@@ -22334,9 +22412,9 @@ function BranchCode(props) {
|
|
|
22334
22412
|
} = useI18nContext();
|
|
22335
22413
|
const {
|
|
22336
22414
|
country: country2,
|
|
22337
|
-
fieldConfig = defaultFieldConfig$
|
|
22415
|
+
fieldConfig = defaultFieldConfig$2
|
|
22338
22416
|
} = props;
|
|
22339
|
-
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$
|
|
22417
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$2);
|
|
22340
22418
|
const mergedProps = mergeFieldMetadataIntoProps("branchCode", metadata, props);
|
|
22341
22419
|
const {
|
|
22342
22420
|
handleChangeFor,
|
|
@@ -22546,11 +22624,11 @@ const ibanMetadata = (country2, inputLength, example, allowLettersInBban) => ({
|
|
|
22546
22624
|
guidanceText: ibanGuidance(allowLettersInBban ? "characters" : "digits", inputLength, example)
|
|
22547
22625
|
});
|
|
22548
22626
|
const gbIbanMetadata = ibanMetadata(CountryCodes.UnitedKingdom, 20, "GB09 BARC 2003 9554 8297 59", true);
|
|
22549
|
-
const defaultFieldMetadata$
|
|
22627
|
+
const defaultFieldMetadata$1 = {
|
|
22550
22628
|
label: "iban",
|
|
22551
22629
|
validators: isNotEmptyValidator
|
|
22552
22630
|
};
|
|
22553
|
-
const defaultFieldConfig$
|
|
22631
|
+
const defaultFieldConfig$1 = {
|
|
22554
22632
|
[CountryCodes.Austria]: ibanMetadata(CountryCodes.Austria, 18, "AT88 5400 0746 7265 9747"),
|
|
22555
22633
|
[CountryCodes.Belgium]: ibanMetadata(CountryCodes.Belgium, 14, "BE59 9788 6743 2226"),
|
|
22556
22634
|
[CountryCodes.Croatia]: ibanMetadata(CountryCodes.Croatia, 19, "HR51 2484 0083 5929 6973 8"),
|
|
@@ -22597,9 +22675,9 @@ function Iban(props) {
|
|
|
22597
22675
|
} = useI18nContext();
|
|
22598
22676
|
const {
|
|
22599
22677
|
country: country2,
|
|
22600
|
-
fieldConfig = defaultFieldConfig$
|
|
22678
|
+
fieldConfig = defaultFieldConfig$1
|
|
22601
22679
|
} = props;
|
|
22602
|
-
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$
|
|
22680
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$1);
|
|
22603
22681
|
const mergedProps = mergeFieldMetadataIntoProps("iban", metadata, props);
|
|
22604
22682
|
const {
|
|
22605
22683
|
handleChangeFor,
|
|
@@ -23524,17 +23602,25 @@ function SolePropComponent(props) {
|
|
|
23524
23602
|
const {
|
|
23525
23603
|
isExperimentEnabled
|
|
23526
23604
|
} = useExperimentsContext();
|
|
23527
|
-
const [
|
|
23605
|
+
const [currentCountry, setCurrentCountry] = useState(props.country);
|
|
23606
|
+
const [currentLegalName, setCurrentLegalName] = useState();
|
|
23528
23607
|
const solePropNameAndCountryFormProps = getFormProps(props, solePropNameAndCountryFormId);
|
|
23529
23608
|
const solePropsRegistrationDetailsFormProps = getFormProps(props, solePropRegistrationDetailsFormId);
|
|
23530
23609
|
const solePropRegistrationAddressFormProps = getNestedOuterFormPropsFromOuterFormProps(props, solePropRegistrationAddressFormId);
|
|
23531
23610
|
const solePropDocumentsFormProps = getFormProps(props, solePropDocumentFormId);
|
|
23532
23611
|
const handleStateChange = ({
|
|
23533
|
-
currentState
|
|
23612
|
+
currentState,
|
|
23613
|
+
prevState
|
|
23534
23614
|
}) => {
|
|
23535
|
-
var _a, _b, _c;
|
|
23536
|
-
const
|
|
23537
|
-
|
|
23615
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
23616
|
+
const companyCountryPrev = (_b = (_a = prevState.data) == null ? void 0 : _a[solePropNameAndCountryFormId]) == null ? void 0 : _b.country;
|
|
23617
|
+
const companyCountry = (_d = (_c = currentState.data) == null ? void 0 : _c[solePropNameAndCountryFormId]) == null ? void 0 : _d.country;
|
|
23618
|
+
setCurrentCountry(companyCountry);
|
|
23619
|
+
const legalCompanyName2 = (_f = (_e = currentState.data) == null ? void 0 : _e[solePropNameAndCountryFormId]) == null ? void 0 : _f.legalCompanyName;
|
|
23620
|
+
setCurrentLegalName(legalCompanyName2);
|
|
23621
|
+
if (companyCountry != null && companyCountry !== companyCountryPrev) {
|
|
23622
|
+
(_g = props.onCountryChange) == null ? void 0 : _g.call(props, companyCountry);
|
|
23623
|
+
}
|
|
23538
23624
|
};
|
|
23539
23625
|
const renderActiveForm = (activeForm) => {
|
|
23540
23626
|
var _a;
|
|
@@ -23564,14 +23650,11 @@ function SolePropComponent(props) {
|
|
|
23564
23650
|
className: activeForm.formId !== solePropRegistrationDetailsFormId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
23565
23651
|
children: jsx(CompanyRegistrationDetailsComponent, {
|
|
23566
23652
|
...solePropsRegistrationDetailsFormProps,
|
|
23567
|
-
data: {
|
|
23568
|
-
...solePropsRegistrationDetailsFormProps == null ? void 0 : solePropsRegistrationDetailsFormProps.data,
|
|
23569
|
-
tradingName: tradingName2
|
|
23570
|
-
},
|
|
23571
23653
|
heading: i18n.get("registrationDetails"),
|
|
23572
23654
|
id: solePropRegistrationDetailsFormId,
|
|
23573
23655
|
companyType: CompanyTypesValue.SOLE_PROPRIETORSHIP,
|
|
23574
|
-
country:
|
|
23656
|
+
country: currentCountry,
|
|
23657
|
+
legalName: currentLegalName
|
|
23575
23658
|
})
|
|
23576
23659
|
}), jsx("div", {
|
|
23577
23660
|
className: activeForm.formId !== solePropRegistrationAddressFormId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
@@ -23909,6 +23992,278 @@ const getCountrySpecificTrustTypeOptions = (country2) => {
|
|
|
23909
23992
|
return countrySpecificTrustTypeOption;
|
|
23910
23993
|
});
|
|
23911
23994
|
};
|
|
23995
|
+
const businessRegistrationNumberFields = ["registrationNumber", "exemptedFromRegistrationNumber"];
|
|
23996
|
+
function BusinessRegistrationNumber(props) {
|
|
23997
|
+
var _a, _b, _c, _d;
|
|
23998
|
+
const fieldConfig = props.fieldConfig ?? defaultFieldConfig$9;
|
|
23999
|
+
const {
|
|
24000
|
+
i18n
|
|
24001
|
+
} = useI18nContext();
|
|
24002
|
+
const stateRef = useRef({
|
|
24003
|
+
setState: null
|
|
24004
|
+
});
|
|
24005
|
+
const schema = props.requiredFields || ["registrationNumber"];
|
|
24006
|
+
const {
|
|
24007
|
+
companyType: companyType2,
|
|
24008
|
+
country: country2
|
|
24009
|
+
} = props;
|
|
24010
|
+
const registrationNumberOptions = useMemo(() => getCompanyRegistrationNumberOptions(country2, companyType2), [country2, companyType2]);
|
|
24011
|
+
const defaultRegistrationNumberType = ((_a = props.data) == null ? void 0 : _a.registrationNumber) ? inferCompanyRegistrationNumberType((_b = props.data) == null ? void 0 : _b.registrationNumber, country2, companyType2) : registrationNumberOptions == null ? void 0 : registrationNumberOptions[0].id;
|
|
24012
|
+
const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
|
|
24013
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {
|
|
24014
|
+
companyType: companyType2,
|
|
24015
|
+
registrationNumberType
|
|
24016
|
+
}, defaultFieldMetadata$9);
|
|
24017
|
+
const mergedProps = mergeFieldMetadataIntoProps("registrationNumber", metadata, {
|
|
24018
|
+
requiredFields: schema,
|
|
24019
|
+
readOnlyFields: props.readOnlyFields
|
|
24020
|
+
});
|
|
24021
|
+
const {
|
|
24022
|
+
handleChangeFor,
|
|
24023
|
+
data,
|
|
24024
|
+
valid,
|
|
24025
|
+
errors,
|
|
24026
|
+
isValid,
|
|
24027
|
+
fieldProblems
|
|
24028
|
+
} = useForm({
|
|
24029
|
+
...mergedProps,
|
|
24030
|
+
schema: (data2) => data2.exemptedFromRegistrationNumber ? ["exemptedFromRegistrationNumber"] : ["registrationNumber", "exemptedFromRegistrationNumber"],
|
|
24031
|
+
rules: mergedProps.validators,
|
|
24032
|
+
defaultData: {
|
|
24033
|
+
...props.data,
|
|
24034
|
+
exemptedFromRegistrationNumber: !!((_c = props.data) == null ? void 0 : _c.exemptedFromRegistrationNumber)
|
|
24035
|
+
},
|
|
24036
|
+
// exemptedFromRegistrationNumber should be a boolean
|
|
24037
|
+
fieldProblems: props == null ? void 0 : props.fieldValidationErrors
|
|
24038
|
+
});
|
|
24039
|
+
useEffect(() => {
|
|
24040
|
+
var _a2, _b2;
|
|
24041
|
+
(_b2 = (_a2 = stateRef == null ? void 0 : stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
|
|
24042
|
+
type: "addToState",
|
|
24043
|
+
value: {
|
|
24044
|
+
data,
|
|
24045
|
+
valid,
|
|
24046
|
+
errors,
|
|
24047
|
+
caller: "businessRegistration",
|
|
24048
|
+
dataStoreId: props.dataStoreId
|
|
24049
|
+
}
|
|
24050
|
+
});
|
|
24051
|
+
}, [data, valid, errors, isValid]);
|
|
24052
|
+
useEffect(() => {
|
|
24053
|
+
if (data.registrationNumber || registrationNumberType) {
|
|
24054
|
+
handleChangeFor("registrationNumber", "blur")(data.registrationNumber);
|
|
24055
|
+
}
|
|
24056
|
+
}, [props.country, registrationNumberType]);
|
|
24057
|
+
const formUtils = formUtilities(mergedProps, i18n);
|
|
24058
|
+
const exemptionIsPossible = ((_d = mergedProps.requiredFields) == null ? void 0 : _d.includes("exemptedFromRegistrationNumber")) ?? false;
|
|
24059
|
+
const showExemptedOption = exemptionIsPossible && !!registrationNumberOptions && registrationNumberOptions.length > 1;
|
|
24060
|
+
const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
|
|
24061
|
+
if (regNumberType === "exempted") {
|
|
24062
|
+
if (!exemptionIsPossible) {
|
|
24063
|
+
throw Error(`${country2} does not allow tax exemptions`);
|
|
24064
|
+
}
|
|
24065
|
+
handleChangeFor("exemptedFromRegistrationNumber")(true);
|
|
24066
|
+
setRegistrationNumberType(void 0);
|
|
24067
|
+
return;
|
|
24068
|
+
}
|
|
24069
|
+
if (exemptionIsPossible && data.exemptedFromRegistrationNumber === true) {
|
|
24070
|
+
handleChangeFor("exemptedFromRegistrationNumber")(false);
|
|
24071
|
+
}
|
|
24072
|
+
setRegistrationNumberType(regNumberType);
|
|
24073
|
+
};
|
|
24074
|
+
return jsxs("div", {
|
|
24075
|
+
className: "adyen-kyc-field__business-registration adyen-kyc-u-margin-bottom-16",
|
|
24076
|
+
children: [jsx(StateContextSetter, {
|
|
24077
|
+
stateRef
|
|
24078
|
+
}), jsx(CompanyRegistrationNumberTypeSelector, {
|
|
24079
|
+
companyType: companyType2,
|
|
24080
|
+
country: country2,
|
|
24081
|
+
setSelected: handleCompanyRegistrationNumberTypeChange,
|
|
24082
|
+
selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
|
|
24083
|
+
exemptedOption: showExemptedOption ? formUtils.getLabel("exemptedFromRegistrationNumber", "iDontHaveARegistrationNumber") : false
|
|
24084
|
+
}), jsx(MaskedInputText, {
|
|
24085
|
+
name: "registrationNumber",
|
|
24086
|
+
label: formUtils.getLabel("registrationNumber", "companyRegistrationNumber"),
|
|
24087
|
+
formatGuidance: formUtils.getGuidanceText("registrationNumber"),
|
|
24088
|
+
classNameModifiers: {
|
|
24089
|
+
field: ["registrationNumber"],
|
|
24090
|
+
input: ["registrationNumber"]
|
|
24091
|
+
},
|
|
24092
|
+
errorMessage: formUtils.getErrorMessage("registrationNumber", errors, fieldProblems),
|
|
24093
|
+
shouldValidate: props.shouldValidate,
|
|
24094
|
+
isValid: valid.registrationNumber,
|
|
24095
|
+
"aria-required": formUtils.isRequiredField("registrationNumber"),
|
|
24096
|
+
"aria-label": formUtils.getLabel("registrationNumber"),
|
|
24097
|
+
"aria-invalid": !valid.registrationNumber,
|
|
24098
|
+
disabled: data.exemptedFromRegistrationNumber,
|
|
24099
|
+
onBlur: handleChangeFor("registrationNumber", "blur"),
|
|
24100
|
+
readonly: formUtils.isReadOnly("registrationNumber"),
|
|
24101
|
+
value: data.registrationNumber ?? "",
|
|
24102
|
+
onInput: handleChangeFor("registrationNumber", "input"),
|
|
24103
|
+
...formUtils.getMask("registrationNumber")
|
|
24104
|
+
}), formUtils.isRequiredField("exemptedFromRegistrationNumber") && !showExemptedOption && jsx(Checkbox, {
|
|
24105
|
+
name: "exemptedFromRegistrationNumber",
|
|
24106
|
+
label: formUtils.getLabel("iDontHaveARegistrationNumber"),
|
|
24107
|
+
value: "exemptedFromRegistrationNumber",
|
|
24108
|
+
readonly: formUtils.isReadOnly("exemptedFromRegistrationNumber"),
|
|
24109
|
+
classNameModifiers: ["exempted-from-registration"],
|
|
24110
|
+
checked: data.exemptedFromRegistrationNumber ?? false,
|
|
24111
|
+
onChange: handleChangeFor("exemptedFromRegistrationNumber"),
|
|
24112
|
+
"aria-required": formUtils.isRequiredField("exemptedFromRegistrationNumber"),
|
|
24113
|
+
"aria-label": formUtils.getLabel("exemptedFromRegistrationNumber"),
|
|
24114
|
+
"aria-invalid": false
|
|
24115
|
+
})]
|
|
24116
|
+
});
|
|
24117
|
+
}
|
|
24118
|
+
const taxIdFields = ["taxId", "exemptedFromTax", "isUen"];
|
|
24119
|
+
function TaxId(props) {
|
|
24120
|
+
var _a, _b, _c;
|
|
24121
|
+
const {
|
|
24122
|
+
data: propData,
|
|
24123
|
+
country: country2,
|
|
24124
|
+
companyType: companyType2,
|
|
24125
|
+
fieldValidationErrors,
|
|
24126
|
+
dataStoreId,
|
|
24127
|
+
fieldConfig = defaultFieldConfig$8
|
|
24128
|
+
} = props;
|
|
24129
|
+
const existingTaxId = propData == null ? void 0 : propData.taxId;
|
|
24130
|
+
const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, companyType2) : (_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id;
|
|
24131
|
+
const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
|
|
24132
|
+
const metadata = resolveFieldMetadata(fieldConfig[country2], {
|
|
24133
|
+
taxIdNumberType,
|
|
24134
|
+
companyType: companyType2
|
|
24135
|
+
}, defaultFieldMetadata$8);
|
|
24136
|
+
const mergedProps = mergeFieldMetadataIntoProps("taxId", metadata, props);
|
|
24137
|
+
const {
|
|
24138
|
+
i18n
|
|
24139
|
+
} = useI18nContext();
|
|
24140
|
+
const formUtils = formUtilities(mergedProps, i18n);
|
|
24141
|
+
const stateRef = useRef({
|
|
24142
|
+
setState: null
|
|
24143
|
+
});
|
|
24144
|
+
const {
|
|
24145
|
+
handleChangeFor,
|
|
24146
|
+
data,
|
|
24147
|
+
valid,
|
|
24148
|
+
errors,
|
|
24149
|
+
isValid,
|
|
24150
|
+
fieldProblems
|
|
24151
|
+
} = useForm({
|
|
24152
|
+
...mergedProps,
|
|
24153
|
+
schema: (data2) => formUtils.isRequiredField("isUen") ? ["taxId", "isUen"] : data2.exemptedFromTax ? ["exemptedFromTax"] : ["taxId", "exemptedFromTax"],
|
|
24154
|
+
rules: mergedProps.validators,
|
|
24155
|
+
defaultData: {
|
|
24156
|
+
...propData,
|
|
24157
|
+
exemptedFromTax: Boolean(propData == null ? void 0 : propData.exemptedFromTax),
|
|
24158
|
+
// exemptedFromTax should be a boolean
|
|
24159
|
+
isUen: formUtils.isRequiredField("isUen") ? Boolean(propData == null ? void 0 : propData.isUen) : void 0
|
|
24160
|
+
},
|
|
24161
|
+
fieldProblems: fieldValidationErrors
|
|
24162
|
+
});
|
|
24163
|
+
useEffect(() => {
|
|
24164
|
+
if (data.taxId || taxIdNumberType) {
|
|
24165
|
+
handleChangeFor("taxId", "blur")(data.taxId);
|
|
24166
|
+
}
|
|
24167
|
+
}, [taxIdNumberType, country2]);
|
|
24168
|
+
useEffect(() => {
|
|
24169
|
+
var _a2, _b2;
|
|
24170
|
+
(_b2 = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
|
|
24171
|
+
type: "addToState",
|
|
24172
|
+
value: {
|
|
24173
|
+
data,
|
|
24174
|
+
valid,
|
|
24175
|
+
errors,
|
|
24176
|
+
caller: "taxId",
|
|
24177
|
+
dataStoreId
|
|
24178
|
+
}
|
|
24179
|
+
});
|
|
24180
|
+
}, [data, valid, errors, isValid, dataStoreId]);
|
|
24181
|
+
const {
|
|
24182
|
+
sliceData: companyRegistrationDetails
|
|
24183
|
+
} = useGlobalDataSlice("companyRegistrationDetails");
|
|
24184
|
+
const registrationNumber2 = companyRegistrationDetails == null ? void 0 : companyRegistrationDetails.registrationNumber;
|
|
24185
|
+
const handleUenOrGstChange = (isUen) => {
|
|
24186
|
+
handleChangeFor("isUen", "input")(isUen);
|
|
24187
|
+
if (isUen) {
|
|
24188
|
+
handleChangeFor("taxId", "blur")(registrationNumber2);
|
|
24189
|
+
return;
|
|
24190
|
+
}
|
|
24191
|
+
handleChangeFor("taxId", "blur")("");
|
|
24192
|
+
};
|
|
24193
|
+
useEffect(() => {
|
|
24194
|
+
if (data.isUen) {
|
|
24195
|
+
handleChangeFor("taxId", "blur")(registrationNumber2);
|
|
24196
|
+
}
|
|
24197
|
+
}, [registrationNumber2]);
|
|
24198
|
+
if (!formUtils.isRequiredField("taxId")) {
|
|
24199
|
+
return null;
|
|
24200
|
+
}
|
|
24201
|
+
const exemptionIsPossible = ((_b = mergedProps.requiredFields) == null ? void 0 : _b.includes("exemptedFromTax")) ?? false;
|
|
24202
|
+
const showTaxIdExemptedOption = exemptionIsPossible && (((_c = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _c.length) ?? 0) > 1;
|
|
24203
|
+
const handleTaxIdNumberTypeChange = (taxIdType) => {
|
|
24204
|
+
if (taxIdType === "exempted") {
|
|
24205
|
+
if (!exemptionIsPossible) {
|
|
24206
|
+
throw Error(`${country2} does not allow tax exemptions`);
|
|
24207
|
+
}
|
|
24208
|
+
handleChangeFor("exemptedFromTax")(true);
|
|
24209
|
+
setTaxIdNumberType(void 0);
|
|
24210
|
+
return;
|
|
24211
|
+
}
|
|
24212
|
+
if (exemptionIsPossible && data.exemptedFromTax === true) {
|
|
24213
|
+
handleChangeFor("exemptedFromTax")(false);
|
|
24214
|
+
}
|
|
24215
|
+
setTaxIdNumberType(taxIdType);
|
|
24216
|
+
};
|
|
24217
|
+
return jsxs("div", {
|
|
24218
|
+
className: "adyen-kyc-field--tax-id",
|
|
24219
|
+
children: [jsx(StateContextSetter, {
|
|
24220
|
+
stateRef
|
|
24221
|
+
}), jsx(TaxIdNumberTypeSelector, {
|
|
24222
|
+
country: country2,
|
|
24223
|
+
companyType: companyType2,
|
|
24224
|
+
setSelected: handleTaxIdNumberTypeChange,
|
|
24225
|
+
selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
|
|
24226
|
+
exemptedOption: showTaxIdExemptedOption ? formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId") : false
|
|
24227
|
+
}), !data.isUen && jsx(MaskedInputText, {
|
|
24228
|
+
name: "taxId",
|
|
24229
|
+
label: formUtils.getLabel("taxId"),
|
|
24230
|
+
formatGuidance: formUtils.getGuidanceText("taxId"),
|
|
24231
|
+
...formUtils.getMask("taxId"),
|
|
24232
|
+
classNameModifiers: {
|
|
24233
|
+
field: ["tax-id"],
|
|
24234
|
+
input: ["tax-id"]
|
|
24235
|
+
},
|
|
24236
|
+
errorMessage: formUtils.getErrorMessage("taxId", errors, fieldProblems),
|
|
24237
|
+
shouldValidate: props.shouldValidate,
|
|
24238
|
+
isValid: valid.taxId,
|
|
24239
|
+
value: data.taxId ?? "",
|
|
24240
|
+
readonly: formUtils.isReadOnly("taxId"),
|
|
24241
|
+
onInput: handleChangeFor("taxId", "input"),
|
|
24242
|
+
onBlur: handleChangeFor("taxId", "blur"),
|
|
24243
|
+
disabled: data.exemptedFromTax || data.isUen
|
|
24244
|
+
}), formUtils.isRequiredField("isUen") && jsx(Checkbox, {
|
|
24245
|
+
name: "isUen",
|
|
24246
|
+
label: formUtils.getLabel("iDoNotHaveGst"),
|
|
24247
|
+
classNameModifiers: ["exempted-from-tax"],
|
|
24248
|
+
checked: Boolean(data.isUen),
|
|
24249
|
+
onChange: handleUenOrGstChange,
|
|
24250
|
+
"aria-required": false,
|
|
24251
|
+
"aria-label": formUtils.getLabel("iDoNotHaveGst"),
|
|
24252
|
+
"aria-invalid": false
|
|
24253
|
+
}), formUtils.isRequiredField("exemptedFromTax") && !showTaxIdExemptedOption && jsx(Checkbox, {
|
|
24254
|
+
name: "exemptedFromTax",
|
|
24255
|
+
label: formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId"),
|
|
24256
|
+
value: "exemptedFromTax",
|
|
24257
|
+
readonly: formUtils.isReadOnly("exemptedFromTax"),
|
|
24258
|
+
classNameModifiers: ["exempted-from-tax"],
|
|
24259
|
+
checked: Boolean(data.exemptedFromTax),
|
|
24260
|
+
onChange: handleChangeFor("exemptedFromTax"),
|
|
24261
|
+
"aria-required": false,
|
|
24262
|
+
"aria-label": formUtils.getLabel("exemptedFromTax"),
|
|
24263
|
+
"aria-invalid": false
|
|
24264
|
+
})]
|
|
24265
|
+
});
|
|
24266
|
+
}
|
|
23912
24267
|
const trustRegistrationDetailsValidations = {
|
|
23913
24268
|
trustType: {
|
|
23914
24269
|
modes: ["blur"],
|
|
@@ -25927,127 +26282,6 @@ const getFieldsWithExistingData = (legalEntity, isExperimentEnabled) => {
|
|
|
25927
26282
|
}
|
|
25928
26283
|
return nonDocumentFields;
|
|
25929
26284
|
};
|
|
25930
|
-
const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
|
|
25931
|
-
function BusinessRegistrationNumberField({
|
|
25932
|
-
data,
|
|
25933
|
-
valid,
|
|
25934
|
-
errors,
|
|
25935
|
-
labels: labels2,
|
|
25936
|
-
mask,
|
|
25937
|
-
guidanceText,
|
|
25938
|
-
placeholders,
|
|
25939
|
-
readonly,
|
|
25940
|
-
shouldValidate,
|
|
25941
|
-
optional: optional2,
|
|
25942
|
-
handleChangeFor,
|
|
25943
|
-
country: country2,
|
|
25944
|
-
canExempt,
|
|
25945
|
-
companyType: companyType2,
|
|
25946
|
-
registrationNumberOptions,
|
|
25947
|
-
registrationNumberType,
|
|
25948
|
-
setRegistrationNumberType
|
|
25949
|
-
}) {
|
|
25950
|
-
const showExemptedOption = canExempt && !!registrationNumberOptions && registrationNumberOptions.length > 1;
|
|
25951
|
-
const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
|
|
25952
|
-
if (regNumberType === "exempted") {
|
|
25953
|
-
if (!canExempt) {
|
|
25954
|
-
throw Error(`${country2} does not allow tax exemptions`);
|
|
25955
|
-
}
|
|
25956
|
-
handleChangeFor("exemptedFromRegistrationNumber")(true);
|
|
25957
|
-
setRegistrationNumberType(void 0);
|
|
25958
|
-
return;
|
|
25959
|
-
}
|
|
25960
|
-
if (canExempt && data.exemptedFromRegistrationNumber === true) {
|
|
25961
|
-
handleChangeFor("exemptedFromRegistrationNumber")(false);
|
|
25962
|
-
}
|
|
25963
|
-
setRegistrationNumberType(regNumberType);
|
|
25964
|
-
};
|
|
25965
|
-
return jsxs("div", {
|
|
25966
|
-
className: "adyen-kyc-field__business-registration",
|
|
25967
|
-
children: [jsx(CompanyRegistrationNumberTypeSelector, {
|
|
25968
|
-
companyType: companyType2,
|
|
25969
|
-
country: country2,
|
|
25970
|
-
setSelected: handleCompanyRegistrationNumberTypeChange,
|
|
25971
|
-
selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
|
|
25972
|
-
exemptedOption: showExemptedOption ? labels2.exemptedFromRegistrationNumber : false
|
|
25973
|
-
}), jsx(MaskedInputText, {
|
|
25974
|
-
"aria-required": true,
|
|
25975
|
-
"aria-label": labels2.registrationNumber,
|
|
25976
|
-
"aria-invalid": !valid.registrationNumber,
|
|
25977
|
-
classNameModifiers: {
|
|
25978
|
-
field: ["registrationNumber"],
|
|
25979
|
-
input: ["registrationNumber"]
|
|
25980
|
-
},
|
|
25981
|
-
name: "registrationNumber",
|
|
25982
|
-
value: (data == null ? void 0 : data.registrationNumber) ?? "",
|
|
25983
|
-
label: labels2.registrationNumber ?? "",
|
|
25984
|
-
formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
|
|
25985
|
-
placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
|
|
25986
|
-
errorMessage: errors.registrationNumber,
|
|
25987
|
-
isValid: Boolean(valid.registrationNumber),
|
|
25988
|
-
onInput: handleChangeFor("registrationNumber", "input"),
|
|
25989
|
-
onBlur: handleChangeFor("registrationNumber", "blur"),
|
|
25990
|
-
disabled: data.exemptedFromRegistrationNumber,
|
|
25991
|
-
optional: optional2,
|
|
25992
|
-
readonly,
|
|
25993
|
-
shouldValidate: !optional2 && shouldValidate,
|
|
25994
|
-
...mask
|
|
25995
|
-
}), canExempt && jsx(Checkbox, {
|
|
25996
|
-
"aria-required": false,
|
|
25997
|
-
"aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
|
|
25998
|
-
"aria-invalid": false,
|
|
25999
|
-
name: "exemptedFromRegistrationNumber",
|
|
26000
|
-
value: "exemptedFromRegistrationNumber",
|
|
26001
|
-
checked: Boolean(data.exemptedFromRegistrationNumber),
|
|
26002
|
-
label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
|
|
26003
|
-
readonly,
|
|
26004
|
-
classNameModifiers: ["exempted-from-registration"],
|
|
26005
|
-
onChange: handleChangeFor("exemptedFromRegistrationNumber")
|
|
26006
|
-
})]
|
|
26007
|
-
});
|
|
26008
|
-
}
|
|
26009
|
-
const DATE_OF_INCORPORATION_FIELD = ["dateOfIncorporation"];
|
|
26010
|
-
function DateOfIncorporationField({
|
|
26011
|
-
data,
|
|
26012
|
-
valid,
|
|
26013
|
-
errors,
|
|
26014
|
-
labels: labels2,
|
|
26015
|
-
placeholders,
|
|
26016
|
-
readonly,
|
|
26017
|
-
handleChangeFor
|
|
26018
|
-
}) {
|
|
26019
|
-
return jsx(Field, {
|
|
26020
|
-
name: "dateOfIncorporation",
|
|
26021
|
-
label: labels2.dateOfIncorporation,
|
|
26022
|
-
classNameModifiers: ["dateOfIncorporation"],
|
|
26023
|
-
errorMessage: errors.dateOfIncorporation,
|
|
26024
|
-
isValid: valid.dateOfIncorporation,
|
|
26025
|
-
children: (childProps) => jsx(InputDate, {
|
|
26026
|
-
...childProps,
|
|
26027
|
-
"aria-required": true,
|
|
26028
|
-
"aria-label": labels2.dateOfIncorporation,
|
|
26029
|
-
"aria-invalid": !valid.dateOfIncorporation,
|
|
26030
|
-
name: "dateOfIncorporation",
|
|
26031
|
-
value: data.dateOfIncorporation,
|
|
26032
|
-
placeholder: placeholders == null ? void 0 : placeholders.dateOfIncorporation,
|
|
26033
|
-
readonly,
|
|
26034
|
-
onInput: handleChangeFor("dateOfIncorporation", "input"),
|
|
26035
|
-
onBlur: handleChangeFor("dateOfIncorporation", "blur"),
|
|
26036
|
-
max: formatDateObj(/* @__PURE__ */ new Date())
|
|
26037
|
-
})
|
|
26038
|
-
});
|
|
26039
|
-
}
|
|
26040
|
-
const DateOfIncorporationFieldValidation = () => ({
|
|
26041
|
-
dateOfIncorporation: [{
|
|
26042
|
-
modes: ["blur"],
|
|
26043
|
-
validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
|
|
26044
|
-
errorMessage: "fieldIsRequired"
|
|
26045
|
-
}, {
|
|
26046
|
-
modes: ["blur"],
|
|
26047
|
-
validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
|
|
26048
|
-
errorMessage: "invalidDateOfIncorporation"
|
|
26049
|
-
}]
|
|
26050
|
-
});
|
|
26051
26285
|
const DBA_NAME_FIELD = ["hasDba", "dbaName"];
|
|
26052
26286
|
function DBANameField({
|
|
26053
26287
|
data,
|
|
@@ -26116,207 +26350,6 @@ const dbaNameFieldMetadata = {
|
|
|
26116
26350
|
label: "dbaName",
|
|
26117
26351
|
validators: [validateNotEmptyOnBlur]
|
|
26118
26352
|
};
|
|
26119
|
-
const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
|
|
26120
|
-
function TaxInformationField({
|
|
26121
|
-
data,
|
|
26122
|
-
valid,
|
|
26123
|
-
errors,
|
|
26124
|
-
labels: labels2,
|
|
26125
|
-
mask,
|
|
26126
|
-
guidanceText,
|
|
26127
|
-
placeholders,
|
|
26128
|
-
readonly,
|
|
26129
|
-
shouldValidate,
|
|
26130
|
-
handleChangeFor,
|
|
26131
|
-
country: country2,
|
|
26132
|
-
canExempt,
|
|
26133
|
-
registrationNumber: registrationNumber2,
|
|
26134
|
-
isUen,
|
|
26135
|
-
companyType: companyType2,
|
|
26136
|
-
taxIdNumberType,
|
|
26137
|
-
setTaxIdNumberType,
|
|
26138
|
-
defaultData
|
|
26139
|
-
}) {
|
|
26140
|
-
var _a;
|
|
26141
|
-
useEffect(() => {
|
|
26142
|
-
handleChangeFor("taxInformation", "input")(defaultData);
|
|
26143
|
-
}, [country2]);
|
|
26144
|
-
const currentCountryTaxInformation = useMemo(() => {
|
|
26145
|
-
var _a2;
|
|
26146
|
-
return (_a2 = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a2.find((taxInfo) => taxInfo.country === country2);
|
|
26147
|
-
}, [data, country2]);
|
|
26148
|
-
const showTaxIdExemptedOption = canExempt && (((_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a.length) ?? 0) > 1;
|
|
26149
|
-
const removeCurrentCountryTaxInformation = () => {
|
|
26150
|
-
var _a2;
|
|
26151
|
-
const filterdTaxInformation = (_a2 = data.taxInformation) == null ? void 0 : _a2.filter((taxId2) => taxId2.country !== country2);
|
|
26152
|
-
handleChangeFor("taxInformation", "input")(filterdTaxInformation);
|
|
26153
|
-
};
|
|
26154
|
-
const setUenAsTaxId = (uen2) => {
|
|
26155
|
-
if (!data.taxInformation) {
|
|
26156
|
-
return handleChangeFor("taxInformation", "blur")([{
|
|
26157
|
-
country: country2,
|
|
26158
|
-
number: uen2 ?? "",
|
|
26159
|
-
type: "UEN"
|
|
26160
|
-
}]);
|
|
26161
|
-
}
|
|
26162
|
-
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
26163
|
-
country: country2,
|
|
26164
|
-
number: uen2 ?? "",
|
|
26165
|
-
type: "UEN"
|
|
26166
|
-
}];
|
|
26167
|
-
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
26168
|
-
if (taxInfo.country !== country2) return taxInfo;
|
|
26169
|
-
return {
|
|
26170
|
-
country: country2,
|
|
26171
|
-
number: uen2 ?? "",
|
|
26172
|
-
type: "UEN"
|
|
26173
|
-
};
|
|
26174
|
-
});
|
|
26175
|
-
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
|
|
26176
|
-
};
|
|
26177
|
-
const handleTaxInformationInput = (value) => {
|
|
26178
|
-
if (!data.taxInformation) {
|
|
26179
|
-
const updatedTaxInformation2 = [{
|
|
26180
|
-
country: country2,
|
|
26181
|
-
number: value,
|
|
26182
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26183
|
-
}];
|
|
26184
|
-
return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
|
|
26185
|
-
}
|
|
26186
|
-
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
26187
|
-
country: country2,
|
|
26188
|
-
number: value,
|
|
26189
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26190
|
-
}];
|
|
26191
|
-
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
26192
|
-
if (taxInfo.country !== country2) return taxInfo;
|
|
26193
|
-
return {
|
|
26194
|
-
country: country2,
|
|
26195
|
-
number: value,
|
|
26196
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26197
|
-
};
|
|
26198
|
-
});
|
|
26199
|
-
return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
|
|
26200
|
-
};
|
|
26201
|
-
const handleTaxInformationBlur = (e) => {
|
|
26202
|
-
const {
|
|
26203
|
-
value
|
|
26204
|
-
} = e.target;
|
|
26205
|
-
if (!data.taxInformation) {
|
|
26206
|
-
const updatedTaxInformation2 = [{
|
|
26207
|
-
country: country2,
|
|
26208
|
-
number: value,
|
|
26209
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26210
|
-
}];
|
|
26211
|
-
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
|
|
26212
|
-
}
|
|
26213
|
-
const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
|
|
26214
|
-
country: country2,
|
|
26215
|
-
number: value,
|
|
26216
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26217
|
-
}];
|
|
26218
|
-
const updatedTaxInformation = taxInformation.map((taxInfo) => {
|
|
26219
|
-
if (taxInfo.country !== country2) return taxInfo;
|
|
26220
|
-
return {
|
|
26221
|
-
country: country2,
|
|
26222
|
-
number: value,
|
|
26223
|
-
type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
|
|
26224
|
-
};
|
|
26225
|
-
});
|
|
26226
|
-
return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
|
|
26227
|
-
};
|
|
26228
|
-
const handleTaxIdNumberTypeChange = (taxIdType) => {
|
|
26229
|
-
if (taxIdType === "exempted") {
|
|
26230
|
-
if (!canExempt) {
|
|
26231
|
-
throw Error(`${country2} does not allow tax exemptions`);
|
|
26232
|
-
}
|
|
26233
|
-
handleChangeFor("exemptedFromTax")(true);
|
|
26234
|
-
removeCurrentCountryTaxInformation();
|
|
26235
|
-
setTaxIdNumberType(void 0);
|
|
26236
|
-
return;
|
|
26237
|
-
}
|
|
26238
|
-
if (isUen) {
|
|
26239
|
-
if (taxIdType === "UEN") {
|
|
26240
|
-
handleChangeFor("isUen")(true);
|
|
26241
|
-
setUenAsTaxId(registrationNumber2);
|
|
26242
|
-
} else {
|
|
26243
|
-
handleChangeFor("isUen")(false);
|
|
26244
|
-
removeCurrentCountryTaxInformation();
|
|
26245
|
-
}
|
|
26246
|
-
}
|
|
26247
|
-
if (canExempt && data.exemptedFromTax === true) {
|
|
26248
|
-
handleChangeFor("exemptedFromTax")(false);
|
|
26249
|
-
}
|
|
26250
|
-
setTaxIdNumberType(taxIdType);
|
|
26251
|
-
};
|
|
26252
|
-
const handleExemptedFromTaxChange = (exempted) => {
|
|
26253
|
-
handleChangeFor("exemptedFromTax")(exempted);
|
|
26254
|
-
removeCurrentCountryTaxInformation();
|
|
26255
|
-
};
|
|
26256
|
-
return jsxs("div", {
|
|
26257
|
-
className: "adyen-kyc-field__tax-information",
|
|
26258
|
-
children: [jsx(TaxIdNumberTypeSelector, {
|
|
26259
|
-
country: country2,
|
|
26260
|
-
companyType: companyType2,
|
|
26261
|
-
setSelected: handleTaxIdNumberTypeChange,
|
|
26262
|
-
selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
|
|
26263
|
-
exemptedOption: showTaxIdExemptedOption ? labels2.exemptedFromTax : false
|
|
26264
|
-
}), !data.isUen && jsx(MaskedInputText, {
|
|
26265
|
-
"aria-required": true,
|
|
26266
|
-
"aria-label": labels2.taxInformation,
|
|
26267
|
-
"aria-invalid": !valid.taxInformation,
|
|
26268
|
-
name: "taxInformationNumber",
|
|
26269
|
-
label: labels2.taxInformation ?? "",
|
|
26270
|
-
formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
|
|
26271
|
-
value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
|
|
26272
|
-
errorMessage: errors.taxInformation,
|
|
26273
|
-
placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
|
|
26274
|
-
isValid: Boolean(valid.taxInformation) && !!currentCountryTaxInformation,
|
|
26275
|
-
onInput: handleTaxInformationInput,
|
|
26276
|
-
onBlur: handleTaxInformationBlur,
|
|
26277
|
-
disabled: data.exemptedFromTax || data.isUen,
|
|
26278
|
-
readonly,
|
|
26279
|
-
shouldValidate,
|
|
26280
|
-
...mask
|
|
26281
|
-
}), canExempt && !showTaxIdExemptedOption && jsx(Checkbox, {
|
|
26282
|
-
"aria-required": false,
|
|
26283
|
-
"aria-label": labels2.exemptedFromTax,
|
|
26284
|
-
"aria-invalid": false,
|
|
26285
|
-
name: "exemptedFromTax",
|
|
26286
|
-
label: labels2.exemptedFromTax,
|
|
26287
|
-
value: "exemptedFromTax",
|
|
26288
|
-
classNameModifiers: ["exempted-from-tax"],
|
|
26289
|
-
checked: Boolean(data.exemptedFromTax),
|
|
26290
|
-
onChange: handleExemptedFromTaxChange
|
|
26291
|
-
})]
|
|
26292
|
-
});
|
|
26293
|
-
}
|
|
26294
|
-
const defaultFieldMetadata$1 = defaultFieldMetadata$8;
|
|
26295
|
-
const defaultFieldConfig$1 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig, [country2, countryEntry]) => ({
|
|
26296
|
-
...fieldConfig,
|
|
26297
|
-
[country2]: ({
|
|
26298
|
-
taxIdNumberType,
|
|
26299
|
-
companyType: companyType2
|
|
26300
|
-
}) => {
|
|
26301
|
-
const fieldMetadata = resolveFieldMetadata(countryEntry, {
|
|
26302
|
-
taxIdNumberType,
|
|
26303
|
-
companyType: companyType2
|
|
26304
|
-
}, defaultFieldMetadata$8);
|
|
26305
|
-
const taxIdValidators = fieldMetadata.validators ? Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators] : [];
|
|
26306
|
-
const mappedValidators = taxIdValidators.map((validator) => ({
|
|
26307
|
-
...validator,
|
|
26308
|
-
validate: (taxInformation) => {
|
|
26309
|
-
var _a;
|
|
26310
|
-
const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
|
|
26311
|
-
return taxIdNumber2 ? validator.validate(taxIdNumber2) : false;
|
|
26312
|
-
}
|
|
26313
|
-
}));
|
|
26314
|
-
return {
|
|
26315
|
-
...fieldMetadata,
|
|
26316
|
-
validators: mappedValidators
|
|
26317
|
-
};
|
|
26318
|
-
}
|
|
26319
|
-
}), {});
|
|
26320
26353
|
function VerifiedBusinessCard({
|
|
26321
26354
|
verifiedBusiness
|
|
26322
26355
|
}) {
|
|
@@ -26446,7 +26479,20 @@ function AdditionalInformationComponent({
|
|
|
26446
26479
|
if (currentData.exemptedFromVat) {
|
|
26447
26480
|
fieldsToRemove.push("vatNumber");
|
|
26448
26481
|
} else {
|
|
26449
|
-
fieldsToRemove.push("vatAbsenceReason");
|
|
26482
|
+
fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
|
|
26483
|
+
}
|
|
26484
|
+
if (currentData.exemptedFromTax) {
|
|
26485
|
+
fieldsToRemove.push("taxInformation");
|
|
26486
|
+
} else {
|
|
26487
|
+
fieldsToRemove.push("exemptedFromTax");
|
|
26488
|
+
}
|
|
26489
|
+
if (currentData.isUen) {
|
|
26490
|
+
fieldsToRemove.push("taxInformation", "exemptedFromTax");
|
|
26491
|
+
}
|
|
26492
|
+
if (currentData.exemptedFromRegistrationNumber) {
|
|
26493
|
+
fieldsToRemove.push("registrationNumber");
|
|
26494
|
+
} else {
|
|
26495
|
+
fieldsToRemove.push("exemptedFromRegistrationNumber");
|
|
26450
26496
|
}
|
|
26451
26497
|
if (!currentData.hasDba) {
|
|
26452
26498
|
fieldsToRemove.push("dbaName");
|
|
@@ -26471,9 +26517,9 @@ function AdditionalInformationComponent({
|
|
|
26471
26517
|
registrationNumberType
|
|
26472
26518
|
}, defaultFieldMetadata$9), acc);
|
|
26473
26519
|
case "taxInformation":
|
|
26474
|
-
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$
|
|
26520
|
+
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
26475
26521
|
taxIdNumberType
|
|
26476
|
-
}, defaultFieldMetadata$
|
|
26522
|
+
}, defaultFieldMetadata$6), acc);
|
|
26477
26523
|
case "vatNumber":
|
|
26478
26524
|
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
|
|
26479
26525
|
vatNumberType
|
|
@@ -26481,13 +26527,7 @@ function AdditionalInformationComponent({
|
|
|
26481
26527
|
case "vatAbsenceReason":
|
|
26482
26528
|
return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
|
|
26483
26529
|
case "dateOfIncorporation":
|
|
26484
|
-
return
|
|
26485
|
-
...acc,
|
|
26486
|
-
validators: {
|
|
26487
|
-
...acc.validators,
|
|
26488
|
-
...DateOfIncorporationFieldValidation()
|
|
26489
|
-
}
|
|
26490
|
-
};
|
|
26530
|
+
return mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, acc);
|
|
26491
26531
|
case "stockExchangeMIC":
|
|
26492
26532
|
return mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, acc);
|
|
26493
26533
|
case "stockISIN":
|
|
@@ -26873,9 +26913,9 @@ function BasicInformationComponent({
|
|
|
26873
26913
|
state: sliceData == null ? void 0 : sliceData.stateOrProvince
|
|
26874
26914
|
}, defaultFieldMetadata$9), acc);
|
|
26875
26915
|
case "taxInformation":
|
|
26876
|
-
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$
|
|
26916
|
+
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
26877
26917
|
taxIdNumberType
|
|
26878
|
-
}, defaultFieldMetadata$
|
|
26918
|
+
}, defaultFieldMetadata$6), acc);
|
|
26879
26919
|
default:
|
|
26880
26920
|
return acc;
|
|
26881
26921
|
}
|
|
@@ -29031,11 +29071,11 @@ const formatBasicInformation = (data, labels2, datasetUtils, companyType2) => {
|
|
|
29031
29071
|
companyType: companyType2,
|
|
29032
29072
|
registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country2, companyType2) : (_a = getCompanyRegistrationNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id
|
|
29033
29073
|
}, defaultFieldMetadata$9).label;
|
|
29034
|
-
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$
|
|
29074
|
+
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
29035
29075
|
taxIdNumberType: countryToTaxInfoTypeMap[country2] ?? void 0,
|
|
29036
29076
|
// TODO use type selector
|
|
29037
29077
|
companyType: void 0
|
|
29038
|
-
}, defaultFieldMetadata$
|
|
29078
|
+
}, defaultFieldMetadata$6).label;
|
|
29039
29079
|
return {
|
|
29040
29080
|
[((_b = labels2 == null ? void 0 : labels2.basicInformation) == null ? void 0 : _b.country) ?? "country"]: datasetUtils.getCountryName(data.country),
|
|
29041
29081
|
[getKeyForField("stateOrProvince", data.country)]: datasetUtils.getStateName(data.stateOrProvince, data.country),
|
|
@@ -29049,11 +29089,11 @@ const formatAdditionalInformation = (data, labels2, country2, companyType2) => {
|
|
|
29049
29089
|
companyType: companyType2,
|
|
29050
29090
|
registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country2, companyType2) : (_a = getCompanyRegistrationNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id
|
|
29051
29091
|
}, defaultFieldMetadata$9).label;
|
|
29052
|
-
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$
|
|
29092
|
+
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
29053
29093
|
taxIdNumberType: countryToTaxInfoTypeMap[country2] ?? void 0,
|
|
29054
29094
|
// TODO use type selector
|
|
29055
29095
|
companyType: void 0
|
|
29056
|
-
}, defaultFieldMetadata$
|
|
29096
|
+
}, defaultFieldMetadata$6).label;
|
|
29057
29097
|
return {
|
|
29058
29098
|
[((_b = labels2 == null ? void 0 : labels2.additionalInformation) == null ? void 0 : _b.legalCompanyName) ?? "legalCompanyName"]: data.legalCompanyName,
|
|
29059
29099
|
[((_c = labels2 == null ? void 0 : labels2.additionalInformation) == null ? void 0 : _c.dbaName) ?? "dbaName"]: data.dbaName,
|
|
@@ -29879,7 +29919,7 @@ function CompanyDropinComponent({
|
|
|
29879
29919
|
}, []);
|
|
29880
29920
|
const datasetUtils = datasetUtilities(i18n.locale);
|
|
29881
29921
|
const formatDataForSummary2 = (data2, forms22) => {
|
|
29882
|
-
var _a2, _b2, _c, _d, _e, _f;
|
|
29922
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
29883
29923
|
let summaryData = cloneObject(data2);
|
|
29884
29924
|
if (summaryData.companyNameAndCountry) {
|
|
29885
29925
|
if (isCountryOfGoverningLawEnabled) {
|
|
@@ -29910,6 +29950,16 @@ function CompanyDropinComponent({
|
|
|
29910
29950
|
summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason2);
|
|
29911
29951
|
}
|
|
29912
29952
|
}
|
|
29953
|
+
if ((_g = summaryData.companyRegistrationDetails) == null ? void 0 : _g.taxInformation) {
|
|
29954
|
+
const taxInformation = summaryData.companyRegistrationDetails.taxInformation.find((taxId2) => {
|
|
29955
|
+
var _a3;
|
|
29956
|
+
return taxId2.country === ((_a3 = data2.companyNameAndCountry) == null ? void 0 : _a3.country);
|
|
29957
|
+
});
|
|
29958
|
+
if (taxInformation) {
|
|
29959
|
+
summaryData.companyRegistrationDetails[taxInformation.type] = taxInformation.number;
|
|
29960
|
+
}
|
|
29961
|
+
delete summaryData.companyRegistrationDetails.taxInformation;
|
|
29962
|
+
}
|
|
29913
29963
|
if (isDocumentsRequired$2(forms22)) {
|
|
29914
29964
|
companyDocumentForms.forEach((formId) => delete summaryData[formId]);
|
|
29915
29965
|
summaryData = {
|
|
@@ -30420,10 +30470,10 @@ function CompanyBasics({
|
|
|
30420
30470
|
isBusiness: false
|
|
30421
30471
|
}, defaultFieldMetadata), acc);
|
|
30422
30472
|
case "taxInformation":
|
|
30423
|
-
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$
|
|
30473
|
+
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
30424
30474
|
taxIdNumberType,
|
|
30425
30475
|
companyType: companyType2
|
|
30426
|
-
}, defaultFieldMetadata$
|
|
30476
|
+
}, defaultFieldMetadata$6), acc);
|
|
30427
30477
|
default:
|
|
30428
30478
|
return acc;
|
|
30429
30479
|
}
|
|
@@ -30551,64 +30601,6 @@ function CompanyBasics({
|
|
|
30551
30601
|
});
|
|
30552
30602
|
}
|
|
30553
30603
|
const CompanyBasicsComponent = memo(CompanyBasics, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.placeholders, nextProps.placeholders) && objectsDeepEqual(prevProps.helperText, nextProps.helperText) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.heading === nextProps.heading && prevProps.description === nextProps.description && prevProps.readOnly === nextProps.readOnly && prevProps.requiredFields === nextProps.requiredFields && prevProps.obscuredFields === nextProps.obscuredFields && prevProps.optionalFields === nextProps.optionalFields && prevProps.readOnlyFields === nextProps.readOnlyFields && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.companyType === nextProps.companyType && objectsDeepEqual(prevProps.kompanyVerifiedData, nextProps.kompanyVerifiedData));
|
|
30554
|
-
const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
|
|
30555
|
-
function TradingNameField({
|
|
30556
|
-
data,
|
|
30557
|
-
valid,
|
|
30558
|
-
errors,
|
|
30559
|
-
labels: labels2,
|
|
30560
|
-
readonly,
|
|
30561
|
-
handleChangeFor,
|
|
30562
|
-
legalCompanyName: legalCompanyName2
|
|
30563
|
-
}) {
|
|
30564
|
-
const handleSameAsLegalName = useCallback((isChecked) => {
|
|
30565
|
-
handleChangeFor("sameNameAsLegalName", "input")(isChecked);
|
|
30566
|
-
if (isChecked) {
|
|
30567
|
-
handleChangeFor("tradingName")(legalCompanyName2);
|
|
30568
|
-
}
|
|
30569
|
-
}, [handleChangeFor, legalCompanyName2]);
|
|
30570
|
-
useEffect(() => {
|
|
30571
|
-
if (data.sameNameAsLegalName && data.tradingName && legalCompanyName2 && data.tradingName !== legalCompanyName2) {
|
|
30572
|
-
return handleChangeFor("tradingName")(legalCompanyName2);
|
|
30573
|
-
}
|
|
30574
|
-
}, [legalCompanyName2, data.sameNameAsLegalName, data.tradingName, handleChangeFor]);
|
|
30575
|
-
return jsxs(Fragment, {
|
|
30576
|
-
children: [jsx(Field, {
|
|
30577
|
-
name: "tradingNameField",
|
|
30578
|
-
label: labels2.tradingName,
|
|
30579
|
-
classNameModifiers: ["tradingName"],
|
|
30580
|
-
errorMessage: errors.tradingName,
|
|
30581
|
-
isValid: valid.tradingName,
|
|
30582
|
-
children: (childProps) => jsx(InputText, {
|
|
30583
|
-
...childProps,
|
|
30584
|
-
"aria-required": true,
|
|
30585
|
-
"aria-label": labels2.tradingName,
|
|
30586
|
-
"aria-invalid": !valid.tradingName,
|
|
30587
|
-
name: "tradingName",
|
|
30588
|
-
value: data.tradingName,
|
|
30589
|
-
readonly: readonly || data.sameNameAsLegalName,
|
|
30590
|
-
classNameModifiers: ["tradingName"],
|
|
30591
|
-
onInput: handleChangeFor("tradingName", "input"),
|
|
30592
|
-
onBlur: handleChangeFor("tradingName", "blur")
|
|
30593
|
-
})
|
|
30594
|
-
}), jsx(Checkbox, {
|
|
30595
|
-
"aria-required": false,
|
|
30596
|
-
"aria-label": labels2.sameNameAsLegalName,
|
|
30597
|
-
"aria-invalid": false,
|
|
30598
|
-
name: "sameNameAsLegalName",
|
|
30599
|
-
label: labels2.sameNameAsLegalName,
|
|
30600
|
-
checked: Boolean(data.sameNameAsLegalName),
|
|
30601
|
-
onChange: handleSameAsLegalName
|
|
30602
|
-
})]
|
|
30603
|
-
});
|
|
30604
|
-
}
|
|
30605
|
-
const TradingNameFieldValidation = () => ({
|
|
30606
|
-
tradingName: [{
|
|
30607
|
-
modes: ["blur"],
|
|
30608
|
-
validate: (tradingName2) => !isEmpty(tradingName2),
|
|
30609
|
-
errorMessage: "fieldIsRequired"
|
|
30610
|
-
}]
|
|
30611
|
-
});
|
|
30612
30604
|
const COMPANY_OTHER_DETAILS_FORM_ID = "companyOtherDetails";
|
|
30613
30605
|
const companyOtherDetailsFields = [...TRADING_NAME_FIELD, ...STOCK_EXCHANGE_MIC_FIELD, ...STOCK_ISIN_FIELD, ...STOCK_TICKER_SYMBOL_FIELD, ...DATE_OF_INCORPORATION_FIELD, ...BUSINESS_REGISTRATION_NUMBER_FIELD, ...TAX_INFORMATION_FIELD, ...VAT_NUMBER_FIELD];
|
|
30614
30606
|
function CompanyOtherDetails({
|
|
@@ -30646,7 +30638,6 @@ function CompanyOtherDetails({
|
|
|
30646
30638
|
const existingTaxId = (_c = (_b = data == null ? void 0 : data.taxInformation) == null ? void 0 : _b.find((taxId2) => taxId2.country === country2)) == null ? void 0 : _c.number;
|
|
30647
30639
|
const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, companyType2) : (_d = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _d[0].id;
|
|
30648
30640
|
const [taxIdNumberType, setTaxIdNumberType] = useState$1(defaultTaxIdNumberType);
|
|
30649
|
-
const directChildFields = companyOtherDetailsFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation"].includes(field));
|
|
30650
30641
|
const initialFormUtilsProps = useMemo$1(() => ({
|
|
30651
30642
|
allFields,
|
|
30652
30643
|
labels: labels2,
|
|
@@ -30664,21 +30655,9 @@ function CompanyOtherDetails({
|
|
|
30664
30655
|
return (_a2 = initialFormUtilsProps.allFields) == null ? void 0 : _a2.reduce((acc, field) => {
|
|
30665
30656
|
switch (field) {
|
|
30666
30657
|
case "tradingName":
|
|
30667
|
-
return
|
|
30668
|
-
...acc,
|
|
30669
|
-
validators: {
|
|
30670
|
-
...acc.validators,
|
|
30671
|
-
...TradingNameFieldValidation()
|
|
30672
|
-
}
|
|
30673
|
-
};
|
|
30658
|
+
return mergeFieldMetadataIntoProps("tradingName", tradingNameFieldMetadata, acc);
|
|
30674
30659
|
case "dateOfIncorporation":
|
|
30675
|
-
return
|
|
30676
|
-
...acc,
|
|
30677
|
-
validators: {
|
|
30678
|
-
...acc.validators,
|
|
30679
|
-
...DateOfIncorporationFieldValidation()
|
|
30680
|
-
}
|
|
30681
|
-
};
|
|
30660
|
+
return mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, acc);
|
|
30682
30661
|
case "stockExchangeMIC":
|
|
30683
30662
|
return mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, acc);
|
|
30684
30663
|
case "stockISIN":
|
|
@@ -30691,10 +30670,10 @@ function CompanyOtherDetails({
|
|
|
30691
30670
|
registrationNumberType
|
|
30692
30671
|
}, defaultFieldMetadata$9), acc);
|
|
30693
30672
|
case "taxInformation":
|
|
30694
|
-
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$
|
|
30673
|
+
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
30695
30674
|
taxIdNumberType,
|
|
30696
30675
|
companyType: companyType2
|
|
30697
|
-
}, defaultFieldMetadata$
|
|
30676
|
+
}, defaultFieldMetadata$6), acc);
|
|
30698
30677
|
case "vatNumber":
|
|
30699
30678
|
return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
|
|
30700
30679
|
vatNumberType
|
|
@@ -30706,6 +30685,32 @@ function CompanyOtherDetails({
|
|
|
30706
30685
|
}
|
|
30707
30686
|
}, initialFormUtilsProps);
|
|
30708
30687
|
}, [companyType2, country2, initialFormUtilsProps, registrationNumberType, taxIdNumberType, vatNumberType]);
|
|
30688
|
+
const getFormSchema2 = useCallback$1((currentData) => {
|
|
30689
|
+
var _a2;
|
|
30690
|
+
const fieldsToRemove = [];
|
|
30691
|
+
if (currentData.sameNameAsLegalName) {
|
|
30692
|
+
fieldsToRemove.push("tradingName");
|
|
30693
|
+
}
|
|
30694
|
+
if (currentData.exemptedFromVat) {
|
|
30695
|
+
fieldsToRemove.push("vatNumber");
|
|
30696
|
+
} else {
|
|
30697
|
+
fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
|
|
30698
|
+
}
|
|
30699
|
+
if (currentData.exemptedFromTax) {
|
|
30700
|
+
fieldsToRemove.push("taxInformation");
|
|
30701
|
+
} else {
|
|
30702
|
+
fieldsToRemove.push("exemptedFromTax");
|
|
30703
|
+
}
|
|
30704
|
+
if (currentData.isUen) {
|
|
30705
|
+
fieldsToRemove.push("taxInformation", "exemptedFromTax");
|
|
30706
|
+
}
|
|
30707
|
+
if (currentData.exemptedFromRegistrationNumber) {
|
|
30708
|
+
fieldsToRemove.push("registrationNumber");
|
|
30709
|
+
} else {
|
|
30710
|
+
fieldsToRemove.push("exemptedFromRegistrationNumber");
|
|
30711
|
+
}
|
|
30712
|
+
return ((_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.filter((field) => !fieldsToRemove.includes(field))) ?? TRADING_NAME_FIELD;
|
|
30713
|
+
}, [initialFormUtilsProps.requiredFields]);
|
|
30709
30714
|
const {
|
|
30710
30715
|
schema: formSchema,
|
|
30711
30716
|
data: formData,
|
|
@@ -30714,7 +30719,7 @@ function CompanyOtherDetails({
|
|
|
30714
30719
|
fieldProblems: formFieldProblems,
|
|
30715
30720
|
handleChangeFor
|
|
30716
30721
|
} = useForm({
|
|
30717
|
-
schema:
|
|
30722
|
+
schema: getFormSchema2,
|
|
30718
30723
|
defaultData: data,
|
|
30719
30724
|
rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
|
|
30720
30725
|
optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
|
|
@@ -30948,10 +30953,10 @@ const formatDataForSummary = (data, forms2, labels2, i18n) => {
|
|
|
30948
30953
|
var _a;
|
|
30949
30954
|
const datasetUtils = datasetUtilities(i18n.locale);
|
|
30950
30955
|
const country2 = (_a = data.companyBasics) == null ? void 0 : _a.country;
|
|
30951
|
-
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$
|
|
30956
|
+
const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
|
|
30952
30957
|
taxIdNumberType: countryToTaxInfoTypeMap[country2],
|
|
30953
30958
|
companyType: void 0
|
|
30954
|
-
}, defaultFieldMetadata$
|
|
30959
|
+
}, defaultFieldMetadata$6).label;
|
|
30955
30960
|
return entriesOf(data).reduce((summaryData, [form, formData]) => {
|
|
30956
30961
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
30957
30962
|
if (!form) return summaryData;
|
|
@@ -37128,7 +37133,7 @@ function SolePropDropinComponent({
|
|
|
37128
37133
|
};
|
|
37129
37134
|
const isCountryOfGoverningLawEnabled = isExperimentEnabled("EnableCountryOfGoverningLawForUKCompanies");
|
|
37130
37135
|
const formatDataForSummary2 = (data2, forms22) => {
|
|
37131
|
-
var _a2, _b2, _c, _d, _e;
|
|
37136
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
37132
37137
|
let summaryData = cloneObject(data2);
|
|
37133
37138
|
if (isCountryOfGoverningLawEnabled) {
|
|
37134
37139
|
summaryData.solePropNameAndCountry = getUpdatedCountryOfGoverningLaw(summaryData.solePropNameAndCountry);
|
|
@@ -37139,11 +37144,21 @@ function SolePropDropinComponent({
|
|
|
37139
37144
|
countryRegionOfEstablishment: solePropCountry,
|
|
37140
37145
|
countryOfGoverningLaw: ((_c = summaryData.solePropNameAndCountry) == null ? void 0 : _c.countryOfGoverningLaw) && datasetUtils.getCountryName(summaryData.solePropNameAndCountry.countryOfGoverningLaw)
|
|
37141
37146
|
};
|
|
37142
|
-
if ((_d = summaryData.
|
|
37147
|
+
if ((_d = summaryData.companyRegistrationDetails) == null ? void 0 : _d.taxInformation) {
|
|
37148
|
+
const taxInformation = summaryData.companyRegistrationDetails.taxInformation.find((taxId2) => {
|
|
37149
|
+
var _a3;
|
|
37150
|
+
return taxId2.country === ((_a3 = data2.solePropNameAndCountry) == null ? void 0 : _a3.country);
|
|
37151
|
+
});
|
|
37152
|
+
if (taxInformation) {
|
|
37153
|
+
summaryData.companyRegistrationDetails[taxInformation.type] = taxInformation.number;
|
|
37154
|
+
}
|
|
37155
|
+
delete summaryData.companyRegistrationDetails.taxInformation;
|
|
37156
|
+
}
|
|
37157
|
+
if ((_e = summaryData.solePropRegistrationAddress) == null ? void 0 : _e.registrationAddress) {
|
|
37143
37158
|
summaryData.solePropRegistrationAddress.hasInnerForms = true;
|
|
37144
37159
|
summaryData.solePropRegistrationAddress.registrationAddress = mapAddressLabels(summaryData.solePropRegistrationAddress.registrationAddress, datasetUtils);
|
|
37145
37160
|
}
|
|
37146
|
-
if ((
|
|
37161
|
+
if ((_f = summaryData.solePropRegistrationAddress) == null ? void 0 : _f.operationalAddress) {
|
|
37147
37162
|
summaryData.solePropRegistrationAddress.operationalAddress = mapAddressLabels(summaryData.solePropRegistrationAddress.operationalAddress, datasetUtils);
|
|
37148
37163
|
}
|
|
37149
37164
|
if (isDocumentsRequired(forms22)) {
|
|
@@ -42144,7 +42159,7 @@ const ConfigurationApiProvider = ({
|
|
|
42144
42159
|
isEmbeddedDropin,
|
|
42145
42160
|
loadingContext
|
|
42146
42161
|
} = authContext;
|
|
42147
|
-
const sdkVersion = "3.23.
|
|
42162
|
+
const sdkVersion = "3.23.2";
|
|
42148
42163
|
useAnalytics({
|
|
42149
42164
|
onUserEvent,
|
|
42150
42165
|
legalEntityId: rootLegalEntityId,
|