Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [IOCOM-1172] Update business logic for payment reminder on a message details screen with the new DS #5613

Merged
merged 91 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
e92a770
WiP
Vangaorth Mar 5, 2024
4b3c322
WiP 2
Vangaorth Mar 5, 2024
cbef3ba
Merge branch 'master' into IOCOM-857-paymentonmessage
Vangaorth Mar 5, 2024
238743e
WiP 3
Vangaorth Mar 5, 2024
b2723f5
Merge branch 'master' into IOCOM-857-paymentonmessage
Vangaorth Mar 5, 2024
acbf947
Fix for payment update
Vangaorth Mar 6, 2024
60f8126
Tests for isProfileEmailValidatedSelector
Vangaorth Mar 6, 2024
044ccf4
Merge branch 'master' into IOCOM-857-paymentonmessage
Vangaorth Mar 6, 2024
ad48d3c
Tests for addUserSelectedPaymentRptId and userSelectedPaymentRptIdSel…
Vangaorth Mar 6, 2024
53ec7f2
isUserSelectedPayment Tests
Vangaorth Mar 6, 2024
c9689b8
canNavigateToPaymentFromMessageSelector tests
Vangaorth Mar 6, 2024
3a5468f
messagePaymentDataSelector tests
Vangaorth Mar 6, 2024
412d0c1
pnUserSelectedPaymentRptIdSelector tests
Vangaorth Mar 6, 2024
9c1c7d5
getRptIdStringFromPaymentData tests
Vangaorth Mar 6, 2024
c7bea54
pnUserSelectedPaymentRptIdSelector tests fix
Vangaorth Mar 6, 2024
454017c
initializeAndNavigateToWalletForPayment tests
Vangaorth Mar 6, 2024
f44a149
duplicateSetAndAdd and duplicateSetAndRemove tests
Vangaorth Mar 6, 2024
7b56fa3
MessageDetailsPayment tests
Vangaorth Mar 6, 2024
c3b734a
MessageFooter tests
Vangaorth Mar 6, 2024
2222ca0
WiP
Vangaorth Mar 8, 2024
84f0c02
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 8, 2024
c07cba9
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 8, 2024
4daf15d
Working code, still missing tests
Vangaorth Mar 8, 2024
d3f8bc4
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
6dc99e1
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
dbd5c7b
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
6a83043
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
b8f56cc
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
98d49b4
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 12, 2024
122b84d
WiP tests for paymentsButtonStateSelector selector
Vangaorth Mar 12, 2024
51e2860
Tests for paymentsButtonStateSelector
Vangaorth Mar 13, 2024
8907dbd
Tests for isPaymentsButtonVisibleSelector
Vangaorth Mar 13, 2024
10c0e0f
Tests for CTAsBar, MessageDetailsScrollViewAdditionalSpace and Messag…
Vangaorth Mar 13, 2024
adb80f8
Fixed bad test
Vangaorth Mar 13, 2024
db17726
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 13, 2024
97e480e
Updated snapshots
Vangaorth Mar 13, 2024
7565010
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 14, 2024
857c4a5
Merge branch 'master' into IOCOM-859-paybutton
Vangaorth Mar 14, 2024
13df90b
SEND attachments with new DS system
Vangaorth Mar 14, 2024
3bca10f
Fixed bad input for MessageDetails.test.tsx
Vangaorth Mar 14, 2024
ff1e296
Removed unused import on MessageDetails
Vangaorth Mar 14, 2024
b69f2bb
Updated snapshot for MessageDetailsScreen
Vangaorth Mar 14, 2024
6efcf9f
Updated snapshot for MessageDetails.test.tsx
Vangaorth Mar 14, 2024
e6c4747
Merge branch 'master' into IOCOM-869-pnattach
Vangaorth Mar 14, 2024
b0b10b4
Merge branch 'master' into IOCOM-869-pnattach
Vangaorth Mar 14, 2024
a59e83e
WiP
Vangaorth Mar 14, 2024
4176a01
Fixed attachment download and preview for PN attachments
Vangaorth Mar 15, 2024
dce0275
Merge branch 'IOCOM-869-pnattach' into IOCOM-872-pnf24section
Vangaorth Mar 15, 2024
253fcfe
Proper Button Link and business logic for F24 module
Vangaorth Mar 15, 2024
52129df
Merge branch 'master' into IOCOM-872-pnf24section
Vangaorth Mar 15, 2024
17a3d5b
Tests for F24s
Vangaorth Mar 15, 2024
68317f0
Merge branch 'IOCOM-872-pnf24section' of https://github.com/pagopa/io…
Vangaorth Mar 15, 2024
1e8b033
Updated snapshot
Vangaorth Mar 15, 2024
0f86ef4
SEND F24 bottom sheet
Vangaorth Mar 18, 2024
98ec6a6
Merge branch 'master' into IOCOM-879-f24bs
Vangaorth Mar 18, 2024
4e0f6fc
Merge branch 'master' into IOCOM-879-f24bs
Vangaorth Mar 19, 2024
c79349b
Merge branch 'master' into IOCOM-879-f24bs
Vangaorth Mar 20, 2024
eabe26b
Merge branch 'master' into IOCOM-879-f24bs
Vangaorth Mar 20, 2024
8666f24
Merge branch 'master' into IOCOM-879-f24bs
Vangaorth Mar 20, 2024
37c4b5d
New business logic for message reminder
Vangaorth Mar 20, 2024
9ce6952
Merged master into IOCOM-879-f24bs
Vangaorth Mar 20, 2024
2bf4c7e
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 20, 2024
50aa0cf
Tests for paymentExpirationBannerStateSelector
Vangaorth Mar 21, 2024
1893694
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 21, 2024
d277b70
Removed obsolete tests
Vangaorth Mar 21, 2024
8971d9d
Tests for MessageDetailsReminderExpired
Vangaorth Mar 21, 2024
e19eba5
Tests for MessageDeatilsReminderExpiring
Vangaorth Mar 21, 2024
4fe0503
Fixed logic for Expiring Reminder, never used with a loading state
Vangaorth Mar 21, 2024
b5b2ec3
Tests for MessageDetailsReminder
Vangaorth Mar 21, 2024
a22aa09
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 21, 2024
54dcfed
Fixed failing test
Vangaorth Mar 21, 2024
c08dd34
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 22, 2024
5bee598
Removed bad files
Vangaorth Mar 22, 2024
aba5261
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 25, 2024
4ad8ce1
Merge branch 'master' into IOCOM-1172-remidner
forrest57 Mar 26, 2024
b6f4989
Merge branch 'master' into IOCOM-1172-remidner
forrest57 Mar 26, 2024
f162b07
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 26, 2024
b627092
Merge branch 'master' into IOCOM-1172-remidner
dmnplb Mar 27, 2024
080ec59
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
df5d311
Updated snapshots
Vangaorth Mar 27, 2024
73550b3
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
081b867
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
100f471
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
041fabc
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
1d86029
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 27, 2024
730febb
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 28, 2024
b22ded0
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 28, 2024
5214a12
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 28, 2024
703467c
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 29, 2024
04fb35b
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 29, 2024
50395ff
Merge branch 'master' into IOCOM-1172-remidner
Vangaorth Mar 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React, { useCallback } from "react";
import { Alert } from "@pagopa/io-app-design-system";
import React from "react";
import { VSpacer } from "@pagopa/io-app-design-system";
import { UIMessageId } from "../../types";
import { useIONavigation } from "../../../../navigation/params/AppParamsList";
import I18n from "../../../../i18n";
import { localeDateFormat } from "../../../../utils/locale";
import { useIOSelector } from "../../../../store/hooks";
import { useMessageReminder } from "../../hooks/useMessageReminder";
import { preferredCalendarSelector } from "../../../../store/reducers/persistedPreferences";
import { paymentExpirationBannerStateSelector } from "../../store/reducers/payments";
import { MessageDetailsReminderExpiring } from "./MessageDetailsReminderExpiring";
import { MessageDetailsReminderExpired } from "./MessageDetailsReminderExpired";

export type MessageDetailsReminderProps = {
dueDate: Date;
dueDate?: Date;
messageId: UIMessageId;
title: string;
};
Expand All @@ -19,41 +17,29 @@ export const MessageDetailsReminder = ({
messageId,
title
}: MessageDetailsReminderProps) => {
const navigation = useIONavigation();

const preferredCalendar = useIOSelector(preferredCalendarSelector);

const navigate = useCallback(() => {
navigation.navigate("MESSAGES_NAVIGATOR", {
screen: "MESSAGE_DETAIL_CALENDAR",
params: {
messageId
}
});
}, [messageId, navigation]);

const { isEventInDeviceCalendar, upsertReminder } = useMessageReminder(
messageId,
navigate
const reminderVisibility = useIOSelector(state =>
paymentExpirationBannerStateSelector(state, messageId)
);
if (reminderVisibility === "hidden" || !dueDate) {
return null;
}

const isExpiring = reminderVisibility === "visibleExpiring";
return (
<Alert
testID="due-date-alert"
variant="warning"
action={
isEventInDeviceCalendar
? I18n.t("features.messages.alert.removeReminder")
: I18n.t("features.messages.alert.addReminder")
}
onPress={() => upsertReminder(dueDate, title, preferredCalendar)}
content={I18n.t("features.messages.alert.content", {
date: localeDateFormat(
dueDate,
I18n.t("global.dateFormats.shortFormat")
),
time: localeDateFormat(dueDate, I18n.t("global.dateFormats.timeFormat"))
})}
/>
<>
{isExpiring ? (
<MessageDetailsReminderExpiring
dueDate={dueDate}
messageId={messageId}
title={title}
/>
) : (
<MessageDetailsReminderExpired
dueDate={dueDate}
isLoading={reminderVisibility === "loading"}
/>
)}
<VSpacer size={8} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from "react";
import { Alert, IOAlertRadius } from "@pagopa/io-app-design-system";
import Placeholder from "rn-placeholder";
import { localeDateFormat } from "../../../../utils/locale";
import I18n from "../../../../i18n";

type MessageDetailsReminderExpiredProps = {
dueDate: Date;
isLoading: boolean;
};

export const MessageDetailsReminderExpired = ({
dueDate,
isLoading
}: MessageDetailsReminderExpiredProps) =>
isLoading ? (
<Placeholder.Box
animate="shine"
height={84}
width={"100%"}
radius={IOAlertRadius}
/>
) : (
<Alert
testID="due-date-alert"
variant="warning"
content={I18n.t("features.messages.badge.dueDate", {
date: localeDateFormat(
dueDate,
I18n.t("global.dateFormats.dayMonthWithoutTime")
),
time: localeDateFormat(dueDate, I18n.t("global.dateFormats.timeFormat"))
})}
/>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { useCallback } from "react";
import { Alert } from "@pagopa/io-app-design-system";
import { useIONavigation } from "../../../../navigation/params/AppParamsList";
import { useIOSelector } from "../../../../store/hooks";
import { preferredCalendarSelector } from "../../../../store/reducers/persistedPreferences";
import { UIMessageId } from "../../types";
import { useMessageReminder } from "../../hooks/useMessageReminder";
import { localeDateFormat } from "../../../../utils/locale";
import I18n from "../../../../i18n";

type MessageDetailsReminderExpiringProps = {
dueDate: Date;
messageId: UIMessageId;
title: string;
};

export const MessageDetailsReminderExpiring = ({
dueDate,
messageId,
title
}: MessageDetailsReminderExpiringProps) => {
const navigation = useIONavigation();
const preferredCalendar = useIOSelector(preferredCalendarSelector);

const navigate = useCallback(() => {
navigation.navigate("MESSAGES_NAVIGATOR", {
screen: "MESSAGE_DETAIL_CALENDAR",
params: {
messageId
}
});
}, [messageId, navigation]);

const { isEventInDeviceCalendar, upsertReminder } = useMessageReminder(
messageId,
navigate
);
return (
<Alert
testID="due-date-alert"
variant="warning"
action={
isEventInDeviceCalendar
? I18n.t("features.messages.alert.removeReminder")
: I18n.t("features.messages.alert.addReminder")
}
onPress={() => upsertReminder(dueDate, title, preferredCalendar)}
content={I18n.t("features.messages.alert.content", {
date: localeDateFormat(
dueDate,
I18n.t("global.dateFormats.shortFormat")
),
time: localeDateFormat(dueDate, I18n.t("global.dateFormats.timeFormat"))
})}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from "react";
import { createStore } from "redux";
import { MessageDetailsReminder } from "../MessageDetailsReminder";
import { appReducer } from "../../../../../store/reducers";
import { applicationChangeState } from "../../../../../store/actions/application";
import { preferencesDesignSystemSetEnabled } from "../../../../../store/actions/persistedPreferences";
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper";
import { UIMessageId } from "../../../types";
import * as payments from "../../../store/reducers/payments";

const dueDate = new Date(2024, 2, 21, 18, 44, 31);

describe("MessageDetailsReminder", () => {
beforeEach(() => {
jest.resetAllMocks();
jest.restoreAllMocks();
});
it("should match snapshot when the reminder is hidden", () => {
jest
.spyOn(payments, "paymentExpirationBannerStateSelector")
.mockImplementation((_state, _messageId) => "hidden");
const component = renderScreen(dueDate);
expect(component.toJSON()).toMatchSnapshot();
});
it("should match snapshot when the due date is missing", () => {
jest
.spyOn(payments, "paymentExpirationBannerStateSelector")
.mockImplementation((_state, _messageId) => "visibleExpired");
const component = renderScreen();
expect(component.toJSON()).toMatchSnapshot();
});
it("should match snapshot when the reminder is loading", () => {
jest
.spyOn(payments, "paymentExpirationBannerStateSelector")
.mockImplementation((_state, _messageId) => "loading");
const component = renderScreen(dueDate);
expect(component.toJSON()).toMatchSnapshot();
});
it("should match snapshot when the reminder is visible an expiring", () => {
jest
.spyOn(payments, "paymentExpirationBannerStateSelector")
.mockImplementation((_state, _messageId) => "visibleExpiring");
const component = renderScreen(dueDate);
expect(component.toJSON()).toMatchSnapshot();
});
it("should match snapshot when the reminder is visible and expired", () => {
jest
.spyOn(payments, "paymentExpirationBannerStateSelector")
.mockImplementation((_state, _messageId) => "visibleExpired");
const component = renderScreen(dueDate);
expect(component.toJSON()).toMatchSnapshot();
});
});

const renderScreen = (dueDate?: Date) => {
const initialState = appReducer(undefined, applicationChangeState("active"));
const designSystemState = appReducer(
initialState,
preferencesDesignSystemSetEnabled({ isDesignSystemEnabled: true })
);
const store = createStore(appReducer, designSystemState as any);

return renderScreenWithNavigationStoreContext(
() => (
<MessageDetailsReminder
dueDate={dueDate}
messageId={"01HSG6H6M4KK36CV6QWP2VJW3S" as UIMessageId}
title="The title"
/>
),
"DUMMY",
{},
store
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { createStore } from "redux";
import { appReducer } from "../../../../../store/reducers";
import { applicationChangeState } from "../../../../../store/actions/application";
import { preferencesDesignSystemSetEnabled } from "../../../../../store/actions/persistedPreferences";
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper";
import { MessageDetailsReminderExpired } from "../MessageDetailsReminderExpired";

describe("MessageDetailsReminderExpired", () => {
it("should match snapshot when loading", () => {
const component = renderScreen(true);
expect(component.toJSON()).toMatchSnapshot();
});
it("should match snapshot when not loading", () => {
const component = renderScreen();
expect(component.toJSON()).toMatchSnapshot();
});
});

const renderScreen = (isLoading: boolean = false) => {
const initialState = appReducer(undefined, applicationChangeState("active"));
const designSystemState = appReducer(
initialState,
preferencesDesignSystemSetEnabled({ isDesignSystemEnabled: true })
);
const store = createStore(appReducer, designSystemState as any);

return renderScreenWithNavigationStoreContext(
() => (
<MessageDetailsReminderExpired
dueDate={new Date(2024, 2, 21, 10, 33, 42)}
isLoading={isLoading}
/>
),
"DUMMY",
{},
store
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from "react";
import { createStore } from "redux";
import { MessageDetailsReminderExpiring } from "../MessageDetailsReminderExpiring";
import { appReducer } from "../../../../../store/reducers";
import { applicationChangeState } from "../../../../../store/actions/application";
import { preferencesDesignSystemSetEnabled } from "../../../../../store/actions/persistedPreferences";
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper";
import { UIMessageId } from "../../../types";

describe("MessageDetailsReminderExpiring", () => {
it("should match snapshot", () => {
const component = renderScreen();
expect(component.toJSON()).toMatchSnapshot();
});
});

const renderScreen = () => {
const initialState = appReducer(undefined, applicationChangeState("active"));
const designSystemState = appReducer(
initialState,
preferencesDesignSystemSetEnabled({ isDesignSystemEnabled: true })
);
const store = createStore(appReducer, designSystemState as any);

return renderScreenWithNavigationStoreContext(
() => (
<MessageDetailsReminderExpiring
dueDate={new Date(2024, 2, 21, 10, 33, 42)}
messageId={"01HSG6GR1JT2E23AJ5RBTAMZZP" as UIMessageId}
title="The title"
/>
),
"DUMMY",
{},
store
);
};
Loading
Loading