diff --git a/App.tsx b/App.tsx
index fe87972..b37e6fa 100644
--- a/App.tsx
+++ b/App.tsx
@@ -1,10 +1,8 @@
-import ProvideQueryClient from "@components/providers_wrappers/ProvideQueryClient";
import { LOG } from "@logger";
import { DefaultTheme, NavigationContainer } from "@react-navigation/native";
import { ThemeProvider } from "@shopify/restyle";
import { injectStoreIntoAxiosInstance } from "@/axios";
-import { ModalsManagerProvider } from "@/contexts/ModalsManagerContext";
-import { UserAuthenticationContextProvider } from "@/contexts/UserAuthenticationContext";
+import ProvideQueryClient from "@/contexts/ProvideQueryClient";
import { AppMainStackNavigatorAuthWrapper } from "@/navigations/AppMainStackNavigator";
import theme from "@/themes/Theme";
import "react-native-gesture-handler";
@@ -24,30 +22,22 @@ export default function App() {
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/components/BalanceContainer.tsx b/src/components/BalanceContainer.tsx
deleted file mode 100644
index 911ab6b..0000000
--- a/src/components/BalanceContainer.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import Box from "@components/bases/Box";
-import Text from "@components/bases/Text";
-import Card from "@re-card";
-import { images } from "@styles/Commons";
-import * as LocalAuthentication from "expo-local-authentication";
-import { useState } from "react";
-import { Image, TouchableOpacity } from "react-native";
-
-type Props = { balance: number; label: string };
-
-const BalanceContainer = ({ label, balance }: Props) => {
- const [showBalance, setShowBalance] = useState(false);
-
- const handleLocalAuthentication = async () => {
- console.log("handleLocalAuthentication :: start");
- if (showBalance) {
- return setShowBalance(false);
- }
- const result = await LocalAuthentication.authenticateAsync();
- if (result.success) {
- setShowBalance(true);
- }
- console.log("handleLocalAuthentication :: end", result);
- };
-
- return (
-
-
-
-
-
-
-
-
- {showBalance ? (
-
- {balance}
-
- ) : (
-
-
-
- )}
-
-
-
- {label}
-
-
- );
-};
-
-export default BalanceContainer;
diff --git a/src/components/BarWithBeasyAndNotificationsIcon.tsx b/src/components/BarWithBeasyAndNotificationsIcon.tsx
deleted file mode 100644
index 63ad568..0000000
--- a/src/components/BarWithBeasyAndNotificationsIcon.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import {} from "react-native";
-import BeasyLogoIcon from "./BeasyLogoIcon";
-import NotificationIconButton from "./NotificationIconButton";
-import Box from "./bases/Box";
-
-const BarWithBeasyAndNotificationsIcon = () => {
- return (
-
-
-
-
- );
-};
-
-export default BarWithBeasyAndNotificationsIcon;
diff --git a/src/components/BeasyLogoIcon.tsx b/src/components/BeasyLogoIcon.tsx
index 9f41baf..b616cb4 100644
--- a/src/components/BeasyLogoIcon.tsx
+++ b/src/components/BeasyLogoIcon.tsx
@@ -1,10 +1,15 @@
+import { asp as g } from "@asp/asp";
import Box from "@components/bases/Box";
-import { images } from "@styles/Commons";
import { Image } from "react-native";
+
const BeasyLogoIcon = () => {
return (
-
+
);
};
diff --git a/src/components/Button.tsx b/src/components/Button.tsx
deleted file mode 100644
index f8423d0..0000000
--- a/src/components/Button.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import type { BoxProps, VariantProps } from "@shopify/restyle";
-import type { Theme } from "@themes/Theme";
-import { ActivityIndicator, TouchableOpacity } from "react-native";
-import ButtonBase from "./bases/ButtonBase";
-import Text from "./bases/Text";
-
-type Props = BoxProps &
- VariantProps &
- VariantProps & {
- label: string;
- onPress: () => void;
- isLoading?: boolean;
- };
-
-const Button = ({ onPress, label, isLoading, textVariants, variant, ...rest }: Props) => {
- return (
-
-
- {isLoading ? (
-
- ) : (
- {label}
- )}
-
-
- );
-};
-
-export default Button;
diff --git a/src/components/ContainerBorderTopCurved.tsx b/src/components/ContainerBorderTopCurved.tsx
deleted file mode 100644
index e330f7e..0000000
--- a/src/components/ContainerBorderTopCurved.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { containers } from "@styles/Commons";
-import { useEffect } from "react";
-import { Animated, Dimensions } from "react-native";
-import Box from "./bases/Box";
-
-type Props = { children: React.ReactNode };
-const ContainerBorderTopCurved = ({ children }: Props) => {
- const animated = new Animated.Value(0);
- // biome-ignore lint/correctness/useExhaustiveDependencies:
- useEffect(() => {
- Animated.spring(animated, {
- toValue: 1,
- useNativeDriver: true,
- }).start();
- }, []);
-
- return (
-
-
- {children}
-
-
- );
-};
-
-export default ContainerBorderTopCurved;
diff --git a/src/components/GoBackIconButton.tsx b/src/components/GoBackIconButton.tsx
deleted file mode 100644
index 05033b5..0000000
--- a/src/components/GoBackIconButton.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import Box from "@components/bases/Box";
-import { Ionicons } from "@expo/vector-icons";
-import { TouchableOpacity } from "react-native";
-
-type Props = {
- onPress: () => void;
-};
-const GoBackIconButton = ({ onPress }: Props) => {
- return (
-
-
-
-
-
- );
-};
-
-export default GoBackIconButton;
diff --git a/src/components/Input.tsx b/src/components/Input.tsx
deleted file mode 100644
index 7ce7e0c..0000000
--- a/src/components/Input.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { VariantProps } from "@shopify/restyle";
-import type { Theme } from "@themes/Theme";
-import type { TextInputProps } from "react-native";
-import { TextInput } from "react-native";
-import Box from "./bases/Box";
-
-type Props = TextInputProps & VariantProps;
-
-const Input = ({ textVariants, ...rest }: Props) => {
- return (
-
-
-
-
-
- );
-};
-
-export default Input;
diff --git a/src/components/InputWithTopLabel.tsx b/src/components/InputWithTopLabel.tsx
deleted file mode 100644
index 25ca24e..0000000
--- a/src/components/InputWithTopLabel.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { VariantProps } from "@shopify/restyle";
-import type { Theme } from "@themes/Theme";
-import type { TextInputProps } from "react-native";
-import { TextInput } from "react-native";
-import Box from "./bases/Box";
-import Text from "./bases/Text";
-
-type Props = TextInputProps &
- VariantProps & {
- label: string;
- };
-
-const InputWithTopLabel = ({ label, textVariants, ...rest }: Props) => {
- return (
-
- {label}
-
-
-
-
- );
-};
-
-export default InputWithTopLabel;
diff --git a/src/components/NotificationIconButton.tsx b/src/components/NotificationIconButton.tsx
deleted file mode 100644
index 7a49a63..0000000
--- a/src/components/NotificationIconButton.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import Box from "@components/bases/Box";
-import { Ionicons } from "@expo/vector-icons";
-const NotificationIconButton = () => {
- return (
-
-
-
-
-
-
- );
-};
-
-export default NotificationIconButton;
diff --git a/src/components/PaymentOption.tsx b/src/components/PaymentOption.tsx
deleted file mode 100644
index c83f6b6..0000000
--- a/src/components/PaymentOption.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import type { PaymentCode } from "@/utils/requests/types";
-import { images } from "@styles/Commons";
-import { Image, TouchableOpacity } from "react-native";
-import Box from "./bases/Box";
-
-type PaymentOptions = "OM" | "MTN" | "FLOOZ" | "WAVE" | "CB";
-
-type Props = {
- onPress: () => void;
- paymentMethod: PaymentCode;
-};
-
-const PaymentOptionContainer = ({ children }: { children: React.ReactNode }) => {
- return (
-
- {children}
-
- );
-};
-
-const Orange = () => {
- return (
-
- );
-};
-
-const Mtn = () => {
- return ;
-};
-
-const Flooz = () => {
- return ;
-};
-
-const Wave = () => {
- return ;
-};
-
-const Cb = () => {
- return ;
-};
-
-const PaymentOption = ({ onPress, paymentMethod }: Props) => {
- return (
-
- {paymentMethod === "OM" && }
- {paymentMethod === "MTN" && }
- {paymentMethod === "FLOOZ" && }
- {paymentMethod === "WAVE" && }
- {paymentMethod === "CB" && }
-
- );
-};
-
-export default PaymentOption;
diff --git a/src/components/PaymentsOptionsRendererTwoColumn.tsx b/src/components/PaymentsOptionsRendererTwoColumn.tsx
deleted file mode 100644
index bd2dd39..0000000
--- a/src/components/PaymentsOptionsRendererTwoColumn.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import type React from "react";
-import { Dimensions } from "react-native";
-import Box from "./bases/Box";
-
-// const PaymentsOptionsRendererTwoColumn = () => {
-// return (
-//
-//
-//
-// navigation.navigate("paymentAmountInputScreen")}
-// paymentMethod={"OrangeMoney"}
-// />
-//
-//
-// navigation.navigate("paymentAmountInputScreen")}
-// paymentMethod={"MtnMoney"}
-// />
-//
-//
-//
-//
-// navigation.navigate("paymentAmountInputScreen")}
-// paymentMethod={"MoovMoney"}
-// />
-//
-//
-// navigation.navigate("paymentAmountInputScreen")}
-// paymentMethod={"WaveMoney"}
-// />
-//
-//
-//
-// navigation.navigate("paymentAmountInputScreen")}
-// paymentMethod={"VisaCard"}
-// />
-//
-//
-// );
-// };
-
-const screenWidth = Dimensions.get("window").width;
-const paymentOptionCardWidth = screenWidth / 2 - 30;
-const paymentOptionCardHeight = paymentOptionCardWidth * 0.65;
-const PaymentOptionContainer = ({ children }: { children: React.ReactNode }) => {
- return (
-
- {children}
-
- );
-};
-
-// export default PaymentsOptionsRendererTwoColumn;
diff --git a/src/components/TransactionInformationsItem.tsx b/src/components/TransactionInformationsItem.tsx
deleted file mode 100644
index d6a0e43..0000000
--- a/src/components/TransactionInformationsItem.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import type { PaymentCode } from "@/utils/requests/types";
-import moment from "moment";
-import "moment/locale/fr";
-import PaymentOption from "./PaymentOption";
-import Box from "./bases/Box";
-import Text from "./bases/Text";
-
-interface Props {
- paymentType: PaymentCode;
- reference: string;
- date: string;
- amount: number;
- status: "SUCCESS" | "INITIATED" | "FAILED";
-}
-
-moment.locale("fr");
-
-const TransactionInformationsItem = ({ paymentType, reference, date, amount, status }: Props) => {
- const dateObject = Date.parse(date);
- return (
-
-
-
- {}} />
-
-
- {reference}
- {moment(dateObject).fromNow()}
-
-
-
-
-
-
-
- );
-};
-
-const AmountColorRenderer = ({ status, amount }: { status: string; amount: number }) => {
- if (status === "SUCCESS") {
- return {amount};
- }
- if (status === "INITIATED") {
- return {amount};
- }
- return {amount};
-};
-
-const AmountWrapper = ({
- color,
- children,
-}: { color: "secondary" | "softYellow" | "softRed"; children: React.ReactNode }) => {
- return (
-
-
- {children} F
-
-
- );
-};
-
-export default TransactionInformationsItem;
diff --git a/src/components/WrapperTopEdgeCurved.tsx b/src/components/WrapperTopEdgeCurved.tsx
deleted file mode 100644
index a74ac8c..0000000
--- a/src/components/WrapperTopEdgeCurved.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import type React from "react";
-import Box from "./bases/Box";
-
-const WrapperTopEdgeCurved = ({ children }: { children?: React.ReactElement }) => {
- return (
-
- {children}
-
- );
-};
-
-export default WrapperTopEdgeCurved;
diff --git a/src/components/backgrounds/BackgroundGreenWhiteContentArea.tsx b/src/components/backgrounds/BackgroundGreenWhiteContentArea.tsx
deleted file mode 100644
index 12a8070..0000000
--- a/src/components/backgrounds/BackgroundGreenWhiteContentArea.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { containers, images } from "@styles/Commons";
-import { ImageBackground, View } from "react-native";
-
-type Props = { children: React.ReactNode };
-
-const BackgroundGreenWhiteContentArea = ({ children }: Props) => {
- return (
-
-
- {children}
-
-
- );
-};
-
-export default BackgroundGreenWhiteContentArea;
diff --git a/src/components/backgrounds/BackgroundWithBeasyIconAndWhiteContentArea.tsx b/src/components/backgrounds/BackgroundWithBeasyIconAndWhiteContentArea.tsx
deleted file mode 100644
index a440727..0000000
--- a/src/components/backgrounds/BackgroundWithBeasyIconAndWhiteContentArea.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import BeasyLogoIcon from "@components/BeasyLogoIcon";
-import GoBackIconButton from "@components/GoBackIconButton";
-import WrapperTopEdgeCurved from "@components/WrapperTopEdgeCurved";
-import Box from "@components/bases/Box";
-import { useNavigation } from "@react-navigation/native";
-import type { ReactElement } from "react";
-import BackgroundDefault from "./BeasyDefaultBackground";
-
-const BackgroundWithBeasyIconAndWhiteContentArea = ({
- children,
- goBack = false,
-}: { children?: ReactElement; goBack?: boolean }) => {
- const navigation = useNavigation();
- return (
-
-
-
- {goBack && navigation.goBack()} />}
-
- {children}
-
- );
-};
-
-export default BackgroundWithBeasyIconAndWhiteContentArea;
diff --git a/src/components/backgrounds/BeasyDefaultBackground.tsx b/src/components/backgrounds/BeasyDefaultBackground.tsx
deleted file mode 100644
index 3e54f17..0000000
--- a/src/components/backgrounds/BeasyDefaultBackground.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { images } from "@styles/Commons";
-import { ImageBackground } from "react-native";
-
-type Props = { children: React.ReactNode };
-
-const BeasyDefaultBackground = ({ children }: Props) => {
- return (
-
- {children}
-
- );
-};
-
-export default BeasyDefaultBackground;
diff --git a/src/components/bases/ButtonBase.tsx b/src/components/bases/ButtonBase.tsx
deleted file mode 100644
index 87885db..0000000
--- a/src/components/bases/ButtonBase.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { type BoxProps, type VariantProps, createRestyleComponent } from "@shopify/restyle";
-import type { Theme } from "@themes/Theme";
-import { buttonVariants } from "@themes/Variants";
-import Box from "./Box";
-
-const ButtonBase = createRestyleComponent<
- VariantProps &
- BoxProps & {
- children: React.ReactNode;
- },
- Theme
->([buttonVariants], Box);
-
-export default ButtonBase;
diff --git a/src/components/bases/Card.tsx b/src/components/bases/Card.tsx
deleted file mode 100644
index 7393772..0000000
--- a/src/components/bases/Card.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { Theme } from "@/themes/Theme";
-import Box from "@re-box";
-import { type VariantProps, createRestyleComponent, createVariant } from "@shopify/restyle";
-
-const Card = createRestyleComponent<
- VariantProps & React.ComponentProps,
- Theme
->(
- [
- createVariant({
- themeKey: "cardVariants",
- defaults: {
- margin: {
- phone: "s",
- tablet: "m",
- },
- backgroundColor: "red",
- },
- }),
- ],
- Box,
-);
-export default Card;
diff --git a/src/components/bases/Text.tsx b/src/components/bases/Text.tsx
deleted file mode 100644
index ad64fae..0000000
--- a/src/components/bases/Text.tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-import type { Theme } from "@/themes/Theme";
-import { createText } from "@shopify/restyle";
-
-const Text = createText();
-
-export default Text;
diff --git a/src/components/containers/SafeAreaViewTopLeftRightFull.tsx b/src/components/containers/SafeAreaViewTopLeftRightFull.tsx
deleted file mode 100644
index 4454c82..0000000
--- a/src/components/containers/SafeAreaViewTopLeftRightFull.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import Box from "@components/bases/Box";
-import type React from "react";
-import {} from "react-native";
-import { SafeAreaView } from "react-native-safe-area-context";
-
-const SafeAreaViewTopLeftRightFull = ({ children }: { children: React.ReactNode }) => {
- return (
-
-
- {children}
-
-
- );
-};
-
-export default SafeAreaViewTopLeftRightFull;
diff --git a/src/components/icons/CheckIcon.tsx b/src/components/icons/CheckIcon.tsx
index 014924d..3182522 100644
--- a/src/components/icons/CheckIcon.tsx
+++ b/src/components/icons/CheckIcon.tsx
@@ -1,5 +1,5 @@
+import { asp as g } from "@asp/asp";
import Box from "@components/bases/Box";
-import { images } from "@styles/Commons";
import { Image } from "react-native";
const CheckIcon = () => {
@@ -7,7 +7,8 @@ const CheckIcon = () => {
);
diff --git a/src/components/icons/ErrorIcon.tsx b/src/components/icons/ErrorIcon.tsx
index c3dc64e..c7eeb9f 100644
--- a/src/components/icons/ErrorIcon.tsx
+++ b/src/components/icons/ErrorIcon.tsx
@@ -1,5 +1,5 @@
+import { asp as g } from "@asp/asp";
import Box from "@components/bases/Box";
-import { images } from "@styles/Commons";
import { Image } from "react-native";
const ErrorIcon = () => {
@@ -7,7 +7,8 @@ const ErrorIcon = () => {
);
diff --git a/src/components/icons/InformationIcon.tsx b/src/components/icons/InformationIcon.tsx
index 429b096..5cc263c 100644
--- a/src/components/icons/InformationIcon.tsx
+++ b/src/components/icons/InformationIcon.tsx
@@ -1,5 +1,5 @@
+import { asp as g } from "@asp/asp";
import Box from "@components/bases/Box";
-import { images } from "@styles/Commons";
import { Image } from "react-native";
const InformationIcon = () => {
@@ -7,7 +7,8 @@ const InformationIcon = () => {
);
diff --git a/src/components/modals/ErrorModal.tsx b/src/components/modals/ErrorModal.tsx
deleted file mode 100644
index e932ea0..0000000
--- a/src/components/modals/ErrorModal.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { useModalsManagerContext } from "@/contexts/ModalsManagerContext";
-import Button from "@components/Button";
-import ErrorIcon from "@components/icons/ErrorIcon";
-import Box from "@re-box";
-import Card from "@re-card";
-import Text from "@re-text";
-
-interface Props {
- message?: string;
- // onPress?: () => void;
-}
-
-const ErrorModal = ({ message = "Une erreur s'est produite" }: Props) => {
- const { closeModal } = useModalsManagerContext();
- return (
-
-
-
- {message}
-
-
-
-
-
- );
-};
-
-export default ErrorModal;
diff --git a/src/components/modals/InformationModal.tsx b/src/components/modals/InformationModal.tsx
deleted file mode 100644
index 7afc7fa..0000000
--- a/src/components/modals/InformationModal.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { useModalsManagerContext } from "@/contexts/ModalsManagerContext";
-import Button from "@components/Button";
-import Box from "@components/bases/Box";
-import InformationIcon from "@components/icons/InformationIcon";
-import { Text } from "react-native";
-
-interface Props {
- message?: string;
- onPress?: () => void;
- actionLabel?: string;
-}
-
-const InformationModal = ({
- message = "Une erreur s'est produite",
- onPress = undefined,
- actionLabel = "Ok",
-}: Props) => {
- const { closeModal } = useModalsManagerContext();
- return (
-
-
- {message}
-
- {onPress && (
-
- )}
-
-
-
-
- );
-};
-
-export default InformationModal;
diff --git a/src/components/modals/LoadingModal.tsx b/src/components/modals/LoadingModal.tsx
deleted file mode 100644
index 87d1e3e..0000000
--- a/src/components/modals/LoadingModal.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import Box from "@components/bases/Box";
-import { ActivityIndicator, Text } from "react-native";
-
-interface Props {
- message?: string;
-}
-
-const LoadingModal = ({ message = "Veuillez patienter..." }: Props) => {
- return (
-
-
- {message}
-
- );
-};
-
-export default LoadingModal;
diff --git a/src/components/modals/MyModal.tsx b/src/components/modals/MyModal.tsx
deleted file mode 100644
index 35dbd67..0000000
--- a/src/components/modals/MyModal.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import Button from "@components/Button";
-import Box from "@components/bases/Box";
-import InformationIcon from "@components/icons/InformationIcon";
-import { create } from "react-modal-promise";
-import { Text } from "react-native";
-
-interface Props {
- isOpen: boolean;
- onResolve: () => void;
- // biome-ignore lint/suspicious/noExplicitAny:
- onReject: any;
-}
-
-const MyModal = ({ isOpen, onResolve, onReject }: Props) => {
- return (
-
-
- Modal
-
-
-
-
-
- );
-};
-
-const myPromiseModal = create(MyModal);
-
-export { myPromiseModal };
-
-export default MyModal;
diff --git a/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaFull.tsx b/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaFull.tsx
deleted file mode 100644
index 052d0e2..0000000
--- a/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaFull.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import BeasyDefaultBackground from "@components/backgrounds/BeasyDefaultBackground";
-import type React from "react";
-import { SafeAreaView } from "react-native-safe-area-context";
-
-type Props = { children: React.ReactNode };
-
-const WrapperWithDefaultBeasyBackgroundAndSafeAreaFull = ({ children }: Props) => {
- return (
-
- {children}
-
- );
-};
-
-export default WrapperWithDefaultBeasyBackgroundAndSafeAreaFull;
diff --git a/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight.tsx b/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight.tsx
deleted file mode 100644
index 33a0103..0000000
--- a/src/components/wrappers/WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import BeasyDefaultBackground from "@components/backgrounds/BeasyDefaultBackground";
-import type React from "react";
-import { SafeAreaView } from "react-native-safe-area-context";
-
-type Props = { children: React.ReactNode };
-
-const WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight = ({ children }: Props) => {
- return (
-
- {children}
-
- );
-};
-
-export default WrapperWithDefaultBeasyBackgroundAndSafeAreaTopLeftRight;
diff --git a/src/contexts/ModalsManagerContext.tsx b/src/contexts/ModalsManagerContext.tsx
deleted file mode 100644
index 5d83af6..0000000
--- a/src/contexts/ModalsManagerContext.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { createContext, useContext, useEffect, useState } from "react";
-import { View } from "react-native";
-
-export interface ImodalsManagerContext {
- showModal(element: React.ReactElement): void;
- closeModal(): void;
-}
-
-export const ModalsManagerContext = createContext({
- showModal: () => {},
- closeModal: () => {},
-});
-
-export const ModalsManagerProvider = ({ children }: { children: React.ReactNode }) => {
- const [showBackdrop, setShowBackdrop] = useState(false);
-
- const [modalElement, setModalElement] = useState(null);
-
- const showModal = (element: React.ReactElement) => {
- setModalElement(element);
- setShowBackdrop(true);
- };
-
- const closeModal = () => {
- setModalElement(null);
- setShowBackdrop(false);
- };
-
- useEffect(() => {
- return () => {
- setShowBackdrop(false);
- setModalElement(null);
- };
- }, []);
-
- return (
-
- {children}
-
- {modalElement && (
- <>
-
- {modalElement}
- >
- )}
-
- );
-};
-
-export const useModalsManagerContext = () => {
- return useContext(ModalsManagerContext);
-};
-
-export const OVERLAY_BACKDROP_Z_INDEX = 10;
-
-const OverlayBackdrop = () => {
- return (
-
- );
-};
diff --git a/src/components/providers_wrappers/ProvideQueryClient.tsx b/src/contexts/ProvideQueryClient.tsx
similarity index 100%
rename from src/components/providers_wrappers/ProvideQueryClient.tsx
rename to src/contexts/ProvideQueryClient.tsx
diff --git a/src/contexts/Types.ts b/src/contexts/Types.ts
deleted file mode 100644
index e831cc6..0000000
--- a/src/contexts/Types.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface IauthenticationData {
- access: string;
- refresh: string;
-}
diff --git a/src/contexts/UserAuthenticationContext.tsx b/src/contexts/UserAuthenticationContext.tsx
deleted file mode 100644
index d0a214f..0000000
--- a/src/contexts/UserAuthenticationContext.tsx
+++ /dev/null
@@ -1,286 +0,0 @@
-import ErrorModal from "@components/modals/ErrorModal";
-import { LOG } from "@logger";
-import AsyncStorage from "@react-native-async-storage/async-storage";
-import { useMutation } from "@tanstack/react-query";
-import * as SplashScreen from "expo-splash-screen";
-import { createContext, useCallback, useContext, useState } from "react";
-// import { type NavigationProp, useNavigation } from "@react-navigation/native";
-import authenticateUser, { parseAuthicationErrors } from "@/utils/requests/authenticateUser";
-import type { IuserInformations } from "@/utils/requests/types";
-import getUserInformations, {
- parseUserInformationsErrors,
-} from "@/utils/requests/userInformations";
-import { useModalsManagerContext } from "./ModalsManagerContext";
-import type { IauthenticationData } from "./Types";
-
-const log = LOG.extend("UserAuthenticationContext");
-
-// SplashScreen.preventAutoHideAsync();
-SplashScreen.hideAsync();
-
-export interface UserAuthenticationContextProps {
- isAuthenticated: boolean;
- setIsAuthenticated: React.Dispatch>;
- setAuthenticationData: React.Dispatch>;
- userInformations: IuserInformations;
- setUserInformations: React.Dispatch>;
- login: (email: string, password: string) => void;
- isAuthenticating: boolean;
- logout: () => void;
-}
-
-export const UserAuthenticationContext = createContext({
- isAuthenticated: false,
- setIsAuthenticated: () => {},
- setAuthenticationData: () => {},
- userInformations: {
- username: "",
- email: "",
- // biome-ignore lint/style/useNamingConvention:
- first_name: "",
- // biome-ignore lint/style/useNamingConvention:
- last_name: "",
- marchand: {
- // biome-ignore lint/style/useNamingConvention:
- marchand_id: "",
- nom: "",
- code: "",
- adresse: "",
- // biome-ignore lint/style/useNamingConvention:
- url_succes: "",
- // biome-ignore lint/style/useNamingConvention:
- url_echec: "",
- entreprise: 0,
- user: 0,
- },
- },
- setUserInformations: () => {},
- login: () => {},
- isAuthenticating: false,
- logout: () => {},
-});
-
-export const UserAuthenticationContextProvider = ({ children }: { children: React.ReactNode }) => {
- // States
-
- const [isAuthenticated, setIsAuthenticated] = useState(false);
- const [isAuthenticating, setIsAuthenticating] = useState(false);
- const [authenticationData, setAuthenticationData] = useState({
- access: "",
- refresh: "",
- });
- const [_error, setError] = useState("");
- const [userInformations, setUserInformations] = useState({
- username: "JohnDoe",
- email: "JohnDoe@example.com",
- // biome-ignore lint/style/useNamingConvention:
- first_name: "John",
- // biome-ignore lint/style/useNamingConvention:
- last_name: "Doe",
- marchand: {
- // biome-ignore lint/style/useNamingConvention:
- marchand_id: "id123",
- nom: "Beasy",
- code: "BEASY-EXAMPLE-1",
- adresse: "Plateau 2, 1023, Immeuble Chardy",
- // biome-ignore lint/style/useNamingConvention:
- url_succes: "https://example.com/success",
- // biome-ignore lint/style/useNamingConvention:
- url_echec: "https://example.com/echec",
- entreprise: 0,
- user: 0,
- },
- });
-
- // Hoooks
- const { showModal } = useModalsManagerContext();
-
- // const navigation = useNavigation>();
-
- // Mutations
-
- const authenticationMutation = useMutation({
- mutationFn: authenticateUser,
- onMutate: () => {
- setIsAuthenticating(true);
- setError("");
- },
- onSuccess: (data) => {
- setAuthenticationData(data);
-
- log.info("Receive data from authenticateUser, running getUserInformations...");
- userInformationsMutation.mutate(data.access);
- },
- onError: (error: unknown) => {
- const errorString = parseAuthicationErrors(error);
- showModal();
- },
- onSettled: () => {
- setIsAuthenticating(false);
- },
- });
-
- const clearStorages = useCallback(async () => {
- try {
- await AsyncStorage.clear();
- } catch (error) {
- log.error("clearStorages |", JSON.stringify(error, null, 2));
- // saving error
- }
- }, []);
-
- const userInformationsMutation = useMutation({
- mutationFn: (userAccessToken: string) => getUserInformations(userAccessToken),
- onMutate: () => {
- setIsAuthenticating(true);
- setError("");
- },
- onSettled: () => {
- setIsAuthenticating(false);
- },
- onSuccess: (userInformations) => {
- log.info("getUserInformations request was a success, navigating to homepage");
- setUserInformations(userInformations);
- setIsAuthenticated(true);
- storeAuthenticationData(authenticationData);
- storeUserInformations(userInformations);
- // navigation.navigate("appBottomTabsNavigator");
- },
- onError: (error) => {
- log.error("userInformationsMutation", error);
- const errorString = parseUserInformationsErrors(error);
- showModal();
- clearStorages();
- },
- });
-
- // Methods
-
- const login = useCallback(
- (email: string, password: string) => {
- authenticationMutation.mutate({
- username: email,
- password: password,
- });
- },
- [authenticationMutation],
- );
-
- const logout = useCallback(() => {
- (async () => {
- setIsAuthenticated(false);
- setAuthenticationData({
- access: "",
- refresh: "",
- });
- setUserInformations({
- username: "",
- email: "",
- // biome-ignore lint/style/useNamingConvention:
- first_name: "",
- // biome-ignore lint/style/useNamingConvention:
- last_name: "",
- marchand: {
- // biome-ignore lint/style/useNamingConvention:
- marchand_id: "",
- nom: "",
- code: "",
- adresse: "",
- // biome-ignore lint/style/useNamingConvention:
- url_succes: "",
- // biome-ignore lint/style/useNamingConvention:
- url_echec: "",
- entreprise: 0,
- user: 0,
- },
- });
- await clearStorages();
- })();
- }, [clearStorages]);
-
- // Storages
-
- const storeAuthenticationData = async (authenticationData: IauthenticationData) => {
- try {
- await AsyncStorage.setItem("authenticationData", JSON.stringify(authenticationData));
- } catch (error) {
- log.error("storeAuthenticationData |", JSON.stringify(error, null, 2));
- // saving error
- }
- };
-
- const storeUserInformations = async (userInformations: IuserInformations) => {
- try {
- await AsyncStorage.setItem("userInformations", JSON.stringify(userInformations));
- } catch (error) {
- log.error("storeUserInformations |", JSON.stringify(error, null, 2));
- // saving error
- }
- };
-
- const _loadAuthenticationData = async () => {
- log.debug("loadAuthenticationData | Loading authentication data");
- const jsonRepresentation = await AsyncStorage.getItem("authenticationData");
- return jsonRepresentation ? JSON.parse(jsonRepresentation) : null;
- };
-
- const _loadUserInformations = async () => {
- log.debug("loadUserInformations | Loading user informations");
- const jsonRepresentation = await AsyncStorage.getItem("userInformations");
- return jsonRepresentation ? JSON.parse(jsonRepresentation) : null;
- };
-
- // biome-ignore lint/correctness/useExhaustiveDependencies:
- // useEffect(() => {
- // log.debug("UserAuthenticationContext | App Startup | loading saved user data.");
- // (async () => {
- // try {
- // // await loadAssetsAsync();
- // await cacheAssetsAsync({
- // images: [
- // "../assets/background_default.png",
- // "../assets/beasy_default.png",
- // "../assets/beasy_background.png",
- // "../assets/background_content_white2.png",
- // "../../assets/background.png",
- // ],
- // });
- // const authenticationData = await loadAuthenticationData();
- // const userInformations = await loadUserInformations();
- // if (authenticationData && userInformations) {
- // setAuthenticationData(authenticationData);
- // setUserInformations(userInformations);
- // setIsAuthenticated(true);
- // }
- // } catch (error) {
- // log.error(
- // "UserAuthenticationContext | App Startup | error during retrieval of stored data |",
- // JSON.stringify(error, null, 2),
- // );
- // } finally {
- // setTimeout(async () => await SplashScreen.hideAsync(), 500);
- // }
- // })();
- // }, []);
-
- return (
-
- {children}
-
- );
-};
-
-export const useUserAuthenticationContext = () => {
- return useContext(UserAuthenticationContext);
-};
diff --git a/src/features/auth/types.ts b/src/features/auth/types.ts
index 9aaa84f..b6087a7 100644
--- a/src/features/auth/types.ts
+++ b/src/features/auth/types.ts
@@ -1,3 +1,13 @@
+export interface Merchant {
+ marchand_id: string;
+ nom: string;
+ code: string;
+ adresse: string;
+ url_succes: string;
+ url_echec: string;
+ entreprise: number;
+ user: number;
+}
export type UserData = {
id: number;
username: string;
@@ -5,7 +15,7 @@ export type UserData = {
first_name: string;
last_name: string;
role: string;
- marchand: number;
+ marchand: Merchant;
};
export type Token = {
diff --git a/src/hooks/useOrangeMoney.tsx b/src/hooks/useOrangeMoney.tsx
deleted file mode 100644
index 7956dda..0000000
--- a/src/hooks/useOrangeMoney.tsx
+++ /dev/null
@@ -1,239 +0,0 @@
-import ErrorModal from "@components/modals/ErrorModal";
-import LoadingModal from "@components/modals/LoadingModal";
-import { LOG } from "@logger";
-import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
-import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { AxiosError } from "axios";
-import * as WebBrowser from "expo-web-browser";
-import { useRef, useState } from "react";
-import { AppState, Platform } from "react-native";
-import { useModalsManagerContext } from "@/contexts/ModalsManagerContext";
-import type { IpaymentStackNavigator } from "@/navigations/types";
-import {
- getTransactionStatus,
- getTransactionsData,
- type IorangePaymentStarter,
-} from "@/utils/requests/orangePayment";
-
-const log = LOG.extend("useOrangeMoney");
-
-const paymentObjectDefault: IorangePaymentStarter = {
- // biome-ignore lint/style/useNamingConvention:
- type_paiement: 1,
- marchand: "1",
- service: "2",
- montant: 0,
- numero: "0707070707",
- commentaire: "Un commentaire",
-};
-const useOrangeMoney = (
- navigation?: NativeStackNavigationProp<
- IpaymentStackNavigator,
- "paymentAmountInputScreen",
- "IpaymentStackNavigator"
- >,
-) => {
- const queryClient = useQueryClient();
-
- const [isBrowserOpen, setIsBrowserOpen] = useState(false);
- const { showModal, closeModal } = useModalsManagerContext();
- const appState = useRef(AppState.currentState);
- const [_appStateVisible, _setAppStateVisiblee] = useState(appState.current);
-
- const handlePaymentUsingBrowser = async (url: string) => {
- setIsBrowserOpen(true);
- const result = await WebBrowser.openBrowserAsync(url);
- // setResult(result);
- log.debug("handlePaymentUsingBrowser | Result ::", result);
- setIsBrowserOpen(false);
- };
-
- const orangeTransactionInitializerMutation = useMutation({
- mutationFn: (amount: number) =>
- getTransactionsData({
- ...paymentObjectDefault,
- montant: amount,
- }),
- onSuccess: (_data) => {
- // return data.payment_url
- log.debug("orangeTransactionInitializerMutation request success, opening browser...");
- queryClient.invalidateQueries({ queryKey: ["transactionsHistory"] });
- // await handlePaymentUsingBrowser(data.payment_url);
- // await transactionsStatusMutation.mutate(data.order_id);
- // setResult(result);
- },
- onError: (err) => {
- log.error("orangeTransactionInitializerMutation |", err);
- },
- });
-
- const _maxRetry = 3;
- const _retryDelay = 5000;
-
- const transactionsStatusMutation = useMutation({
- mutationFn: (orderId: string) => getTransactionStatus(orderId),
- onSuccess: (data) => {
- log.debug("transactionsStatusMutation request success");
- queryClient.invalidateQueries({ queryKey: ["transactionsHistory"] });
- return data.status;
- },
- onError: (err) => {
- log.error("transactionsStatusMutation |", err);
- queryClient.invalidateQueries({ queryKey: ["transactionsHistory"] });
- },
- // retry: (failureCount, error) => {
- // log.warn("transactionsStatusMutation | retrying", failureCount, error);
- // return failureCount < maxRetry;
- // },
- // retryDelay(_failureCount, _error) {
- // return retryDelay;
- // },
- });
-
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity:
- const checkStatus = async (orderId: string, retry = 0): Promise => {
- // Check the transactions 'retry' time.
- let numberOfTries = 0;
-
- while (numberOfTries <= retry) {
- log.verbose("useOrangePayment | checkStatus | Try No.", numberOfTries + 1);
- try {
- await transactionsStatusMutation.mutateAsync(orderId);
- return;
- } catch (error) {
- // errors are throwned from getTransactions status when the staus is either initiated or failed.
- if (error instanceof AxiosError && error.response?.status === 404) {
- log.error("useOrangeMoney | checkStatus | Transaction not found");
- return error.response.data.error || `Transaction ${orderId} not found !!`;
- }
- if (error instanceof AxiosError && error.name === "ORANGE_PAYMENT_FAILED") {
- return "La transaction à échoué.";
- }
- if (error instanceof AxiosError && error.name === "ORANGE_UNKNOWN_PAYMENT_ERROR") {
- return "Une erreur est survenue.";
- }
- }
-
- numberOfTries += 1;
- }
-
- return "La transaction est toujours en cours.";
- };
-
- const openBrowserThenCheckStatus = async (paymentUrl: string, orderId: string) => {
- try {
- await handlePaymentUsingBrowser(paymentUrl);
- if (Platform.OS === "android") {
- log.debug(
- "useOrangeMoney | openBrowserThenCheckStatus | Android device. Setup listener for browser close event.",
- );
- const sub = AppState.addEventListener("change", async (nextAppState) => {
- log.debug(
- "useOrangeMoney | openBrowserThenCheckStatus | Android device. Browser state :",
- nextAppState,
- );
-
- if (nextAppState === "active") {
- log.debug(
- "useOrangeMoney | openBrowserThenCheckStatus | Android device. Browser is closed. Removing listener. Checking for transaction State.",
- );
- sub.remove();
- log.info("openBrowserThenCheckStatus | Verifying transaction status...");
- showModal(
- ,
- );
- // await transactionsStatusMutation.mutateAsync(orderId);
- const message = await checkStatus(orderId);
- if (message) {
- showModal();
- } else {
- navigation?.getParent()?.navigate("paymentResultScreen");
- }
- }
- });
- } else {
- log.info("openBrowserThenCheckStatus | Verifying transaction status...");
- showModal();
- // await transactionsStatusMutation.mutateAsync(orderId);
- const message = await checkStatus(orderId);
- if (message) {
- showModal();
- } else {
- navigation?.getParent()?.navigate("paymentResultScreen");
- }
- }
- // closeModal();
- } catch (error: unknown) {
- log.verbose("Error catching");
- if (error instanceof AxiosError) {
- log.error("openBrowserThenCheckStatus Catch Block|", error);
- showModal(
- ,
- );
- } else {
- showModal();
- }
- // log.error("openBrowserThenCheckStatus Catch Block|", error);
- // if (error instanceof Error) {
- // log.debug("1");
- // if (error.name === "ORANGE_PAYMENT_IN_PROGRESS") {
- // log.debug("2");
-
- // log.warn("openBrowserThenCheckStatus | ORANGE_PAYMENT_IN_PROGRESS");
- // await showModal(
- // openBrowserThenCheckStatus(paymentUrl, orderId)}
- // />,
- // );
- // log.debug("3");
- // } else if (error.name === "ORANGE_PAYMENT_FAILED") {
- // showModal();
- // log.error("openBrowserThenCheckStatus | ORANGE_PAYMENT_FAILED");
- // }
- // log.debug("4 --", error.name);
- // } else {
- // log.error("openBrowserThenCheckStatus Else Block|", error);
- // closeModal();
- // throw error;
- // }
- }
- };
-
- const orangePaymentTransactionHandler = async (amount: number) => {
- try {
- showModal();
- const { payment_url, order_id } =
- await orangeTransactionInitializerMutation.mutateAsync(amount);
- log.info("orangePaymentTransactionHandler |", payment_url, order_id);
- log.info("Opening browser for payment...");
- await openBrowserThenCheckStatus(payment_url, order_id);
- // biome-ignore lint/suspicious/noExplicitAny:
- } catch (error: any) {
- log.error("makePayment |", error);
- showModal(
- ,
- );
-
- throw error;
- } finally {
- //closeModal(); // just to be ultra sure that the modal is closed
- }
- };
-
- return {
- orangeTransactionInitializerMutation: orangeTransactionInitializerMutation,
-
- handlePaymentUsingBrowser,
- isBrowserOpen,
- isWaitingForOmPaymentUrl: orangeTransactionInitializerMutation.isPending,
- isCheckingForTransactionStatus: transactionsStatusMutation.isPending,
- transactionsStatusMutation,
- orangePaymentTransactionHandler,
- };
-};
-
-export default useOrangeMoney;
diff --git a/src/hooks/useTransactionsHistory.tsx b/src/hooks/useTransactionsHistory.tsx
deleted file mode 100644
index 7f5db7b..0000000
--- a/src/hooks/useTransactionsHistory.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import { type Transaction, getTransactionsHistory } from "@/utils/requests/transactions";
-import type { PaymentCode } from "@/utils/requests/types";
-import { LOG } from "@logger";
-import { useQuery } from "@tanstack/react-query";
-import { useCallback, useMemo, useState } from "react";
-
-const log = LOG.extend("useTransactionsHistory");
-
-// biome-ignore lint/style/useNamingConvention:
-export type OperatorsFilter = { [key in PaymentCode]: boolean };
-
-const useTransactionsHistory = () => {
- log.verbose("useTransactionsHistory");
-
- const [referenceFilter, setReferenceFilter] = useState("");
- // biome-ignore lint/style/useNamingConvention:
- const [operatorsFilter, setOperatorsFilter] = useState({
- // biome-ignore lint/style/useNamingConvention:
- OM: true,
- // biome-ignore lint/style/useNamingConvention:
- MTN: true,
- // biome-ignore lint/style/useNamingConvention:
- FLOOZ: true,
- // biome-ignore lint/style/useNamingConvention:
- WAVE: true,
- // biome-ignore lint/style/useNamingConvention:
- CB: true,
- });
-
- const { data, isLoading, error, refetch } = useQuery({
- queryKey: ["transactionsHistory"],
- queryFn: getTransactionsHistory,
- });
-
- const filterByReference = useCallback(
- (reference: string) => {
- if (!data?.length) return [];
-
- return data.filter(
- (transaction) => transaction.reference.includes(reference) && transaction.reference,
- );
- },
- [data],
- );
-
- const filterDataByReference = (data: Transaction[], reference: string) => {
- if (!data?.length) return [];
-
- return data.filter(
- (transaction) => transaction.reference.includes(reference) && transaction.reference,
- );
- };
-
- const filterByOperators = (data: Transaction[]) => {
- if (!data?.length) return [];
- // create a set
- const set = new Set();
-
- for (const key of Object.keys(operatorsFilter)) {
- if (operatorsFilter[key as keyof OperatorsFilter]) {
- set.add(key as PaymentCode);
- }
- }
- return data.filter((transaction) => {
- // return true if the set is empty, as there is no need to check
- if (set.size === 0) return true;
- // return true if the set contains the value
- return set.has(transaction.type_paiement_label);
- });
- };
-
- const transactionsHistory: Transaction[] = useMemo(() => {
- if (!data) return [];
- const filteredByOperators = filterByOperators(data);
- const filteredByReference = filterDataByReference(filteredByOperators, referenceFilter);
- return filteredByReference;
- // return filterByReference(referenceFilter);
- }, [data, referenceFilter, filterByOperators, filterDataByReference]);
-
- return {
- transactionsHistory,
- isLoading,
- error,
- refetch,
- setReferenceFilter,
- operatorsFilter,
- setOperatorsFilter,
- };
-};
-
-export default useTransactionsHistory;
diff --git a/src/hooks/useWave.tsx b/src/hooks/useWave.tsx
deleted file mode 100644
index d68d192..0000000
--- a/src/hooks/useWave.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-import ErrorModal from "@components/modals/ErrorModal";
-import LoadingModal from "@components/modals/LoadingModal";
-import { LOG } from "@logger";
-import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
-import { useMutation, useQueryClient } from "@tanstack/react-query";
-import * as WebBrowser from "expo-web-browser";
-import { useState } from "react";
-import { useModalsManagerContext } from "@/contexts/ModalsManagerContext";
-import type { IpaymentStackNavigator } from "@/navigations/types";
-import {
- getTransactionStatus,
- type IwavePaymentStarter,
- initTransaction,
-} from "@/utils/requests/wavePayment";
-
-const log = LOG.extend("useWave");
-
-const paymentObjectDefault: IwavePaymentStarter = {
- // biome-ignore lint/style/useNamingConvention:
- type_paiement: 2,
- marchand: "1",
- service: "2",
- montant: 0,
-};
-
-const useWave = (
- navigation?: NativeStackNavigationProp<
- IpaymentStackNavigator,
- "paymentAmountInputScreen",
- "IpaymentStackNavigator"
- >,
-) => {
- const { showModal, closeModal } = useModalsManagerContext();
- const [_isBrowserOpen, setIsBrowserOpen] = useState(false);
-
- const _queryClient = useQueryClient();
-
- // Mutations
-
- const waveTransactionInitializerMutation = useMutation({
- mutationFn: (amount: number) =>
- initTransaction({
- ...paymentObjectDefault,
- montant: amount,
- }),
- onSuccess: (_data) => {},
- onError: (err) => {
- log.error("waveTransactionInitializerMutation |", err);
- },
- });
-
- const waveTransactionStatusMutation = useMutation({
- mutationFn: (orderId: string) => getTransactionStatus(orderId),
- onSuccess: (_data) => {
- log.debug("waveTransactionStatusMutation request success");
- },
- onError: (err) => {
- log.error("waveTransactionStatusMutation |", err);
- },
- });
-
- // Browser stuff
-
- const handlePaymentUsingBrowser = async (url: string) => {
- log.debug("handlePaymentUsingBrowser | Opening the browser at url :: ", url);
-
- setIsBrowserOpen(true);
- const result = await WebBrowser.openBrowserAsync(url);
- // setResult(result);
- log.debug("handlePaymentUsingBrowser | Result ::", result);
- setIsBrowserOpen(false);
- };
-
- const _openBrowserThenCheckStatus = async (paymentUrl: string, orderId: string) => {
- try {
- await handlePaymentUsingBrowser(paymentUrl);
- log.info("openBrowserThenCheckStatus | Verifying transaction status...");
- showModal();
- await waveTransactionStatusMutation.mutateAsync(orderId);
- closeModal();
- // navigation?.getParent()?.navigate("paymentResultScreen");
- } catch (error) {
- log.error("openBrowserThenCheckStatus |", error);
- // if (error instanceof Error) {
- // if (error.name === "ORANGE_PAYMENT_IN_PROGRESS") {
- // log.warn("openBrowserThenCheckStatus | ORANGE_PAYMENT_IN_PROGRESS");
- // await showModal(
- // openBrowserThenCheckStatus(paymentUrl, orderId)}
- // />,
- // );
- // } else if (error.name === "ORANGE_PAYMENT_FAILED") {
- // showModal();
- // log.error("openBrowserThenCheckStatus | ORANGE_PAYMENT_FAILED");
- // }
- // } else {
- // log.error("openBrowserThenCheckStatus |", error);
- // closeModal();
- // throw error;
- // }
- }
- };
-
- // Handlers
-
- const waveTransactionHandler = async (amount: number) => {
- try {
- showModal();
-
- const response = await waveTransactionInitializerMutation.mutateAsync(amount);
- log.info("waveTransactionHandler payment url received :: ", response.wave_launch_url);
- // log.info("Opening browser for payment...");
- log.info("Navigating to the qr code screen...");
- closeModal();
- navigation?.getParent()?.navigate("waveQrCodePaymentScreen", { data: response });
-
- // await openBrowserThenCheckStatus(response.wave_launch_url, response.id);
- } catch (error) {
- log.error("waveTransactionHandler |", error);
- showModal();
- throw error;
- }
- };
-
- const handlePaymentVerification = async (id: string) => {
- log.info("handlePaymentVerification |", id);
- try {
- showModal();
- const _response = await waveTransactionStatusMutation.mutateAsync(id);
- closeModal();
- } catch (error) {
- log.error("handlePaymentVerification |", error);
- // closeModal();
- // showModal();
- } finally {
- // TODO : remove this finally block once a proper implementation workflow is set. currently we close the modal after logging whatever response we get from the request
- closeModal();
- }
- };
-
- return {
- waveTransactionInitializerMutation,
- waveTransactionHandler,
- handlePaymentVerification,
- };
-};
-
-export default useWave;
diff --git a/src/navigations/AppBottomTabsNavigator.tsx b/src/navigations/AppBottomTabsNavigator.tsx
index 165ad0b..2b53882 100644
--- a/src/navigations/AppBottomTabsNavigator.tsx
+++ b/src/navigations/AppBottomTabsNavigator.tsx
@@ -3,10 +3,9 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import TransactionHistoryScreen from "@screens/TransactionHistoryScreen";
import UserProfileScreen from "@screens/UserProfileScreen";
import { useTheme } from "@shopify/restyle";
-// import palette
import type { Theme } from "@themes/Theme";
-import { View } from "react-native";
-import Text from "../components/bases/Text";
+import { Text, View } from "react-native";
+
import PaymentStackNavigator from "./PaymentStackNavigation";
const Tab = createBottomTabNavigator();
@@ -63,22 +62,6 @@ export const AppBottomTabsNavigator = () => {
);
};
-const HomeScreen = () => {
- return (
-
- Home!
-
- );
-};
-
-const Transactions = () => {
- return (
-
- Transactions!
-
- );
-};
-
const SettingsScreen = () => {
return (
@@ -86,11 +69,3 @@ const SettingsScreen = () => {
);
};
-
-const ProfileScreen = () => {
- return (
-
- Profile!
-
- );
-};
diff --git a/src/screens/TransactionHistoryScreen.tsx b/src/screens/TransactionHistoryScreen.tsx
index 8fbc37e..eb6f8ab 100644
--- a/src/screens/TransactionHistoryScreen.tsx
+++ b/src/screens/TransactionHistoryScreen.tsx
@@ -1,4 +1,4 @@
-/** biome-ignore-all lint/style/useNamingConvention: */
+/** biome-ignore-all lint/style/useNamingConvention: */
import { asp as g } from "@asp/asp";
import { BarnoinPayBackground } from "@components/BarnoinPayBackground";
diff --git a/src/screens/UserProfileScreen.tsx b/src/screens/UserProfileScreen.tsx
index 18b01d1..325ad32 100644
--- a/src/screens/UserProfileScreen.tsx
+++ b/src/screens/UserProfileScreen.tsx
@@ -5,17 +5,16 @@ import * as Button from "@components/ButtonNew";
import Ionicons from "@expo/vector-icons/Ionicons";
import { LOG } from "@logger";
import { Text, View } from "react-native";
-import { useDispatch } from "react-redux";
-import { useUserAuthenticationContext } from "@/contexts/UserAuthenticationContext";
+import { useDispatch, useSelector } from "react-redux";
import { logout } from "@/features/auth/slice";
+import type { RootState } from "@/redux";
const log = LOG.extend("UserProfileScreen");
const UserProfileScreen = () => {
log.verbose("UserProfileScreen");
const dispatch = useDispatch();
-
- const { userInformations } = useUserAuthenticationContext();
+ const userInformations = useSelector((state: RootState) => state.auth.user);
return (
diff --git a/src/styles/Commons.tsx b/src/styles/Commons.tsx
deleted file mode 100644
index 48013a9..0000000
--- a/src/styles/Commons.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { StyleSheet } from "react-native";
-
-export const containers = StyleSheet.create({
- fullScreenContentCentered: {
- width: "100%",
- height: "100%",
- flex: 1,
- alignItems: "center",
- justifyContent: "center",
- },
- containerFull: {
- width: "100%",
- height: "100%",
- flex: 1,
- },
- containerFlexUno: {
- flex: 1,
- },
-});
-
-export const images = StyleSheet.create({
- cover: {
- flex: 1,
- width: "100%",
- height: "100%",
- resizeMode: "cover",
- },
- background: {
- flex: 1,
- resizeMode: "cover",
- justifyContent: "center",
- },
- contain: {
- flex: 1,
- width: "100%",
- height: "100%",
- resizeMode: "contain",
- },
-});
diff --git a/src/themes/variants/cardVariants.ts b/src/themes/variants/cardVariants.ts
index e731030..f9a7b4f 100644
--- a/src/themes/variants/cardVariants.ts
+++ b/src/themes/variants/cardVariants.ts
@@ -1,4 +1,5 @@
-import { OVERLAY_BACKDROP_Z_INDEX } from "@/contexts/ModalsManagerContext";
+const OVERLAY_BACKDROP_Z_INDEX = 999;
+
import { Dimensions } from "react-native";
export const cardVariants = {
diff --git a/src/utils/assetsCache.tsx b/src/utils/assetsCache.tsx
deleted file mode 100644
index b395d01..0000000
--- a/src/utils/assetsCache.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-// To load assets asynchronously
-
-import { Asset } from "expo-asset";
-
-import { LOG } from "@logger";
-
-const log = LOG.extend("assetsCache");
-
-export default function cacheAssetsAsync({
- images = [],
- fonts = [],
- videos = [],
-}: { images?: string[]; fonts?: string[]; videos?: string[] }) {
- return Promise.all([...cacheImages(images)]);
-}
-
-function cacheImages(images: string[]) {
- return images.map((image) => Asset.fromModule(image).downloadAsync());
-}
-
-// function cacheVideos(videos) {
-// return videos.map((video) => Asset.fromModule(video).downloadAsync());
-// }
-
-// function cacheFonts(fonts) {
-// return fonts.map((font) => Font.loadAsync(font));
-// }
diff --git a/src/utils/axiosRequest.ts b/src/utils/axiosRequest.ts
deleted file mode 100644
index d911edb..0000000
--- a/src/utils/axiosRequest.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { LOG } from "@logger";
-import axios, { type AxiosError, type AxiosResponse } from "axios";
-
-const log = LOG.extend("AxiosRequest");
-
-const baseUrl = process.env.EXPO_PUBLIC_API_URL;
-
-// biome-ignore lint/style/useNamingConvention:
-const client = axios.create({ baseURL: baseUrl });
-
-const axiosRequest = async ({ ...options }): Promise => {
- // console.log("base Url", baseUrl);
- // client.defaults.headers.common.Authorization = `Bearer ${""}`;
- // client.defaults.headers.common['Content-Type'] = 'application/json';
- // console.log("client default", client.defaults);
- // console.log("client datas", client.defaults.data);
- log.debug("Base url :: ", client.getUri());
- log.debug("RequestOptions :: ", options);
-
- const onSuccess = (response: T) => {
- return response;
- };
- const onError = (error: AxiosError) => {
- log.error(error);
- throw error;
- };
-
- try {
- const response: AxiosResponse = await client({ ...options });
- return onSuccess(response.data);
- } catch (error: unknown) {
- if (axios.isAxiosError(error)) {
- log.error("axiosRequest | Response :: ", JSON.stringify(error.response, null, 2));
- // log.error("Axios RequestError Reponse message:: ", error.message);
- // log.error("Axios RequestError Reponse name:: ", error.response?.data);
- } else {
- log.error("axiosRequest | General RequestError :: ", JSON.stringify(error, null, 2));
- }
- // biome-ignore lint/suspicious/noExplicitAny:
- return onError(error as any);
- }
-};
-
-export default axiosRequest;
diff --git a/src/utils/requests/authenticateUser.ts b/src/utils/requests/authenticateUser.ts
deleted file mode 100644
index b6ad52c..0000000
--- a/src/utils/requests/authenticateUser.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { IauthenticationData } from "@/contexts/Types";
-import { LOG } from "@logger";
-import { AxiosError } from "axios";
-import axiosRequest from "../axiosRequest";
-
-const log = LOG.extend("authenticateUser");
-
-const authenticateUser = async ({ username, password }: { username: string; password: string }) => {
- log.http({ username, password });
- const response = await axiosRequest({
- url: "/login/token/",
- method: "POST",
- data: {
- username: username,
- password: password,
- },
- });
- log.http(JSON.stringify(response, null, 2));
- return response;
-};
-
-export default authenticateUser;
-
-export const parseAuthicationErrors = (error: unknown): string => {
- if (error instanceof AxiosError && error.response) {
- switch (error.response.status) {
- case 401:
- return "Wrong username or password";
- default:
- return "Unknown Error. Please try again.";
- }
- }
- if (error instanceof AxiosError && error.request) {
- return "Network error";
- }
- return "Unknown error";
-};
diff --git a/src/utils/requests/getPaymentTypes.ts b/src/utils/requests/getPaymentTypes.ts
deleted file mode 100644
index f39d498..0000000
--- a/src/utils/requests/getPaymentTypes.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { LOG } from "@logger";
-import base64 from "react-native-base64";
-import axiosRequest from "../axiosRequest";
-import type { IpaginatedResponse, IpaymentType } from "./types";
-
-const basictoken = base64.encode("admin:admin");
-
-const log = LOG.extend("getPaymentTypes");
-const getPaymentTypes = async () => {
- log.http("getPaymentTypes");
- const response = await axiosRequest>({
- url: "/operateur/",
- method: "GET",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- });
- log.http(JSON.stringify(response, null, 2));
- return response;
-};
-
-export default getPaymentTypes;
diff --git a/src/utils/requests/orangePayment.ts b/src/utils/requests/orangePayment.ts
deleted file mode 100644
index a5d974b..0000000
--- a/src/utils/requests/orangePayment.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { LOG } from "@logger";
-import base64 from "react-native-base64";
-import axiosRequest from "../axiosRequest";
-
-export interface IorangePaymentStarter {
- // biome-ignore lint/style/useNamingConvention:
- type_paiement: number;
- marchand: "1";
- service: string;
- montant: number;
- commentaire: string;
- numero: string;
-}
-
-export interface IorangeResponse {
- status: number;
- message: string;
- // biome-ignore lint/style/useNamingConvention:
- pay_token: string;
- // biome-ignore lint/style/useNamingConvention:
- payment_url: string;
- // biome-ignore lint/style/useNamingConvention:
- notif_token: string;
- // biome-ignore lint/style/useNamingConvention:
- order_id: string;
-}
-
-const basictoken = base64.encode("admin:admin");
-
-export type OrangeStatus = "INITIATED" | "SUCCESS" | "FAILED";
-export interface IorangePaymentStatus {
- status: OrangeStatus;
- code: number;
- message: {
- status: OrangeStatus;
- // biome-ignore lint/style/useNamingConvention:
- order_id: string;
- txnid?: string;
- };
-}
-
-const log = LOG.extend("orangePayment");
-
-export const getTransactionsData = async (payload: IorangePaymentStarter) => {
- log.http("getTransactionsData", payload);
-
- // const basictoken = base64.encode("admin:admin");
- const response = await axiosRequest({
- url: "/transactions/",
- method: "POST",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- data: payload,
- });
-
- log.http("getTransactionsData |", JSON.stringify(response, null, 2));
-
- return response;
-};
-
-export const getTransactionStatus = async (orderId: string) => {
- log.http("getTransactionStatus |", { orderId });
-
- try {
- const response = await axiosRequest({
- url: `/api/TransactionCheckStatus/${orderId}/`,
- method: "GET",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- });
-
- log.http("getTransactionStatus |", JSON.stringify(response, null, 2));
- switch (response.status) {
- case "SUCCESS": {
- log.http("getTransactionStatus |", JSON.stringify(response, null, 2));
- return response;
- }
- case "INITIATED": {
- log.warn("Payment is still in progress, throwing error for mutation to catch");
- const error = new Error("Payment is still in progress");
- error.name = "ORANGE_PAYMENT_IN_PROGRESS";
- throw error;
- }
- case "FAILED": {
- log.warn("Payment failed, throwing error for mutation to catch");
- const error = new Error("Payment failed");
- error.name = "ORANGE_PAYMENT_FAILED";
- throw error;
- }
-
- default: {
- log.warn("An unknown error occured, throwing error for mutation to catch");
- const error = new Error("Payment failed");
- error.name = "ORANGE_UNKNOWN_PAYMENT_ERROR";
- throw error;
- }
- }
- } catch (error) {
- log.error(
- "getTransactionStatus | An unexpected error occured |",
- JSON.stringify(error, null, 2),
- );
- throw error;
- }
-};
diff --git a/src/utils/requests/transactions.ts b/src/utils/requests/transactions.ts
deleted file mode 100644
index bb723b9..0000000
--- a/src/utils/requests/transactions.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { LOG } from "@logger";
-import base64 from "react-native-base64";
-import axiosRequest from "../axiosRequest";
-import type { PaymentCode } from "./types";
-
-const log = LOG.extend("transactions");
-
-export interface Transaction {
- // biome-ignore lint/style/useNamingConvention:
- type_paiement: number;
- // biome-ignore lint/style/useNamingConvention:
- type_paiement_label: PaymentCode;
- marchand: string;
- // biome-ignore lint/style/useNamingConvention:
- marchand_name: string;
- service: string;
- montant: number;
- date: string;
- commentaire: string;
- etat: boolean;
- status: "SUCCESS" | "INITIATED" | "FAILED";
- reference: string;
- // biome-ignore lint/style/useNamingConvention:
- transaction_id: number;
- // biome-ignore lint/style/useNamingConvention:
- marchand_code: string;
-}
-
-export interface TransactionHistoryResponse {
- count: number;
- next: string | null;
- previous: string | null;
- results: Transaction[];
-}
-
-export const getTransactionsHistory = async (): Promise => {
- const basictoken = base64.encode("admin:admin");
-
- log.http("getTransactionsHistory");
- try {
- const response = await axiosRequest({
- url: "/transactions/",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- });
-
- log.http("getTransactionsHistory |", JSON.stringify(response, null, 2));
-
- // TODO: Update this when the api is fixed, response should not be reversed
- return response.results.reverse();
- } catch (error) {
- log.error("getTransactionsHistory |", error);
- throw error;
- }
-};
diff --git a/src/utils/requests/types.ts b/src/utils/requests/types.ts
deleted file mode 100644
index a1a3011..0000000
--- a/src/utils/requests/types.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-export type PaymentCode = "OM" | "FLOOZ" | "MTN" | "WAVE" | "CB";
-
-export interface IpaymentType {
- id: number;
- code: PaymentCode;
- etat: boolean;
-}
-
-export interface IpaginatedResponse {
- count: number;
- next: string | null;
- previous: string | null;
- results: T;
-}
-
-export interface ImerchandInformations {
- // biome-ignore lint/style/useNamingConvention:
- marchand_id: string;
- nom: string;
- code: string;
- adresse: string;
- // biome-ignore lint/style/useNamingConvention:
- url_succes: string;
- // biome-ignore lint/style/useNamingConvention:
- url_echec: string;
- entreprise: number;
- user: number;
-}
-
-export interface IuserInformations {
- username: string;
- email: string;
- // biome-ignore lint/style/useNamingConvention:
- first_name: string;
- // biome-ignore lint/style/useNamingConvention:
- last_name: string;
- marchand: ImerchandInformations;
-}
diff --git a/src/utils/requests/userInformations.ts b/src/utils/requests/userInformations.ts
deleted file mode 100644
index f533b83..0000000
--- a/src/utils/requests/userInformations.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { LOG } from "@logger";
-import base64 from "react-native-base64";
-import axiosRequest from "../axiosRequest";
-import type { IuserInformations } from "./types";
-
-const log = LOG.extend("getUserInformations");
-
-const getUserInformations = async (userAccessToken: string) => {
- log.http("getUserInformations", userAccessToken);
- const basictoken = base64.encode("admin:admin");
- log.http("basictoken", basictoken);
-
- const response = await axiosRequest({
- url: "/user-info/",
- method: "GET",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- });
- log.http(JSON.stringify(response, null, 2));
- return response;
-};
-
-export default getUserInformations;
-
-export const parseUserInformationsErrors = (error: unknown): string => {
- // if (error instanceof AxiosError && error.response) {
- // switch (error.response.status) {
- // case 401:
- // return "Wrong username or password";
- // default:
- // return "Unknown Error. Please try again.";
- // }
- // }
- // if (error instanceof AxiosError && error.request) {
- // return "Network error";
- // }
- return "Failure to fetch user informations. Please try again.";
-};
diff --git a/src/utils/requests/wavePayment.ts b/src/utils/requests/wavePayment.ts
deleted file mode 100644
index 79a4cb1..0000000
--- a/src/utils/requests/wavePayment.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import { LOG } from "@logger";
-import base64 from "react-native-base64";
-import axiosRequest from "../axiosRequest";
-
-const log = LOG.extend("wavePayment");
-
-export interface IwavePaymentStarter {
- // biome-ignore lint/style/useNamingConvention:
- type_paiement: 2; // id 2 is for wave.
- marchand: string;
- service: string;
- montant: number;
-}
-
-export interface IwaveStarterRespone {
- id: string;
- amount: string;
- // biome-ignore lint/style/useNamingConvention:
- checkout_status: string;
- // biome-ignore lint/style/useNamingConvention:
- client_reference: unknown;
- currenfy: string;
- // biome-ignore lint/style/useNamingConvention:
- error_url: string;
- // biome-ignore lint/style/useNamingConvention:
- last_payment_errror: unknown;
- // biome-ignore lint/style/useNamingConvention:
- business_name: string;
- // biome-ignore lint/style/useNamingConvention:
- payment_status: string;
- // biome-ignore lint/style/useNamingConvention:
- succes_url: string;
- // biome-ignore lint/style/useNamingConvention:
- wave_launch_url: string;
- // biome-ignore lint/style/useNamingConvention:
- when_completed: unknown;
- // biome-ignore lint/style/useNamingConvention:
- when_created: string;
- // biome-ignore lint/style/useNamingConvention:
- when_expires: string;
-}
-
-export interface IwaveStatusResponse {
- status: string;
- code: number;
- message: IwaveStarterRespone;
-}
-
-const basictoken = base64.encode("admin:admin");
-
-export const initTransaction = async (payload: IwavePaymentStarter) => {
- log.http("initTransaction", payload);
-
- // const basictoken = base64.encode("admin:admin");
- try {
- const response = await axiosRequest({
- url: "/transactions/",
- method: "POST",
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- data: payload,
- });
- log.http("initTransaction |", JSON.stringify(response, null, 2));
- return response;
- } catch (error) {
- log.error("initTransaction |", error);
- throw error;
- }
-};
-
-export const getTransactionStatus = async (id: string) => {
- log.http("getTransactionStatus", id);
-
- try {
- const response = await axiosRequest({
- url: `/wave-session/${id}/`,
- headers: {
- // biome-ignore lint/style/useNamingConvention:
- Authorization: `Basic ${basictoken}`,
- },
- });
- log.http("getTransactionStatus |", JSON.stringify(response, null, 2));
-
- return response;
- } catch (error) {
- log.error("getTransactionStatus |", error);
- throw error;
- }
-};