diff --git a/ts/components/NewRemindEmailValidationOverlay.tsx b/ts/components/NewRemindEmailValidationOverlay.tsx index 504a705386b..8c2f931172b 100644 --- a/ts/components/NewRemindEmailValidationOverlay.tsx +++ b/ts/components/NewRemindEmailValidationOverlay.tsx @@ -213,11 +213,6 @@ const NewRemindEmailValidationOverlay = (props: Props) => { diff --git a/ts/features/zendesk/components/ZendeskSupportComponent.tsx b/ts/features/zendesk/components/ZendeskSupportComponent.tsx index 95816b08f05..3917b028915 100644 --- a/ts/features/zendesk/components/ZendeskSupportComponent.tsx +++ b/ts/features/zendesk/components/ZendeskSupportComponent.tsx @@ -18,7 +18,10 @@ import { IOStackNavigationProp } from "../../../navigation/params/AppParamsList"; import { useIOSelector } from "../../../store/hooks"; -import { profileSelector } from "../../../store/reducers/profile"; +import { + isProfileEmailValidatedSelector, + profileSelector +} from "../../../store/reducers/profile"; import { showToast } from "../../../utils/showToast"; import { openWebUrl } from "../../../utils/url"; import ZENDESK_ROUTES from "../navigation/routes"; @@ -48,6 +51,7 @@ const ZendeskSupportComponent = ({ const maybeProfile: O.Option = pot.toOption(profile); const zendeskRemoteConfig = useIOSelector(zendeskConfigSelector); const navigation = useNavigation>(); + const isEmailValidated = useIOSelector(isProfileEmailValidatedSelector); const handleContactSupportPress = React.useCallback( () => @@ -67,6 +71,8 @@ const ZendeskSupportComponent = ({ ] ); + const showRequestSupportButtons = isEmailValidated || !pot.isSome(profile); + return ( <>

{I18n.t("support.helpCenter.supportComponent.title")}

@@ -91,52 +97,56 @@ const ZendeskSupportComponent = ({ - { - void mixpanelTrack("ZENDESK_SHOW_TICKETS_STARTS"); - if (O.isNone(maybeProfile)) { - navigation.navigate(ZENDESK_ROUTES.MAIN, { - screen: ZENDESK_ROUTES.SEE_REPORTS_ROUTERS, - params: { - assistanceForPayment, - assistanceForCard, - assistanceForFci - } - }); - } else { - navigation.navigate(ZENDESK_ROUTES.MAIN, { - screen: ZENDESK_ROUTES.ASK_SEE_REPORTS_PERMISSIONS, - params: { - assistanceForPayment, - assistanceForCard, - assistanceForFci + {showRequestSupportButtons && ( + <> + { + void mixpanelTrack("ZENDESK_SHOW_TICKETS_STARTS"); + if (O.isNone(maybeProfile)) { + navigation.navigate(ZENDESK_ROUTES.MAIN, { + screen: ZENDESK_ROUTES.SEE_REPORTS_ROUTERS, + params: { + assistanceForPayment, + assistanceForCard, + assistanceForFci + } + }); + } else { + navigation.navigate(ZENDESK_ROUTES.MAIN, { + screen: ZENDESK_ROUTES.ASK_SEE_REPORTS_PERMISSIONS, + params: { + assistanceForPayment, + assistanceForCard, + assistanceForFci + } + }); } - }); - } - }} - style={{ - alignSelf: "stretch" - }} - disabled={false} - bordered={true} - testID={"showTicketsButton"} - > - - - + }} + style={{ + alignSelf: "stretch" + }} + disabled={false} + bordered={true} + testID={"showTicketsButton"} + > + + + - - - + + + + + )} ); }; diff --git a/ts/store/reducers/assistanceTools.ts b/ts/store/reducers/assistanceTools.ts index ec01f4826c8..f58e131b0b0 100644 --- a/ts/store/reducers/assistanceTools.ts +++ b/ts/store/reducers/assistanceTools.ts @@ -1,5 +1,4 @@ import { combineReducers } from "redux"; -import * as pot from "@pagopa/ts-commons/lib/pot"; import { createSelector } from "reselect"; import { Action } from "../actions/types"; import zendeskReducer, { @@ -10,7 +9,6 @@ import { canShowHelp } from "../../utils/supportAssistance"; import { assistanceToolConfigSelector } from "./backendStatus"; -import { isProfileEmailValidatedSelector, profileSelector } from "./profile"; export type AssistanceToolsState = { zendesk: ZendeskState; @@ -21,17 +19,12 @@ const assistanceToolsReducer = combineReducers({ }); // This selector contains the logic to show or not the help button: -// if remote FF is zendesk + ff local + the profile is not potSome or the email is validated +// if remote FF is zendesk + ff local export const canShowHelpSelector = createSelector( assistanceToolConfigSelector, - profileSelector, - isProfileEmailValidatedSelector, - (assistanceToolConfig, profile, isProfileEmailValidated): boolean => { + (assistanceToolConfig): boolean => { const remoteTool = assistanceToolRemoteConfig(assistanceToolConfig); - return canShowHelp( - remoteTool, - !pot.isSome(profile) || isProfileEmailValidated - ); + return canShowHelp(remoteTool); } ); diff --git a/ts/utils/__tests__/supportAssistance.test.ts b/ts/utils/__tests__/supportAssistance.test.ts index ed6499c7d13..f26b926ada1 100644 --- a/ts/utils/__tests__/supportAssistance.test.ts +++ b/ts/utils/__tests__/supportAssistance.test.ts @@ -29,16 +29,12 @@ describe("anonymousAssistanceAddress", () => { describe("canShowHelp", () => { it("if assistanceTool is Zendesk, should return true if the email is validated", () => { - expect(canShowHelp(ToolEnum.zendesk, true)).toBeTruthy(); - expect(canShowHelp(ToolEnum.zendesk, false)).toBeFalsy(); + expect(canShowHelp(ToolEnum.zendesk)).toBeTruthy(); }); it("if assistanceTool is instabug, web or none, should return false", () => { - expect(canShowHelp(ToolEnum.instabug, true)).toBeFalsy(); - expect(canShowHelp(ToolEnum.instabug, false)).toBeFalsy(); - expect(canShowHelp(ToolEnum.web, true)).toBeFalsy(); - expect(canShowHelp(ToolEnum.none, true)).toBeFalsy(); - expect(canShowHelp(ToolEnum.web, false)).toBeFalsy(); - expect(canShowHelp(ToolEnum.none, false)).toBeFalsy(); + expect(canShowHelp(ToolEnum.instabug)).toBeFalsy(); + expect(canShowHelp(ToolEnum.web)).toBeFalsy(); + expect(canShowHelp(ToolEnum.none)).toBeFalsy(); }); }); diff --git a/ts/utils/supportAssistance.ts b/ts/utils/supportAssistance.ts index ab446628975..0bafd417473 100644 --- a/ts/utils/supportAssistance.ts +++ b/ts/utils/supportAssistance.ts @@ -144,13 +144,10 @@ export const resetAssistanceData = () => { export const hasSubCategories = (zendeskCategory: ZendeskCategory): boolean => (zendeskCategory.zendeskSubCategories?.subCategories ?? []).length > 0; // help can be shown only when remote FF is zendesk + local FF + emailValidated -export const canShowHelp = ( - assistanceTool: ToolEnum, - isEmailValidated: boolean -): boolean => { +export const canShowHelp = (assistanceTool: ToolEnum): boolean => { switch (assistanceTool) { case ToolEnum.zendesk: - return zendeskEnabled && isEmailValidated; + return zendeskEnabled; case ToolEnum.instabug: case ToolEnum.web: case ToolEnum.none: