Commit 6e46d04b by G

rendering all payment options inside a single container

parent f785d1ca
...@@ -8,9 +8,12 @@ import BackgroundGreenWhiteContentArea from "@components/backgrounds/BackgroundG ...@@ -8,9 +8,12 @@ import BackgroundGreenWhiteContentArea from "@components/backgrounds/BackgroundG
import Box from "@components/bases/Box"; import Box from "@components/bases/Box";
import Text from "@components/bases/Text"; import Text from "@components/bases/Text";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { Dimensions } from "react-native"; import { Dimensions } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context"; import { SafeAreaView } from "react-native-safe-area-context";
const PAYMENT_TYPES = new Set(["ORANGE", "FLOOZ", "MTN", "WAVE", "CB"]);
const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWithPaymentOptions"> = const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWithPaymentOptions"> =
({ navigation }) => { ({ navigation }) => {
const { data, isLoading, error } = useQuery({ const { data, isLoading, error } = useQuery({
...@@ -19,9 +22,15 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith ...@@ -19,9 +22,15 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith
enabled: true, enabled: true,
}); });
console.log("data", data); // getting valid payments supported
console.log("isLoading", isLoading); const paymentTypesToRender = useMemo(() => {
console.log("error", error); console.log("Filtering payment types");
const paymentTypes = data?.results || [];
return paymentTypes.filter((paymentType) => PAYMENT_TYPES.has(paymentType.code));
}, [data]);
console.log("paymentTypesToRender", paymentTypesToRender);
return ( return (
<BackgroundGreenWhiteContentArea> <BackgroundGreenWhiteContentArea>
<SafeAreaView> <SafeAreaView>
...@@ -44,7 +53,14 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith ...@@ -44,7 +53,14 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith
Méthode de paiement Méthode de paiement
</Text> </Text>
</Box> </Box>
<Box flexDirection={"row"} justifyContent={"space-between"} mb={"s"}> {/* <Box flexDirection={"row"} justifyContent={"space-between"} mb={"s"}> */}
<Box
flex={1}
flexDirection={"row"}
justifyContent={"space-between"}
flexWrap={"wrap"}
rowGap={"m"}
>
<PaymentOptionContainer> <PaymentOptionContainer>
<PaymentOption <PaymentOption
onPress={() => onPress={() =>
...@@ -61,8 +77,6 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith ...@@ -61,8 +77,6 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith
paymentMethod={"MtnMoney"} paymentMethod={"MtnMoney"}
/> />
</PaymentOptionContainer> </PaymentOptionContainer>
</Box>
<Box flexDirection={"row"} justifyContent={"space-between"} mb={"s"}>
<PaymentOptionContainer> <PaymentOptionContainer>
<PaymentOption <PaymentOption
onPress={() => onPress={() =>
...@@ -71,6 +85,7 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith ...@@ -71,6 +85,7 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith
paymentMethod={"MoovMoney"} paymentMethod={"MoovMoney"}
/> />
</PaymentOptionContainer> </PaymentOptionContainer>
<PaymentOptionContainer> <PaymentOptionContainer>
<PaymentOption <PaymentOption
onPress={() => onPress={() =>
...@@ -79,13 +94,16 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith ...@@ -79,13 +94,16 @@ const HomePageWithPaymentOptions: PaymentStackScreenComponentProps<"homePageWith
paymentMethod={"WaveMoney"} paymentMethod={"WaveMoney"}
/> />
</PaymentOptionContainer> </PaymentOptionContainer>
<PaymentOptionContainer>
<PaymentOption
onPress={() =>
navigation.navigate("paymentAmountInputScreen")
}
paymentMethod={"VisaCard"}
/>
</PaymentOptionContainer>
</Box> </Box>
<PaymentOptionContainer>
<PaymentOption
onPress={() => navigation.navigate("paymentAmountInputScreen")}
paymentMethod={"VisaCard"}
/>
</PaymentOptionContainer>
</Box> </Box>
</Box> </Box>
</SafeAreaView> </SafeAreaView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment