Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import { DEFAULT_QUERY_CONFIG } from "@components/VirtualList/hooks/queries";
import { useGetCurrentMerchantId } from "@hooks/common";
import { customInstance } from "@services/api";
import { parseAmount } from "@utils/index";
import { useQuery } from "react-query";
export const useSettlementStats = () => {
const { merchantId } = useGetCurrentMerchantId();
const { data, isLoading } = useQuery(
"get-settlement-stats",
async () =>
await customInstance({
url: `/merchants/${merchantId}/transaction-settlements/stats`,
method: "GET",
}),
{ enabled: Boolean(merchantId), ...DEFAULT_QUERY_CONFIG },
);
const stats = [
{
title: "Total Net Sales",
value: parseAmount(data?.netSalesAmount / 100 || 0),
isAmount: true,
},
{
title: "Total Fees Collected",
value: parseAmount(data?.grossFeesAmount / 100 || 0),
isAmount: true,
},
{
title: "Total Payout",
value: parseAmount(data?.availablePayoutAmount / 100 || 0),
isAmount: true,
},
{
title: "Total Transactions",
value: data?.transactionCount || 0,
},
//this value is not correct we temporary hide it
// {
// title: "Chargebacks (%)",
// value: parseAmount(data?.chargebackPercentage || 0),
// },
];
return {
isLoading,
data: {
totalGrossSales: parseAmount(data?.purchaseAmount / 100 || 0),
stats,
},
};
};
|