@swan-io/shared-business 18.4.0 → 18.6.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.
Files changed (101) hide show
  1. package/package.json +3 -3
  2. package/src/components/BirthdatePicker.d.ts +3 -1
  3. package/src/components/BirthdatePicker.js +2 -2
  4. package/src/components/FraudReport/CardDetailsStep.d.ts +7 -0
  5. package/src/components/FraudReport/CardDetailsStep.js +46 -0
  6. package/src/components/FraudReport/FraudReportLayout.d.ts +23 -0
  7. package/src/components/FraudReport/FraudReportLayout.js +35 -0
  8. package/src/components/FraudReport/FraudsterDetailsStep.d.ts +7 -0
  9. package/src/components/FraudReport/FraudsterDetailsStep.js +56 -0
  10. package/src/components/FraudReport/IncidentStep.d.ts +7 -0
  11. package/src/components/FraudReport/IncidentStep.js +55 -0
  12. package/src/components/FraudReport/IntroStep.d.ts +5 -0
  13. package/src/components/FraudReport/IntroStep.js +32 -0
  14. package/src/components/FraudReport/TransactionPicker.d.ts +13 -0
  15. package/src/components/FraudReport/TransactionPicker.js +213 -0
  16. package/src/components/FraudReport/TransactionPickerFilters.d.ts +8 -0
  17. package/src/components/FraudReport/TransactionPickerFilters.js +213 -0
  18. package/src/components/FraudReport/TransactionRows.d.ts +8 -0
  19. package/src/components/FraudReport/TransactionRows.js +32 -0
  20. package/src/components/FraudReport/TransactionsStep.d.ts +16 -0
  21. package/src/components/FraudReport/TransactionsStep.js +120 -0
  22. package/src/components/FraudReport/VictimStep.d.ts +11 -0
  23. package/src/components/FraudReport/VictimStep.js +88 -0
  24. package/src/components/InlineDatePicker.js +7 -6
  25. package/src/components/LakeModal.js +1 -1
  26. package/src/constants/__tests__/countries.test.js +32 -1
  27. package/src/constants/countries.d.ts +2 -1
  28. package/src/constants/countries.js +36 -2
  29. package/src/hooks/__tests__/useFraudReportFlow.test.d.ts +1 -0
  30. package/src/hooks/__tests__/useFraudReportFlow.test.js +1067 -0
  31. package/src/hooks/useFraudReportFlow.d.ts +32 -0
  32. package/src/hooks/useFraudReportFlow.js +265 -0
  33. package/src/locales/de.json +130 -0
  34. package/src/locales/en.json +130 -0
  35. package/src/locales/es.json +130 -0
  36. package/src/locales/fi.json +130 -0
  37. package/src/locales/fr.json +130 -0
  38. package/src/locales/it.json +130 -0
  39. package/src/locales/nl.json +130 -0
  40. package/src/locales/pt.json +130 -0
  41. package/src/utils/__tests__/fraudReport.card.test.d.ts +1 -0
  42. package/src/utils/__tests__/fraudReport.card.test.js +39 -0
  43. package/src/utils/__tests__/fraudReport.fakeApi.test.js +42 -13
  44. package/src/utils/__tests__/fraudReport.fraudster.test.d.ts +1 -0
  45. package/src/utils/__tests__/fraudReport.fraudster.test.js +35 -0
  46. package/src/utils/__tests__/fraudReport.messages.test.d.ts +1 -0
  47. package/src/utils/__tests__/fraudReport.messages.test.js +28 -0
  48. package/src/utils/__tests__/fraudReport.picker.test.d.ts +1 -0
  49. package/src/utils/__tests__/fraudReport.picker.test.js +171 -0
  50. package/src/utils/__tests__/fraudReport.pickerFilters.test.d.ts +1 -0
  51. package/src/utils/__tests__/fraudReport.pickerFilters.test.js +144 -0
  52. package/src/utils/__tests__/fraudReport.prefill.test.d.ts +1 -0
  53. package/src/utils/__tests__/fraudReport.prefill.test.js +151 -0
  54. package/src/utils/__tests__/fraudReport.rejections.test.d.ts +1 -0
  55. package/src/utils/__tests__/fraudReport.rejections.test.js +155 -0
  56. package/src/utils/__tests__/fraudReport.resume.test.d.ts +1 -0
  57. package/src/utils/__tests__/fraudReport.resume.test.js +81 -0
  58. package/src/utils/__tests__/fraudReport.stepper.test.d.ts +1 -0
  59. package/src/utils/__tests__/fraudReport.stepper.test.js +102 -0
  60. package/src/utils/__tests__/fraudReport.toInput.test.js +111 -37
  61. package/src/utils/__tests__/fraudReport.transactions.test.d.ts +1 -0
  62. package/src/utils/__tests__/fraudReport.transactions.test.js +38 -0
  63. package/src/utils/__tests__/fraudReport.types.test.d.ts +1 -0
  64. package/src/utils/__tests__/fraudReport.types.test.js +22 -0
  65. package/src/utils/__tests__/fraudReport.victim.test.d.ts +1 -0
  66. package/src/utils/__tests__/fraudReport.victim.test.js +168 -0
  67. package/src/utils/__tests__/phone.test.js +60 -5
  68. package/src/utils/__tests__/validation.test.js +69 -2
  69. package/src/utils/fraudReport/card.d.ts +11 -0
  70. package/src/utils/fraudReport/card.js +15 -0
  71. package/src/utils/fraudReport/fakeApi.d.ts +7 -4
  72. package/src/utils/fraudReport/fakeApi.js +19 -6
  73. package/src/utils/fraudReport/fraudster.d.ts +10 -0
  74. package/src/utils/fraudReport/fraudster.js +11 -0
  75. package/src/utils/fraudReport/messages.d.ts +4 -0
  76. package/src/utils/fraudReport/messages.js +7 -0
  77. package/src/utils/fraudReport/picker.d.ts +18 -0
  78. package/src/utils/fraudReport/picker.js +49 -0
  79. package/src/utils/fraudReport/pickerFilters.d.ts +26 -0
  80. package/src/utils/fraudReport/pickerFilters.js +62 -0
  81. package/src/utils/fraudReport/prefill.d.ts +3 -0
  82. package/src/utils/fraudReport/prefill.js +16 -0
  83. package/src/utils/fraudReport/rejections.d.ts +9 -0
  84. package/src/utils/fraudReport/rejections.js +49 -0
  85. package/src/utils/fraudReport/resume.d.ts +4 -0
  86. package/src/utils/fraudReport/resume.js +26 -0
  87. package/src/utils/fraudReport/stepper.d.ts +16 -0
  88. package/src/utils/fraudReport/stepper.js +21 -0
  89. package/src/utils/fraudReport/toInput.d.ts +14 -3
  90. package/src/utils/fraudReport/toInput.js +37 -31
  91. package/src/utils/fraudReport/transactions.d.ts +8 -0
  92. package/src/utils/fraudReport/transactions.js +11 -0
  93. package/src/utils/fraudReport/types.d.ts +8 -0
  94. package/src/utils/fraudReport/validation.d.ts +2 -1
  95. package/src/utils/fraudReport/validation.js +5 -0
  96. package/src/utils/fraudReport/victim.d.ts +41 -0
  97. package/src/utils/fraudReport/victim.js +37 -0
  98. package/src/utils/phone.d.ts +1 -0
  99. package/src/utils/phone.js +31 -4
  100. package/src/utils/validation.d.ts +2 -0
  101. package/src/utils/validation.js +14 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "18.4.0",
3
+ "version": "18.6.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.4.0"
31
+ "@swan-io/lake": "18.6.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.4.0"
57
+ "@swan-io/lake": "18.6.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: validateBirthdate, responsive: responsive }));
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
  };
@@ -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,23 @@
1
+ import { ReactNode } from "react";
2
+ import { FraudReportLayoutStep } from "../../utils/fraudReport/stepper";
3
+ import type { FraudReportFormValues } from "../../utils/fraudReport/toInput";
4
+ import { FraudReportDetailsStep } from "../../utils/fraudReport/types";
5
+ export type FraudReportStepProps<K extends keyof FraudReportFormValues> = {
6
+ values: Pick<FraudReportFormValues, K>;
7
+ onNext: (values: Pick<FraudReportFormValues, K>) => void;
8
+ };
9
+ export declare const useFraudReportSmallLayout: () => boolean;
10
+ type Props = {
11
+ activeStep: FraudReportLayoutStep;
12
+ detailsSteps: readonly FraudReportDetailsStep[];
13
+ children: ReactNode;
14
+ };
15
+ export declare const FraudReportLayout: ({ activeStep, detailsSteps, children }: Props) => import("react").JSX.Element;
16
+ type FooterProps = {
17
+ onPrevious?: () => void;
18
+ onNext: () => void;
19
+ loading?: boolean;
20
+ nextDisabled?: boolean;
21
+ };
22
+ export declare const FraudReportFooter: ({ onPrevious, onNext, loading, nextDisabled }: FooterProps) => import("react").JSX.Element;
23
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LakeButton, LakeButtonGroup } from "@swan-io/lake/src/components/LakeButton";
3
+ import { LakeStepper, MobileStepper } from "@swan-io/lake/src/components/LakeStepper";
4
+ import { ResponsiveContainer } from "@swan-io/lake/src/components/ResponsiveContainer";
5
+ import { Space } from "@swan-io/lake/src/components/Space";
6
+ import { breakpoints } from "@swan-io/lake/src/constants/design";
7
+ import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
8
+ import { createContext, useContext } from "react";
9
+ import { StyleSheet } from "react-native";
10
+ import { match } from "ts-pattern";
11
+ import { getFraudReportStepper, } from "../../utils/fraudReport/stepper";
12
+ import { t } from "../../utils/i18n";
13
+ const styles = StyleSheet.create({
14
+ root: {
15
+ alignSelf: "stretch",
16
+ },
17
+ });
18
+ const SmallLayoutContext = createContext(false);
19
+ export const useFraudReportSmallLayout = () => useContext(SmallLayoutContext);
20
+ const getStepLabel = (step) => match(step)
21
+ .with("Victim", () => t("fraudReport.step.victim"))
22
+ .with("Transactions", () => t("fraudReport.step.transactions"))
23
+ .with("Incident", () => t("fraudReport.step.incident"))
24
+ .with("Details", () => t("fraudReport.step.details"))
25
+ .with("Documents", () => t("fraudReport.step.documents"))
26
+ .with("Submitted", () => t("fraudReport.step.confirmation"))
27
+ .exhaustive();
28
+ export const FraudReportLayout = ({ activeStep, detailsSteps, children }) => {
29
+ const stepper = getFraudReportStepper({ activeStep, detailsSteps, getLabel: getStepLabel });
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
+ };
32
+ export const FraudReportFooter = ({ onPrevious, onNext, loading, nextDisabled }) => {
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 ? t("fraudReport.continue") : undefined, loading: loading, disabled: nextDisabled, onPress: onNext, children: t("fraudReport.continue") })] })] }));
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
+ };
@@ -0,0 +1,7 @@
1
+ import { FraudReportStepProps } from "./FraudReportLayout";
2
+ type Props = FraudReportStepProps<"reportedReason" | "reportedTypology" | "description" | "discoveredAt"> & {
3
+ onPrevious: () => void;
4
+ loading?: boolean;
5
+ };
6
+ export declare const IncidentStep: ({ values, onNext, onPrevious, loading }: Props) => import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,55 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Dict } from "@bloodyowl/boxed";
3
+ import { Grid } from "@swan-io/lake/src/components/Grid";
4
+ import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
5
+ import { LakeSelect } from "@swan-io/lake/src/components/LakeSelect";
6
+ import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
7
+ import { RadioGroup } from "@swan-io/lake/src/components/RadioGroup";
8
+ import { Tile } from "@swan-io/lake/src/components/Tile";
9
+ import { useForm } from "@swan-io/use-form";
10
+ import { match } from "ts-pattern";
11
+ import { DESCRIPTION_MAX_LENGTH, validateDescription, validateNotInFuture, validateSelected, } from "../../utils/fraudReport/validation";
12
+ import { t } from "../../utils/i18n";
13
+ import { InlineDatePicker } from "../InlineDatePicker";
14
+ import { FraudReportFooter, useFraudReportSmallLayout, } from "./FraudReportLayout";
15
+ export const IncidentStep = ({ values, onNext, onPrevious, loading }) => {
16
+ var _a;
17
+ const small = useFraudReportSmallLayout();
18
+ const { Field, submitForm } = useForm({
19
+ reportedReason: { initialValue: values.reportedReason, validate: validateSelected },
20
+ description: { initialValue: (_a = values.description) !== null && _a !== void 0 ? _a : "", validate: validateDescription },
21
+ reportedTypology: { initialValue: values.reportedTypology, validate: validateSelected },
22
+ discoveredAt: { initialValue: values.discoveredAt, validate: validateNotInFuture },
23
+ });
24
+ const reasonItems = [
25
+ { name: t("common.yes"), value: "Manipulated" },
26
+ { name: t("common.no"), value: "Unauthorized" },
27
+ ];
28
+ const typologyLabels = {
29
+ FakeAdvisor: t("fraudReport.incident.typology.FakeAdvisor"),
30
+ ImpersonationOrPhishing: t("fraudReport.incident.typology.ImpersonationOrPhishing"),
31
+ FakeWebsite: t("fraudReport.incident.typology.FakeWebsite"),
32
+ FakeSupplierOrInvoice: t("fraudReport.incident.typology.FakeSupplierOrInvoice"),
33
+ InvestmentScam: t("fraudReport.incident.typology.InvestmentScam"),
34
+ RomanceScam: t("fraudReport.incident.typology.RomanceScam"),
35
+ Other: t("fraudReport.incident.typology.Other"),
36
+ };
37
+ const typologyItems = Dict.entries(typologyLabels).map(([value, name]) => ({ name, value }));
38
+ const onPressNext = () => submitForm({
39
+ onSuccess: ({ reportedReason, reportedTypology, description, discoveredAt }) => onNext({
40
+ reportedReason: reportedReason.toUndefined(),
41
+ reportedTypology: reportedTypology.toUndefined(),
42
+ description: description.toUndefined(),
43
+ discoveredAt: discoveredAt.toUndefined(),
44
+ }),
45
+ });
46
+ return (_jsxs(_Fragment, { children: [_jsxs(Tile, { title: t("fraudReport.incident.title"), description: t("fraudReport.incident.description"), children: [_jsx(Field, { name: "reportedReason", children: ({ value, error, onChange }) => (_jsx(LakeLabel, { type: "radioGroup", label: t("fraudReport.incident.reasonLabel"), render: () => (_jsx(RadioGroup, { direction: small ? "column" : "row", items: reasonItems, value: value, error: error === "Required" ? t("fraudReport.incident.reasonRequired") : undefined, onValueChange: onChange })) })) }), _jsx(Field, { name: "description", children: ({ ref, value, error, onChange, onBlur }) => (_jsx(LakeLabel, { label: t("fraudReport.incident.whatHappenedLabel"), render: id => (_jsx(LakeTextInput, { id: id, ref: ref, multiline: true, placeholder: t("fraudReport.incident.whatHappenedPlaceholder"), value: value, error: match(error)
47
+ .with("Required", () => t("fraudReport.incident.whatHappenedRequired"))
48
+ .with("TooLong", () => t("fraudReport.incident.whatHappenedTooLong", {
49
+ max: DESCRIPTION_MAX_LENGTH,
50
+ }))
51
+ .otherwise(() => undefined), onChangeText: onChange, onBlur: onBlur })) })) }), _jsxs(Grid, { numColumns: small ? 1 : 2, horizontalSpace: 24, children: [_jsx(Field, { name: "reportedTypology", children: ({ ref, value, error, onChange }) => (_jsx(LakeLabel, { label: t("fraudReport.incident.typologyLabel"), render: id => (_jsx(LakeSelect, { id: id, ref: ref, items: typologyItems, value: value, error: error === "Required" ? t("fraudReport.incident.typologyRequired") : undefined, onValueChange: onChange })) })) }), _jsx(Field, { name: "discoveredAt", children: ({ value, error, onChange }) => (_jsx(InlineDatePicker, { label: t("fraudReport.incident.noticedAtLabel"), optionalLabel: t("common.optional"), responsive: !small, value: value, error: match(error)
52
+ .with("InvalidDate", () => t("fraudReport.incident.noticedAtInvalid"))
53
+ .with("DateInFuture", () => t("fraudReport.incident.noticedAtInFuture"))
54
+ .otherwise(() => undefined), validate: () => undefined, onValueChange: onChange })) })] })] }), _jsx(FraudReportFooter, { onPrevious: onPrevious, onNext: onPressNext, loading: loading })] }));
55
+ };
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ onStart: () => void;
3
+ };
4
+ export declare const IntroStep: ({ onStart }: Props) => import("react").JSX.Element;
5
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box } from "@swan-io/lake/src/components/Box";
3
+ import { BulletList } from "@swan-io/lake/src/components/BulletList";
4
+ import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
5
+ import { LakeText } from "@swan-io/lake/src/components/LakeText";
6
+ import { ResponsiveContainer } from "@swan-io/lake/src/components/ResponsiveContainer";
7
+ import { Space } from "@swan-io/lake/src/components/Space";
8
+ import { Tile } from "@swan-io/lake/src/components/Tile";
9
+ import { breakpoints, colors } from "@swan-io/lake/src/constants/design";
10
+ import { StyleSheet } from "react-native";
11
+ import { MAX_TRANSACTIONS } from "../../utils/fraudReport/transactions";
12
+ import { formatNestedMessage, t } from "../../utils/i18n";
13
+ const styles = StyleSheet.create({
14
+ root: {
15
+ alignSelf: "stretch",
16
+ },
17
+ });
18
+ const bold = (chunks) => (_jsx(LakeText, { variant: "smallMedium", color: colors.gray[500], children: chunks }));
19
+ export const IntroStep = ({ onStart }) => (_jsx(ResponsiveContainer, { breakpoint: breakpoints.medium, style: styles.root, children: ({ small }) => {
20
+ const padding = small ? 24 : 32;
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: [
22
+ formatNestedMessage("fraudReport.intro.rule.oneVictim", { bold }),
23
+ formatNestedMessage("fraudReport.intro.rule.transactions", {
24
+ bold,
25
+ max: MAX_TRANSACTIONS,
26
+ }),
27
+ formatNestedMessage("fraudReport.intro.rule.refund", { bold }),
28
+ formatNestedMessage("fraudReport.intro.rule.deadline", { bold }),
29
+ formatNestedMessage("fraudReport.intro.rule.saved", { bold }),
30
+ formatNestedMessage("fraudReport.intro.rule.policeReport", { bold }),
31
+ ] }), _jsx(Space, { height: small ? 24 : 32 }), _jsx(LakeText, { variant: "medium", color: colors.gray[500], children: t("fraudReport.intro.falseInformation") })] }), _jsx(Space, { height: small ? 24 : 48 }), _jsx(Box, { direction: "row", children: _jsx(LakeButton, { color: "current", onPress: onStart, children: t("fraudReport.intro.start") }) })] }));
32
+ } }));
@@ -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 {};
@@ -0,0 +1,213 @@
1
+ import { createElement as _createElement } from "react";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Box } from "@swan-io/lake/src/components/Box";
4
+ import { Cell, CopyableTextCell, HeaderCell, TextCell } from "@swan-io/lake/src/components/Cells";
5
+ import { EmptyView } from "@swan-io/lake/src/components/EmptyView";
6
+ import { Fill } from "@swan-io/lake/src/components/Fill";
7
+ import { LakeAlert } from "@swan-io/lake/src/components/LakeAlert";
8
+ import { LakeButton } from "@swan-io/lake/src/components/LakeButton";
9
+ import { LakeCheckbox } from "@swan-io/lake/src/components/LakeCheckbox";
10
+ import { LakeText } from "@swan-io/lake/src/components/LakeText";
11
+ import { PlainListView } from "@swan-io/lake/src/components/PlainListView";
12
+ import { Pressable } from "@swan-io/lake/src/components/Pressable";
13
+ import { ResponsiveContainer } from "@swan-io/lake/src/components/ResponsiveContainer";
14
+ import { Space } from "@swan-io/lake/src/components/Space";
15
+ import { Tag } from "@swan-io/lake/src/components/Tag";
16
+ import { colors } from "@swan-io/lake/src/constants/design";
17
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
+ import { StyleSheet, View } from "react-native";
19
+ import { getTransactionsLimitMessage } from "../../utils/fraudReport/messages";
20
+ import { countPagesWithoutRows, getPickerTransactions, getSelectAllValue, MAX_PAGES_WITHOUT_ROWS, restartPickerPages, toggleAllTransactions, toggleTransaction, } from "../../utils/fraudReport/picker";
21
+ import { hasPickerFilters, isSamePickerFilters, setPickerFilters, } from "../../utils/fraudReport/pickerFilters";
22
+ import { getTransactionsOverLimit, MAX_TRANSACTIONS } from "../../utils/fraudReport/transactions";
23
+ import { t } from "../../utils/i18n";
24
+ import { LakeModal } from "../LakeModal";
25
+ import { TransactionPickerFilters } from "./TransactionPickerFilters";
26
+ import { formatTransactionAmount, formatTransactionDate, getPaymentMethodLabel, TransactionsTotals, } from "./TransactionRows";
27
+ const LOADING_ROWS = 5;
28
+ const HEADER_HEIGHT = 48;
29
+ const MAX_LIST_HEIGHT = 420;
30
+ // Below it the fixed columns leave no room for "Paid to".
31
+ const TABLE_BREAKPOINT = 800;
32
+ const styles = StyleSheet.create({
33
+ checkbox: {
34
+ padding: 4,
35
+ },
36
+ confirm: {
37
+ alignSelf: "stretch",
38
+ },
39
+ loadMore: {
40
+ alignSelf: "center",
41
+ },
42
+ });
43
+ const CheckboxCell = ({ value, label, onPress, }) => (_jsx(Cell, { children: _jsx(Pressable, { role: "checkbox", "aria-checked": value, "aria-label": label, style: styles.checkbox, onPress: onPress, children: _jsx(LakeCheckbox, { value: value }) }) }));
44
+ const checkboxColumn = {
45
+ id: "checkbox",
46
+ width: 40,
47
+ title: t("fraudReport.picker.selectAll"),
48
+ renderTitle: ({ title, extraInfo: { selectAllValue, onToggleAll } }) => (_jsx(CheckboxCell, { value: selectAllValue, label: title, onPress: onToggleAll })),
49
+ renderCell: ({ item, extraInfo: { selection, onToggle } }) => (_jsx(CheckboxCell, { value: selection.some(({ id }) => id === item.id), label: t("fraudReport.picker.selectTransaction", {
50
+ counterparty: item.counterparty,
51
+ amount: formatTransactionAmount(item),
52
+ date: formatTransactionDate(item),
53
+ }), onPress: () => onToggle(item) })),
54
+ };
55
+ const columns = [
56
+ checkboxColumn,
57
+ {
58
+ id: "date",
59
+ width: 112,
60
+ title: t("fraudReport.transactions.date"),
61
+ renderTitle: ({ title }) => _jsx(HeaderCell, { text: title }),
62
+ renderCell: ({ item }) => _jsx(TextCell, { text: formatTransactionDate(item) }),
63
+ },
64
+ {
65
+ id: "counterparty",
66
+ width: "grow",
67
+ title: t("fraudReport.transactions.paidTo"),
68
+ renderTitle: ({ title }) => _jsx(HeaderCell, { text: title }),
69
+ renderCell: ({ item }) => _jsx(TextCell, { text: item.counterparty }),
70
+ },
71
+ {
72
+ id: "amount",
73
+ width: 112,
74
+ title: t("fraudReport.transactions.amount"),
75
+ renderTitle: ({ title }) => _jsx(HeaderCell, { text: title }),
76
+ renderCell: ({ item }) => _jsx(TextCell, { text: formatTransactionAmount(item) }),
77
+ },
78
+ {
79
+ id: "paymentMethod",
80
+ width: 228,
81
+ title: t("fraudReport.transactions.paymentMethod"),
82
+ renderTitle: ({ title }) => _jsx(HeaderCell, { text: title }),
83
+ renderCell: ({ item }) => (_jsx(Cell, { children: _jsx(Tag, { color: "gray", children: getPaymentMethodLabel(item.type) }) })),
84
+ },
85
+ {
86
+ id: "transactionId",
87
+ width: 128,
88
+ title: t("fraudReport.transactions.transactionId"),
89
+ renderTitle: ({ title }) => _jsx(HeaderCell, { text: title }),
90
+ renderCell: ({ item }) => (_jsx(CopyableTextCell, { text: item.id, copyWording: t("copyButton.copyTooltip"), copiedWording: t("copyButton.copiedTooltip") })),
91
+ },
92
+ ];
93
+ const smallColumns = [
94
+ checkboxColumn,
95
+ {
96
+ id: "summary",
97
+ width: "grow",
98
+ title: "",
99
+ renderTitle: () => null,
100
+ renderCell: ({ item }) => (_jsxs(Cell, { direction: "column", children: [_jsx(LakeText, { numberOfLines: 1, color: colors.gray[700], children: item.counterparty }), _jsx(LakeText, { variant: "medium", color: colors.gray[900], children: formatTransactionAmount(item) })] })),
101
+ },
102
+ {
103
+ id: "date",
104
+ width: 124,
105
+ title: "",
106
+ renderTitle: () => null,
107
+ renderCell: ({ item }) => (_jsx(TextCell, { align: "right", color: colors.gray[700], text: formatTransactionDate(item) })),
108
+ },
109
+ ];
110
+ const TransactionPickerContent = ({ rows, victimAccountMembershipId, selection, loading = false, hasMore = false, large, filters, onFiltersPatch, onEndReached, onSelectionChange, onConfirm, }) => {
111
+ const listed = useMemo(() => getPickerTransactions(rows, victimAccountMembershipId), [rows, victimAccountMembershipId]);
112
+ const [pages, setPages] = useState({
113
+ rowCount: rows.length,
114
+ listedCount: listed.length,
115
+ withoutRows: 0,
116
+ restarted: false,
117
+ });
118
+ // Other filters bring another list: its pages are counted from the start.
119
+ const [countedFilters, setCountedFilters] = useState(filters);
120
+ const base = filters === countedFilters ? pages : restartPickerPages(pages);
121
+ // The user asked for more after a pause: the page it brings starts the count again.
122
+ const [requested, setRequested] = useState(false);
123
+ // The end of a load tells that another list arrived, even with as many rows as the one before.
124
+ const [wasLoading, setWasLoading] = useState(loading);
125
+ const loaded = wasLoading && !loading;
126
+ const counted = countPagesWithoutRows(base, rows.length, listed.length, loaded);
127
+ const currentPages = counted !== base && requested ? { ...counted, withoutRows: 0 } : counted;
128
+ if (loading !== wasLoading) {
129
+ setWasLoading(loading);
130
+ }
131
+ if (currentPages !== pages) {
132
+ setPages(currentPages);
133
+ setCountedFilters(filters);
134
+ setRequested(false);
135
+ }
136
+ // After a few pages with no row for this victim, the user decides whether to keep looking.
137
+ const paused = hasMore && !loading && currentPages.withoutRows >= MAX_PAGES_WITHOUT_ROWS;
138
+ const requesting = requested && hasMore;
139
+ // The whole selection counts, with the transactions that aren't listed.
140
+ const overLimit = getTransactionsOverLimit(selection.length);
141
+ const rowHeight = large ? 56 : 72;
142
+ // A loaded page can hold no row for this victim: more pages may, so it isn't empty yet.
143
+ const waiting = loading || requesting || (hasMore && listed.length === 0 && !paused);
144
+ // The list scrolls inside the modal: it takes its rows' height, up to MAX_LIST_HEIGHT.
145
+ const listHeight = (large && listed.length > 0 ? HEADER_HEIGHT : 0) +
146
+ (listed.length + (waiting ? LOADING_ROWS : 0)) * rowHeight;
147
+ // The list asks for the next page when its end comes into view, once per callback. A new
148
+ // callback after each page makes it ask again while the end is still in view, which happens
149
+ // when a page holds few rows for this victim, or none.
150
+ // biome-ignore lint/correctness/useExhaustiveDependencies(rows.length): see above
151
+ const askForMore = useCallback(() => onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached(), [onEndReached, rows.length]);
152
+ const loadMore = () => {
153
+ setRequested(true);
154
+ onEndReached === null || onEndReached === void 0 ? void 0 : onEndReached();
155
+ };
156
+ return (_jsxs(_Fragment, { children: [_jsx(LakeText, { color: colors.gray[700], children: t("fraudReport.picker.description", { max: MAX_TRANSACTIONS }) }), _jsx(Space, { height: 24 }), overLimit > 0 ? (_jsxs(_Fragment, { children: [_jsx(View, { role: "alert", children: _jsx(LakeAlert, { variant: "error", title: getTransactionsLimitMessage({ toRemove: overLimit }) }) }), _jsx(Space, { height: 24 })] })) : null, onFiltersPatch == null ? null : (_jsxs(_Fragment, { children: [_jsx(TransactionPickerFilters, { filters: filters, large: large, onChange: onFiltersPatch }), _jsx(Space, { height: 24 })] })), listed.length === 0 && !waiting ? (_jsx(EmptyView, { icon: "lake-inbox-empty", borderedIcon: true, title: t(paused
157
+ ? "fraudReport.picker.noneYetTitle"
158
+ : hasPickerFilters(filters)
159
+ ? "fraudReport.picker.noMatchTitle"
160
+ : "fraudReport.picker.emptyTitle") })) : (_jsx(View, { style: { height: Math.min(MAX_LIST_HEIGHT, listHeight) }, children: _jsx(PlainListView, { data: listed, keyExtractor: ({ id }) => id, extraInfo: {
161
+ selection,
162
+ selectAllValue: getSelectAllValue(selection, listed),
163
+ onToggle: transaction => onSelectionChange(toggleTransaction(selection, transaction)),
164
+ onToggleAll: () => onSelectionChange(toggleAllTransactions(selection, listed)),
165
+ }, columns: columns, smallColumns: smallColumns,
166
+ // The picker already measured its width: the list follows it.
167
+ breakpoint: large ? 0 : Number.POSITIVE_INFINITY, headerHeight: HEADER_HEIGHT, rowHeight: rowHeight,
168
+ // PlainListView counts one group header in its scroll height, even without groups.
169
+ groupHeaderHeight: 0, loading: { isLoading: waiting, count: LOADING_ROWS }, onEndReached: hasMore && !loading && !paused ? askForMore : undefined }) })), paused && !requesting ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 16 }), _jsx(LakeButton, { mode: "secondary", size: "small", style: styles.loadMore, onPress: loadMore, children: t("fraudReport.picker.loadMore") })] })) : null, _jsx(Space, { height: 24 }), _jsxs(Box, { direction: large ? "row" : "column", alignItems: large ? "center" : "stretch", children: [_jsx(TransactionsTotals, { transactions: selection, overLimit: overLimit > 0 }), _jsx(Fill, { minWidth: 24 }), large ? null : _jsx(Space, { height: 24 }), _jsx(LakeButton, { color: "current", size: large ? "small" : "large", style: large ? undefined : styles.confirm, disabled: overLimit > 0, onPress: onConfirm, children: t("fraudReport.picker.confirm") })] })] }));
170
+ };
171
+ const NO_FILTERS = {};
172
+ export const TransactionPicker = ({ visible, selected, onConfirm, onClose, onFiltersChange, ...props }) => {
173
+ const [selection, setSelection] = useState(selected);
174
+ const [wasVisible, setWasVisible] = useState(visible);
175
+ const [filters, setFilters] = useState(NO_FILTERS);
176
+ const [openCount, setOpenCount] = useState(0);
177
+ // Each opening starts from the step's selection: what was ticked before a close is dropped.
178
+ if (visible !== wasVisible) {
179
+ setWasVisible(visible);
180
+ if (visible) {
181
+ setSelection(selected);
182
+ setFilters(NO_FILTERS);
183
+ setOpenCount(openCount + 1);
184
+ }
185
+ }
186
+ // A search can come after the close, while the modal fades out with the content of its last
187
+ // render: only a ref tells it that the picker is closed.
188
+ const open = useRef(visible);
189
+ useEffect(() => {
190
+ open.current = visible;
191
+ }, [visible]);
192
+ const changeFilters = (next) => {
193
+ if (!isSamePickerFilters(filters, next)) {
194
+ setFilters(next);
195
+ onFiltersChange === null || onFiltersChange === void 0 ? void 0 : onFiltersChange(next);
196
+ }
197
+ };
198
+ // The app goes back to the rows without filters, ready for the next opening.
199
+ const leave = (callback) => {
200
+ changeFilters(NO_FILTERS);
201
+ callback();
202
+ };
203
+ return (_jsx(LakeModal, { visible: visible, title: t("fraudReport.picker.title"), maxWidth: 915, onPressClose: () => leave(onClose), children: _jsx(ResponsiveContainer, { breakpoint: TABLE_BREAKPOINT, children: ({ large }) => (_createElement(TransactionPickerContent, { ...props,
204
+ // Each opening starts again: the text typed in the filter bar and the count of
205
+ // pages without rows go.
206
+ key: openCount, large: large, filters: filters, onFiltersPatch: onFiltersChange == null
207
+ ? undefined
208
+ : patch => {
209
+ if (open.current) {
210
+ changeFilters(setPickerFilters(filters, patch));
211
+ }
212
+ }, selection: selection, onSelectionChange: setSelection, onConfirm: () => leave(() => onConfirm(selection)) })) }) }));
213
+ };
@@ -0,0 +1,8 @@
1
+ import { FraudReportPickerFilters } from "../../utils/fraudReport/pickerFilters";
2
+ type Props = {
3
+ filters: FraudReportPickerFilters;
4
+ large: boolean;
5
+ onChange: (patch: FraudReportPickerFilters) => void;
6
+ };
7
+ export declare const TransactionPickerFilters: ({ filters, large, onChange }: Props) => import("react").JSX.Element;
8
+ export {};