@swan-io/shared-business 18.5.0 → 18.7.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 +3 -3
- package/src/components/BirthdatePicker.d.ts +3 -1
- package/src/components/BirthdatePicker.js +2 -2
- package/src/components/FileInput.js +25 -10
- package/src/components/FileTile.d.ts +4 -3
- package/src/components/FileTile.js +14 -7
- package/src/components/FilesUploader.js +12 -4
- package/src/components/FraudReport/CardDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/CardDetailsStep.js +46 -0
- package/src/components/FraudReport/DocumentsStep.d.ts +13 -0
- package/src/components/FraudReport/DocumentsStep.js +49 -0
- package/src/components/FraudReport/FraudReportLayout.d.ts +2 -1
- package/src/components/FraudReport/FraudReportLayout.js +2 -2
- package/src/components/FraudReport/FraudsterDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/FraudsterDetailsStep.js +56 -0
- package/src/components/FraudReport/IntroStep.js +5 -1
- package/src/components/FraudReport/TransactionPicker.d.ts +13 -0
- package/src/components/FraudReport/TransactionPicker.js +213 -0
- package/src/components/FraudReport/TransactionPickerFilters.d.ts +8 -0
- package/src/components/FraudReport/TransactionPickerFilters.js +213 -0
- package/src/components/FraudReport/TransactionRows.d.ts +8 -0
- package/src/components/FraudReport/TransactionRows.js +32 -0
- package/src/components/FraudReport/TransactionsStep.js +9 -27
- package/src/components/FraudReport/TransferDetailsStep.d.ts +7 -0
- package/src/components/FraudReport/TransferDetailsStep.js +25 -0
- package/src/components/FraudReport/VictimStep.d.ts +3 -1
- package/src/components/FraudReport/VictimStep.js +38 -5
- package/src/components/LakeModal.js +1 -1
- package/src/components/SupportingDocumentCollection.d.ts +1 -0
- package/src/components/SupportingDocumentCollection.js +13 -14
- package/src/hooks/__tests__/useFilesUploader.test.d.ts +1 -0
- package/src/hooks/__tests__/useFilesUploader.test.js +101 -0
- package/src/hooks/__tests__/useFraudReportFlow.test.js +108 -20
- package/src/hooks/useFilesUploader.d.ts +2 -1
- package/src/hooks/useFilesUploader.js +28 -9
- package/src/hooks/useFraudReportFlow.js +12 -7
- package/src/locales/de.json +84 -8
- package/src/locales/en.json +77 -1
- package/src/locales/es.json +77 -1
- package/src/locales/fi.json +77 -1
- package/src/locales/fr.json +77 -1
- package/src/locales/it.json +77 -1
- package/src/locales/nl.json +77 -1
- package/src/locales/pt.json +77 -1
- package/src/utils/SwanFile.d.ts +2 -0
- package/src/utils/__tests__/fraudReport.card.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.card.test.js +39 -0
- package/src/utils/__tests__/fraudReport.documents.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.documents.test.js +61 -0
- package/src/utils/__tests__/fraudReport.fraudster.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.fraudster.test.js +35 -0
- package/src/utils/__tests__/fraudReport.messages.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.messages.test.js +28 -0
- package/src/utils/__tests__/fraudReport.picker.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.picker.test.js +186 -0
- package/src/utils/__tests__/fraudReport.pickerFilters.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.pickerFilters.test.js +144 -0
- package/src/utils/__tests__/fraudReport.prefill.test.js +7 -1
- package/src/utils/__tests__/fraudReport.rejections.test.js +11 -19
- package/src/utils/__tests__/fraudReport.resume.test.js +19 -4
- package/src/utils/__tests__/fraudReport.toInput.test.js +160 -40
- package/src/utils/__tests__/fraudReport.transactions.test.js +11 -1
- package/src/utils/__tests__/fraudReport.transfer.test.d.ts +1 -0
- package/src/utils/__tests__/fraudReport.transfer.test.js +31 -0
- package/src/utils/__tests__/fraudReport.victim.test.js +27 -1
- package/src/utils/__tests__/validation.test.js +81 -7
- package/src/utils/fraudReport/card.d.ts +11 -0
- package/src/utils/fraudReport/card.js +15 -0
- package/src/utils/fraudReport/documents.d.ts +9 -0
- package/src/utils/fraudReport/documents.js +18 -0
- package/src/utils/fraudReport/fakeApi.js +1 -1
- package/src/utils/fraudReport/fraudster.d.ts +10 -0
- package/src/utils/fraudReport/fraudster.js +11 -0
- package/src/utils/fraudReport/messages.d.ts +4 -0
- package/src/utils/fraudReport/messages.js +7 -0
- package/src/utils/fraudReport/picker.d.ts +19 -0
- package/src/utils/fraudReport/picker.js +50 -0
- package/src/utils/fraudReport/pickerFilters.d.ts +26 -0
- package/src/utils/fraudReport/pickerFilters.js +62 -0
- package/src/utils/fraudReport/prefill.d.ts +1 -1
- package/src/utils/fraudReport/prefill.js +6 -3
- package/src/utils/fraudReport/rejections.d.ts +0 -1
- package/src/utils/fraudReport/rejections.js +2 -6
- package/src/utils/fraudReport/resume.js +4 -4
- package/src/utils/fraudReport/toInput.d.ts +6 -3
- package/src/utils/fraudReport/toInput.js +41 -24
- package/src/utils/fraudReport/transactions.d.ts +2 -0
- package/src/utils/fraudReport/transactions.js +4 -0
- package/src/utils/fraudReport/transfer.d.ts +6 -0
- package/src/utils/fraudReport/transfer.js +8 -0
- package/src/utils/fraudReport/types.d.ts +1 -1
- package/src/utils/fraudReport/validation.d.ts +1 -1
- package/src/utils/fraudReport/validation.js +4 -0
- package/src/utils/fraudReport/victim.d.ts +11 -0
- package/src/utils/fraudReport/victim.js +9 -0
- package/src/utils/validation.d.ts +2 -0
- package/src/utils/validation.js +15 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/shared-business",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.7.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">22.12.0"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react": ">=19.0.0",
|
|
29
29
|
"react-dom": ">=19.0.0",
|
|
30
30
|
"react-native-web": ">=0.21.2",
|
|
31
|
-
"@swan-io/lake": "18.
|
|
31
|
+
"@swan-io/lake": "18.7.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@formatjs/intl": "^4.1.16",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"react-dom": "^19.2.7",
|
|
55
55
|
"react-native-web": "^0.21.2",
|
|
56
56
|
"type-fest": "^5.8.0",
|
|
57
|
-
"@swan-io/lake": "18.
|
|
57
|
+
"@swan-io/lake": "18.7.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { InlineDatePickerProps } from "./InlineDatePicker";
|
|
2
3
|
export type BirthdatePickerProps = {
|
|
3
4
|
label: string;
|
|
4
5
|
value: string | undefined;
|
|
@@ -7,5 +8,6 @@ export type BirthdatePickerProps = {
|
|
|
7
8
|
style?: StyleProp<ViewStyle>;
|
|
8
9
|
readOnly?: boolean;
|
|
9
10
|
responsive?: boolean;
|
|
11
|
+
validate?: InlineDatePickerProps["validate"];
|
|
10
12
|
};
|
|
11
|
-
export declare const BirthdatePicker: ({ value, label, readOnly, onValueChange, error: externalError, style, responsive, }: BirthdatePickerProps) => import("react").JSX.Element;
|
|
13
|
+
export declare const BirthdatePicker: ({ value, label, readOnly, onValueChange, error: externalError, style, responsive, validate, }: BirthdatePickerProps) => import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { validateBirthdate } from "../utils/validation";
|
|
3
3
|
import { InlineDatePicker } from "./InlineDatePicker";
|
|
4
|
-
export const BirthdatePicker = ({ value, label, readOnly = false, onValueChange, error: externalError, style, responsive = true, }) => {
|
|
5
|
-
return (_jsx(InlineDatePicker, { value: value, label: label, readOnly: readOnly, onValueChange: onValueChange, error: externalError, style: style, validate:
|
|
4
|
+
export const BirthdatePicker = ({ value, label, readOnly = false, onValueChange, error: externalError, style, responsive = true, validate = validateBirthdate, }) => {
|
|
5
|
+
return (_jsx(InlineDatePicker, { value: value, label: label, readOnly: readOnly, onValueChange: onValueChange, error: externalError, style: style, validate: validate, responsive: responsive }));
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Option, Result } from "@bloodyowl/boxed";
|
|
2
|
+
import { Array, Option, Result } from "@bloodyowl/boxed";
|
|
3
3
|
import { Icon } from "@swan-io/lake/src/components/Icon";
|
|
4
4
|
import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
|
|
5
5
|
import { LakeHeading } from "@swan-io/lake/src/components/LakeHeading";
|
|
@@ -10,11 +10,11 @@ import { backgroundColor, colors, radii, shadows, spacings, } from "@swan-io/lak
|
|
|
10
10
|
import { useBoolean } from "@swan-io/lake/src/hooks/useBoolean";
|
|
11
11
|
import { getIconNameFromFilename } from "@swan-io/lake/src/utils/file";
|
|
12
12
|
import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
|
|
13
|
-
import { useMemo } from "react";
|
|
14
|
-
import { useDropzone } from "react-dropzone";
|
|
13
|
+
import { useId, useMemo } from "react";
|
|
14
|
+
import { ErrorCode, useDropzone } from "react-dropzone";
|
|
15
15
|
import { StyleSheet, Text, View } from "react-native";
|
|
16
16
|
import { match, P } from "ts-pattern";
|
|
17
|
-
import { formatNestedMessage, t } from "../utils/i18n";
|
|
17
|
+
import { formatNestedMessage, locale, t } from "../utils/i18n";
|
|
18
18
|
const styles = StyleSheet.create({
|
|
19
19
|
container: {
|
|
20
20
|
backgroundColor: backgroundColor.accented,
|
|
@@ -94,8 +94,9 @@ const styles = StyleSheet.create({
|
|
|
94
94
|
top: spacings[20],
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
|
+
const getFormatName = (type) => { var _a; var _b; return (_a = ((_b = type.split("/")[1]) !== null && _b !== void 0 ? _b : type).split("+")[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase(); };
|
|
97
98
|
export const FileInput = ({ id, icon = "document-regular", accept, value, disabled = false, onPressRemove, onFiles, onError, layout = "vertical", description, error, maxSize, }) => {
|
|
98
|
-
var _a;
|
|
99
|
+
var _a, _b;
|
|
99
100
|
const [isHovered, setIsHovered] = useBoolean(false);
|
|
100
101
|
// We use the `accept` field as a heuristic to know if we can display a preview
|
|
101
102
|
// to avoid the cost of an extra fetch to extract the actual mimeType.
|
|
@@ -123,26 +124,40 @@ export const FileInput = ({ id, icon = "document-regular", accept, value, disabl
|
|
|
123
124
|
disabled,
|
|
124
125
|
maxSize,
|
|
125
126
|
});
|
|
126
|
-
|
|
127
|
+
const errorMessage = error !== null && error !== void 0 ? error : match((_b = (_a = fileRejections[0]) === null || _a === void 0 ? void 0 : _a.errors[0]) === null || _b === void 0 ? void 0 : _b.code)
|
|
128
|
+
.with(ErrorCode.FileTooLarge, () => isNotNullish(maxSize)
|
|
129
|
+
? t("fileInput.error.tooLarge", { maxSizeMB: maxSize / 1000000 })
|
|
130
|
+
: undefined)
|
|
131
|
+
.with(ErrorCode.FileInvalidType, () => t("fileInput.error.invalidType", {
|
|
132
|
+
formats: new Intl.ListFormat(locale.language, { type: "disjunction" }).format(Array.filterMap(accept, type => Option.fromUndefined(getFormatName(type)))),
|
|
133
|
+
}))
|
|
134
|
+
.otherwise(() => undefined);
|
|
135
|
+
const errorId = useId();
|
|
136
|
+
const showsError = isNotNullish(errorMessage) && file.isNone();
|
|
137
|
+
return (_jsx(View, { style: commonStyles.fill, children: _jsx("div", { ...getRootProps(), onMouseEnter: setIsHovered.on, onMouseLeave: setIsHovered.off, children: _jsxs(View, { style: [
|
|
127
138
|
styles.container,
|
|
128
139
|
disabled && styles.disabled,
|
|
129
140
|
layout === "horizontal" && styles.horizontalContainer,
|
|
130
141
|
!disabled && isHovered && styles.hoveredContainer,
|
|
131
142
|
isDragActive && styles.activeContainer,
|
|
132
143
|
(error != null || fileRejections.length > 0) && styles.errorContainer,
|
|
133
|
-
], children: [_jsx("input", { ...getInputProps({
|
|
144
|
+
], children: [_jsx("input", { ...getInputProps({
|
|
145
|
+
id,
|
|
146
|
+
"aria-describedby": showsError ? errorId : undefined,
|
|
147
|
+
"aria-invalid": showsError,
|
|
148
|
+
}) }), match({ file, isImageOnly })
|
|
134
149
|
.with({ file: Option.Some(P.select()), isImageOnly: true }, ({ url }) => (_jsxs(_Fragment, { children: [_jsx(View, { style: [styles.preview, { backgroundImage: `url("${url}")` }] }), onPressRemove != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress: onPressRemove, style: styles.deleteButton, ariaLabel: t("common.remove") })) : null] })))
|
|
135
|
-
.with({ file: Option.Some(P.select()), isImageOnly: false }, ({ name }) => (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(name), size: 48, color: disabled ? colors.gray[200] : colors.current[500] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level:
|
|
150
|
+
.with({ file: Option.Some(P.select()), isImageOnly: false }, ({ name }) => (_jsxs(_Fragment, { children: [_jsx(Icon, { name: getIconNameFromFilename(name), size: 48, color: disabled ? colors.gray[200] : colors.current[500] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: "none", variant: "h5", align: layout === "horizontal" ? "left" : "center", children: t("fileInput.clickToModify") }), _jsx(Space, { height: 4 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[200], align: layout === "horizontal" ? "left" : "center", children: name })] }), onPressRemove != null ? (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", style: styles.deleteButton, onPress: onPressRemove, ariaLabel: t("common.remove") })) : null] })))
|
|
136
151
|
.otherwise(() => (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.icon, children: [_jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
|
|
137
152
|
styles.decorativeIconLeft,
|
|
138
153
|
(isDragActive || isHovered) && styles.decorativeIconLeftHovered,
|
|
139
154
|
] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500], style: [
|
|
140
155
|
styles.decorativeIconRight,
|
|
141
156
|
(isDragActive || isHovered) && styles.decorativeIconRightHovered,
|
|
142
|
-
] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500] })] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level:
|
|
157
|
+
] }), _jsx(Icon, { name: icon, size: 48, color: disabled ? colors.gray[200] : colors.current[500] })] }), _jsx(Space, { width: layout === "horizontal" ? 48 : 16, height: layout === "horizontal" ? 48 : 16 }), _jsxs(View, { style: styles.browseBlock, children: [_jsx(LakeHeading, { level: "none", variant: "h5", align: layout === "horizontal" ? "left" : "center", color: disabled ? colors.gray[200] : undefined, children: disabled
|
|
143
158
|
? t("fileInput.noFile")
|
|
144
159
|
: formatNestedMessage("fileInput.dropFile", {
|
|
145
160
|
browse: _jsx(Text, { style: styles.browse, children: t("fileInput.browse") }),
|
|
146
|
-
}) }), isNotNullish(
|
|
161
|
+
}) }), isNotNullish(errorMessage) ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { id: errorId, role: "alert", color: colors.negative[400], align: layout === "horizontal" ? "left" : "center", children: errorMessage })] })) : (!disabled &&
|
|
147
162
|
isNotNullish(description) && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 4 }), _jsx(LakeText, { align: layout === "horizontal" ? "left" : "center", children: description })] })))] })] })))] }) }) }));
|
|
148
163
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Future } from "@bloodyowl/boxed";
|
|
1
|
+
import { Future, Result } from "@bloodyowl/boxed";
|
|
2
2
|
import { SwanFile } from "../utils/SwanFile";
|
|
3
3
|
type Props = {
|
|
4
4
|
file: SwanFile;
|
|
5
5
|
showId?: boolean;
|
|
6
|
-
onRemove?: () => Future<unknown
|
|
6
|
+
onRemove?: () => Future<Result<unknown, unknown>>;
|
|
7
|
+
onRetry?: () => void;
|
|
7
8
|
};
|
|
8
|
-
export declare const FileTile: ({ file: { id, statusInfo, name, url }, showId, onRemove, }: Props) => import("react").JSX.Element;
|
|
9
|
+
export declare const FileTile: ({ file: { id, statusInfo, name, url }, showId, onRemove, onRetry, }: Props) => import("react").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -48,15 +48,19 @@ const styles = StyleSheet.create({
|
|
|
48
48
|
alignSelf: "flex-start",
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
|
-
export const FileTile = ({ file: { id, statusInfo, name, url }, showId = false, onRemove, }) => {
|
|
51
|
+
export const FileTile = ({ file: { id, statusInfo, name, url }, showId = false, onRemove, onRetry, }) => {
|
|
52
52
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
53
53
|
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
|
|
54
|
+
const [removeFailures, setRemoveFailures] = useState(0);
|
|
54
55
|
const onPressRemove = useCallback(() => {
|
|
55
56
|
if (onRemove != null) {
|
|
56
57
|
setIsDeleting(true);
|
|
57
|
-
onRemove().tap(
|
|
58
|
+
onRemove().tap(result => {
|
|
58
59
|
setIsDeleting(false);
|
|
59
60
|
setIsDeleteModalVisible(false);
|
|
61
|
+
if (result.isError()) {
|
|
62
|
+
setRemoveFailures(count => count + 1);
|
|
63
|
+
}
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
}, [onRemove]);
|
|
@@ -68,13 +72,13 @@ export const FileTile = ({ file: { id, statusInfo, name, url }, showId = false,
|
|
|
68
72
|
.with("Uploaded", "Uploading", () => colors.gray[100])
|
|
69
73
|
.with("Pending", () => colors.shakespear[100])
|
|
70
74
|
.with("Validated", () => colors.positive[500])
|
|
71
|
-
.with("Refused", () => colors.negative[100])
|
|
75
|
+
.with("Refused", "UploadFailed", () => colors.negative[100])
|
|
72
76
|
.exhaustive(),
|
|
73
77
|
},
|
|
74
78
|
], children: [_jsx(Box, { alignItems: "center", direction: "row", style: styles.content, children: statusInfo.status === "Uploading" ? (_jsxs(_Fragment, { children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], children: t("fileTile.uploading") }), _jsx(Space, { width: 20 }), _jsx(View, { role: "progressbar", style: styles.progressBar, children: _jsx(View, { style: [styles.progress, { width: `${statusInfo.progress * 100}%` }] }) })] })) : (_jsxs(_Fragment, { children: [statusInfo.status === "Validated" ? (_jsx(Icon, { size: 24, color: colors.positive[500], name: "checkmark-circle-regular" })) : (_jsx(Tag, { icon: getIconNameFromFilename(name), iconSize: 20, color: match(statusInfo)
|
|
75
79
|
.with({ status: P.union("Uploaded", "Pending") }, () => "shakespear")
|
|
76
|
-
.with({ status: "Refused" }, () => "negative")
|
|
77
|
-
.exhaustive() })), _jsx(Space, { width: 16 }), _jsxs(Box, { grow: 1, children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], style: commonStyles.fill, children: name }), showId ? (_jsx(View, { style: styles.id, children: _jsx(LakeTooltip, { describedBy: "copy", onHide: () => setVisibleState("copy"), togglableOnFocus: true, content: visibleState === "copy"
|
|
80
|
+
.with({ status: P.union("Refused", "UploadFailed") }, () => "negative")
|
|
81
|
+
.exhaustive() })), _jsx(Space, { width: 16 }), _jsxs(Box, { grow: 1, children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], style: commonStyles.fill, children: name }), showId && statusInfo.status !== "UploadFailed" ? (_jsx(View, { style: styles.id, children: _jsx(LakeTooltip, { describedBy: "copy", onHide: () => setVisibleState("copy"), togglableOnFocus: true, content: visibleState === "copy"
|
|
78
82
|
? t("copyButton.copyTooltip")
|
|
79
83
|
: t("copyButton.copiedTooltip"), children: _jsx(Pressable, { onPress: event => {
|
|
80
84
|
event.stopPropagation();
|
|
@@ -83,8 +87,11 @@ export const FileTile = ({ file: { id, statusInfo, name, url }, showId = false,
|
|
|
83
87
|
setVisibleState("copied");
|
|
84
88
|
}, children: _jsxs(Box, { direction: "row", alignItems: "center", children: [_jsx(LakeText, { numberOfLines: 1, variant: "smallRegular", children: t("fileTile.id", { id }) }), _jsx(Space, { width: 4 }), _jsx(Icon, { size: 14, name: "copy-regular" })] }) }) }) })) : null] }), _jsx(Space, { width: 12 }), isNotNullishOrEmpty(url) && (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "open-filled", onPress: () => {
|
|
85
89
|
window.open(url, "_blank");
|
|
86
|
-
}, ariaLabel: t("common.open") })), isNotNullish(onRemove) && (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress:
|
|
90
|
+
}, ariaLabel: t("common.open") })), isNotNullish(onRemove) && (_jsx(LakeButton, { mode: "tertiary", size: "small", icon: "delete-regular", color: "negative", onPress: statusInfo.status === "UploadFailed"
|
|
91
|
+
? onPressRemove
|
|
92
|
+
: () => setIsDeleteModalVisible(true), ariaLabel: t("common.remove") })), _jsx(LakeModal, { title: t("fileTile.deleteModal.title"), icon: "subtract-circle-regular", visible: isDeleteModalVisible, onPressClose: () => setIsDeleteModalVisible(false), color: "negative", children: _jsx(LakeButtonGroup, { paddingBottom: 0, children: _jsx(LakeButton, { loading: isDeleting, grow: true, color: "negative", onPress: onPressRemove, children: t("fileTile.deleteModal.delete") }) }) })] })) }), match(statusInfo)
|
|
87
93
|
.with({ status: "Pending" }, () => (_jsx(LakeAlert, { anchored: true, title: t("fileTile.status.Pending"), variant: "info" })))
|
|
88
94
|
.with({ status: "Refused" }, ({ reason, reasonCode }) => (_jsx(LakeAlert, { anchored: true, variant: "error", title: getRejectionReasonLabel(reasonCode), children: isNotNullishOrEmpty(reason) ? _jsx(LakeText, { children: reason }) : null })))
|
|
89
|
-
.
|
|
95
|
+
.with({ status: "UploadFailed" }, () => (_jsx(View, { role: "alert", children: _jsx(LakeAlert, { anchored: true, variant: "error", title: t("fileTile.error.upload"), children: isNotNullish(onRetry) ? (_jsx(Box, { alignItems: "start", children: _jsx(LakeButton, { size: "small", mode: "secondary", color: "gray", onPress: onRetry, children: t("fileTile.tryAgain") }) })) : null }) })))
|
|
96
|
+
.otherwise(() => removeFailures > 0 ? (_jsx(View, { role: "alert", children: _jsx(LakeAlert, { anchored: true, variant: "error", title: t("fileTile.error.remove"), children: _jsx(Box, { alignItems: "start", children: _jsx(LakeButton, { size: "small", mode: "secondary", color: "gray", loading: isDeleting, onPress: onPressRemove, children: t("fileTile.tryAgain") }) }) }) }, removeFailures)) : null)] }));
|
|
90
97
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Future, Result } from "@bloodyowl/boxed";
|
|
2
3
|
import { Box } from "@swan-io/lake/src/components/Box";
|
|
3
4
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
4
5
|
import { Fragment, useEffect, useImperativeHandle, useRef } from "react";
|
|
6
|
+
import { match } from "ts-pattern";
|
|
5
7
|
import { useFilesUploader } from "../hooks/useFilesUploader";
|
|
6
8
|
import { FileInput } from "./FileInput";
|
|
7
9
|
import { FileTile } from "./FileTile";
|
|
8
10
|
export const FilesUploader = ({ ref, id, maxSize, accept, icon, getUploadConfig, onRemoveFile, onChange, formatAndSizeDescription, canUpload = true, showIds = false, ...config }) => {
|
|
9
|
-
const { files, upload, remove, add } = useFilesUploader(config);
|
|
11
|
+
const { files, upload, remove, retry, add } = useFilesUploader(config);
|
|
10
12
|
// Keep the `onChange` callback as a ref to avoid running the effect
|
|
11
13
|
// every time the function updates
|
|
12
14
|
const onChangeRef = useRef(onChange);
|
|
@@ -23,16 +25,22 @@ export const FilesUploader = ({ ref, id, maxSize, accept, icon, getUploadConfig,
|
|
|
23
25
|
}
|
|
24
26
|
const onChange = onChangeRef.current;
|
|
25
27
|
if (onChange != null) {
|
|
26
|
-
onChange(files);
|
|
28
|
+
onChange(files.filter(file => file.statusInfo.status !== "UploadFailed"));
|
|
27
29
|
}
|
|
28
30
|
}, [files]);
|
|
29
31
|
return (_jsxs(Box, { children: [canUpload ? (_jsxs(_Fragment, { children: [_jsx(FileInput, { id: id, layout: "horizontal", onFiles: files => {
|
|
30
32
|
files.forEach(file => {
|
|
31
33
|
upload(getUploadConfig(file), file);
|
|
32
34
|
});
|
|
33
|
-
}, accept: accept, icon: icon, description: formatAndSizeDescription, maxSize: maxSize }), _jsx(Space, { height: 12 })] })) : null, files.map((file, index) => (_jsxs(Fragment, { children: [index > 0 ? _jsx(Space, { height: 12 }) : null, _jsx(FileTile, { file: file, showId: showIds,
|
|
35
|
+
}, accept: accept, icon: icon, description: formatAndSizeDescription, maxSize: maxSize }), _jsx(Space, { height: 12 })] })) : null, files.map((file, index) => (_jsxs(Fragment, { children: [index > 0 ? _jsx(Space, { height: 12 }) : null, _jsx(FileTile, { file: file, showId: showIds, onRetry: () => retry(file.id), onRemove: match(file.statusInfo.status)
|
|
36
|
+
.with("UploadFailed", () => () => {
|
|
37
|
+
remove(file.id);
|
|
38
|
+
return Future.value(Result.Ok(undefined));
|
|
39
|
+
})
|
|
40
|
+
.with("Uploaded", () => onRemoveFile != null
|
|
34
41
|
? () => onRemoveFile(file).tapOk(() => {
|
|
35
42
|
remove(file.id);
|
|
36
43
|
})
|
|
37
|
-
: undefined
|
|
44
|
+
: undefined)
|
|
45
|
+
.otherwise(() => undefined) })] }, file.id)))] }));
|
|
38
46
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FraudReportStepProps } from "./FraudReportLayout";
|
|
2
|
+
type Props = FraudReportStepProps<"isLostOrStolen" | "lostOrStolenNoticedAt" | "hasContactedMerchant" | "hasFiledPoliceComplaint"> & {
|
|
3
|
+
onPrevious: () => void;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const CardDetailsStep: ({ values, onNext, onPrevious, loading }: Props) => import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Grid } from "@swan-io/lake/src/components/Grid";
|
|
3
|
+
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
4
|
+
import { LakeText } from "@swan-io/lake/src/components/LakeText";
|
|
5
|
+
import { MultiSelect } from "@swan-io/lake/src/components/MultiSelect";
|
|
6
|
+
import { RadioGroup } from "@swan-io/lake/src/components/RadioGroup";
|
|
7
|
+
import { Space } from "@swan-io/lake/src/components/Space";
|
|
8
|
+
import { Tile } from "@swan-io/lake/src/components/Tile";
|
|
9
|
+
import { colors } from "@swan-io/lake/src/constants/design";
|
|
10
|
+
import { useForm } from "@swan-io/use-form";
|
|
11
|
+
import { match } from "ts-pattern";
|
|
12
|
+
import { getCardActions, toCardValues } from "../../utils/fraudReport/card";
|
|
13
|
+
import { validateNotInFuture, } from "../../utils/fraudReport/validation";
|
|
14
|
+
import { t } from "../../utils/i18n";
|
|
15
|
+
import { InlineDatePicker } from "../InlineDatePicker";
|
|
16
|
+
import { FraudReportFooter, useFraudReportSmallLayout, } from "./FraudReportLayout";
|
|
17
|
+
export const CardDetailsStep = ({ values, onNext, onPrevious, loading }) => {
|
|
18
|
+
const small = useFraudReportSmallLayout();
|
|
19
|
+
const { Field, FieldsListener, submitForm } = useForm({
|
|
20
|
+
isLostOrStolen: { initialValue: values.isLostOrStolen },
|
|
21
|
+
lostOrStolenNoticedAt: {
|
|
22
|
+
initialValue: values.lostOrStolenNoticedAt,
|
|
23
|
+
validate: validateNotInFuture,
|
|
24
|
+
},
|
|
25
|
+
actions: { initialValue: getCardActions(values) },
|
|
26
|
+
});
|
|
27
|
+
const lostOrStolenItems = [
|
|
28
|
+
{ name: t("common.yes"), value: true },
|
|
29
|
+
{ name: t("common.no"), value: false },
|
|
30
|
+
];
|
|
31
|
+
const actionItems = [
|
|
32
|
+
{ label: t("fraudReport.card.action.merchant"), value: "Merchant", group: "" },
|
|
33
|
+
{ label: t("fraudReport.card.action.police"), value: "Police", group: "" },
|
|
34
|
+
];
|
|
35
|
+
const onPressNext = () => submitForm({
|
|
36
|
+
onSuccess: ({ isLostOrStolen, lostOrStolenNoticedAt, actions }) => onNext(toCardValues({
|
|
37
|
+
isLostOrStolen: isLostOrStolen.toUndefined(),
|
|
38
|
+
lostOrStolenNoticedAt: lostOrStolenNoticedAt.toUndefined(),
|
|
39
|
+
actions: actions.getOr([]),
|
|
40
|
+
})),
|
|
41
|
+
});
|
|
42
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Tile, { title: t("fraudReport.card.title"), children: [_jsxs(Grid, { numColumns: small ? 1 : 2, horizontalSpace: 24, children: [_jsx(Field, { name: "isLostOrStolen", children: ({ value, onChange }) => (_jsx(LakeLabel, { type: "radioGroup", label: t("fraudReport.card.lostOrStolenLabel"), optionalLabel: t("common.optional"), render: () => (_jsx(RadioGroup, { direction: small ? "column" : "row", items: lostOrStolenItems, value: value, onValueChange: onChange })) })) }), _jsx(FieldsListener, { names: ["isLostOrStolen"], children: ({ isLostOrStolen }) => isLostOrStolen.value === true ? (_jsx(Field, { name: "lostOrStolenNoticedAt", children: ({ value, error, onChange }) => (_jsx(InlineDatePicker, { label: t("fraudReport.card.noticedAtLabel"), optionalLabel: t("common.optional"), responsive: !small, value: value, error: match(error)
|
|
43
|
+
.with("InvalidDate", () => t("fraudReport.card.noticedAtInvalid"))
|
|
44
|
+
.with("DateInFuture", () => t("fraudReport.card.noticedAtInFuture"))
|
|
45
|
+
.otherwise(() => undefined), validate: () => undefined, onValueChange: onChange })) })) : null })] }), _jsx(FieldsListener, { names: ["isLostOrStolen"], children: ({ isLostOrStolen }) => isLostOrStolen.value === true ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 24 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[500], children: t("fraudReport.card.blockCards") })] })) : null })] }), _jsx(Space, { height: 24 }), _jsx(Tile, { title: t("fraudReport.card.actionsTitle"), children: _jsx(Field, { name: "actions", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("fraudReport.card.actionsLabel"), optionalLabel: t("common.optional"), render: id => (_jsx(MultiSelect, { id: id, enableGroups: false, placeholder: t("fraudReport.card.actionsPlaceholder"), items: actionItems, values: value, onValueChange: onChange })) })) }) }), _jsx(FraudReportFooter, { onPrevious: onPrevious, onNext: onPressNext, loading: loading })] }));
|
|
46
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FraudReportApi } from "../../utils/fraudReport/api";
|
|
2
|
+
import { FraudReportDocument } from "../../utils/fraudReport/documents";
|
|
3
|
+
import { FraudReportStepProps } from "./FraudReportLayout";
|
|
4
|
+
type Props = FraudReportStepProps<never> & {
|
|
5
|
+
supportingDocumentCollectionId: string;
|
|
6
|
+
api: Pick<FraudReportApi, "generateUpload" | "uploadFile" | "removeFile">;
|
|
7
|
+
initialDocuments: FraudReportDocument[];
|
|
8
|
+
onDocumentsChange: (documents: FraudReportDocument[]) => void;
|
|
9
|
+
onPrevious: () => void;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const DocumentsStep: ({ supportingDocumentCollectionId, api, initialDocuments, onDocumentsChange, onNext, onPrevious, loading, }: Props) => import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
3
|
+
import { Space } from "@swan-io/lake/src/components/Space";
|
|
4
|
+
import { Tile } from "@swan-io/lake/src/components/Tile";
|
|
5
|
+
import { Fragment, useRef, useState } from "react";
|
|
6
|
+
import { match } from "ts-pattern";
|
|
7
|
+
import { MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE, MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE_MB, } from "../../constants/uploads";
|
|
8
|
+
import { fraudReportDocumentGroups, getGroupFiles, getUploadPurpose, setGroupFiles, } from "../../utils/fraudReport/documents";
|
|
9
|
+
import { t } from "../../utils/i18n";
|
|
10
|
+
import { FilesUploader } from "../FilesUploader";
|
|
11
|
+
import { uploadSupportingDocumentFile } from "../SupportingDocumentCollection";
|
|
12
|
+
import { FraudReportFooter } from "./FraudReportLayout";
|
|
13
|
+
const ACCEPTED_FORMATS = ["application/pdf", "image/jpeg", "image/png", "image/heic"];
|
|
14
|
+
const isSameDocuments = (documents, others) => documents.length === others.length &&
|
|
15
|
+
documents.every(document => others.some(({ file, purpose }) => file === document.file && purpose === document.purpose));
|
|
16
|
+
const getGroupText = (group) => match(group)
|
|
17
|
+
.with("PoliceReport", () => ({
|
|
18
|
+
label: t("fraudReport.documents.policeReport"),
|
|
19
|
+
description: t("fraudReport.documents.policeReportDescription"),
|
|
20
|
+
}))
|
|
21
|
+
.with("OtherDocuments", () => ({
|
|
22
|
+
label: t("fraudReport.documents.otherDocuments"),
|
|
23
|
+
description: t("fraudReport.documents.otherDocumentsDescription"),
|
|
24
|
+
}))
|
|
25
|
+
.exhaustive();
|
|
26
|
+
export const DocumentsStep = ({ supportingDocumentCollectionId, api, initialDocuments, onDocumentsChange, onNext, onPrevious, loading, }) => {
|
|
27
|
+
const documentsRef = useRef(initialDocuments);
|
|
28
|
+
const [uploadingGroups, setUploadingGroups] = useState({});
|
|
29
|
+
const isUploading = Object.values(uploadingGroups).some(Boolean);
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx(Tile, { title: t("fraudReport.documents.title"), description: t("fraudReport.documents.description"), children: fraudReportDocumentGroups.map((group, index) => {
|
|
31
|
+
const { label, description } = getGroupText(group);
|
|
32
|
+
return (_jsxs(Fragment, { children: [index > 0 ? _jsx(Space, { height: 24 }) : null, _jsx(LakeLabel, { label: label, optionalLabel: t("common.optional"), description: description, render: id => { var _a; return (_jsx(FilesUploader, { id: id, accept: ACCEPTED_FORMATS, maxSize: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE, icon: "document-regular", formatAndSizeDescription: t("fraudReport.documents.formats", {
|
|
33
|
+
maxSizeMB: MAX_SUPPORTING_DOCUMENT_UPLOAD_SIZE_MB,
|
|
34
|
+
}), initialFiles: getGroupFiles(initialDocuments, group), getUploadConfig: file => ({
|
|
35
|
+
fileName: file.name,
|
|
36
|
+
purpose: getUploadPurpose(group),
|
|
37
|
+
}), generateUpload: input => api.generateUpload({ supportingDocumentCollectionId, ...input }), uploadFile: (_a = api.uploadFile) !== null && _a !== void 0 ? _a : uploadSupportingDocumentFile, onRemoveFile: api.removeFile, onChange: files => {
|
|
38
|
+
setUploadingGroups(groups => ({
|
|
39
|
+
...groups,
|
|
40
|
+
[group]: files.some(({ statusInfo }) => statusInfo.status === "Uploading"),
|
|
41
|
+
}));
|
|
42
|
+
const documents = setGroupFiles(documentsRef.current, group, files.filter(({ statusInfo }) => statusInfo.status !== "Uploading"));
|
|
43
|
+
if (!isSameDocuments(documents, documentsRef.current)) {
|
|
44
|
+
documentsRef.current = documents;
|
|
45
|
+
onDocumentsChange(documents);
|
|
46
|
+
}
|
|
47
|
+
} })); } })] }, group));
|
|
48
|
+
}) }), _jsx(FraudReportFooter, { onPrevious: onPrevious, onNext: () => onNext({}), loading: loading === true || isUploading, nextLabel: t("fraudReport.documents.reviewReport") })] }));
|
|
49
|
+
};
|
|
@@ -18,6 +18,7 @@ type FooterProps = {
|
|
|
18
18
|
onNext: () => void;
|
|
19
19
|
loading?: boolean;
|
|
20
20
|
nextDisabled?: boolean;
|
|
21
|
+
nextLabel?: string;
|
|
21
22
|
};
|
|
22
|
-
export declare const FraudReportFooter: ({ onPrevious, onNext, loading, nextDisabled }: FooterProps) => import("react").JSX.Element;
|
|
23
|
+
export declare const FraudReportFooter: ({ onPrevious, onNext, loading, nextDisabled, nextLabel, }: FooterProps) => import("react").JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -29,7 +29,7 @@ export const FraudReportLayout = ({ activeStep, detailsSteps, children }) => {
|
|
|
29
29
|
const stepper = getFraudReportStepper({ activeStep, detailsSteps, getLabel: getStepLabel });
|
|
30
30
|
return (_jsx(ResponsiveContainer, { breakpoint: breakpoints.medium, style: styles.root, children: ({ small }) => (_jsxs(SmallLayoutContext.Provider, { value: small, children: [small ? (_jsx(MobileStepper, { steps: stepper.steps, activeStepId: stepper.activeStepId })) : (_jsx(LakeStepper, { steps: stepper.steps, activeStepId: stepper.activeStepId })), _jsx(Space, { height: small ? 24 : 48 }), children] })) }));
|
|
31
31
|
};
|
|
32
|
-
export const FraudReportFooter = ({ onPrevious, onNext, loading, nextDisabled }) => {
|
|
32
|
+
export const FraudReportFooter = ({ onPrevious, onNext, loading, nextDisabled, nextLabel = t("fraudReport.continue"), }) => {
|
|
33
33
|
const small = useFraudReportSmallLayout();
|
|
34
|
-
return (_jsxs(_Fragment, { children: [_jsx(Space, { height: small ? 8 : 16 }), _jsxs(LakeButtonGroup, { paddingBottom: 0, children: [isNotNullish(onPrevious) ? (_jsx(LakeButton, { mode: "secondary", color: "gray", disabled: loading, onPress: onPrevious, children: t("common.previous") })) : null, _jsx(LakeButton, { color: "current", ariaLabel: loading === true ?
|
|
34
|
+
return (_jsxs(_Fragment, { children: [_jsx(Space, { height: small ? 8 : 16 }), _jsxs(LakeButtonGroup, { paddingBottom: 0, children: [isNotNullish(onPrevious) ? (_jsx(LakeButton, { mode: "secondary", color: "gray", disabled: loading, onPress: onPrevious, children: t("common.previous") })) : null, _jsx(LakeButton, { color: "current", ariaLabel: loading === true ? nextLabel : undefined, loading: loading, disabled: nextDisabled, onPress: onNext, children: nextLabel })] })] }));
|
|
35
35
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FraudReportStepProps } from "./FraudReportLayout";
|
|
2
|
+
type Props = FraudReportStepProps<"fraudsterChannels" | "sharedInformationWithFraudster"> & {
|
|
3
|
+
onPrevious: () => void;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const FraudsterDetailsStep: ({ values, onNext, onPrevious, loading }: Props) => import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dict } from "@bloodyowl/boxed";
|
|
3
|
+
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
|
|
4
|
+
import { MultiSelect } from "@swan-io/lake/src/components/MultiSelect";
|
|
5
|
+
import { RadioGroup } from "@swan-io/lake/src/components/RadioGroup";
|
|
6
|
+
import { Tile } from "@swan-io/lake/src/components/Tile";
|
|
7
|
+
import { useForm } from "@swan-io/use-form";
|
|
8
|
+
import { getSharedInformationChoice, toSharedInformation, } from "../../utils/fraudReport/fraudster";
|
|
9
|
+
import { t } from "../../utils/i18n";
|
|
10
|
+
import { FraudReportFooter, useFraudReportSmallLayout, } from "./FraudReportLayout";
|
|
11
|
+
export const FraudsterDetailsStep = ({ values, onNext, onPrevious, loading }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const small = useFraudReportSmallLayout();
|
|
14
|
+
const sharedInformation = getSharedInformationChoice(values.sharedInformationWithFraudster);
|
|
15
|
+
const { Field, FieldsListener, submitForm } = useForm({
|
|
16
|
+
fraudsterChannels: { initialValue: (_a = values.fraudsterChannels) !== null && _a !== void 0 ? _a : [] },
|
|
17
|
+
sharedInformationAnswer: { initialValue: sharedInformation.answer },
|
|
18
|
+
sharedInformationItems: { initialValue: sharedInformation.items },
|
|
19
|
+
});
|
|
20
|
+
const channelLabels = {
|
|
21
|
+
Phone: t("fraudReport.fraudster.channel.Phone"),
|
|
22
|
+
Sms: t("fraudReport.fraudster.channel.Sms"),
|
|
23
|
+
Email: t("fraudReport.fraudster.channel.Email"),
|
|
24
|
+
Website: t("fraudReport.fraudster.channel.Website"),
|
|
25
|
+
Application: t("fraudReport.fraudster.channel.Application"),
|
|
26
|
+
Other: t("fraudReport.fraudster.channel.Other"),
|
|
27
|
+
};
|
|
28
|
+
const sharedLabels = {
|
|
29
|
+
SwanPasscode: t("fraudReport.fraudster.shared.SwanPasscode"),
|
|
30
|
+
VerificationCode: t("fraudReport.fraudster.shared.VerificationCode"),
|
|
31
|
+
PartnerPassword: t("fraudReport.fraudster.shared.PartnerPassword"),
|
|
32
|
+
CardDetails: t("fraudReport.fraudster.shared.CardDetails"),
|
|
33
|
+
BankDetails: t("fraudReport.fraudster.shared.BankDetails"),
|
|
34
|
+
PersonalInformation: t("fraudReport.fraudster.shared.PersonalInformation"),
|
|
35
|
+
Other: t("fraudReport.fraudster.shared.Other"),
|
|
36
|
+
};
|
|
37
|
+
const channelItems = Dict.entries(channelLabels).map(([value, label]) => ({ label, value, group: "" }));
|
|
38
|
+
const sharedItems = Dict.entries(sharedLabels).map(([value, label]) => ({ label, value, group: "" }));
|
|
39
|
+
const answerItems = [
|
|
40
|
+
{ name: t("common.yes"), value: "Yes" },
|
|
41
|
+
{ name: t("common.no"), value: "No" },
|
|
42
|
+
];
|
|
43
|
+
const onPressNext = () => submitForm({
|
|
44
|
+
onSuccess: ({ fraudsterChannels, sharedInformationAnswer, sharedInformationItems }) => {
|
|
45
|
+
const channels = fraudsterChannels.getOr([]);
|
|
46
|
+
onNext({
|
|
47
|
+
fraudsterChannels: channels.length > 0 ? channels : undefined,
|
|
48
|
+
sharedInformationWithFraudster: toSharedInformation({
|
|
49
|
+
answer: sharedInformationAnswer.toUndefined(),
|
|
50
|
+
items: sharedInformationItems.getOr([]),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Tile, { title: t("fraudReport.fraudster.title"), description: t("fraudReport.fraudster.description"), children: [_jsx(Field, { name: "fraudsterChannels", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("fraudReport.fraudster.channelLabel"), optionalLabel: t("common.optional"), render: id => (_jsx(MultiSelect, { id: id, enableGroups: false, emptyResultText: t("common.noResult"), items: channelItems, values: value, onValueChange: onChange })) })) }), _jsx(Field, { name: "sharedInformationAnswer", children: ({ value, onChange }) => (_jsx(LakeLabel, { type: "radioGroup", label: t("fraudReport.fraudster.sharedLabel"), optionalLabel: t("common.optional"), render: () => (_jsx(RadioGroup, { direction: small ? "column" : "row", items: answerItems, value: value, onValueChange: onChange })) })) }), _jsx(FieldsListener, { names: ["sharedInformationAnswer"], children: ({ sharedInformationAnswer }) => sharedInformationAnswer.value === "Yes" ? (_jsx(Field, { name: "sharedInformationItems", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("fraudReport.fraudster.sharedItemsLabel"), optionalLabel: t("common.optional"), render: id => (_jsx(MultiSelect, { id: id, enableGroups: false, emptyResultText: t("common.noResult"), items: sharedItems, values: value, onValueChange: onChange })) })) })) : null })] }), _jsx(FraudReportFooter, { onPrevious: onPrevious, onNext: onPressNext, loading: loading })] }));
|
|
56
|
+
};
|
|
@@ -8,6 +8,7 @@ import { Space } from "@swan-io/lake/src/components/Space";
|
|
|
8
8
|
import { Tile } from "@swan-io/lake/src/components/Tile";
|
|
9
9
|
import { breakpoints, colors } from "@swan-io/lake/src/constants/design";
|
|
10
10
|
import { StyleSheet } from "react-native";
|
|
11
|
+
import { MAX_TRANSACTIONS } from "../../utils/fraudReport/transactions";
|
|
11
12
|
import { formatNestedMessage, t } from "../../utils/i18n";
|
|
12
13
|
const styles = StyleSheet.create({
|
|
13
14
|
root: {
|
|
@@ -19,7 +20,10 @@ export const IntroStep = ({ onStart }) => (_jsx(ResponsiveContainer, { breakpoin
|
|
|
19
20
|
const padding = small ? 24 : 32;
|
|
20
21
|
return (_jsxs(_Fragment, { children: [_jsx(Tile, { title: t("fraudReport.intro.title"), description: t("fraudReport.intro.description"), paddingVertical: padding, paddingHorizontal: padding }), _jsx(Space, { height: small ? 24 : 48 }), _jsxs(Tile, { title: t("fraudReport.intro.rulesTitle"), paddingVertical: padding, paddingHorizontal: padding, children: [_jsx(BulletList, { variant: "smallRegular", color: colors.gray[500], items: [
|
|
21
22
|
formatNestedMessage("fraudReport.intro.rule.oneVictim", { bold }),
|
|
22
|
-
formatNestedMessage("fraudReport.intro.rule.transactions", {
|
|
23
|
+
formatNestedMessage("fraudReport.intro.rule.transactions", {
|
|
24
|
+
bold,
|
|
25
|
+
max: MAX_TRANSACTIONS,
|
|
26
|
+
}),
|
|
23
27
|
formatNestedMessage("fraudReport.intro.rule.refund", { bold }),
|
|
24
28
|
formatNestedMessage("fraudReport.intro.rule.deadline", { bold }),
|
|
25
29
|
formatNestedMessage("fraudReport.intro.rule.saved", { bold }),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FraudReportPickerRow } from "../../utils/fraudReport/picker";
|
|
2
|
+
import { FraudReportPickerFilters } from "../../utils/fraudReport/pickerFilters";
|
|
3
|
+
import type { FraudReportTransactionPickerProps } from "./TransactionsStep";
|
|
4
|
+
type Props = FraudReportTransactionPickerProps & {
|
|
5
|
+
rows: FraudReportPickerRow[];
|
|
6
|
+
victimAccountMembershipId: string | undefined;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
hasMore?: boolean;
|
|
9
|
+
onEndReached?: () => void;
|
|
10
|
+
onFiltersChange?: (filters: FraudReportPickerFilters) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const TransactionPicker: ({ visible, selected, onConfirm, onClose, onFiltersChange, ...props }: Props) => import("react").JSX.Element;
|
|
13
|
+
export {};
|