@swan-io/shared-business 4.10.1 → 5.0.0
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/package.json +2 -2
- package/src/components/BeneficiaryForm.js +73 -74
- package/src/components/DatePicker.d.ts +5 -5
- package/src/components/DatePicker.js +15 -12
- package/src/components/SupportingDocument.js +11 -8
- package/src/locales/de.json +0 -1
- package/src/locales/en.json +0 -1
- package/src/locales/es.json +0 -1
- package/src/locales/fi.json +0 -1
- package/src/locales/fr.json +0 -1
- package/src/locales/it.json +0 -1
- package/src/locales/nl.json +0 -1
- package/src/locales/pt.json +0 -1
- package/src/utils/i18n.d.ts +1 -1
- package/src/utils/validation.d.ts +1 -1
- package/src/components/AddressFormPart.d.ts +0 -21
- package/src/components/AddressFormPart.js +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/shared-business",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.0.0",
|
|
6
6
|
"yarn": "^1.22.0"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-dom": "^18.2.0",
|
|
40
40
|
"react-dropzone": "^14.2.3",
|
|
41
41
|
"react-native-web": "^0.19.10",
|
|
42
|
-
"
|
|
42
|
+
"@swan-io/use-form": "^2.0.0-rc.2",
|
|
43
43
|
"rifm": "^0.12.1",
|
|
44
44
|
"ts-pattern": "^5.0.8",
|
|
45
45
|
"urql": "^4.0.6",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Option } from "@swan-io/boxed";
|
|
2
3
|
import { Box } from "@swan-io/lake/src/components/Box";
|
|
3
4
|
import { LakeLabelledCheckbox } from "@swan-io/lake/src/components/LakeCheckbox";
|
|
4
5
|
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
@@ -10,10 +11,11 @@ import { Space } from "@swan-io/lake/src/components/Space";
|
|
|
10
11
|
import { StepDots } from "@swan-io/lake/src/components/StepDots";
|
|
11
12
|
import { breakpoints, colors } from "@swan-io/lake/src/constants/design";
|
|
12
13
|
import { noop } from "@swan-io/lake/src/utils/function";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
14
|
+
import { isNotNullishOrEmpty } from "@swan-io/lake/src/utils/nullish";
|
|
15
|
+
import { pick } from "@swan-io/lake/src/utils/object";
|
|
16
|
+
import { combineValidators, useForm } from "@swan-io/use-form";
|
|
17
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
15
18
|
import { StyleSheet, View } from "react-native";
|
|
16
|
-
import { combineValidators, hasDefinedKeys, useForm } from "react-ux-form";
|
|
17
19
|
import { Rifm } from "rifm";
|
|
18
20
|
import { match } from "ts-pattern";
|
|
19
21
|
import { v4 as uuid } from "uuid";
|
|
@@ -21,8 +23,8 @@ import { allCountries, isCountryCCA3 } from "../constants/countries";
|
|
|
21
23
|
import { decodeBirthDate, encodeBirthDate } from "../utils/date";
|
|
22
24
|
import { locale, rifmDateProps, t } from "../utils/i18n";
|
|
23
25
|
import { validateBooleanRequired, validateIndividualTaxNumber, validateNullableRequired, validateRequired, } from "../utils/validation";
|
|
24
|
-
import { AddressFormPart } from "./AddressFormPart";
|
|
25
26
|
import { CountryPicker } from "./CountryPicker";
|
|
27
|
+
import { PlacekitAddressSearchInput } from "./PlacekitAddressSearchInput";
|
|
26
28
|
import { PlacekitCityInput } from "./PlacekitCityInput";
|
|
27
29
|
import { TaxIdentificationNumberInput } from "./TaxIdentificationNumberInput";
|
|
28
30
|
const styles = StyleSheet.create({
|
|
@@ -98,27 +100,6 @@ export const validateUbo = (editorState, accountCountry) => {
|
|
|
98
100
|
: validateBooleanRequired(editorState.direct),
|
|
99
101
|
};
|
|
100
102
|
};
|
|
101
|
-
const getCapitalType = (direct, indirect) => {
|
|
102
|
-
if (direct === true && indirect === true) {
|
|
103
|
-
return "both";
|
|
104
|
-
}
|
|
105
|
-
if (direct === true) {
|
|
106
|
-
return "direct";
|
|
107
|
-
}
|
|
108
|
-
if (indirect === true) {
|
|
109
|
-
return "indirect";
|
|
110
|
-
}
|
|
111
|
-
return "none";
|
|
112
|
-
};
|
|
113
|
-
const getDirectAndIndirect = (capitalType) => {
|
|
114
|
-
return match(capitalType)
|
|
115
|
-
.returnType()
|
|
116
|
-
.with("both", () => [true, true])
|
|
117
|
-
.with("direct", () => [true, false])
|
|
118
|
-
.with("indirect", () => [false, true])
|
|
119
|
-
.with("none", () => [false, false])
|
|
120
|
-
.exhaustive();
|
|
121
|
-
};
|
|
122
103
|
/**
|
|
123
104
|
* This component was created to handle validation easily with react-ux-form
|
|
124
105
|
* Without this component, we have to validate direct and indirect checkboxes separately
|
|
@@ -208,13 +189,19 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
208
189
|
validate: validateRequired,
|
|
209
190
|
},
|
|
210
191
|
capitalType: {
|
|
211
|
-
initialValue:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
192
|
+
initialValue: match({
|
|
193
|
+
direct: initialState === null || initialState === void 0 ? void 0 : initialState.direct,
|
|
194
|
+
indirect: initialState === null || initialState === void 0 ? void 0 : initialState.indirect,
|
|
195
|
+
})
|
|
196
|
+
.returnType()
|
|
197
|
+
.with({ direct: true, indirect: true }, () => "both")
|
|
198
|
+
.with({ direct: true }, () => "direct")
|
|
199
|
+
.with({ indirect: true }, () => "indirect")
|
|
200
|
+
.otherwise(() => "none"),
|
|
201
|
+
validate: (value, { getFieldValue }) => {
|
|
202
|
+
if (getFieldValue("type") === "HasCapital" && value === "none") {
|
|
215
203
|
return t("beneficiaryForm.beneficiary.directOrIndirect");
|
|
216
204
|
}
|
|
217
|
-
return undefined;
|
|
218
205
|
},
|
|
219
206
|
},
|
|
220
207
|
totalCapitalPercentage: {
|
|
@@ -245,8 +232,8 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
245
232
|
},
|
|
246
233
|
taxIdentificationNumber: {
|
|
247
234
|
initialValue: initialState === null || initialState === void 0 ? void 0 : initialState.taxIdentificationNumber,
|
|
248
|
-
validate: (value, {
|
|
249
|
-
const uboCountry =
|
|
235
|
+
validate: (value, { getFieldValue }) => {
|
|
236
|
+
const uboCountry = getFieldValue("country");
|
|
250
237
|
if (accountCountry === "DEU" && uboCountry === "DEU") {
|
|
251
238
|
return combineValidators(validateNullableRequired, validateIndividualTaxNumber(accountCountry))(value);
|
|
252
239
|
}
|
|
@@ -259,7 +246,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
259
246
|
useEffect(() => {
|
|
260
247
|
if (initialState != null) {
|
|
261
248
|
// submit form to validate all fields
|
|
262
|
-
submitForm(
|
|
249
|
+
submitForm();
|
|
263
250
|
}
|
|
264
251
|
}, [initialState, submitForm]);
|
|
265
252
|
useEffect(() => {
|
|
@@ -294,44 +281,56 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
294
281
|
},
|
|
295
282
|
submit: () => {
|
|
296
283
|
hasBeenSubmittedOnce.current = true;
|
|
297
|
-
submitForm(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
isAddressRequired &&
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
284
|
+
submitForm({
|
|
285
|
+
onSuccess: values => {
|
|
286
|
+
const firstStepValues = Option.allFromDict(pick(values, requiredStepFields));
|
|
287
|
+
if (step === "common" && isAddressRequired && firstStepValues.isSome()) {
|
|
288
|
+
commonStepValues.current = {
|
|
289
|
+
...firstStepValues.get(),
|
|
290
|
+
capitalType: values.capitalType.getWithDefault(undefined),
|
|
291
|
+
totalCapitalPercentage: values.totalCapitalPercentage.getWithDefault(undefined),
|
|
292
|
+
address: values.address.getWithDefault(undefined),
|
|
293
|
+
city: values.city.getWithDefault(undefined),
|
|
294
|
+
postalCode: values.postalCode.getWithDefault(undefined),
|
|
295
|
+
country: values.country.getWithDefault(undefined),
|
|
296
|
+
taxIdentificationNumber: values.taxIdentificationNumber.getWithDefault(undefined),
|
|
297
|
+
};
|
|
298
|
+
return onStepChange("address");
|
|
299
|
+
}
|
|
300
|
+
const secondStepValues = Option.allFromDict(pick({ ...commonStepValues.current, ...values }, requiredStepFields));
|
|
301
|
+
if (secondStepValues.isSome()) {
|
|
302
|
+
const { birthDate, ...rest } = secondStepValues.get();
|
|
303
|
+
const capitalType = values.capitalType.getWithDefault("none");
|
|
304
|
+
return onSave({
|
|
305
|
+
...rest,
|
|
306
|
+
reference,
|
|
307
|
+
birthDate: encodeBirthDate(birthDate),
|
|
308
|
+
direct: capitalType === "both" || capitalType === "direct",
|
|
309
|
+
indirect: capitalType === "both" || capitalType === "indirect",
|
|
310
|
+
totalCapitalPercentage: values.totalCapitalPercentage
|
|
311
|
+
.flatMap(value => Option.fromNullable(value))
|
|
312
|
+
.map(value => parseInt(value, 10))
|
|
313
|
+
.getWithDefault(undefined),
|
|
314
|
+
residencyAddressLine1: values.address.getWithDefault(undefined),
|
|
315
|
+
residencyAddressCity: values.city.getWithDefault(undefined),
|
|
316
|
+
residencyAddressCountry: values.country.getWithDefault(undefined),
|
|
317
|
+
residencyAddressPostalCode: values.postalCode.getWithDefault(undefined),
|
|
318
|
+
taxIdentificationNumber: values.taxIdentificationNumber.getWithDefault(undefined),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
},
|
|
330
322
|
});
|
|
331
323
|
},
|
|
332
324
|
};
|
|
333
325
|
});
|
|
334
|
-
|
|
326
|
+
const onSuggestion = useCallback((place) => {
|
|
327
|
+
setFieldValue("address", place.completeAddress);
|
|
328
|
+
setFieldValue("city", place.city);
|
|
329
|
+
if (place.postalCode != null) {
|
|
330
|
+
setFieldValue("postalCode", place.postalCode);
|
|
331
|
+
}
|
|
332
|
+
}, [setFieldValue]);
|
|
333
|
+
return (_jsx(ResponsiveContainer, { breakpoint: breakpoints.tiny, children: ({ small }) => (_jsxs(_Fragment, { children: [match(step)
|
|
335
334
|
.with("common", () => (_jsxs(View, { role: "form", children: [_jsxs(Box, { direction: small ? "column" : "row", children: [_jsx(Field, { name: "firstName", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.firstName"), style: styles.inputContainer, render: id => (_jsx(LakeTextInput, { error: error, placeholder: t("beneficiaryForm.beneficiary.firstNamePlaceholder"), id: id, value: value, onChangeText: onChange })) })) }), _jsx(Space, { width: 12 }), _jsx(Field, { name: "lastName", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.lastName"), style: styles.inputContainer, render: id => (_jsx(LakeTextInput, { error: error, placeholder: t("beneficiaryForm.beneficiary.lastNamePlaceholder"), id: id, value: value, onChangeText: onChange })) })) })] }), _jsxs(Box, { direction: small ? "column" : "row", children: [_jsx(Field, { name: "birthDate", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.birthDate"), optionalLabel: isBirthInfoRequired ? undefined : t("common.optional"), style: styles.inputContainer, render: id => (_jsx(Rifm, { value: value !== null && value !== void 0 ? value : "", onChange: onChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { error: error, placeholder: locale.datePlaceholder, id: id, value: value, onChange: onChange })) })) })) }), _jsx(Space, { width: 12 }), _jsx(Field, { name: "birthCountryCode", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.birthCountry"), style: styles.inputContainer, render: id => (_jsx(CountryPicker, { id: id, error: error, value: value, placeholder: t("beneficiaryForm.beneficiary.birthCountryPlaceholder"), countries: allCountries, onValueChange: onChange })) })) })] }), _jsx(Box, { direction: small ? "column" : "row", children: _jsx(FieldsListener, { names: ["birthCountryCode"], children: ({ birthCountryCode }) => (_jsxs(_Fragment, { children: [_jsx(Field, { name: "birthCity", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.birthCity"), optionalLabel: isBirthInfoRequired ? undefined : t("common.optional"), style: styles.inputContainer, render: id => (_jsx(PlacekitCityInput, { id: id, apiKey: placekitApiKey, error: error, country: birthCountryCode.value, value: value !== null && value !== void 0 ? value : "", onValueChange: onChange, placeholder: birthCountryCode.value == null
|
|
336
335
|
? t("beneficiaryForm.beneficiary.fillBirthCountry")
|
|
337
336
|
: t("beneficiaryForm.beneficiary.birthCityPlaceholder"), onSuggestion: place => {
|
|
@@ -342,12 +341,12 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
342
341
|
}, onLoadError: onCityLoadError })) })) }), _jsx(Space, { width: 12 }), _jsx(Field, { name: "birthCityPostalCode", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.birthPostalCode"), optionalLabel: isBirthInfoRequired ? undefined : t("common.optional"), style: styles.inputContainer, render: id => (_jsx(LakeTextInput, { error: error, placeholder: birthCountryCode.value == null
|
|
343
342
|
? t("beneficiaryForm.beneficiary.fillBirthCountry")
|
|
344
343
|
: t("beneficiaryForm.beneficiary.birthPostalCodePlaceholder"), id: id, disabled: birthCountryCode.value === undefined, value: value, onChangeText: onChange })) })) })] })) }) }), _jsx(Field, { name: "type", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.type"), type: "radioGroup", render: () => (_jsx(RadioGroup, { direction: "row", value: value, onValueChange: onChange, items: beneficiaryTypes })) })) }), _jsx(FieldsListener, { names: ["type"], children: ({ type }) => type.value === "HasCapital" ? (_jsxs(_Fragment, { children: [_jsx(Field, { name: "totalCapitalPercentage", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.totalCapitalPercentage"), render: id => (_jsx(LakeTextInput, { error: error, unit: "%", inputMode: "decimal", "aria-valuemin": 0, "aria-valuemax": 100, id: id, value: value, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "capitalType", children: ({ value, error, onChange }) => (_jsx(CapitalTypeCheckboxes, { value: value !== null && value !== void 0 ? value : "none", error: error, onChange: onChange })) })] })) : null })] })))
|
|
345
|
-
.with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: allCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
344
|
+
.with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: allCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => (_jsxs(_Fragment, { children: [_jsx(Field, { name: "address", children: ({ ref, value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.address"), render: id => {
|
|
345
|
+
var _a;
|
|
346
|
+
return (_jsx(PlacekitAddressSearchInput, { inputRef: ref, apiKey: placekitApiKey, emptyResultText: t("common.noResult"), placeholder: t("addressFormPart.placeholder"), language: locale.language, id: id, country: (_a = country.value) !== null && _a !== void 0 ? _a : accountCountry, value: value, error: error, onValueChange: onChange, onSuggestion: onSuggestion }));
|
|
347
|
+
} })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "city", children: ({ ref, value, valid, error, onChange }) => (_jsx(LakeLabel, { label: t("addressFormPart.cityLabel"), render: id => (_jsx(LakeTextInput, { ref: ref, id: id, value: value, valid: valid, error: error, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "postalCode", children: ({ ref, value, valid, error, onChange }) => (_jsx(LakeLabel, { label: t("addressFormPart.postCodeLabel"), render: id => (_jsx(LakeTextInput, { ref: ref, id: id, value: value, valid: valid, error: error, onChangeText: onChange })) })) }), ((accountCountry === "DEU" && (country === null || country === void 0 ? void 0 : country.value) === "DEU") ||
|
|
348
|
+
accountCountry === "ESP") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value !== null && value !== void 0 ? value : "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
|
|
349
|
+
// is mandatory for German accounts with UBO living in Germany
|
|
350
|
+
required: accountCountry === "DEU" && (country === null || country === void 0 ? void 0 : country.value) === "DEU" })) })] }))] })) })] })))
|
|
352
351
|
.exhaustive(), isAddressRequired && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(StepDots, { currentStep: step, steps: formSteps })] }))] })) }));
|
|
353
352
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from "@swan-io/boxed";
|
|
2
|
-
import { ValidatorResult } from "
|
|
2
|
+
import { ValidatorResult } from "@swan-io/use-form";
|
|
3
3
|
import { Except } from "type-fest";
|
|
4
4
|
export type MonthNames = readonly [
|
|
5
5
|
string,
|
|
@@ -56,9 +56,9 @@ type DatePickerModalProps = Except<DatePickerProps, "error"> & {
|
|
|
56
56
|
cancelLabel: string;
|
|
57
57
|
confirmLabel: string;
|
|
58
58
|
validate?: (value: string) => ValidatorResult;
|
|
59
|
-
|
|
59
|
+
onDismiss: () => void;
|
|
60
60
|
};
|
|
61
|
-
export declare const DatePickerModal: ({ value, format, firstWeekDay, isSelectable, onChange, visible, label, cancelLabel, confirmLabel, validate,
|
|
61
|
+
export declare const DatePickerModal: ({ value, format, firstWeekDay, isSelectable, onChange, visible, label, cancelLabel, confirmLabel, validate, onDismiss, }: DatePickerModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
62
62
|
export type DateRangePickerProps = {
|
|
63
63
|
value: {
|
|
64
64
|
start: string;
|
|
@@ -80,7 +80,7 @@ type DateRangePickerModalProps = DateRangePickerProps & {
|
|
|
80
80
|
visible: boolean;
|
|
81
81
|
cancelLabel: string;
|
|
82
82
|
confirmLabel: string;
|
|
83
|
-
|
|
83
|
+
onDismiss: () => void;
|
|
84
84
|
};
|
|
85
|
-
export declare const DateRangePickerModal: ({ value, error, format, firstWeekDay, isSelectable, onChange, visible, startLabel, endLabel, cancelLabel, confirmLabel,
|
|
85
|
+
export declare const DateRangePickerModal: ({ value, error, format, firstWeekDay, isSelectable, onChange, visible, startLabel, endLabel, cancelLabel, confirmLabel, onDismiss, }: DateRangePickerModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
86
86
|
export {};
|
|
@@ -18,12 +18,12 @@ import { useDisclosure } from "@swan-io/lake/src/hooks/useDisclosure";
|
|
|
18
18
|
import { useFirstMountState } from "@swan-io/lake/src/hooks/useFirstMountState";
|
|
19
19
|
import { useResponsive } from "@swan-io/lake/src/hooks/useResponsive";
|
|
20
20
|
import { noop } from "@swan-io/lake/src/utils/function";
|
|
21
|
-
import { isNotNullish, isNotNullishOrEmpty, isNullishOrEmpty, } from "@swan-io/lake/src/utils/nullish";
|
|
21
|
+
import { isNotEmpty, isNotNullish, isNotNullishOrEmpty, isNullishOrEmpty, } from "@swan-io/lake/src/utils/nullish";
|
|
22
22
|
import { getRifmProps } from "@swan-io/lake/src/utils/rifm";
|
|
23
|
+
import { useForm } from "@swan-io/use-form";
|
|
23
24
|
import dayjs from "dayjs";
|
|
24
25
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
25
26
|
import { StyleSheet, View } from "react-native";
|
|
26
|
-
import { useForm } from "react-ux-form";
|
|
27
27
|
import { Rifm } from "rifm";
|
|
28
28
|
import { P, match } from "ts-pattern";
|
|
29
29
|
import { t } from "../utils/i18n";
|
|
@@ -479,7 +479,7 @@ export const DatePicker = ({ label, value, error, format, firstWeekDay, isSelect
|
|
|
479
479
|
const popoverId = useId();
|
|
480
480
|
return (_jsxs(_Fragment, { children: [_jsx(Box, { direction: "row", alignItems: "end", children: _jsx(LakeLabel, { label: label, style: styles.label, actions: _jsx(LakeButton, { mode: "secondary", icon: "calendar-ltr-regular", size: "small", onPress: open, ariaLabel: t("common.open") }), render: id => (_jsx(Rifm, { value: value !== null && value !== void 0 ? value : "", onChange: onChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { ref: ref, id: id, placeholder: format, value: value, error: error, onChange: onChange, ariaExpanded: isOpened })) })) }) }), _jsx(Popover, { id: popoverId, role: "dialog", onDismiss: close, referenceRef: ref, visible: isOpened, field: true, children: _jsx(View, { style: desktop ? styles.popoverDesktop : styles.popover, children: _jsx(DatePickerPopoverContent, { value: value, format: format, firstWeekDay: firstWeekDay, desktop: desktop, isSelectable: isSelectable, onChange: onChange }) }) })] }));
|
|
481
481
|
};
|
|
482
|
-
export const DatePickerModal = ({ value, format, firstWeekDay, isSelectable, onChange, visible, label, cancelLabel, confirmLabel, validate,
|
|
482
|
+
export const DatePickerModal = ({ value, format, firstWeekDay, isSelectable, onChange, visible, label, cancelLabel, confirmLabel, validate, onDismiss, }) => {
|
|
483
483
|
const { desktop } = useResponsive(DATE_PICKER_MOBILE_THRESHOLD);
|
|
484
484
|
const { Field, submitForm, setFieldValue, resetField } = useForm({
|
|
485
485
|
date: {
|
|
@@ -489,14 +489,17 @@ export const DatePickerModal = ({ value, format, firstWeekDay, isSelectable, onC
|
|
|
489
489
|
});
|
|
490
490
|
const handleCancel = () => {
|
|
491
491
|
setFieldValue("date", value !== null && value !== void 0 ? value : "");
|
|
492
|
-
|
|
492
|
+
onDismiss();
|
|
493
493
|
};
|
|
494
494
|
const handleConfirm = () => {
|
|
495
|
-
submitForm(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
495
|
+
submitForm({
|
|
496
|
+
onSuccess: values => {
|
|
497
|
+
const date = values.date.getWithDefault("");
|
|
498
|
+
if (isNotEmpty(date)) {
|
|
499
|
+
onChange(date);
|
|
500
|
+
}
|
|
501
|
+
onDismiss();
|
|
502
|
+
},
|
|
500
503
|
});
|
|
501
504
|
};
|
|
502
505
|
useEffect(() => {
|
|
@@ -618,7 +621,7 @@ export const DateRangePicker = ({ value, error, format, startLabel, endLabel, fi
|
|
|
618
621
|
}, [value, onChange]);
|
|
619
622
|
return (_jsxs(View, { children: [_jsxs(Box, { direction: "row", alignItems: "end", children: [_jsx(LakeLabel, { label: startLabel, style: styles.label, render: id => (_jsx(Rifm, { value: value.start, onChange: handleStartChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { ref: ref, id: id, placeholder: format, value: value, onChange: onChange, error: error, hideErrors: true, ariaExpanded: isOpened })) })) }), _jsx(Space, { width: 12 }), _jsx(Box, { style: styles.arrowContainer, justifyContent: "center", children: _jsx(Icon, { name: "arrow-right-filled", size: 20 }) }), _jsx(Space, { width: 12 }), _jsx(LakeLabel, { label: endLabel, style: styles.label, render: id => (_jsx(Rifm, { value: value.end, onChange: handleEndChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { id: id, placeholder: format, value: value, onChange: onChange, error: error, hideErrors: true, ariaExpanded: isOpened })) })) }), _jsx(Space, { width: 12 }), _jsx(LakeButton, { mode: "secondary", icon: "calendar-ltr-regular", size: "small", onPress: open, ariaLabel: t("common.open") })] }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], children: error !== null && error !== void 0 ? error : " " }), _jsx(DateModal, { visible: isOpened, maxWidth: 900, withCloseButton: true, onPressClose: close, children: _jsx(DateRangePickerModalContent, { value: value, format: format, firstWeekDay: firstWeekDay, desktop: desktop, displayTwoCalendar: displayTwoCalendar, isSelectable: isSelectable, onChange: onChange }) })] }));
|
|
620
623
|
};
|
|
621
|
-
export const DateRangePickerModal = ({ value, error, format, firstWeekDay, isSelectable, onChange, visible, startLabel, endLabel, cancelLabel, confirmLabel,
|
|
624
|
+
export const DateRangePickerModal = ({ value, error, format, firstWeekDay, isSelectable, onChange, visible, startLabel, endLabel, cancelLabel, confirmLabel, onDismiss, }) => {
|
|
622
625
|
const { desktop } = useResponsive(MODALE_MOBILE_THRESHOLD);
|
|
623
626
|
const { desktop: displayTwoCalendar } = useResponsive(DATE_RANGE_PICKER_THRESHOLD);
|
|
624
627
|
const [localeValue, setLocaleValue] = useState(value);
|
|
@@ -633,11 +636,11 @@ export const DateRangePickerModal = ({ value, error, format, firstWeekDay, isSel
|
|
|
633
636
|
};
|
|
634
637
|
const handleCancel = () => {
|
|
635
638
|
setLocaleValue(value);
|
|
636
|
-
|
|
639
|
+
onDismiss();
|
|
637
640
|
};
|
|
638
641
|
const handleConfirm = () => {
|
|
639
642
|
onChange(localeValue);
|
|
640
|
-
|
|
643
|
+
onDismiss();
|
|
641
644
|
};
|
|
642
645
|
return (_jsxs(DateModal, { visible: visible, maxWidth: 900, onPressClose: handleCancel, children: [_jsxs(View, { children: [_jsxs(Box, { direction: "row", alignItems: "end", children: [_jsx(LakeLabel, { label: startLabel, style: styles.label, render: id => (_jsx(Rifm, { value: localeValue.start, onChange: handleStartChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { id: id, placeholder: format, value: value, onChange: onChange, error: error, hideErrors: true })) })) }), _jsx(Space, { width: 12 }), _jsx(Box, { style: styles.arrowContainer, justifyContent: "center", children: _jsx(Icon, { name: "arrow-right-filled", size: 20 }) }), _jsx(Space, { width: 12 }), _jsx(LakeLabel, { label: endLabel, style: styles.label, render: id => (_jsx(Rifm, { value: localeValue.end, onChange: handleEndChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { id: id, placeholder: format, value: value, onChange: onChange, error: error, hideErrors: true })) })) })] }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], children: error !== null && error !== void 0 ? error : " " })] }), _jsx(DateRangePickerModalContent, { value: localeValue, format: format, firstWeekDay: firstWeekDay, desktop: desktop, displayTwoCalendar: displayTwoCalendar, isSelectable: isSelectable, onChange: setLocaleValue }), _jsx(Space, { height: 24 }), _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(LakeButton, { mode: "secondary", size: "small", onPress: handleCancel, style: styles.button, children: cancelLabel }), _jsx(Space, { width: 24 }), _jsx(LakeButton, { color: "current", size: "small", onPress: handleConfirm, style: styles.button, children: confirmLabel })] })] }));
|
|
643
646
|
};
|
|
@@ -7,9 +7,9 @@ import { LakeText } from "@swan-io/lake/src/components/LakeText";
|
|
|
7
7
|
import { LakeTooltip } from "@swan-io/lake/src/components/LakeTooltip";
|
|
8
8
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
9
9
|
import { isNotNullishOrEmpty, isNullish } from "@swan-io/lake/src/utils/nullish";
|
|
10
|
+
import { useForm } from "@swan-io/use-form";
|
|
10
11
|
import { Fragment, forwardRef, useEffect, useImperativeHandle, useMemo, useState, } from "react";
|
|
11
12
|
import { StyleSheet } from "react-native";
|
|
12
|
-
import { useForm } from "react-ux-form";
|
|
13
13
|
import { match } from "ts-pattern";
|
|
14
14
|
import { MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE, MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE_MB, } from "../constants/uploads";
|
|
15
15
|
import { isTranslationKey, locale, t } from "../utils/i18n";
|
|
@@ -73,7 +73,7 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
73
73
|
}, {}), [documents]);
|
|
74
74
|
const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
|
|
75
75
|
const [showSwornStatementModal, setShowSwornStatementModal] = useState(false);
|
|
76
|
-
const { Field, setFieldValue,
|
|
76
|
+
const { Field, setFieldValue, getFieldValue, listenFields, submitForm } = useForm(requiredDocumentPurposes.reduce((acc, purpose) => {
|
|
77
77
|
var _a;
|
|
78
78
|
return ({
|
|
79
79
|
...acc,
|
|
@@ -86,7 +86,10 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
86
86
|
useImperativeHandle(externalRef, () => {
|
|
87
87
|
return {
|
|
88
88
|
submit: (callback) => {
|
|
89
|
-
submitForm(
|
|
89
|
+
submitForm({
|
|
90
|
+
onSuccess: () => callback(true),
|
|
91
|
+
onFailure: () => callback(false),
|
|
92
|
+
});
|
|
90
93
|
},
|
|
91
94
|
};
|
|
92
95
|
});
|
|
@@ -117,7 +120,7 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
117
120
|
.then(({ upload: { url, fields }, id }) => {
|
|
118
121
|
const xhr = new XMLHttpRequest();
|
|
119
122
|
xhr.open("POST", url, true);
|
|
120
|
-
const state =
|
|
123
|
+
const state = getFieldValue(fieldName);
|
|
121
124
|
setFieldValue(fieldName, state.map(doc => doc.id === NO_ID_YET
|
|
122
125
|
? {
|
|
123
126
|
status: "uploading",
|
|
@@ -128,11 +131,11 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
128
131
|
: doc));
|
|
129
132
|
xhr.upload.onprogress = event => {
|
|
130
133
|
const progress = (event.loaded / event.total) * 100;
|
|
131
|
-
const state =
|
|
134
|
+
const state = getFieldValue(fieldName);
|
|
132
135
|
setFieldValue(fieldName, state.map(uploadState => uploadState.id === id ? { ...uploadState, progress } : uploadState));
|
|
133
136
|
};
|
|
134
137
|
xhr.onerror = () => {
|
|
135
|
-
const state =
|
|
138
|
+
const state = getFieldValue(fieldName);
|
|
136
139
|
setFieldValue(fieldName, state.map(uploadState => uploadState.id === id
|
|
137
140
|
? {
|
|
138
141
|
status: "failed",
|
|
@@ -144,7 +147,7 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
144
147
|
: uploadState));
|
|
145
148
|
};
|
|
146
149
|
xhr.onload = () => {
|
|
147
|
-
const state =
|
|
150
|
+
const state = getFieldValue(fieldName);
|
|
148
151
|
if (xhr.status !== 200 && xhr.status !== 204) {
|
|
149
152
|
setFieldValue(fieldName, state.map(uploadState => uploadState.id === id
|
|
150
153
|
? {
|
|
@@ -167,7 +170,7 @@ const SupportingDocumentWithRef = ({ documents, getAwsUrl, onChange, requiredDoc
|
|
|
167
170
|
xhr.send(formData);
|
|
168
171
|
})
|
|
169
172
|
.catch(() => {
|
|
170
|
-
const state =
|
|
173
|
+
const state = getFieldValue(fieldName);
|
|
171
174
|
setFieldValue(fieldName, state.map(uploadState => uploadState.id === NO_ID_YET
|
|
172
175
|
? {
|
|
173
176
|
status: "failed",
|
package/src/locales/de.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Ort",
|
|
4
4
|
"addressFormPart.placeholder": "Mit der Eingabe beginnen …",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Postleitzahl",
|
|
6
|
-
"addressFormPart.setManual": "Manuell eingeben",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Adresse des Empfängers finden",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Geburtsort",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Geburtsort des Empfängers suchen",
|
package/src/locales/en.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "City",
|
|
4
4
|
"addressFormPart.placeholder": "Start typing…",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Postcode",
|
|
6
|
-
"addressFormPart.setManual": "Enter manually",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Find beneficiary address",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Birth city",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Search for the beneficiary's birth city",
|
package/src/locales/es.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Ciudad",
|
|
4
4
|
"addressFormPart.placeholder": "Escribe aquí...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Código postal",
|
|
6
|
-
"addressFormPart.setManual": "Introducir manualmente",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Busca la dirección del beneficiario",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Ciudad de nacimiento",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Busca la ciudad de nacimiento del beneficiario",
|
package/src/locales/fi.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Kaupunki",
|
|
4
4
|
"addressFormPart.placeholder": "Aloita kirjoittaminen...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Postinumero",
|
|
6
|
-
"addressFormPart.setManual": "Kirjoita käsin",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Etsi edunsaajan osoite",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Syntymäkaupunki",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Etsi edunsaajan syntymäkaupunki",
|
package/src/locales/fr.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Ville",
|
|
4
4
|
"addressFormPart.placeholder": "Commencer à écrire...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Code postal",
|
|
6
|
-
"addressFormPart.setManual": "Saisir manuellement",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Trouver l'adresse du bénéficiaire",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Ville de naissance",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Rechercher la ville de naissance du bénéficiaire",
|
package/src/locales/it.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Città",
|
|
4
4
|
"addressFormPart.placeholder": "Inizia a digitare...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Codice postale",
|
|
6
|
-
"addressFormPart.setManual": "Inserisca manualmente",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Trova l'indirizzo del beneficiario",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Comune di nascita",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Cerca il comune di nascita del beneficiario",
|
package/src/locales/nl.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Stad",
|
|
4
4
|
"addressFormPart.placeholder": "Begin met typen...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Postcode",
|
|
6
|
-
"addressFormPart.setManual": "Handmatig invoeren",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Vind adres begunstigde",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Geboortestad",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Zoek de geboortestad van de begunstigde",
|
package/src/locales/pt.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"addressFormPart.cityLabel": "Cidade",
|
|
4
4
|
"addressFormPart.placeholder": "Comece a escrever...",
|
|
5
5
|
"addressFormPart.postCodeLabel": "Código Postal",
|
|
6
|
-
"addressFormPart.setManual": "Introduza manualmente",
|
|
7
6
|
"beneficiaryForm.beneficiary.address": "Encontre o endereço do beneficiário",
|
|
8
7
|
"beneficiaryForm.beneficiary.birthCity": "Cidade de nascimento",
|
|
9
8
|
"beneficiaryForm.beneficiary.birthCityPlaceholder": "Pesquisar a cidade de nascimento do beneficiário",
|
package/src/utils/i18n.d.ts
CHANGED
|
@@ -19,6 +19,6 @@ export declare const locale: Locale;
|
|
|
19
19
|
export declare const t: (key: TranslationKey, params?: TranslationParams) => string;
|
|
20
20
|
export declare const formatNestedMessage: (key: TranslationKey, params: Record<string, string | number | ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((children: ReactNode) => ReactNode)>) => (string | ReactElement<any, string | import("react").JSXElementConstructor<any>>)[];
|
|
21
21
|
export declare const rifmDateProps: RifmProps;
|
|
22
|
-
export declare const isTranslationKey: (value: unknown) => value is "addressFormPart.addressLabel" | "addressFormPart.cityLabel" | "addressFormPart.placeholder" | "addressFormPart.postCodeLabel" | "addressFormPart.setManual" | "beneficiaryForm.beneficiary.address" | "beneficiaryForm.beneficiary.birthCity" | "beneficiaryForm.beneficiary.birthCityPlaceholder" | "beneficiaryForm.beneficiary.birthCountry" | "beneficiaryForm.beneficiary.birthCountryPlaceholder" | "beneficiaryForm.beneficiary.birthDate" | "beneficiaryForm.beneficiary.birthPostalCode" | "beneficiaryForm.beneficiary.birthPostalCodePlaceholder" | "beneficiaryForm.beneficiary.country" | "beneficiaryForm.beneficiary.directOrIndirect" | "beneficiaryForm.beneficiary.directly" | "beneficiaryForm.beneficiary.fillBirthCountry" | "beneficiaryForm.beneficiary.firstName" | "beneficiaryForm.beneficiary.firstNamePlaceholder" | "beneficiaryForm.beneficiary.indirectly" | "beneficiaryForm.beneficiary.lastName" | "beneficiaryForm.beneficiary.lastNamePlaceholder" | "beneficiaryForm.beneficiary.legalRepresentative" | "beneficiaryForm.beneficiary.other" | "beneficiaryForm.beneficiary.ownershipOfCapital" | "beneficiaryForm.beneficiary.taxIdentificationNumber" | "beneficiaryForm.beneficiary.totalCapitalPercentage" | "beneficiaryForm.beneficiary.type" | "businessActivity.administrativeServices" | "businessActivity.agriculture" | "businessActivity.arts" | "businessActivity.businessAndRetail" | "businessActivity.construction" | "businessActivity.education" | "businessActivity.electricalDistributionAndWaterSupply" | "businessActivity.financialAndInsuranceOperations" | "businessActivity.health" | "businessActivity.housekeeping" | "businessActivity.informationAndCommunication" | "businessActivity.lodgingAndFoodServices" | "businessActivity.manufacturingAndMining" | "businessActivity.other" | "businessActivity.publicAdministration" | "businessActivity.realEstate" | "businessActivity.scientificActivities" | "businessActivity.transportation" | "common.cancel" | "common.close" | "common.form.help.nbCharacters" | "common.form.help.nbDigits" | "common.form.invalidTaxIdentificationNumber" | "common.form.taxIdentificationNumber.placeholder" | "common.form.taxIdentificationNumber.tooltip.deu" | "common.next" | "common.noResult" | "common.open" | "common.optional" | "common.previous" | "common.remove" | "common.showLess" | "common.showMore" | "common.skipToContent" | "datePicker.day.friday" | "datePicker.day.monday" | "datePicker.day.saturday" | "datePicker.day.sunday" | "datePicker.day.thursday" | "datePicker.day.tuesday" | "datePicker.day.wednesday" | "datePicker.month.april" | "datePicker.month.august" | "datePicker.month.december" | "datePicker.month.february" | "datePicker.month.january" | "datePicker.month.july" | "datePicker.month.june" | "datePicker.month.march" | "datePicker.month.may" | "datePicker.month.next" | "datePicker.month.november" | "datePicker.month.october" | "datePicker.month.previous" | "datePicker.month.september" | "error.generic" | "error.iban.invalid" | "error.network.500" | "error.network.503" | "error.requiredField" | "monthlyPaymentVolume.between10000And50000" | "monthlyPaymentVolume.between50000And100000" | "monthlyPaymentVolume.lessThan10000" | "monthlyPaymentVolume.moreThan100000" | "registrationPage.defaultNumberLabel" | "registrationPage.withOrganismLabel" | "registrationPage.withoutOrganismNameLabel" | "rejection.AccountHolderNotFoundRejection" | "rejection.AccountHolderTypeIndividualRejection" | "rejection.AccountMembershipCannotBeDisabledRejection" | "rejection.AccountMembershipCannotBeUpdatedRejection" | "rejection.AccountMembershipNotAllowedRejection" | "rejection.AccountMembershipNotFoundRejection" | "rejection.AccountMembershipNotReadyToBeBoundRejection" | "rejection.AccountNotEligibleRejection" | "rejection.AccountNotFoundRejection" | "rejection.AccountVerificationAlreadyRejectedRejection" | "rejection.AccountVerificationWrongStatusRejection" | "rejection.AddingCardsToDifferentAccountsRejection" | "rejection.AlreadyValidPhysicalCardRejection" | "rejection.ApplePayNotAllowedForProjectRejection" | "rejection.BadAccountStatusRejection" | "rejection.BadRequestRejection" | "rejection.CannotActivatePhysicalCardRejection" | "rejection.CapitalDepositDocumentCanNotBeUploaded" | "rejection.CardCanNotBeDigitalizedRejection" | "rejection.CardNotFoundRejection" | "rejection.CardProductDisabledRejection" | "rejection.CardProductNotApplicableToPhysicalCardsRejection" | "rejection.CardProductNotFoundRejection" | "rejection.CardProductSuspendedRejection" | "rejection.CardProductUsedRejection" | "rejection.CardWrongStatusRejection" | "rejection.ConsentNotFoundRejection" | "rejection.ConsentTypeNotSupportedByServerConsentRejection" | "rejection.ConsentsAlreadyLinkedToMultiConsentRejection" | "rejection.ConsentsNotAllInCreatedStatusRejection" | "rejection.ConsentsNotFoundRejection" | "rejection.DebtorAccountClosedRejection" | "rejection.DebtorAccountNotAllowedRejection" | "rejection.DigitalCardNotFoundRejection" | "rejection.EnabledCardDesignNotFoundRejection" | "rejection.ExternalAccountAlreadyExistsRejection" | "rejection.ExternalAccountBalanceAlreadyExistsRejection" | "rejection.ForbiddenRejection" | "rejection.FundingLimitExceededRejection" | "rejection.FundingLimitSettingsChangeRequestBadAmountRejection" | "rejection.FundingSourceNotFoundRejection" | "rejection.FundingSourceWrongStatusRejection" | "rejection.GlobalFundingLimitExceededRejection" | "rejection.GlobalInstantFundingLimitExceededRejection" | "rejection.IBANNotReachableRejection" | "rejection.IBANNotValidRejection" | "rejection.IbanValidationRejection" | "rejection.IdentityAlreadyBindToAccountMembershipRejection" | "rejection.InstantFundingLimitExceededRejection" | "rejection.InsufficientFundsRejection" | "rejection.InternalErrorRejection" | "rejection.InvalidArgumentRejection" | "rejection.InvalidPhoneNumberRejection" | "rejection.InvalidSirenNumberRejection" | "rejection.LegalRepresentativeAccountMembershipCannotBeDisabledRejection" | "rejection.LegalRepresentativeAccountMembershipCannotBeSuspendedRejection" | "rejection.MerchantProfileWrongStatusRejection" | "rejection.MissingMandatoryFieldRejection" | "rejection.NotFoundRejection" | "rejection.NotReachableConsentStatusRejection" | "rejection.NotSupportedCountryRejection" | "rejection.OnboardingNotCompletedRejection" | "rejection.PINNotReadyRejection" | "rejection.PaymentMandateMandateNotFoundRejection" | "rejection.PaymentMandateReferenceAlreadyUsedRejection" | "rejection.PaymentMethodNotCompatibleRejection" | "rejection.PermissionCannotBeGrantedRejection" | "rejection.PhysicalCardNotFoundRejection" | "rejection.PhysicalCardWrongStatusRejection" | "rejection.ProjectForbiddenRejection" | "rejection.ProjectFundingLimitExceededRejection" | "rejection.ProjectInstantFundingLimitExceededRejection" | "rejection.ProjectInvalidStatusRejection" | "rejection.ProjectNotFound" | "rejection.ProjectNotFoundRejection" | "rejection.ProjectSettingsForbiddenError" | "rejection.ProjectSettingsNotFound" | "rejection.ProjectSettingsStatusNotReachable" | "rejection.PublicOnboardingDisabledRejection" | "rejection.ReceivedDirectDebitMandateAlreadyExistRejection" | "rejection.ReceivedDirectDebitMandateCanceledRejection" | "rejection.ReceivedDirectDebitMandateNotB2bRejection" | "rejection.ReceivedDirectDebitMandateNotFoundRejection" | "rejection.RefundRejection" | "rejection.RestrictedToUserRejection" | "rejection.SchemeWrongRejection" | "rejection.ServerConsentCredentialsNotValidOrOutdatedRejection" | "rejection.ServerConsentNotAllowedForConsentOperationRejection" | "rejection.ServerConsentNotAllowedForProjectRejection" | "rejection.ServerConsentProjectCredentialMissingRejection" | "rejection.ServerConsentProjectCredentialNotFoundRejection" | "rejection.ServerConsentProjectSettingsNotFoundRejection" | "rejection.ServerConsentSignatureNotValidRejection" | "rejection.StandingOrderNotFoundRejection" | "rejection.SupportingDocumentCollectionNotFoundRejection" | "rejection.SupportingDocumentCollectionStatusDoesNotAllowDeletionRejection" | "rejection.SupportingDocumentCollectionStatusDoesNotAllowUpdateRejection" | "rejection.SupportingDocumentCollectionStatusNotAllowedRejection" | "rejection.SupportingDocumentNotFoundRejection" | "rejection.SupportingDocumentStatusDoesNotAllowDeletionRejection" | "rejection.SupportingDocumentStatusDoesNotAllowUpdateRejection" | "rejection.SupportingDocumentStatusNotAllowedRejection" | "rejection.SupportingDocumentUploadNotAllowedRejection" | "rejection.SuspendReceivedDirectDebitMandatedRejection" | "rejection.TooManyChildConsentsRejection" | "rejection.TooManyItemsRejection" | "rejection.TransactionNotFoundRejection" | "rejection.UpdateUserConsentSettingsTokenRejection" | "rejection.UserNotAllowedToDisableItsOwnAccountMembershipRejection" | "rejection.UserNotAllowedToManageAccountMembershipRejection" | "rejection.UserNotAllowedToSuspendItsOwnAccountMembershipRejection" | "rejection.UserNotCardHolderRejection" | "rejection.ValidationRejection" | "rejection.WrongValueProvidedRejection" | "rib.accountHolder" | "rib.accountNumber" | "rib.address" | "rib.agency" | "rib.bank" | "rib.bankDetails" | "rib.bic" | "rib.iban" | "rib.key" | "rib.nationalCode" | "rib.number" | "rib.partnership" | "supportingDocuments.documentTypes" | "supportingDocuments.errorUpload" | "supportingDocuments.noRequiredDocuments" | "supportingDocuments.downloadTemplate" | "supportingDocuments.powerOfAttorneyModal.title" | "supportingDocuments.powerOfAttorneyModal.description" | "supportingDocuments.help.whatIsThis" | "supportingDocuments.purpose.AdministratorDecisionOfAppointment" | "supportingDocuments.purpose.AdministratorDecisionOfAppointment.description" | "supportingDocuments.purpose.AssociationRegistration" | "supportingDocuments.purpose.AssociationRegistration.description" | "supportingDocuments.purpose.Banking" | "supportingDocuments.purpose.Banking.description" | "supportingDocuments.purpose.CompanyRegistration" | "supportingDocuments.purpose.CompanyRegistration.description" | "supportingDocuments.purpose.FinancialStatements" | "supportingDocuments.purpose.FinancialStatements.description" | "supportingDocuments.purpose.GeneralAssemblyMinutes" | "supportingDocuments.purpose.GeneralAssemblyMinutes.description" | "supportingDocuments.purpose.LegalRepresentativeProofOfIdentity" | "supportingDocuments.purpose.LegalRepresentativeProofOfIdentity.description" | "supportingDocuments.purpose.NIFAccreditationCard" | "supportingDocuments.purpose.NIFAccreditationCard.description" | "supportingDocuments.purpose.Other" | "supportingDocuments.purpose.Other.description" | "supportingDocuments.purpose.PowerOfAttorney" | "supportingDocuments.purpose.PowerOfAttorney.description" | "supportingDocuments.purpose.PresidentDecisionOfAppointment" | "supportingDocuments.purpose.PresidentDecisionOfAppointment.description" | "supportingDocuments.purpose.ProofOfCompanyAddress" | "supportingDocuments.purpose.ProofOfCompanyAddress.description" | "supportingDocuments.purpose.ProofOfCompanyIncome" | "supportingDocuments.purpose.ProofOfCompanyIncome.description" | "supportingDocuments.purpose.ProofOfIdentity" | "supportingDocuments.purpose.ProofOfIdentity.description" | "supportingDocuments.purpose.ProofOfIndividualAddress" | "supportingDocuments.purpose.ProofOfIndividualAddress.description" | "supportingDocuments.purpose.ProofOfIndividualIncome" | "supportingDocuments.purpose.ProofOfIndividualIncome.description" | "supportingDocuments.purpose.ProofOfOriginOfFunds" | "supportingDocuments.purpose.ProofOfOriginOfFunds.description" | "supportingDocuments.purpose.SignedStatus" | "supportingDocuments.purpose.SignedStatus.description" | "supportingDocuments.purpose.SwornStatement" | "supportingDocuments.purpose.SwornStatement.description" | "supportingDocuments.purpose.UBODeclaration" | "supportingDocuments.purpose.UBODeclaration.description" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfAddress" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfAddress.description" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfIdentity" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfIdentity.description" | "uploadArea.browse" | "uploadArea.dropFile" | "uploadArea.droppedFile" | "uploadArea.noValue" | "uploadArea.unknownFileName" | "uploadArea.uploading";
|
|
22
|
+
export declare const isTranslationKey: (value: unknown) => value is "addressFormPart.addressLabel" | "addressFormPart.cityLabel" | "addressFormPart.placeholder" | "addressFormPart.postCodeLabel" | "beneficiaryForm.beneficiary.address" | "beneficiaryForm.beneficiary.birthCity" | "beneficiaryForm.beneficiary.birthCityPlaceholder" | "beneficiaryForm.beneficiary.birthCountry" | "beneficiaryForm.beneficiary.birthCountryPlaceholder" | "beneficiaryForm.beneficiary.birthDate" | "beneficiaryForm.beneficiary.birthPostalCode" | "beneficiaryForm.beneficiary.birthPostalCodePlaceholder" | "beneficiaryForm.beneficiary.country" | "beneficiaryForm.beneficiary.directOrIndirect" | "beneficiaryForm.beneficiary.directly" | "beneficiaryForm.beneficiary.fillBirthCountry" | "beneficiaryForm.beneficiary.firstName" | "beneficiaryForm.beneficiary.firstNamePlaceholder" | "beneficiaryForm.beneficiary.indirectly" | "beneficiaryForm.beneficiary.lastName" | "beneficiaryForm.beneficiary.lastNamePlaceholder" | "beneficiaryForm.beneficiary.legalRepresentative" | "beneficiaryForm.beneficiary.other" | "beneficiaryForm.beneficiary.ownershipOfCapital" | "beneficiaryForm.beneficiary.taxIdentificationNumber" | "beneficiaryForm.beneficiary.totalCapitalPercentage" | "beneficiaryForm.beneficiary.type" | "businessActivity.administrativeServices" | "businessActivity.agriculture" | "businessActivity.arts" | "businessActivity.businessAndRetail" | "businessActivity.construction" | "businessActivity.education" | "businessActivity.electricalDistributionAndWaterSupply" | "businessActivity.financialAndInsuranceOperations" | "businessActivity.health" | "businessActivity.housekeeping" | "businessActivity.informationAndCommunication" | "businessActivity.lodgingAndFoodServices" | "businessActivity.manufacturingAndMining" | "businessActivity.other" | "businessActivity.publicAdministration" | "businessActivity.realEstate" | "businessActivity.scientificActivities" | "businessActivity.transportation" | "common.cancel" | "common.close" | "common.form.help.nbCharacters" | "common.form.help.nbDigits" | "common.form.invalidTaxIdentificationNumber" | "common.form.taxIdentificationNumber.placeholder" | "common.form.taxIdentificationNumber.tooltip.deu" | "common.next" | "common.noResult" | "common.open" | "common.optional" | "common.previous" | "common.remove" | "common.showLess" | "common.showMore" | "common.skipToContent" | "datePicker.day.friday" | "datePicker.day.monday" | "datePicker.day.saturday" | "datePicker.day.sunday" | "datePicker.day.thursday" | "datePicker.day.tuesday" | "datePicker.day.wednesday" | "datePicker.month.april" | "datePicker.month.august" | "datePicker.month.december" | "datePicker.month.february" | "datePicker.month.january" | "datePicker.month.july" | "datePicker.month.june" | "datePicker.month.march" | "datePicker.month.may" | "datePicker.month.next" | "datePicker.month.november" | "datePicker.month.october" | "datePicker.month.previous" | "datePicker.month.september" | "error.generic" | "error.iban.invalid" | "error.network.500" | "error.network.503" | "error.requiredField" | "monthlyPaymentVolume.between10000And50000" | "monthlyPaymentVolume.between50000And100000" | "monthlyPaymentVolume.lessThan10000" | "monthlyPaymentVolume.moreThan100000" | "registrationPage.defaultNumberLabel" | "registrationPage.withOrganismLabel" | "registrationPage.withoutOrganismNameLabel" | "rejection.AccountHolderNotFoundRejection" | "rejection.AccountHolderTypeIndividualRejection" | "rejection.AccountMembershipCannotBeDisabledRejection" | "rejection.AccountMembershipCannotBeUpdatedRejection" | "rejection.AccountMembershipNotAllowedRejection" | "rejection.AccountMembershipNotFoundRejection" | "rejection.AccountMembershipNotReadyToBeBoundRejection" | "rejection.AccountNotEligibleRejection" | "rejection.AccountNotFoundRejection" | "rejection.AccountVerificationAlreadyRejectedRejection" | "rejection.AccountVerificationWrongStatusRejection" | "rejection.AddingCardsToDifferentAccountsRejection" | "rejection.AlreadyValidPhysicalCardRejection" | "rejection.ApplePayNotAllowedForProjectRejection" | "rejection.BadAccountStatusRejection" | "rejection.BadRequestRejection" | "rejection.CannotActivatePhysicalCardRejection" | "rejection.CapitalDepositDocumentCanNotBeUploaded" | "rejection.CardCanNotBeDigitalizedRejection" | "rejection.CardNotFoundRejection" | "rejection.CardProductDisabledRejection" | "rejection.CardProductNotApplicableToPhysicalCardsRejection" | "rejection.CardProductNotFoundRejection" | "rejection.CardProductSuspendedRejection" | "rejection.CardProductUsedRejection" | "rejection.CardWrongStatusRejection" | "rejection.ConsentNotFoundRejection" | "rejection.ConsentTypeNotSupportedByServerConsentRejection" | "rejection.ConsentsAlreadyLinkedToMultiConsentRejection" | "rejection.ConsentsNotAllInCreatedStatusRejection" | "rejection.ConsentsNotFoundRejection" | "rejection.DebtorAccountClosedRejection" | "rejection.DebtorAccountNotAllowedRejection" | "rejection.DigitalCardNotFoundRejection" | "rejection.EnabledCardDesignNotFoundRejection" | "rejection.ExternalAccountAlreadyExistsRejection" | "rejection.ExternalAccountBalanceAlreadyExistsRejection" | "rejection.ForbiddenRejection" | "rejection.FundingLimitExceededRejection" | "rejection.FundingLimitSettingsChangeRequestBadAmountRejection" | "rejection.FundingSourceNotFoundRejection" | "rejection.FundingSourceWrongStatusRejection" | "rejection.GlobalFundingLimitExceededRejection" | "rejection.GlobalInstantFundingLimitExceededRejection" | "rejection.IBANNotReachableRejection" | "rejection.IBANNotValidRejection" | "rejection.IbanValidationRejection" | "rejection.IdentityAlreadyBindToAccountMembershipRejection" | "rejection.InstantFundingLimitExceededRejection" | "rejection.InsufficientFundsRejection" | "rejection.InternalErrorRejection" | "rejection.InvalidArgumentRejection" | "rejection.InvalidPhoneNumberRejection" | "rejection.InvalidSirenNumberRejection" | "rejection.LegalRepresentativeAccountMembershipCannotBeDisabledRejection" | "rejection.LegalRepresentativeAccountMembershipCannotBeSuspendedRejection" | "rejection.MerchantProfileWrongStatusRejection" | "rejection.MissingMandatoryFieldRejection" | "rejection.NotFoundRejection" | "rejection.NotReachableConsentStatusRejection" | "rejection.NotSupportedCountryRejection" | "rejection.OnboardingNotCompletedRejection" | "rejection.PINNotReadyRejection" | "rejection.PaymentMandateMandateNotFoundRejection" | "rejection.PaymentMandateReferenceAlreadyUsedRejection" | "rejection.PaymentMethodNotCompatibleRejection" | "rejection.PermissionCannotBeGrantedRejection" | "rejection.PhysicalCardNotFoundRejection" | "rejection.PhysicalCardWrongStatusRejection" | "rejection.ProjectForbiddenRejection" | "rejection.ProjectFundingLimitExceededRejection" | "rejection.ProjectInstantFundingLimitExceededRejection" | "rejection.ProjectInvalidStatusRejection" | "rejection.ProjectNotFound" | "rejection.ProjectNotFoundRejection" | "rejection.ProjectSettingsForbiddenError" | "rejection.ProjectSettingsNotFound" | "rejection.ProjectSettingsStatusNotReachable" | "rejection.PublicOnboardingDisabledRejection" | "rejection.ReceivedDirectDebitMandateAlreadyExistRejection" | "rejection.ReceivedDirectDebitMandateCanceledRejection" | "rejection.ReceivedDirectDebitMandateNotB2bRejection" | "rejection.ReceivedDirectDebitMandateNotFoundRejection" | "rejection.RefundRejection" | "rejection.RestrictedToUserRejection" | "rejection.SchemeWrongRejection" | "rejection.ServerConsentCredentialsNotValidOrOutdatedRejection" | "rejection.ServerConsentNotAllowedForConsentOperationRejection" | "rejection.ServerConsentNotAllowedForProjectRejection" | "rejection.ServerConsentProjectCredentialMissingRejection" | "rejection.ServerConsentProjectCredentialNotFoundRejection" | "rejection.ServerConsentProjectSettingsNotFoundRejection" | "rejection.ServerConsentSignatureNotValidRejection" | "rejection.StandingOrderNotFoundRejection" | "rejection.SupportingDocumentCollectionNotFoundRejection" | "rejection.SupportingDocumentCollectionStatusDoesNotAllowDeletionRejection" | "rejection.SupportingDocumentCollectionStatusDoesNotAllowUpdateRejection" | "rejection.SupportingDocumentCollectionStatusNotAllowedRejection" | "rejection.SupportingDocumentNotFoundRejection" | "rejection.SupportingDocumentStatusDoesNotAllowDeletionRejection" | "rejection.SupportingDocumentStatusDoesNotAllowUpdateRejection" | "rejection.SupportingDocumentStatusNotAllowedRejection" | "rejection.SupportingDocumentUploadNotAllowedRejection" | "rejection.SuspendReceivedDirectDebitMandatedRejection" | "rejection.TooManyChildConsentsRejection" | "rejection.TooManyItemsRejection" | "rejection.TransactionNotFoundRejection" | "rejection.UpdateUserConsentSettingsTokenRejection" | "rejection.UserNotAllowedToDisableItsOwnAccountMembershipRejection" | "rejection.UserNotAllowedToManageAccountMembershipRejection" | "rejection.UserNotAllowedToSuspendItsOwnAccountMembershipRejection" | "rejection.UserNotCardHolderRejection" | "rejection.ValidationRejection" | "rejection.WrongValueProvidedRejection" | "rib.accountHolder" | "rib.accountNumber" | "rib.address" | "rib.agency" | "rib.bank" | "rib.bankDetails" | "rib.bic" | "rib.iban" | "rib.key" | "rib.nationalCode" | "rib.number" | "rib.partnership" | "supportingDocuments.documentTypes" | "supportingDocuments.errorUpload" | "supportingDocuments.noRequiredDocuments" | "supportingDocuments.downloadTemplate" | "supportingDocuments.powerOfAttorneyModal.title" | "supportingDocuments.powerOfAttorneyModal.description" | "supportingDocuments.help.whatIsThis" | "supportingDocuments.purpose.AdministratorDecisionOfAppointment" | "supportingDocuments.purpose.AdministratorDecisionOfAppointment.description" | "supportingDocuments.purpose.AssociationRegistration" | "supportingDocuments.purpose.AssociationRegistration.description" | "supportingDocuments.purpose.Banking" | "supportingDocuments.purpose.Banking.description" | "supportingDocuments.purpose.CompanyRegistration" | "supportingDocuments.purpose.CompanyRegistration.description" | "supportingDocuments.purpose.FinancialStatements" | "supportingDocuments.purpose.FinancialStatements.description" | "supportingDocuments.purpose.GeneralAssemblyMinutes" | "supportingDocuments.purpose.GeneralAssemblyMinutes.description" | "supportingDocuments.purpose.LegalRepresentativeProofOfIdentity" | "supportingDocuments.purpose.LegalRepresentativeProofOfIdentity.description" | "supportingDocuments.purpose.NIFAccreditationCard" | "supportingDocuments.purpose.NIFAccreditationCard.description" | "supportingDocuments.purpose.Other" | "supportingDocuments.purpose.Other.description" | "supportingDocuments.purpose.PowerOfAttorney" | "supportingDocuments.purpose.PowerOfAttorney.description" | "supportingDocuments.purpose.PresidentDecisionOfAppointment" | "supportingDocuments.purpose.PresidentDecisionOfAppointment.description" | "supportingDocuments.purpose.ProofOfCompanyAddress" | "supportingDocuments.purpose.ProofOfCompanyAddress.description" | "supportingDocuments.purpose.ProofOfCompanyIncome" | "supportingDocuments.purpose.ProofOfCompanyIncome.description" | "supportingDocuments.purpose.ProofOfIdentity" | "supportingDocuments.purpose.ProofOfIdentity.description" | "supportingDocuments.purpose.ProofOfIndividualAddress" | "supportingDocuments.purpose.ProofOfIndividualAddress.description" | "supportingDocuments.purpose.ProofOfIndividualIncome" | "supportingDocuments.purpose.ProofOfIndividualIncome.description" | "supportingDocuments.purpose.ProofOfOriginOfFunds" | "supportingDocuments.purpose.ProofOfOriginOfFunds.description" | "supportingDocuments.purpose.SignedStatus" | "supportingDocuments.purpose.SignedStatus.description" | "supportingDocuments.purpose.SwornStatement" | "supportingDocuments.purpose.SwornStatement.description" | "supportingDocuments.purpose.UBODeclaration" | "supportingDocuments.purpose.UBODeclaration.description" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfAddress" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfAddress.description" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfIdentity" | "supportingDocuments.purpose.UltimateBeneficialOwnerProofOfIdentity.description" | "uploadArea.browse" | "uploadArea.dropFile" | "uploadArea.droppedFile" | "uploadArea.noValue" | "uploadArea.unknownFileName" | "uploadArea.uploading";
|
|
23
23
|
export declare const translateError: (error: unknown) => string;
|
|
24
24
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Validator } from "
|
|
1
|
+
import { Validator } from "@swan-io/use-form";
|
|
2
2
|
import { AccountCountry } from "./templateTranslations";
|
|
3
3
|
export declare const isValidVatNumber: (maybeVat: string) => boolean;
|
|
4
4
|
export declare const isValidEmail: (maybeEmail: string) => boolean;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Form } from "react-ux-form";
|
|
2
|
-
import { CountryCCA3 } from "../constants/countries";
|
|
3
|
-
type AddressField = {
|
|
4
|
-
address: string;
|
|
5
|
-
city: string;
|
|
6
|
-
postalCode: string;
|
|
7
|
-
};
|
|
8
|
-
type FormProps = Pick<Form<AddressField>, "Field" | "setFieldValue" | "listenFields">;
|
|
9
|
-
type Props = {
|
|
10
|
-
initialAddress: string;
|
|
11
|
-
initialCity: string;
|
|
12
|
-
initialPostalCode: string;
|
|
13
|
-
country: CountryCCA3;
|
|
14
|
-
label: string;
|
|
15
|
-
optionalLabel?: string;
|
|
16
|
-
placeholder?: string;
|
|
17
|
-
isLarge: boolean;
|
|
18
|
-
apiKey: string;
|
|
19
|
-
} & FormProps;
|
|
20
|
-
export declare const AddressFormPart: ({ initialAddress, initialCity, initialPostalCode, country, label, optionalLabel, placeholder, Field, setFieldValue, listenFields, isLarge, apiKey, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
|
|
3
|
-
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
4
|
-
import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
|
|
5
|
-
import { Space } from "@swan-io/lake/src/components/Space";
|
|
6
|
-
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
7
|
-
import { useCallback, useEffect } from "react";
|
|
8
|
-
import { locale, t } from "../utils/i18n";
|
|
9
|
-
import { PlacekitAddressSearchInput } from "./PlacekitAddressSearchInput";
|
|
10
|
-
export const AddressFormPart = ({ initialAddress, initialCity, initialPostalCode, country, label, optionalLabel, placeholder, Field, setFieldValue, listenFields, isLarge, apiKey, }) => {
|
|
11
|
-
const [manualModeEnabled, setManualMode] = useBoolean(initialAddress !== "" || initialCity !== "" || initialPostalCode !== "");
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!manualModeEnabled) {
|
|
14
|
-
return listenFields(["city", "postalCode"], () => {
|
|
15
|
-
setManualMode.on();
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}, [manualModeEnabled, listenFields, setManualMode]);
|
|
19
|
-
const onSuggestion = useCallback((place) => {
|
|
20
|
-
setFieldValue("address", place.completeAddress);
|
|
21
|
-
setFieldValue("city", place.city);
|
|
22
|
-
if (place.postalCode != null) {
|
|
23
|
-
setFieldValue("postalCode", place.postalCode);
|
|
24
|
-
}
|
|
25
|
-
setManualMode.on();
|
|
26
|
-
}, [setManualMode, setFieldValue]);
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsx(Field, { name: "address", children: ({ ref, value, onChange, error }) => (_jsx(LakeLabel, { label: label !== null && label !== void 0 ? label : t("addressFormPart.addressLabel"), optionalLabel: optionalLabel, render: id => (_jsx(PlacekitAddressSearchInput, { inputRef: ref, apiKey: apiKey, emptyResultText: t("common.noResult"), placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("addressFormPart.placeholder"), language: locale.language, id: id, country: country, value: value, error: error, onValueChange: onChange, onSuggestion: onSuggestion })), actions: !manualModeEnabled && isLarge ? (_jsx(LakeButton, { mode: "secondary", size: "small", onPress: setManualMode.on, children: t("addressFormPart.setManual") })) : null })) }), !manualModeEnabled && !isLarge ? (_jsx(LakeButton, { mode: "secondary", size: "small", onPress: setManualMode.on, children: t("addressFormPart.setManual") })) : null, manualModeEnabled ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "city", children: ({ ref, value, valid, error, onChange }) => (_jsx(LakeLabel, { label: t("addressFormPart.cityLabel"), render: id => (_jsx(LakeTextInput, { ref: ref, id: id, value: value, valid: valid, error: error, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "postalCode", children: ({ ref, value, valid, error, onChange }) => (_jsx(LakeLabel, { label: t("addressFormPart.postCodeLabel"), render: id => (_jsx(LakeTextInput, { ref: ref, id: id, value: value, valid: valid, error: error, onChangeText: onChange })) })) })] })) : null] }));
|
|
28
|
-
};
|