@swan-io/shared-business 1.4.2 → 1.4.4
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 +1 -1
- package/src/components/AddressFormPart.d.ts +1 -1
- package/src/components/AddressFormPart.js +1 -1
- package/src/components/AddressSearchInput.js +1 -1
- package/src/components/BeneficiaryForm.js +3 -3
- package/src/components/LakeCityInput.js +1 -1
- package/src/components/SupportingDocument.d.ts +0 -1
- package/src/components/SupportingDocument.js +8 -12
- package/src/components/UploadArea.js +5 -5
- package/src/constants/countries.d.ts +1 -0
- package/src/constants/countries.js +8 -1
- package/src/hooks/useGoogleMapSDK.js +1 -1
- package/src/utils/i18n.d.ts +1 -1
- package/src/utils/i18n.js +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AddressSearchInput } from "./AddressSearchInput";
|
|
3
2
|
import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
|
|
4
3
|
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
5
4
|
import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
|
|
@@ -7,6 +6,7 @@ import { Space } from "@swan-io/lake/src/components/Space";
|
|
|
7
6
|
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
8
7
|
import { useCallback, useEffect } from "react";
|
|
9
8
|
import { locale, t } from "../utils/i18n";
|
|
9
|
+
import { AddressSearchInput } from "./AddressSearchInput";
|
|
10
10
|
export const AddressFormPart = ({ initialAddress, initialCity, initialPostalCode, country, label, optionalLabel, placeholder, Field, setFieldValue, listenFields, isLarge, }) => {
|
|
11
11
|
const [manualModeEnabled, setManualMode] = useBoolean(initialAddress !== "" || initialCity !== "" || initialPostalCode !== "");
|
|
12
12
|
useEffect(() => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AsyncData, Future } from "@swan-io/boxed";
|
|
3
|
-
import { countriesWithMultipleCCA3, getCCA3forCCA2, } from "@swan-io/shared-business/src/constants/countries";
|
|
4
3
|
import { AutoWidthImage } from "@swan-io/lake/src/components/AutoWidthImage";
|
|
5
4
|
import { Box } from "@swan-io/lake/src/components/Box";
|
|
6
5
|
import { LakeCombobox } from "@swan-io/lake/src/components/LakeCombobox";
|
|
@@ -8,6 +7,7 @@ import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
|
|
|
8
7
|
import { colors } from "@swan-io/lake/src/constants/colors";
|
|
9
8
|
import { typography } from "@swan-io/lake/src/constants/typography";
|
|
10
9
|
import { useFirstMountState } from "@swan-io/lake/src/hooks/useFirstMountState";
|
|
10
|
+
import { countriesWithMultipleCCA3, getCCA3forCCA2, } from "@swan-io/shared-business/src/constants/countries";
|
|
11
11
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { StyleSheet, Text } from "react-native";
|
|
13
13
|
import { match } from "ts-pattern";
|
|
@@ -17,7 +17,7 @@ import { hasDefinedKeys, useForm } from "react-ux-form";
|
|
|
17
17
|
import { Rifm } from "rifm";
|
|
18
18
|
import { match } from "ts-pattern";
|
|
19
19
|
import { v4 as uuid } from "uuid";
|
|
20
|
-
import { individualCountriesItems, isCountryCCA3 } from "../constants/countries";
|
|
20
|
+
import { allCountriesItems, individualCountriesItems, isCountryCCA3, } from "../constants/countries";
|
|
21
21
|
import { decodeBirthDate, encodeBirthDate } from "../utils/date";
|
|
22
22
|
import { locale, rifmDateProps, t } from "../utils/i18n";
|
|
23
23
|
import { validateBooleanRequired, validateIndividualTaxNumber, validateNullableRequired, validateRequired, } from "../utils/validation";
|
|
@@ -242,7 +242,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
242
242
|
}
|
|
243
243
|
const allStepsValues = { ...commonStepValues.current, ...values };
|
|
244
244
|
if (hasDefinedKeys(allStepsValues, requiredStepFields)) {
|
|
245
|
-
const [direct, indirect] = getDirectAndIndirect(
|
|
245
|
+
const [direct, indirect] = getDirectAndIndirect(allStepsValues.capitalType ?? "none");
|
|
246
246
|
return onSave({
|
|
247
247
|
reference,
|
|
248
248
|
firstName: allStepsValues.firstName,
|
|
@@ -269,7 +269,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
269
269
|
};
|
|
270
270
|
});
|
|
271
271
|
return (_jsx(ResponsiveContainer, { breakpoint: breakpoints.tiny, children: ({ small, large }) => (_jsxs(_Fragment, { children: [match(step)
|
|
272
|
-
.with("common", () => (_jsxs(View, { accessibilityRole: "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"), nativeID: 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"), nativeID: 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"), style: styles.inputContainer, render: id => (_jsx(Rifm, { value: value ?? "", onChange: onChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { error: error, placeholder: locale.datePlaceholder, nativeID: 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, { nativeID: id, error: error, value: value, placeholder: t("beneficiaryForm.beneficiary.birthCountryPlaceholder"), items:
|
|
272
|
+
.with("common", () => (_jsxs(View, { accessibilityRole: "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"), nativeID: 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"), nativeID: 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"), style: styles.inputContainer, render: id => (_jsx(Rifm, { value: value ?? "", onChange: onChange, ...rifmDateProps, children: ({ value, onChange }) => (_jsx(LakeTextInput, { error: error, placeholder: locale.datePlaceholder, nativeID: 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, { nativeID: id, error: error, value: value, placeholder: t("beneficiaryForm.beneficiary.birthCountryPlaceholder"), items: allCountriesItems, 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"), style: styles.inputContainer, render: id => (_jsx(LakeCityInput, { nativeID: id, error: error, country: birthCountryCode.value, value: value ?? "", onValueChange: onChange, placeholder: birthCountryCode.value == null
|
|
273
273
|
? t("beneficiaryForm.beneficiary.fillBirthCountry")
|
|
274
274
|
: t("beneficiaryForm.beneficiary.birthCityPlaceholder"), onSuggestion: place => {
|
|
275
275
|
onChange(place.city);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AsyncData, Future } from "@swan-io/boxed";
|
|
3
|
-
import { useGoogleMapSDK } from "../hooks/useGoogleMapSDK";
|
|
4
3
|
import { AutoWidthImage } from "@swan-io/lake/src/components/AutoWidthImage";
|
|
5
4
|
import { Box } from "@swan-io/lake/src/components/Box";
|
|
6
5
|
import { LakeCombobox } from "@swan-io/lake/src/components/LakeCombobox";
|
|
@@ -12,6 +11,7 @@ import { StyleSheet, Text } from "react-native";
|
|
|
12
11
|
import { match } from "ts-pattern";
|
|
13
12
|
import poweredByGoogle from "../assets/images/powered_by_google_on_white_hdpi.png";
|
|
14
13
|
import { countriesWithMultipleCCA3 } from "../constants/countries";
|
|
14
|
+
import { useGoogleMapSDK } from "../hooks/useGoogleMapSDK";
|
|
15
15
|
import { t } from "../utils/i18n";
|
|
16
16
|
const styles = StyleSheet.create({
|
|
17
17
|
itemTitle: {
|
|
@@ -22,7 +22,6 @@ type Props = {
|
|
|
22
22
|
documents: Document[];
|
|
23
23
|
requiredDocumentTypes: SupportingDocumentPurposeEnum[];
|
|
24
24
|
onChange?: (documents: Document[]) => void;
|
|
25
|
-
withoutRepresentationRadio?: boolean;
|
|
26
25
|
onboardingLanguage?: string;
|
|
27
26
|
};
|
|
28
27
|
export type SupportingDocumentRef = {
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { Box } from "@swan-io/lake/src/components/Box";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { Form } from "@swan-io/lake/src/components/Form";
|
|
4
3
|
import { LakeButton, LakeButtonGroup } from "@swan-io/lake/src/components/LakeButton";
|
|
5
4
|
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
6
5
|
import { LakeModal } from "@swan-io/lake/src/components/LakeModal";
|
|
7
|
-
import { LakeRadio } from "@swan-io/lake/src/components/LakeRadio";
|
|
8
6
|
import { LakeText } from "@swan-io/lake/src/components/LakeText";
|
|
9
7
|
import { LakeTooltip } from "@swan-io/lake/src/components/LakeTooltip";
|
|
10
|
-
import { Pressable } from "@swan-io/lake/src/components/Pressable";
|
|
11
8
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
12
|
-
import {
|
|
13
|
-
import { isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
|
|
9
|
+
import { isNullish } from "@swan-io/lake/src/utils/nullish";
|
|
14
10
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react";
|
|
15
11
|
import { StyleSheet } from "react-native";
|
|
16
12
|
import { useForm } from "react-ux-form";
|
|
17
13
|
import { match } from "ts-pattern";
|
|
18
14
|
import { MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE } from "../constants/uploads";
|
|
19
15
|
import { locale, t } from "../utils/i18n";
|
|
16
|
+
import { UploadArea } from "./UploadArea";
|
|
20
17
|
const ACCEPTED_FORMATS = ["application/pdf", "image/png", "image/jpeg"];
|
|
21
18
|
const NO_ID_YET = "NO_ID_YET";
|
|
22
19
|
const validateNotEmpty = value => {
|
|
@@ -39,7 +36,7 @@ const Help = (props) => {
|
|
|
39
36
|
.with({ type: "button" }, ({ label, onPress }) => (_jsx(LakeButton, { mode: "tertiary", size: "small", color: "gray", icon: "question-circle-regular", onPress: onPress, style: styles.button, accessibilityLabel: t("supportingDoc.whatIsThis"), children: label })))
|
|
40
37
|
.exhaustive();
|
|
41
38
|
};
|
|
42
|
-
export const SupportingDocument = forwardRef(({ documents, getAwsUrl, onChange, requiredDocumentTypes, onboardingLanguage = locale.language
|
|
39
|
+
export const SupportingDocument = forwardRef(({ documents, getAwsUrl, onChange, requiredDocumentTypes, onboardingLanguage = locale.language }, externalRef) => {
|
|
43
40
|
const initialValues = useMemo(() => documents.reduce((acc, doc) => {
|
|
44
41
|
return {
|
|
45
42
|
...acc,
|
|
@@ -55,7 +52,6 @@ export const SupportingDocument = forwardRef(({ documents, getAwsUrl, onChange,
|
|
|
55
52
|
};
|
|
56
53
|
}, {}), [documents]);
|
|
57
54
|
const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
|
|
58
|
-
const [isOther, setIsOther] = useState(isNotNullish(initialValues["Other"]) || isNotNullish(initialValues["ProofOfIdentity"]));
|
|
59
55
|
const { Field, setFieldValue, getFieldState, listenFields, submitForm } = useForm({
|
|
60
56
|
CompanyRegistration: {
|
|
61
57
|
initialValue: initialValues["CompanyRegistration"] ?? [],
|
|
@@ -151,7 +147,7 @@ export const SupportingDocument = forwardRef(({ documents, getAwsUrl, onChange,
|
|
|
151
147
|
})
|
|
152
148
|
.catch(console.error);
|
|
153
149
|
};
|
|
154
|
-
return (_jsxs(Form, { children: [
|
|
150
|
+
return (_jsxs(Form, { children: [requiredDocumentTypes.some(t => t === "CompanyRegistration") && (_jsxs(_Fragment, { children: [_jsx(LakeLabel, { label: t("supportingDoc.companyRegistration"), help: _jsx(Help, { type: "tooltip", text: "supportingDoc.companyRegistration.description" }), render: () => (_jsx(Field, { name: "CompanyRegistration", children: ({ value, onChange, error }) => (_jsx(UploadArea, { layout: "horizontal", error: error, onDropAccepted: files => {
|
|
155
151
|
onChange([...value, { id: NO_ID_YET }]);
|
|
156
152
|
handleUpload(files, "CompanyRegistration");
|
|
157
153
|
}, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.some(t => t === "AssociationRegistration") && (_jsxs(_Fragment, { children: [_jsx(LakeLabel, { label: t("supportingDoc.associationRegistration"), help: _jsx(Help, { type: "tooltip", text: "supportingDoc.associationRegistration.description" }), render: () => (_jsx(Field, { name: "AssociationRegistration", children: ({ value, onChange, error }) => (_jsx(UploadArea, { layout: "horizontal", onDropAccepted: files => {
|
|
@@ -160,13 +156,13 @@ export const SupportingDocument = forwardRef(({ documents, getAwsUrl, onChange,
|
|
|
160
156
|
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.some(t => t === "SignedStatus") && (_jsxs(_Fragment, { children: [_jsx(LakeLabel, { label: t("supportingDoc.signedStatus"), help: _jsx(Help, { type: "tooltip", text: "supportingDoc.signedStatus.description" }), render: () => (_jsx(Field, { name: "SignedStatus", children: ({ value, onChange, error }) => (_jsx(UploadArea, { layout: "horizontal", onDropAccepted: files => {
|
|
161
157
|
onChange([...value, { id: NO_ID_YET }]);
|
|
162
158
|
handleUpload(files, "SignedStatus");
|
|
163
|
-
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })),
|
|
159
|
+
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.some(t => t === "ProofOfIdentity") && (_jsxs(_Fragment, { children: [_jsx(LakeLabel, { label: t("supportingDoc.proofOfIdentity"), help: _jsx(Help, { type: "tooltip", width: 600, text: "supportingDoc.proofOfIdentity.description" }), render: () => (_jsx(Field, { name: "ProofOfIdentity", children: ({ value, onChange, error }) => (_jsx(UploadArea, { layout: "horizontal", onDropAccepted: files => {
|
|
164
160
|
onChange([...value, { id: NO_ID_YET }]);
|
|
165
161
|
handleUpload(files, "ProofOfIdentity");
|
|
166
|
-
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })),
|
|
162
|
+
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.some(t => t === "PowerOfAttorney") && (_jsxs(_Fragment, { children: [_jsx(LakeLabel, { label: t("supportingDoc.powerAttornySigned"), help: _jsx(Help, { type: "button", label: t("supportingDoc.whatIsThis"), onPress: () => setShowPowerOfAttorneyModal(true) }), render: () => (_jsx(Field, { name: "Other", children: ({ value, onChange, error }) => (_jsx(UploadArea, { layout: "horizontal", onDropAccepted: files => {
|
|
167
163
|
onChange([...value, { id: NO_ID_YET }]);
|
|
168
164
|
handleUpload(files, "Other");
|
|
169
|
-
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.length === 0
|
|
165
|
+
}, error: error, documents: value, accept: ACCEPTED_FORMATS, icon: "document-regular", description: t("supportingDoc.documentTypes"), maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE })) })) }), _jsx(Space, { height: 24 })] })), requiredDocumentTypes.length === 0 ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 24 }), _jsx(LakeText, { children: t("supportingDoc.noRequiredDocuments") }), _jsx(Space, { height: 24 })] })) : null, _jsxs(LakeModal, { visible: showPowerOfAttorneyModal, title: t("supportingDoc.powerAttorney"), icon: "document-regular", onPressClose: () => setShowPowerOfAttorneyModal(false), children: [_jsx(LakeText, { children: t("supportingDoc.powerAttornySigned.description") }), _jsx(Space, { height: 16 }), _jsx(LakeButtonGroup, { paddingBottom: 0, children: _jsx(LakeButton, { grow: true, color: "current", onPress: () => window.open(`/power-of-attorney-template/${match(onboardingLanguage)
|
|
170
166
|
.with("fr", () => "fr")
|
|
171
167
|
.with("de", () => "de")
|
|
172
168
|
.with("es", () => "es")
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { formatNestedMessage, t } from "../utils/i18n";
|
|
3
2
|
import { Box } from "@swan-io/lake/src/components/Box";
|
|
3
|
+
import { FileTile } from "@swan-io/lake/src/components/FileTile";
|
|
4
4
|
import { Icon } from "@swan-io/lake/src/components/Icon";
|
|
5
5
|
import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
|
|
6
6
|
import { LakeText } from "@swan-io/lake/src/components/LakeText";
|
|
7
7
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
8
|
+
import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
|
|
8
9
|
import { backgroundColor, colors, gray75, radii, shadows, spacings, } from "@swan-io/lake/src/constants/design";
|
|
10
|
+
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
11
|
+
import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
|
|
9
12
|
import { isNotNullish, isNullish } from "@swan-io/lake/src/utils/nullish";
|
|
10
13
|
import { Fragment, useLayoutEffect, useRef } from "react";
|
|
11
14
|
import { useDropzone } from "react-dropzone";
|
|
12
15
|
import { StyleSheet, Text, View } from "react-native";
|
|
13
|
-
import {
|
|
14
|
-
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
15
|
-
import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
|
|
16
|
-
import { FileTile } from "@swan-io/lake/src/components/FileTile";
|
|
16
|
+
import { formatNestedMessage, t } from "../utils/i18n";
|
|
17
17
|
const styles = StyleSheet.create({
|
|
18
18
|
container: {
|
|
19
19
|
backgroundColor: backgroundColor.accented,
|
|
@@ -1985,6 +1985,7 @@ export declare const getCCA3forCCA2: (cca2: CountryCCA2) => "ALA" | "ASM" | "AND
|
|
|
1985
1985
|
export declare const getCountryNameByCCA3: (cca3: string) => string;
|
|
1986
1986
|
export declare const companyWithUboCountries: readonly ["BEL", "DEU", "FRA", "ITA", "LTU", "LUX", "NLD"];
|
|
1987
1987
|
export type CompanyWithUboCountryCCA3 = (typeof companyWithUboCountries)[number];
|
|
1988
|
+
export declare const allCountriesItems: CountryItem<CountryCCA3>[];
|
|
1988
1989
|
declare const individualCountries: ("BEL" | "CZE" | "DNK" | "DEU" | "EST" | "IRL" | "ESP" | "FRA" | "HRV" | "ISL" | "ITA" | "LVA" | "LIE" | "LTU" | "LUX" | "HUN" | "MLT" | "NLD" | "NOR" | "AUT" | "POL" | "PRT" | "ROU" | "SVN" | "SVK" | "FIN" | "SWE" | "GRC" | "CYP" | "BGR")[];
|
|
1989
1990
|
export type IndividualCountryCCA3 = (typeof individualCountries)[number];
|
|
1990
1991
|
export declare const individualCountriesItems: CountryItem<IndividualCountryCCA3>[];
|
|
@@ -2220,6 +2220,7 @@ const readonlyCountries = [
|
|
|
2220
2220
|
export const countries = readonlyCountries.concat([]);
|
|
2221
2221
|
export const getCCA2forCCA3 = (cca3) => countries.find(country => country.cca3 === cca3)?.cca2;
|
|
2222
2222
|
export const getCCA3forCCA2 = (cca2) => countries.find(country => country.cca2 === cca2)?.cca3;
|
|
2223
|
+
const isTranslatedCountry = (value) => Object.keys(names).includes(value);
|
|
2223
2224
|
export const getCountryNameByCCA3 = (cca3) => {
|
|
2224
2225
|
if (isTranslatedCountry(cca3)) {
|
|
2225
2226
|
return names[cca3];
|
|
@@ -2259,6 +2260,13 @@ const names = {
|
|
|
2259
2260
|
SVN: t("country.SVN"),
|
|
2260
2261
|
SWE: t("country.SWE"),
|
|
2261
2262
|
};
|
|
2263
|
+
export const allCountriesItems = countries
|
|
2264
|
+
.map(country => ({
|
|
2265
|
+
name: getCountryNameByCCA3(country.cca3),
|
|
2266
|
+
cca3: country.cca3,
|
|
2267
|
+
cca2: country.cca2,
|
|
2268
|
+
}))
|
|
2269
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
2262
2270
|
const individualCountries = [
|
|
2263
2271
|
"AUT",
|
|
2264
2272
|
"BEL",
|
|
@@ -2346,7 +2354,6 @@ export const isCountryCCA2 = (value) => countries.some(({ cca2 }) => cca2 === va
|
|
|
2346
2354
|
export const isIndividualCountryCCA3 = (value) => individualCountries.includes(value);
|
|
2347
2355
|
export const isCompanyCountryCCA3 = (value) => companyCountries.includes(value);
|
|
2348
2356
|
export const isCompanyWithUboCountryCCA3 = (value) => companyWithUboCountries.includes(value);
|
|
2349
|
-
const isTranslatedCountry = (value) => Object.keys(names).includes(value);
|
|
2350
2357
|
const getBestNavigatorCountryIndividual = () => {
|
|
2351
2358
|
const navigatorCountries = navigator.languages
|
|
2352
2359
|
.map(lang => lang.split("-")[1])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Loader } from "@googlemaps/js-api-loader";
|
|
1
2
|
import { AsyncData } from "@swan-io/boxed";
|
|
2
3
|
import { useEffect } from "react";
|
|
3
4
|
import { atom, useAtom } from "react-atomic-state";
|
|
4
|
-
import { Loader } from "@googlemaps/js-api-loader";
|
|
5
5
|
const sdk = atom(AsyncData.NotAsked());
|
|
6
6
|
export const useGoogleMapSDK = ({ language, apiKey }) => {
|
|
7
7
|
const googleSdk = useAtom(sdk);
|
package/src/utils/i18n.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RifmProps } from "@swan-io/lake/src/utils/rifm";
|
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
3
|
import translationEN from "../locales/en.json";
|
|
4
4
|
declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "nl", "pt"];
|
|
5
|
-
type SupportedLanguage = typeof supportedLanguages[number];
|
|
5
|
+
type SupportedLanguage = (typeof supportedLanguages)[number];
|
|
6
6
|
type TranslationParams = Record<string, string | number>;
|
|
7
7
|
export type TranslationKey = keyof typeof translationEN;
|
|
8
8
|
type Locale = {
|
package/src/utils/i18n.js
CHANGED
|
@@ -20,7 +20,7 @@ import translationFR from "../locales/fr.json";
|
|
|
20
20
|
import translationIT from "../locales/it.json";
|
|
21
21
|
import translationNL from "../locales/nl.json";
|
|
22
22
|
import translationPT from "../locales/pt.json";
|
|
23
|
-
import {
|
|
23
|
+
import { LANGUAGE_FALLBACK, getLanguagesHelpers } from "./languages";
|
|
24
24
|
// https://day.js.org/docs/en/plugin/plugin
|
|
25
25
|
dayjs.extend(utc);
|
|
26
26
|
dayjs.extend(customParseFormat);
|