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: [IOPID-2634] Implement Zendesk FAQ Banner in the accesso_a_io subCategories screen #6714

Merged
merged 10 commits into from
Feb 20, 2025
Merged
2 changes: 1 addition & 1 deletion scripts/generate-api-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare -a apis=(
"./definitions/fims_history https://raw.githubusercontent.com/pagopa/io-backend/$IO_BACKEND_VERSION/api_io_fims.yaml"
"./definitions/fims_sso https://raw.githubusercontent.com/pagopa/io-fims/a93f1a1abf5230f103d9f489b139902b87288061/apps/op-app/openapi.yaml"
# CDN APIs
"./definitions/content https://raw.githubusercontent.com/pagopa/io-services-metadata/$IO_SERVICES_METADATA_VERSION/definitions.yml"
"./definitions/content https://raw.githubusercontent.com/pagopa/io-services-metadata/refs/heads/feature/content-educational-zendesk-subcategories/definitions.yml"
# Session Manager APIs
"./definitions/session_manager https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/internal.yaml"
"./definitions/fast_login https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/fast-login.yaml"
Expand Down
44 changes: 42 additions & 2 deletions ts/features/zendesk/screens/ZendeskChooseSubCategory.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {
Banner,
ContentWrapper,
Divider,
IOVisualCostants,
ListItemNav
ListItemNav,
useIOToast,
VSpacer
} from "@pagopa/io-app-design-system";
import { FlatList, ListRenderItemInfo } from "react-native";
import { ZendeskSubCategory } from "../../../../definitions/content/ZendeskSubCategory";
Expand All @@ -21,6 +25,7 @@ import {
zendeskSupportFailure
} from "../store/actions";
import { zendeskSelectedCategorySelector } from "../store/reducers";
import { openWebUrl } from "../../../utils/url";

export type ZendeskChooseSubCategoryNavigationParams = {
assistanceType: ZendeskAssistanceType;
Expand All @@ -31,11 +36,20 @@ type Props = IOStackNavigationRouteProps<
"ZENDESK_CHOOSE_SUB_CATEGORY"
>;

function getOrFallback<
O extends object,
K1 extends keyof O,
K2 extends keyof O
>(obj: O, key: K1, fallback: K2) {
return obj[key] ?? obj[fallback];
}

/**
* this screen shows the sub-categories for which the user can ask support with the assistance
* see {@link ZendeskChooseCategory} to check the previous category screen
*/
const ZendeskChooseSubCategory = (props: Props) => {
const { error } = useIOToast();
const selectedCategory = useIOSelector(zendeskSelectedCategorySelector);
const dispatch = useIODispatch();
const { assistanceType } = props.route.params;
Expand All @@ -61,6 +75,8 @@ const ZendeskChooseSubCategory = (props: Props) => {
selectedCategory.zendeskSubCategories?.subCategories ?? [];
const subCategoriesId: string =
selectedCategory.zendeskSubCategories?.id ?? "";
const bannerEducational =
selectedCategory.zendeskSubCategories?.bannerEducational;

const locale = getFullLocale();

Expand Down Expand Up @@ -90,6 +106,30 @@ const ZendeskChooseSubCategory = (props: Props) => {
ignoreSafeAreaMargin={true}
testID={"ZendeskChooseCategory"}
>
{bannerEducational && (
<ContentWrapper>
<Banner
pictogramName="charity"
size="big"
color="neutral"
title={getOrFallback(bannerEducational.title, locale, "it-IT")}
content={getOrFallback(bannerEducational.content, locale, "it-IT")}
action={getOrFallback(
bannerEducational.action.label,
locale,
"it-IT"
)}
onPress={() => {
const href = bannerEducational.action.href;

openWebUrl(getOrFallback(href, locale, "it-IT"), () => {
error(I18n.t("global.jserror.title"));
});
}}
/>
<VSpacer size={8} />
</ContentWrapper>
)}
<FlatList
scrollEnabled={false}
contentContainerStyle={{
Expand All @@ -98,7 +138,7 @@ const ZendeskChooseSubCategory = (props: Props) => {
data={subCategories}
keyExtractor={c => c.value}
renderItem={renderItem}
ItemSeparatorComponent={() => <Divider />}
ItemSeparatorComponent={Divider}
/>
</IOScrollViewWithLargeHeader>
);
Expand Down
Loading