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(IDPay): [IOBP-1147] Add request help from IDPay beneficiary details screen #6622

Merged
merged 30 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
53e41be
feat: First implementation of initiative type `EXPENSE`
Hantex9 Jan 21, 2025
5c40e39
feat: Add request help CTA from IDPay beneficiary details
Hantex9 Jan 21, 2025
7c9c89a
chore: Temporary add custom idpay definitions
Hantex9 Jan 21, 2025
44e24e2
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Jan 21, 2025
e6aa9f9
chore: added missing locales
Hantex9 Jan 21, 2025
56265ae
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Jan 21, 2025
9277e93
Merge branch 'master' into IOBP-1139-add-idpay-expense-details
Hantex9 Jan 21, 2025
a0e85dc
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Jan 21, 2025
e48aaa1
chore: Add i18n label
Hantex9 Jan 22, 2025
2bd7743
Merge branch 'master' into IOBP-1139-add-idpay-expense-details
Hantex9 Jan 31, 2025
f15ac7c
chore: removed idpay temp openapi and added tag to correct definitions
Hantex9 Feb 4, 2025
ee4e29b
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Feb 4, 2025
ab428c8
Merge remote-tracking branch 'origin/master' into IOBP-1139-add-idpay…
Hantex9 Feb 4, 2025
beff021
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Feb 4, 2025
973d767
fix: color of bodysmall
Hantex9 Feb 4, 2025
db23d0f
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Feb 4, 2025
450ce1e
tests: add pressable prop
Hantex9 Feb 4, 2025
eed859e
Merge branch 'IOBP-1139-add-idpay-expense-details' into IOBP-1147-add…
Hantex9 Feb 4, 2025
9e11533
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 5, 2025
d1f8f5f
Merge remote-tracking branch 'origin/master' into IOBP-1147-add-reque…
Hantex9 Feb 5, 2025
c2a843c
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 5, 2025
5b612bd
fix: tests
Hantex9 Feb 5, 2025
e3c4f49
refactor: removed comments
Hantex9 Feb 5, 2025
500907e
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 5, 2025
38d50e8
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
LeleDallas Feb 5, 2025
afd3390
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 6, 2025
809d73c
refactor: replaced the switch-case with the if-else statement
Hantex9 Feb 6, 2025
e62c050
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 6, 2025
7c2556a
chore: Add idpay category id and expense subcategory
Hantex9 Feb 6, 2025
f56d44f
Merge branch 'master' into IOBP-1147-add-request-help-from-idpay-details
Hantex9 Feb 6, 2025
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
1 change: 1 addition & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3798,6 +3798,7 @@ idpay:
buttons:
privacy: Preferenze & Privacy
unsubscribe: Rimuovi {{initiativeName}}
requestHelp: Chiedi aiuto
operationDetails:
discount:
labels:
Expand Down
1 change: 1 addition & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3798,6 +3798,7 @@ idpay:
buttons:
privacy: Preferenze & Privacy
unsubscribe: Rimuovi {{initiativeName}}
requestHelp: Chiedi aiuto
operationDetails:
discount:
labels:
Expand Down
56 changes: 56 additions & 0 deletions ts/features/idpay/common/hooks/useIdPaySupportModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ToolEnum } from "../../../../../definitions/content/AssistanceToolConfig";
import { useIODispatch, useIOSelector } from "../../../../store/hooks";
import { assistanceToolConfigSelector } from "../../../../store/reducers/backendStatus/remoteConfig";
import {
addTicketCustomField,
assistanceToolRemoteConfig,
defaultIdPayExpenseCategory,
resetCustomFields,
zendeskIdPayCategoryId
} from "../../../../utils/supportAssistance";
import {
zendeskSelectedCategory,
zendeskSupportStart
} from "../../../zendesk/store/actions";

type PaymentFailureSupportModal = {
startIdPaySupport: (startingRoute?: string) => void;
};

const useIdPaySupportModal = (): PaymentFailureSupportModal => {
const assistanceToolConfig = useIOSelector(assistanceToolConfigSelector);
const choosenTool = assistanceToolRemoteConfig(assistanceToolConfig);

const dispatch = useIODispatch();

const zendeskAssistanceLogAndStart = (startingRoute?: string) => {
resetCustomFields();
// attach the main zendesk category to the ticket
addTicketCustomField(
zendeskIdPayCategoryId,
defaultIdPayExpenseCategory.value
);

dispatch(
zendeskSupportStart({
startingRoute: startingRoute ?? "n/a",
assistanceType: {
idPay: true
}
})
);
dispatch(zendeskSelectedCategory(defaultIdPayExpenseCategory));
};

const startIdPaySupport = (startingRoute?: string) => {
if (choosenTool === ToolEnum.zendesk) {
zendeskAssistanceLogAndStart(startingRoute);
}
};

return {
startIdPaySupport
};
};

export { useIdPaySupportModal };
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Body,
BodySmall,
Divider,
ListItemAction,
ListItemHeader,
ListItemInfo,
ListItemTransaction,
Expand Down Expand Up @@ -35,6 +36,8 @@ import { format } from "../../../../utils/dates";
import { SERVICES_ROUTES } from "../../../services/common/navigation/routes";
import { formatNumberCurrencyOrDefault } from "../../common/utils/strings";
import { IdPayUnsubscriptionRoutes } from "../../unsubscription/navigation/routes";
import { useIdPaySupportModal } from "../../common/hooks/useIdPaySupportModal";
import { IDPayDetailsRoutes } from "../navigation";
import {
InitiativeRulesInfoBox,
InitiativeRulesInfoBoxSkeleton
Expand Down Expand Up @@ -63,6 +66,7 @@ const formatDate = (fmt: string) => (date: Date) => format(date, fmt);

const BeneficiaryDetailsContent = (props: BeneficiaryDetailsProps) => {
const navigation = useNavigation<IOStackNavigationProp<AppParamsList>>();
const { startIdPaySupport } = useIdPaySupportModal();
const { initiativeDetails, beneficiaryDetails, onboardingStatus, isLoading } =
props;

Expand Down Expand Up @@ -200,6 +204,10 @@ const BeneficiaryDetailsContent = (props: BeneficiaryDetailsProps) => {
)
);

const handleRequestHelpPress = () => {
startIdPaySupport(IDPayDetailsRoutes.IDPAY_DETAILS_BENEFICIARY);
};

const handleUnsubscribePress = () => {
pipe(
sequenceS(O.Monad)({
Expand Down Expand Up @@ -325,9 +333,21 @@ const BeneficiaryDetailsContent = (props: BeneficiaryDetailsProps) => {
return (
<>
<VSpacer size={32} />
<Body weight="Semibold" asLink onPress={handlePrivacyLinkPress}>
{I18n.t("idpay.initiative.beneficiaryDetails.buttons.privacy")}
</Body>
<ListItemAction
label={I18n.t(
"idpay.initiative.beneficiaryDetails.buttons.privacy"
)}
onPress={handlePrivacyLinkPress}
variant="primary"
/>
<Divider />
<ListItemAction
label={I18n.t(
"idpay.initiative.beneficiaryDetails.buttons.requestHelp"
)}
onPress={handleRequestHelpPress}
variant="danger"
/>
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, within } from "@testing-library/react-native";
import { within } from "@testing-library/react-native";
import configureMockStore from "redux-mock-store";
import {
InitiativeRewardTypeEnum,
StatusEnum as InitiativeStatusEnum
Expand All @@ -10,6 +11,11 @@ import {
} from "../BeneficiaryDetailsContent";
import { StatusEnum as OnboardingStatusEnum } from "../../../../../../definitions/idpay/OnboardingStatusDTO";
import { RewardValueTypeEnum } from "../../../../../../definitions/idpay/RewardValueDTO";
import { appReducer } from "../../../../../store/reducers";
import { applicationChangeState } from "../../../../../store/actions/application";
import { GlobalState } from "../../../../../store/reducers/types";
import { renderScreenWithNavigationStoreContext } from "../../../../../utils/testWrapper";
import { IDPayDetailsRoutes } from "../../navigation";

setLocale("it");

Expand Down Expand Up @@ -49,7 +55,7 @@ const T_REWARD_VALUE_ABSOLUTE_STRING = "30,00 €";

describe("Test BeneficiaryDetailsContent component", () => {
it("should correctly render all the info ", () => {
const component = renderComponent(InitiativeRewardTypeEnum.REFUND);
const { component } = renderComponent(InitiativeRewardTypeEnum.REFUND);

const statusRow = within(component.getByTestId("statusTestID"));
expect(
Expand Down Expand Up @@ -147,7 +153,7 @@ describe("Test BeneficiaryDetailsContent component", () => {
});

it("should correctly render absolute reward type data", () => {
const component = renderComponent(
const { component } = renderComponent(
InitiativeRewardTypeEnum.REFUND,
RewardValueTypeEnum.ABSOLUTE
);
Expand All @@ -165,12 +171,12 @@ describe("Test BeneficiaryDetailsContent component", () => {
).toBeTruthy();
});
it("should correctly render type dependant entries in case of a discount initiative", () => {
const component = renderComponent(InitiativeRewardTypeEnum.DISCOUNT);
const { component } = renderComponent(InitiativeRewardTypeEnum.DISCOUNT);
expect(component.queryByTestId("accruedTestID")).toBeTruthy();
expect(component.queryByTestId("refundedTestID")).toBeFalsy();
});
it("should correctly render type dependant entries in case of a refund initiative", () => {
const component = renderComponent(InitiativeRewardTypeEnum.REFUND);
const { component } = renderComponent(InitiativeRewardTypeEnum.REFUND);
expect(component.queryByTestId("accruedTestID")).toBeTruthy();
expect(component.queryByTestId("refundedTestID")).toBeTruthy();
});
Expand Down Expand Up @@ -208,5 +214,19 @@ const renderComponent = (
}
};

return render(<BeneficiaryDetailsContent {...props} />);
const globalState = appReducer(undefined, applicationChangeState("active"));
const mockStore = configureMockStore<GlobalState>();
const store: ReturnType<typeof mockStore> = mockStore({
...globalState
});

return {
component: renderScreenWithNavigationStoreContext<GlobalState>(
() => <BeneficiaryDetailsContent {...props} />,
IDPayDetailsRoutes.IDPAY_DETAILS_MAIN,
{},
store
),
store
};
};
1 change: 1 addition & 0 deletions ts/features/zendesk/store/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ZendeskAssistanceType = Partial<{
card: boolean;
fci: boolean;
itWallet: boolean;
idPay: boolean;
}>;

export type ZendeskStartPayload = {
Expand Down
4 changes: 3 additions & 1 deletion ts/features/zendesk/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const handleContactSupport = (
zendeskRemoteConfig: ZendeskConfig
) => {
const canSkipCategoryChoice: boolean =
!isReady(zendeskRemoteConfig) || !!assistanceType.payment;
!isReady(zendeskRemoteConfig) ||
!!assistanceType.payment ||
!!assistanceType.idPay;

if (isPanicModeActive(zendeskRemoteConfig)) {
// Go to panic mode screen
Expand Down
3 changes: 2 additions & 1 deletion ts/hooks/useStartSupportRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const useStartSupportRequest = ({
payment: false,
card: false,
fci: false,
itWallet: false
itWallet: false,
idPay: false
}
})
);
Expand Down
10 changes: 10 additions & 0 deletions ts/utils/supportAssistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const zendeskCurrentAppVersionId = "4414316660369";
export const zendeskVersionsHistoryId = "4419641151505";
export const zendeskFciId = "14874226407825";
export const zendeskItWalletFailureCode = "31775197295633";
export const zendeskIdPayCategoryId = "8086481365265";

export const defaultZendeskPaymentCategory: ZendeskCategory = {
value: "io_pagamenti_pagopa",
Expand Down Expand Up @@ -151,6 +152,15 @@ export const zendeskItWalletCategory: ZendeskCategory = {
}
};

export const defaultIdPayExpenseCategory: ZendeskCategory = {
value: "idpay_guidonia",
description: {
"it-IT": "Pagamento pagoPA",
"en-EN": "pagoPA payment",
"de-DE": "pagoPA-Zahlung"
}
};

export const resetAssistanceData = () => {
resetCustomFields();
resetLog();
Expand Down
Loading