@adyen/kyc-components 3.0.0 → 3.0.1
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.
|
@@ -7975,6 +7975,24 @@ function CompanyRegistrationNumberTypeSelector({
|
|
|
7975
7975
|
})
|
|
7976
7976
|
});
|
|
7977
7977
|
}
|
|
7978
|
+
const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
|
|
7979
|
+
const optionsForCountry = companyRegistrationNumberOptions[country2];
|
|
7980
|
+
const metadataFn = defaultFieldConfig[country2];
|
|
7981
|
+
if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
|
|
7982
|
+
return void 0;
|
|
7983
|
+
for (const option of optionsForCountry) {
|
|
7984
|
+
const fieldMetadata = metadataFn({
|
|
7985
|
+
companyType: companyType2,
|
|
7986
|
+
registrationNumberType: option.id
|
|
7987
|
+
});
|
|
7988
|
+
if (!fieldMetadata.validators)
|
|
7989
|
+
continue;
|
|
7990
|
+
const validators = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
|
|
7991
|
+
if (validators.every((validator) => validator.validate(registrationNumber2))) {
|
|
7992
|
+
return option.id;
|
|
7993
|
+
}
|
|
7994
|
+
}
|
|
7995
|
+
};
|
|
7978
7996
|
function TaxIdNumberTypeSelector({
|
|
7979
7997
|
country: country2,
|
|
7980
7998
|
selected,
|
|
@@ -8991,14 +9009,14 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
|
|
|
8991
9009
|
}];
|
|
8992
9010
|
const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", ...vatNumberFields, ...taxIdFields, "dateOfIncorporation"];
|
|
8993
9011
|
function CompanyRegistrationDetailsComponent(props) {
|
|
8994
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
9012
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8995
9013
|
const {
|
|
8996
9014
|
i18n
|
|
8997
9015
|
} = useI18nContext();
|
|
8998
9016
|
const {
|
|
8999
9017
|
isExperimentEnabled
|
|
9000
9018
|
} = useExperimentsContext();
|
|
9001
|
-
const
|
|
9019
|
+
const isTypeSelectorEnabled = isExperimentEnabled(ExperimentNames.EnableIdentityFieldTypeSelector);
|
|
9002
9020
|
const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === props.country && f.companyType.includes(props.companyType));
|
|
9003
9021
|
const stateRef = useRef({
|
|
9004
9022
|
setState: null
|
|
@@ -9031,8 +9049,8 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9031
9049
|
rules: companyRegistrationDetailsValidationRules,
|
|
9032
9050
|
fieldProblems: props == null ? void 0 : props.fieldValidationErrors
|
|
9033
9051
|
});
|
|
9034
|
-
const defaultRegistrationNumberType =
|
|
9035
|
-
const defaultVatNumberType = ((
|
|
9052
|
+
const defaultRegistrationNumberType = props.data.registrationNumber ? inferCompanyRegistrationNumberType(props.data.registrationNumber, props.country, props.companyType) : (_e = companyRegistrationNumberOptions[companyCountry2]) == null ? void 0 : _e[0].id;
|
|
9053
|
+
const defaultVatNumberType = ((_f = taxIdNumberOptions[companyCountry2]) == null ? void 0 : _f[0].id) ?? ((_g = props.labels) == null ? void 0 : _g.vatNumber);
|
|
9036
9054
|
const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
|
|
9037
9055
|
const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
|
|
9038
9056
|
useEffect(() => {
|
|
@@ -9200,7 +9218,7 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9200
9218
|
"aria-label": formUtils.getLabel("stockISIN"),
|
|
9201
9219
|
"aria-invalid": !valid.stockISIN
|
|
9202
9220
|
})
|
|
9203
|
-
}),
|
|
9221
|
+
}), isTypeSelectorEnabled && formUtils.isRequiredField("registrationNumber") && jsx(CompanyRegistrationNumberTypeSelector, {
|
|
9204
9222
|
companyType: props.companyType,
|
|
9205
9223
|
country: props.country,
|
|
9206
9224
|
setSelected: setRegistrationNumberType,
|
|
@@ -9212,7 +9230,7 @@ function CompanyRegistrationDetailsComponent(props) {
|
|
|
9212
9230
|
dataStoreId: COMPANY_REGISTRATION_DETAILS,
|
|
9213
9231
|
labels: registrationNumberCustomLabel,
|
|
9214
9232
|
registrationNumberType
|
|
9215
|
-
}),
|
|
9233
|
+
}), isTypeSelectorEnabled && formUtils.isRequiredField("vatNumber") && jsx(TaxIdNumberTypeSelector, {
|
|
9216
9234
|
country: props.country,
|
|
9217
9235
|
setSelected: setVatNumberType,
|
|
9218
9236
|
selected: vatNumberType
|
package/dist/types/components/internal/IdFieldTypeSelector/inferCompanyRegistrationNumberType.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompanyTypesValue } from '../../../core/models/api/company-types-value';
|
|
2
|
+
import { CountryCode } from '../../../core/models/country-code';
|
|
3
|
+
import { CompanyRegistrationNumberType } from './countryIdNumberTypes';
|
|
4
|
+
/**
|
|
5
|
+
* For existing data, we need to infer the company registration number type from the existing data.
|
|
6
|
+
* Otherwise, the incorrect mask will be applied.
|
|
7
|
+
* We don't store this choice in the API.
|
|
8
|
+
* @param registrationNumber the existing company registration number
|
|
9
|
+
* @param country the country of the LE
|
|
10
|
+
* @param companyType the company type, e.g. `nonProfit`
|
|
11
|
+
*/
|
|
12
|
+
export declare const inferCompanyRegistrationNumberType: (registrationNumber: string, country: CountryCode, companyType: CompanyTypesValue) => CompanyRegistrationNumberType | undefined;
|