Skip to content

Commit

Permalink
Merge branch 'master' into IOBP-1119-convert-table-and-custom-list-to…
Browse files Browse the repository at this point in the history
…-list-item-component
  • Loading branch information
LeleDallas authored Jan 10, 2025
2 parents 5266cd8 + 7e5ca4a commit c1d0677
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 23 deletions.
2 changes: 1 addition & 1 deletion scripts/generate-api-models.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

IO_BACKEND_VERSION=v16.4.0-RELEASE
IO_SERVICES_METADATA_VERSION=1.0.51
IO_SERVICES_METADATA_VERSION=1.0.54

declare -a apis=(
# Backend APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import { ItwCredentialIssuanceMachineContext } from "../../machine/provider";
import { useCredentialEventsTracking } from "../hooks/useCredentialEventsTracking";
import { useIOSelector } from "../../../../store/hooks";
import { itwDeferredIssuanceScreenContentSelector } from "../../../../store/reducers/backendStatus/remoteConfig";
import { getFullLocale } from "../../../../utils/locale";
import {
fallbackForLocalizedMessageKeys,
getFullLocale
} from "../../../../utils/locale";
import { serializeFailureReason } from "../../common/utils/itwStoreUtils";

export const ItwIssuanceCredentialFailureScreen = () => {
Expand Down Expand Up @@ -65,6 +68,7 @@ const ContentView = ({ failure }: ContentViewProps) => {
selectIssuerConfigurationOption
);
const locale = getFullLocale();
const localeFallback = fallbackForLocalizedMessageKeys(locale);
const deferredIssuanceScreenContent = useIOSelector(
itwDeferredIssuanceScreenContentSelector
);
Expand Down Expand Up @@ -118,10 +122,10 @@ const ContentView = ({ failure }: ContentViewProps) => {
case CredentialIssuanceFailureType.ASYNC_ISSUANCE:
return {
title:
deferredIssuanceScreenContent?.title?.[locale] ??
deferredIssuanceScreenContent?.title?.[localeFallback] ??
I18n.t("features.itWallet.issuance.asyncCredentialError.title"),
subtitle:
deferredIssuanceScreenContent?.description?.[locale] ??
deferredIssuanceScreenContent?.description?.[localeFallback] ??
I18n.t("features.itWallet.issuance.asyncCredentialError.body"),
pictogram: "pending",
action: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
isPaymentsFeedbackBannerEnabledSelector,
paymentsFeedbackBannerConfigSelector
} from "../../../../store/reducers/backendStatus/remoteConfig";
import { getFullLocale } from "../../../../utils/locale";
import {
fallbackForLocalizedMessageKeys,
getFullLocale
} from "../../../../utils/locale";

const WalletPaymentFeebackBanner = () => {
const bannerViewRef = React.useRef<View>(null);
Expand All @@ -19,6 +22,7 @@ const WalletPaymentFeebackBanner = () => {
paymentsFeedbackBannerConfigSelector
);
const locale = getFullLocale();
const localeFallback = fallbackForLocalizedMessageKeys(locale);

const handleBannerPress = () => {
if (!feedbackBannerConfig?.action) {
Expand All @@ -42,9 +46,9 @@ const WalletPaymentFeebackBanner = () => {
pictogramName="feedback"
size="big"
viewRef={bannerViewRef}
title={feedbackBannerConfig.title?.[locale]}
content={feedbackBannerConfig.description[locale]}
action={feedbackBannerConfig.action?.label[locale]}
title={feedbackBannerConfig.title?.[localeFallback]}
content={feedbackBannerConfig.description[localeFallback]}
action={feedbackBannerConfig.action?.label[localeFallback]}
onPress={handleBannerPress}
/>
</>
Expand Down
25 changes: 18 additions & 7 deletions ts/features/payments/home/components/PaymentsAlertStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import * as React from "react";
import { constVoid } from "fp-ts/lib/function";
import { Alert } from "@pagopa/io-app-design-system";
import Animated, { FadeIn, FadeOut, Layout } from "react-native-reanimated";
import { constVoid } from "fp-ts/lib/function";
import * as React from "react";
import { GestureResponderEvent } from "react-native";
import Animated, {
FadeIn,
FadeOut,
LinearTransition
} from "react-native-reanimated";
import I18n from "../../../../i18n";
import { useIOSelector } from "../../../../store/hooks";
import { sectionStatusByKeySelector } from "../../../../store/reducers/backendStatus/sectionStatus";
import { getFullLocale } from "../../../../utils/locale";
import {
fallbackForLocalizedMessageKeys,
getFullLocale
} from "../../../../utils/locale";
import { openWebUrl } from "../../../../utils/url";
import { getAlertVariant } from "../../common/utils";

Expand All @@ -22,18 +29,22 @@ export const PaymentsAlertStatus = () => {

const handleOnPressAlertStatusInfo = (_: GestureResponderEvent) => {
if (alertInfo && alertInfo.web_url && alertInfo.web_url[getFullLocale()]) {
openWebUrl(alertInfo.web_url[getFullLocale()]);
openWebUrl(
alertInfo.web_url[fallbackForLocalizedMessageKeys(getFullLocale())]
);
}
};

return (
<Animated.View
entering={FadeIn.duration(200)}
exiting={FadeOut.duration(200)}
layout={Layout.duration(200)}
layout={LinearTransition.duration(200)}
>
<Alert
content={alertInfo.message[getFullLocale()]}
content={
alertInfo.message[fallbackForLocalizedMessageKeys(getFullLocale())]
}
variant={getAlertVariant(alertInfo.level)}
action={actionLabel}
onPress={
Expand Down
12 changes: 8 additions & 4 deletions ts/hooks/useStatusAlertProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import * as O from "fp-ts/lib/Option";
import { GestureResponderEvent } from "react-native";
import { useIOSelector } from "../store/hooks";
import { statusMessageByRouteSelector } from "../store/reducers/backendStatus/statusMessages";
import { getFullLocale } from "../utils/locale";
import {
fallbackForLocalizedMessageKeys,
getFullLocale
} from "../utils/locale";
import { LevelEnum } from "../../definitions/content/StatusMessage";
import I18n from "../i18n";
import { openWebUrl } from "../utils/url";
Expand Down Expand Up @@ -33,6 +36,7 @@ export const useStatusAlertProps = (
statusMessageByRouteSelector(routeName)
);
const locale = getFullLocale();
const localeFallback = fallbackForLocalizedMessageKeys(locale);

return useMemo(() => {
if (!currentStatusMessage || currentStatusMessage.length === 0) {
Expand All @@ -48,15 +52,15 @@ export const useStatusAlertProps = (
() => ({}),
url => ({
action: I18n.t("global.sectionStatus.moreInfo"),
onPress: () => openWebUrl(url[locale])
onPress: () => openWebUrl(url[localeFallback])
})
)
);

return {
content: firstAlert.message[locale],
content: firstAlert.message[localeFallback],
variant: statusVariantMap[firstAlert.level],
...statusAction
};
}, [currentStatusMessage, locale]);
}, [currentStatusMessage, localeFallback]);
};
3 changes: 2 additions & 1 deletion ts/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const localeToLocalizedMessageKey = new Map<
LocalizedMessageKeys
>([
["it", "it-IT"],
["en", "en-EN"]
["en", "en-EN"],
["de", "de-DE"]
]);

export const localeToPreferredLanguageMapping = new Map<
Expand Down
2 changes: 2 additions & 0 deletions ts/store/reducers/__mock__/backendStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export const baseRawBackendStatus: BackendStatus = {
android: "0.0.0.0",
ios: "0.0.0.0"
},
ipatente_cta_visible: true,
feedback_banner_visible: true,
disabled_identification_methods: [],
disabled_credentials: []
Expand Down Expand Up @@ -393,6 +394,7 @@ export const baseBackendConfig: Config = {
android: "0.0.0.0",
ios: "0.0.0.0"
},
ipatente_cta_visible: true,
feedback_banner_visible: true,
disabled_credentials: [],
disabled_identification_methods: []
Expand Down
11 changes: 9 additions & 2 deletions ts/utils/locale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as O from "fp-ts/lib/Option";
import * as AR from "fp-ts/lib/Array";
import { pipe } from "fp-ts/lib/function";
import * as O from "fp-ts/lib/Option";
import { PreferredLanguageEnum } from "../../definitions/backend/PreferredLanguage";
import { Locales } from "../../locales/locales";
import I18n, {
availableTranslations,
Expand All @@ -9,7 +10,6 @@ import I18n, {
localeToPreferredLanguageMapping,
LocalizedMessageKeys
} from "../i18n";
import { PreferredLanguageEnum } from "../../definitions/backend/PreferredLanguage";
/**
* Helpers for handling locales
*/
Expand Down Expand Up @@ -84,3 +84,10 @@ export const fromPreferredLanguageToLocale = (
O.fromNullable,
O.getOrElseW(() => localeFallback.locale)
);

// This function is for the case where the localized message key is not available. When german translation is not available, we use italian as a fallback.
// This function will be removed when the german translation will be available for all the keys.
export const fallbackForLocalizedMessageKeys = (
locale: LocalizedMessageKeys
): Exclude<LocalizedMessageKeys, "de-DE"> =>
locale === "de-DE" ? "it-IT" : locale;
4 changes: 3 additions & 1 deletion ts/utils/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ export const getPaymentOutcomeCodeDescription = (
outcomeCodes[maybeOutcomeCodeKey.right] as OutcomeCode,
O.fromNullable,
O.chainNullableK(oc => oc.description),
O.map(description => description[getFullLocale()])
O.map(
description => description[getFullLocale() as keyof typeof description]
)
);
}
return O.none;
Expand Down

0 comments on commit c1d0677

Please sign in to comment.