From 6e46d04bb96af25572c0c36a362f210ff953fba8 Mon Sep 17 00:00:00 2001 From: G Date: Wed, 8 May 2024 11:01:07 +0000 Subject: [PATCH] rendering all payment options inside a single container --- src/screens/HomePageWithPaymentOptions.tsx | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/screens/HomePageWithPaymentOptions.tsx b/src/screens/HomePageWithPaymentOptions.tsx index 86478d7..9db248d 100644 --- a/src/screens/HomePageWithPaymentOptions.tsx +++ b/src/screens/HomePageWithPaymentOptions.tsx @@ -8,9 +8,12 @@ import BackgroundGreenWhiteContentArea from "@components/backgrounds/BackgroundG import Box from "@components/bases/Box"; import Text from "@components/bases/Text"; import { useQuery } from "@tanstack/react-query"; +import { useMemo } from "react"; import { Dimensions } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; +const PAYMENT_TYPES = new Set(["ORANGE", "FLOOZ", "MTN", "WAVE", "CB"]); + const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWithPaymentOptions"> = ({ navigation }) => { const { data, isLoading, error } = useQuery({ @@ -19,9 +22,15 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith enabled: true, }); - console.log("data", data); - console.log("isLoading", isLoading); - console.log("error", error); + // getting valid payments supported + const paymentTypesToRender = useMemo(() => { + console.log("Filtering payment types"); + const paymentTypes = data?.results || []; + return paymentTypes.filter((paymentType) => PAYMENT_TYPES.has(paymentType.code)); + }, [data]); + + console.log("paymentTypesToRender", paymentTypesToRender); + return ( @@ -44,7 +53,14 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith Méthode de paiement - + {/* */} + @@ -61,8 +77,6 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith paymentMethod={"MtnMoney"} /> - - @@ -71,6 +85,7 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith paymentMethod={"MoovMoney"} /> + @@ -79,13 +94,16 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith paymentMethod={"WaveMoney"} /> + + + + navigation.navigate("paymentAmountInputScreen") + } + paymentMethod={"VisaCard"} + /> + - - navigation.navigate("paymentAmountInputScreen")} - paymentMethod={"VisaCard"} - /> - -- libgit2 0.27.1