Skip to content

Commit

Permalink
fix: 🐛 Corrige la redirection vers les articles depuis les tnd
Browse files Browse the repository at this point in the history
  • Loading branch information
benguedj committed Jan 15, 2024
1 parent 204a176 commit ad155a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 61 deletions.
2 changes: 2 additions & 0 deletions front/src/navigation/BottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ const TabSurveysNavigator: FC = () => (
options={{}}
/>
<TabSurveysStack.Screen name="parentheque" component={Parentheque} />
<TabCalendarStack.Screen name="article" component={ArticleDetail} />
<TabCalendarStack.Screen name="articleSwipe" component={ArticleSwipe} />
</TabSurveysStack.Navigator>
);

Expand Down
66 changes: 5 additions & 61 deletions front/src/screens/tndSurvey/tndSurveyResult.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ import HTML from "react-native-render-html";
import WebView from "react-native-webview";

import ImgBtnReview from "../../assets/images/btn-review-sp-plus.svg";
import { ArticleList } from "../../components";
import {
CommonText,
SecondaryTextItalic,
TitleH1,
View,
} from "../../components/baseComponents";
import { ArticleCard } from "../../components";
import { CommonText, TitleH1, View } from "../../components/baseComponents";
import {
FetchPoliciesConstants,
HomeDbQueries,
Expand All @@ -27,58 +22,8 @@ import { GraphQLMutation, GraphQLQuery } from "../../services";
import { Colors, FontWeight, Margins, Paddings, Sizes } from "../../styles";
import type { SurveyQuestionAndAnswers } from "../../type";
import type { TndAnswers, TndQuestionnaire } from "../../type/tndSurvey.types";
import type { Article, Step } from "../../types";
import type { Article } from "../../types";
import { LinkingUtils, TndSurveyUtils } from "../../utils";
import ArticleDetail from "../articles/articleDetail.component";

export const ArticlesRoute = (
updatedText: string,
articles: Article[]
): React.ReactElement => {
const [showArticle, setShowArticle] = useState(false);
const [currentArticleId, setCurrentArticleId] = useState(0);
const [currentArticleStep, setCurrentArticleStep] = useState<
Step | undefined
>();

const onBackButtonPressed = useCallback(() => {
setShowArticle(false);
}, []);

const onUpdateStepAndArticleId = useCallback(
(articleId: number, step: Step | undefined) => {
setShowArticle(true);
setCurrentArticleId(articleId);
setCurrentArticleStep(step);
},
[]
);

if (articles.length <= 0) {
return (
<View style={styles.center}>
<SecondaryTextItalic>{updatedText}</SecondaryTextItalic>
</View>
);
}

return showArticle ? (
<ArticleDetail
_articleId={currentArticleId}
_articleStep={currentArticleStep}
goBack={onBackButtonPressed}
/>
) : (
<View style={styles.listContainer}>
<ArticleList
articles={articles}
animationDuration={500}
isFromSearchScreen
setStepAndArticleId={onUpdateStepAndArticleId}
/>
</View>
);
};

interface Props {
result: number;
Expand Down Expand Up @@ -173,16 +118,15 @@ const TndSurveyResult: FC<Props> = ({ survey, tndQuestionnaire }) => {
<CommonText style={styles.listArticlesTitle}>
{Labels.tndSurvey.surveyResult.articlesToRead}
</CommonText>
{/* {handicapArticles.map((article, index) => (
{handicapArticles.map((article, index) => (
<View key={index}>
<ArticleCard
selectedArticleId={article.id}
articles={handicapArticles}
isFromTndScreen={true}
/>
</View>
))} */}
{ArticlesRoute("", handicapArticles)}
))}
</View>
)}
</ScrollView>
Expand Down

0 comments on commit ad155a0

Please # to comment.