commit
This commit is contained in:
@@ -15,37 +15,24 @@ import Skeleton from '../../Component/Skelton/Skelton';
|
||||
|
||||
const LiveAuction = () => {
|
||||
const Dispatch = useDispatch()
|
||||
const user = useSelector((state: any) => state.token?.token);
|
||||
const onEndReachedCalledDuringMomentum = useRef(true);
|
||||
const SelectedPurchaseList = useSelector((state: any) => state.selectPurchaseAuction);
|
||||
const [showRefreshBanner, setShowRefreshBanner] = useState(false);
|
||||
const [allBoolean, setAllBoolean] = useState({ liveAuctionData: [], isLoading: false })
|
||||
const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, isRefetching, refetch, isPending }: any = useFetchLiveAuction();
|
||||
|
||||
console.log("object----",data,)
|
||||
// My Methods
|
||||
|
||||
const getMyAuction = async () => {
|
||||
try {
|
||||
setAllBoolean(prev => ({ ...prev, isLoading: true }))
|
||||
const res = await apiCall<any>('get', `${GET_MY_AUCTION}`,);
|
||||
|
||||
if (res?.statusCode === 200) {
|
||||
const purchasedIds = new Set(res.data.map((item: any) => item.auctionId));
|
||||
const filteredLive = data?.result.map((item: any) => ({ ...item, active: !purchasedIds.has(item.auctionId) }));
|
||||
setAllBoolean(prev => ({ ...prev, liveAuctionData: filteredLive }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('getMyAuction error', error);
|
||||
} finally {
|
||||
setAllBoolean(prev => ({ ...prev, isLoading: false }));
|
||||
}
|
||||
};
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item, index }: any) => {
|
||||
console.log("item core ",item)
|
||||
const isPurchase = SelectedPurchaseList.findIndex((prev: any) => prev.auctionNumber === item.auctionNumber)
|
||||
return <LiveAuctionTile
|
||||
data={item}
|
||||
index={index}
|
||||
isPurchasedByContractor={item.contractorId?.includes(String(user.contractorId))}
|
||||
auctionId={item.auctionId}
|
||||
auctionDispatchDate={item.auctionDispatchDate}
|
||||
isPurchased={isPurchase !== -1 ? true : false}
|
||||
@@ -90,11 +77,6 @@ const LiveAuction = () => {
|
||||
}
|
||||
}, [isRefetching]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.result?.length > 0) {
|
||||
getMyAuction()
|
||||
}
|
||||
}, [data])
|
||||
|
||||
if (isLoading) {
|
||||
return <Skelton />;
|
||||
@@ -141,9 +123,9 @@ const LiveAuction = () => {
|
||||
</Animated.View>
|
||||
)}
|
||||
{
|
||||
isPending || allBoolean.isLoading ? <Skeleton /> :
|
||||
isPending ? <Skeleton /> :
|
||||
<FlatList
|
||||
data={allBoolean.liveAuctionData ?? []}
|
||||
data={data?.result ?? []}
|
||||
renderItem={renderItem}
|
||||
showsVerticalScrollIndicator={false}
|
||||
contentContainerStyle={{ paddingBottom: 50, paddingTop: 10 }}
|
||||
|
||||
Reference in New Issue
Block a user