Commit b6aedca7 by G

use the custom hook to retrieve and show transactions history

parent b3c5e622
import { getTransactionsHistory } from "@/utils/requests/transactions"; import Input from "@components/Input";
import TransactionInformationsItem from "@components/TransactionInformationsItem"; import TransactionInformationsItem from "@components/TransactionInformationsItem";
import BackgroundWithBeasyIconAndWhiteContentArea from "@components/backgrounds/BackgroundWithBeasyIconAndWhiteContentArea"; import BackgroundWithBeasyIconAndWhiteContentArea from "@components/backgrounds/BackgroundWithBeasyIconAndWhiteContentArea";
import Box from "@components/bases/Box";
import useTransactionsHistory from "@hooks/useTransactionsHistory";
import { LOG } from "@logger"; import { LOG } from "@logger";
import { useQuery } from "@tanstack/react-query";
import { RefreshControl, ScrollView } from "react-native"; import { RefreshControl, ScrollView } from "react-native";
const log = LOG.extend("TransactionHistoryScreen"); const log = LOG.extend("TransactionHistoryScreen");
...@@ -10,37 +11,44 @@ const log = LOG.extend("TransactionHistoryScreen"); ...@@ -10,37 +11,44 @@ const log = LOG.extend("TransactionHistoryScreen");
const TransactionHistoryScreen = () => { const TransactionHistoryScreen = () => {
log.verbose("TransactionHistoryScreen"); log.verbose("TransactionHistoryScreen");
const { data, isLoading, error, refetch } = useQuery({ const { transactionsHistory: data, isLoading, error, refetch } = useTransactionsHistory();
queryKey: ["transactionsHistory"],
queryFn: getTransactionsHistory, // const { data, isLoading, error, refetch } = useQuery({
}); // queryKey: ["transactionsHistory"],
// queryFn: getTransactionsHistory,
// });
console.info("Data", data); console.info("Data", data);
return ( return (
<BackgroundWithBeasyIconAndWhiteContentArea> <BackgroundWithBeasyIconAndWhiteContentArea>
<ScrollView <>
refreshControl={<RefreshControl refreshing={isLoading} onRefresh={refetch} />} <Box px={"m"} mt={"m"}>
contentContainerStyle={{ <Input label={"Reference"} />
gap: 10, </Box>
padding: 10, <ScrollView
marginTop: 10, refreshControl={<RefreshControl refreshing={isLoading} onRefresh={refetch} />}
paddingBottom: 30, contentContainerStyle={{
flexDirection: "column", gap: 10,
}} padding: 10,
showsVerticalScrollIndicator={false} // marginTop: 10,
> paddingBottom: 30,
{data?.map((transaction) => ( flexDirection: "column",
<TransactionInformationsItem }}
key={transaction.reference} showsVerticalScrollIndicator={false}
paymentType={transaction.type_paiement_label} >
reference={transaction.reference} {data?.map((transaction) => (
amount={transaction.montant} <TransactionInformationsItem
date={transaction.date} key={transaction.reference}
status={transaction.status} paymentType={transaction.type_paiement_label}
/> reference={transaction.reference}
))} amount={transaction.montant}
</ScrollView> date={transaction.date}
status={transaction.status}
/>
))}
</ScrollView>
</>
</BackgroundWithBeasyIconAndWhiteContentArea> </BackgroundWithBeasyIconAndWhiteContentArea>
); );
}; };
......
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