latest code with fix modal back Press problem
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { fetchAuctionItem, fetchDashboard, fetchEmdCheck, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseAuctionList, fetchPurchaseTender, getAuction, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, viewAuctionDocumentDownload, viewAuctionDocuments, viewAuctionItemDocuments } from './apis';
|
||||
import { fetchAuctionItem, fetchDashboard, fetchEmdCheck, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseAuctionList, fetchPurchaseTender, getAuction, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, viewAuctionDocumentDownload, viewAuctionDocuments, viewAuctionItemDocuments, fetchPurchaseAuctionPage } from './apis';
|
||||
|
||||
// User
|
||||
|
||||
@@ -63,6 +63,36 @@ export const useFetchPurchaseAuction = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useFetchLiveAuctionPage = () => {
|
||||
return useInfiniteQuery<any>({
|
||||
queryKey: ['fetchPurchaseAuctionPage'],
|
||||
queryFn: ({ pageParam = 0 }) =>
|
||||
fetchPurchaseAuctionPage({
|
||||
page: pageParam,
|
||||
size: 10,
|
||||
}),
|
||||
initialPageParam: 0,
|
||||
|
||||
getNextPageParam: (lastPage, allPages) => {
|
||||
const { size, totalCount } = lastPage;
|
||||
const totalPages = Math.ceil(totalCount / size);
|
||||
const nextPage = allPages.length;
|
||||
return nextPage < totalPages ? nextPage : undefined;
|
||||
},
|
||||
|
||||
select: (data) => {
|
||||
const mergedResults = data.pages.flatMap(
|
||||
(page: any) => page?.data ?? []
|
||||
);
|
||||
|
||||
return {
|
||||
...data,
|
||||
result: mergedResults,
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const useFetchLiveAuction = () => {
|
||||
return useInfiniteQuery<any>({
|
||||
queryKey: ['fetchLiveAuction'],
|
||||
|
||||
Reference in New Issue
Block a user