From 75dcf1f531f9c750f4e4b1c080abccfae3829576 Mon Sep 17 00:00:00 2001
From: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com>
Date: Fri, 3 Jan 2025 17:42:47 +0100
Subject: [PATCH] refactor: replace legacy markdown component
---
.../components/InitiativeRulesInfoBox.tsx | 4 +-
.../OnboardingDescriptionMarkdown.tsx | 39 +------------------
.../screens/InitiativeDetailsScreen.tsx | 15 ++-----
.../screens/PDNDPrerequisitesScreen.tsx | 8 ++--
4 files changed, 11 insertions(+), 55 deletions(-)
diff --git a/ts/features/idpay/details/components/InitiativeRulesInfoBox.tsx b/ts/features/idpay/details/components/InitiativeRulesInfoBox.tsx
index 4b01d37103a..8d0713be8c6 100644
--- a/ts/features/idpay/details/components/InitiativeRulesInfoBox.tsx
+++ b/ts/features/idpay/details/components/InitiativeRulesInfoBox.tsx
@@ -12,9 +12,9 @@ import React from "react";
import { StyleSheet, View } from "react-native";
import Placeholder from "rn-placeholder";
import { IOStyles } from "../../../../components/core/variables/IOStyles";
-import LegacyMarkdown from "../../../../components/ui/Markdown/LegacyMarkdown";
import I18n from "../../../../i18n";
import { useIOBottomSheetAutoresizableModal } from "../../../../utils/hooks/bottomSheet";
+import IOMarkdown from "../../../../components/IOMarkdown";
type Props = {
content: string;
@@ -25,7 +25,7 @@ const InitiativeRulesInfoBox = (props: Props) => {
const { bottomSheet, present, dismiss } = useIOBottomSheetAutoresizableModal(
{
- component: {content},
+ component: ,
title: I18n.t("idpay.initiative.beneficiaryDetails.infoModal.title"),
footer: (
diff --git a/ts/features/idpay/onboarding/components/OnboardingDescriptionMarkdown.tsx b/ts/features/idpay/onboarding/components/OnboardingDescriptionMarkdown.tsx
index 52aa30f4632..3dfe684ba63 100644
--- a/ts/features/idpay/onboarding/components/OnboardingDescriptionMarkdown.tsx
+++ b/ts/features/idpay/onboarding/components/OnboardingDescriptionMarkdown.tsx
@@ -1,42 +1,7 @@
+import { VSpacer } from "@pagopa/io-app-design-system";
import * as React from "react";
import { View } from "react-native";
import Placeholder from "rn-placeholder";
-import { VSpacer } from "@pagopa/io-app-design-system";
-import LegacyMarkdown from "../../../../components/ui/Markdown/LegacyMarkdown";
-
-type Props = {
- description: string;
- onLoadEnd: () => void;
-};
-
-const OnboardingDescriptionMarkdown = (props: Props) => {
- const { description, onLoadEnd } = props;
-
- const [isLoaded, setLoaded] = React.useState(false);
-
- const handleOnLoadEnd = () => {
- // The markdown component has a different height for some istants after finishing loading
- // Setting a timeout allows to properly display other components once the Markdown has finished
- // loading.
- setTimeout(() => {
- setLoaded(true);
- onLoadEnd();
- }, 300);
- };
-
- if (description.length > 0) {
- return (
-
- {!isLoaded && }
-
- {description}
-
-
- );
- }
-
- return ;
-};
const OnboardingDescriptionMarkdownSkeleton = () => (
<>
@@ -68,4 +33,4 @@ const OnboardingDescriptionMarkdownSkeleton = () => (
>
);
-export { OnboardingDescriptionMarkdown, OnboardingDescriptionMarkdownSkeleton };
+export { OnboardingDescriptionMarkdownSkeleton };
diff --git a/ts/features/idpay/onboarding/screens/InitiativeDetailsScreen.tsx b/ts/features/idpay/onboarding/screens/InitiativeDetailsScreen.tsx
index 9755eb21792..35026ebf6b0 100644
--- a/ts/features/idpay/onboarding/screens/InitiativeDetailsScreen.tsx
+++ b/ts/features/idpay/onboarding/screens/InitiativeDetailsScreen.tsx
@@ -5,16 +5,14 @@ import { pipe } from "fp-ts/lib/function";
import * as React from "react";
import { StyleSheet, View } from "react-native";
import { ForceScrollDownView } from "../../../../components/ForceScrollDownView";
+import IOMarkdown from "../../../../components/IOMarkdown";
import ItemSeparatorComponent from "../../../../components/ItemSeparatorComponent";
import { FooterActions } from "../../../../components/ui/FooterActions";
import { useHeaderSecondLevel } from "../../../../hooks/useHeaderSecondLevel";
import I18n from "../../../../i18n";
import { emptyContextualHelp } from "../../../../utils/emptyContextualHelp";
import { isLoadingSelector } from "../../common/machine/selectors";
-import {
- OnboardingDescriptionMarkdown,
- OnboardingDescriptionMarkdownSkeleton
-} from "../components/OnboardingDescriptionMarkdown";
+import { OnboardingDescriptionMarkdownSkeleton } from "../components/OnboardingDescriptionMarkdown";
import { OnboardingPrivacyAdvice } from "../components/OnboardingPrivacyAdvice";
import { OnboardingServiceHeader } from "../components/OnboardingServiceHeader";
import { IdPayOnboardingMachineContext } from "../machine/provider";
@@ -47,7 +45,6 @@ export const InitiativeDetailsScreen = () => {
const initiative = useSelector(selectInitiative);
const isLoading = useSelector(isLoadingSelector);
- const [isDescriptionLoaded, setDescriptionLoaded] = React.useState(false);
const handleGoBackPress = () => machine.send({ type: "close" });
const handleContinuePress = () => machine.send({ type: "next" });
@@ -66,12 +63,7 @@ export const InitiativeDetailsScreen = () => {
initiative,
O.fold(
() => ,
- ({ description }) => (
- setDescriptionLoaded(true)}
- description={description}
- />
- )
+ ({ description }) =>
)
);
@@ -85,7 +77,6 @@ export const InitiativeDetailsScreen = () => {
return (
diff --git a/ts/features/idpay/onboarding/screens/PDNDPrerequisitesScreen.tsx b/ts/features/idpay/onboarding/screens/PDNDPrerequisitesScreen.tsx
index 94de1ac7d30..e9b42051a32 100644
--- a/ts/features/idpay/onboarding/screens/PDNDPrerequisitesScreen.tsx
+++ b/ts/features/idpay/onboarding/screens/PDNDPrerequisitesScreen.tsx
@@ -13,8 +13,8 @@ import { pipe } from "fp-ts/lib/function";
import React from "react";
import { ScrollView, StyleSheet, View } from "react-native";
import { ServiceId } from "../../../../../definitions/backend/ServiceId";
+import IOMarkdown from "../../../../components/IOMarkdown";
import { IOStyles } from "../../../../components/core/variables/IOStyles";
-import LegacyMarkdown from "../../../../components/ui/Markdown/LegacyMarkdown";
import { useHeaderSecondLevel } from "../../../../hooks/useHeaderSecondLevel";
import I18n from "../../../../i18n";
import { useIOSelector } from "../../../../store/hooks";
@@ -58,14 +58,14 @@ export const PDNDPrerequisitesScreen = () => {
"idpay.onboarding.PDNDPrerequisites.prerequisites.info.header"
),
component: (
-
- {I18n.t(
+
+ />
),
footer: (