From aa740a608e5d2b5122e74d686157b5cc0c68c74a Mon Sep 17 00:00:00 2001 From: rohit-kumar-fullstack Date: Tue, 13 Jan 2026 11:53:07 +0530 Subject: [PATCH] latest code with fix modal back Press problem --- .../org.eclipse.buildship.core.prefs | 13 +++ src/Component/SideDrawer/SideDrawer.tsx | 30 +++-- src/Constant/NavigationString.tsx | 1 + src/Screens/Auction/Auction.tsx | 10 +- src/Screens/Auction/Modal/AuctionDetail.tsx | 49 +++----- .../Auction/Modal/AuctionItemDetail.tsx | 37 ++---- src/Screens/Auction/PurchaseAuction.tsx | 110 ++++++++++++++---- src/Screens/Tender/utils/excelHtml.ts | 63 ---------- src/Services/BBPS/ApiUrls.tsx | 2 + src/Services/BBPS/Hooks.ts | 32 ++++- src/Services/BBPS/apis.ts | 7 +- 11 files changed, 190 insertions(+), 164 deletions(-) create mode 100644 android/.settings/org.eclipse.buildship.core.prefs delete mode 100644 src/Screens/Tender/utils/excelHtml.ts diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e479558 --- /dev/null +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir= +eclipse.preferences.version=1 +gradle.user.home= +java.home= +jvm.arguments= +offline.mode=false +override.workspace.settings=false +show.console.view=false +show.executions.view=false diff --git a/src/Component/SideDrawer/SideDrawer.tsx b/src/Component/SideDrawer/SideDrawer.tsx index 03bd8f4..49e580c 100644 --- a/src/Component/SideDrawer/SideDrawer.tsx +++ b/src/Component/SideDrawer/SideDrawer.tsx @@ -2,13 +2,13 @@ import React, { useEffect } from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Dimensions, Image } from 'react-native'; import Modal from 'react-native-modal'; import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated'; -import { X, Home, Gavel, FileText, User, LogOut, ChevronRight } from 'lucide-react-native'; +import { Home, Gavel, FileText, User, LogOut, ChevronRight } from 'lucide-react-native'; import { CommonActions, useNavigation } from '@react-navigation/native'; import { useDispatch } from 'react-redux'; import { removeToken } from '../../Redux/Slices/Token'; import NavigationString from '../../Constant/NavigationString'; -const { width } = Dimensions.get('window'); +const { width, height } = Dimensions.get('window'); const DRAWER_WIDTH = width * 0.78; interface Props { visible: boolean; onClose: () => void; } @@ -22,7 +22,7 @@ const SideDrawer: React.FC = ({ visible, onClose }) => { useEffect(() => { translateX.value = visible - ? withTiming(0, { duration: 300 }) + ? withTiming(0, { duration: 0 }) : withTiming(-DRAWER_WIDTH, { duration: 250 }); }, [visible]); @@ -45,12 +45,12 @@ const SideDrawer: React.FC = ({ visible, onClose }) => { label: 'Tenders', icon: FileText, onPress: () => navigation.navigate(NavigationString.Tender), - }, - { - label: 'Profile', - icon: User, - onPress: () => { }, - }, + } + // { + // label: 'Profile', + // icon: User, + // onPress: () => { }, + // }, ]; return ( @@ -63,13 +63,17 @@ const SideDrawer: React.FC = ({ visible, onClose }) => { animationOut="fadeOut" style={styles.modal} useNativeDriver + coverScreen={false} + propagateSwipe > {/* ================= Header / Profile ================= */} - + {/* { + console.log('sdfadsfdsf'); + }}> - + */} @@ -151,7 +155,7 @@ const styles = StyleSheet.create({ drawer: { width: DRAWER_WIDTH, - height: '100%', + height: height - 80, backgroundColor: '#FFFFFF', borderTopRightRadius: 24, borderBottomRightRadius: 24, @@ -171,6 +175,8 @@ const styles = StyleSheet.create({ position: 'absolute', top: 20, right: 16, + padding: 10, + zIndex: 20 }, avatar: { diff --git a/src/Constant/NavigationString.tsx b/src/Constant/NavigationString.tsx index ff2ed1e..305f2e5 100644 --- a/src/Constant/NavigationString.tsx +++ b/src/Constant/NavigationString.tsx @@ -16,5 +16,6 @@ const NavigationString = { TenderBidding:'TenderBidding', ProceedToBidDetail:'ProceedToBidDetail', LiveTenderDetail:'LiveTenderDetail', + AuctionDetail: 'AuctionDetail', } export default NavigationString \ No newline at end of file diff --git a/src/Screens/Auction/Auction.tsx b/src/Screens/Auction/Auction.tsx index 11efd31..1fac4c8 100644 --- a/src/Screens/Auction/Auction.tsx +++ b/src/Screens/Auction/Auction.tsx @@ -19,13 +19,9 @@ const Auction = () => { const { data: purchaseAuctionData = {} } = useFetchPurchaseAuction(); const SelectedPurchaseList = useSelector((state: any) => state.selectPurchaseAuction); - const liveCount = Array.isArray(liveAuctionData?.result) - ? liveAuctionData?.pages[0]?.totalCount - : 0; + const liveCount = Array.isArray(liveAuctionData?.result) ? liveAuctionData?.pages[0]?.totalCount : 0; - const purchaseCount = Array.isArray(purchaseAuctionData?.data) - ? purchaseAuctionData.data.length - : 0; + const purchaseCount = Array.isArray(purchaseAuctionData?.data) ? purchaseAuctionData.data.length : 0; const [selectedTab, setSelectedTab] = useState<'live' | 'purchase'>('live'); @@ -44,7 +40,7 @@ const Auction = () => { - {/* Switch Tabs */} + {/* Tabs */} void; data?: any } @@ -20,8 +18,8 @@ const AuctionFullDetail: React.FC = ({ visible, onClose, data }) => { const [aucitonDetail, setAuciotnDetail] = useState(auctionData) const [allBoolean, setAllBoolean] = useState({ showItemDetail: false, selectedItem: {}, fileLoading: false }); const { data: auctionDocuments } = useGetAucitonDocument({ auctionId: data?.auctionId }) - const { mutate: downloadDocument, isPending } = useAucitonDocDownload() const { mutate } = useAuctionItem() + const formatDate = (date?: string) => { if (!date) return '-'; return moment(date, 'DD-MM-YYYY HH:mm:ss').format('DD MMM YYYY, hh:mm A'); @@ -47,23 +45,20 @@ const AuctionFullDetail: React.FC = ({ visible, onClose, data }) => { ); - - const handleDownload = async (id: number, fileName: string) => { try { setAllBoolean((prev: any) => ({ ...prev, fileLoading: true })); const { dirs } = ReactNativeBlobUtil.fs; - // ✅ PUBLIC DOWNLOADS DIRECTORY const path = `${dirs.DownloadDir}/${fileName}.pdf`; - console.log('📂 Saving to:', path); + // console.log('Saving to:', path); const downloadUrl = `${AUCTION_DOCUMENT_DOWNLOAD}?documentId=${id}&isAmendment=false`; - console.log('🌐 Download URL:', downloadUrl); + // console.log('Download URL:', downloadUrl); const response = await ReactNativeBlobUtil.config({ - fileCache: false, // important for public folder + fileCache: false, addAndroidDownloads: { useDownloadManager: true, notification: true, @@ -71,23 +66,17 @@ const AuctionFullDetail: React.FC = ({ visible, onClose, data }) => { mime: 'application/pdf', title: `${fileName}.pdf`, description: 'Downloading document', - mediaScannable: true, // 👈 makes it visible instantly + mediaScannable: true, }, }).fetch('GET', downloadUrl, { Accept: 'application/pdf', }); - console.log('✅ Download completed'); - console.log('📦 Status:', response.info().status); - console.log('📦 Headers:', response.info().headers); - console.log('📍 Saved at:', path); - const stat = await ReactNativeBlobUtil.fs.stat(path); - console.log('📦 File size:', stat.size); + console.log('File size:', stat.size); } catch (error: any) { - console.log('❌ Download failed'); - console.log('❌ Error:', error?.message || error); + console.log('Error:', error?.message || error); } finally { setAllBoolean((prev: any) => ({ ...prev, fileLoading: false })); } @@ -106,15 +95,11 @@ const AuctionFullDetail: React.FC = ({ visible, onClose, data }) => { return ( diff --git a/src/Screens/Auction/Modal/AuctionItemDetail.tsx b/src/Screens/Auction/Modal/AuctionItemDetail.tsx index 876b2c2..83af290 100644 --- a/src/Screens/Auction/Modal/AuctionItemDetail.tsx +++ b/src/Screens/Auction/Modal/AuctionItemDetail.tsx @@ -1,6 +1,5 @@ import React, { memo, useState } from 'react'; -import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform } from 'react-native'; -import Modal from 'react-native-modal'; +import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Platform, Modal } from 'react-native'; import { Package, IndianRupee, FileText, Download, ArrowLeft, Info, } from 'lucide-react-native'; import colors from '../../../Constant/Color'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; @@ -40,16 +39,15 @@ const AuctionItemDetail: React.FC = ({ visible, onClose, data }) => { setAllBoolean((prev: any) => ({ ...prev, fileLoading: true })); const { dirs } = ReactNativeBlobUtil.fs; - // ✅ PUBLIC DOWNLOADS DIRECTORY const path = `${dirs.DownloadDir}/${fileName}.pdf`; - console.log('📂 Saving to:', path); + // console.log('Saving to:', path); const downloadUrl = `${AUCTION_ITEM_DOCUMENT_DOWNLOAD}?auctionItemId=${id}`; - console.log('🌐 Download URL:', downloadUrl); + // console.log('Download URL:', downloadUrl); const response = await ReactNativeBlobUtil.config({ - fileCache: false, // important for public folder + fileCache: false, addAndroidDownloads: { useDownloadManager: true, notification: true, @@ -57,41 +55,30 @@ const AuctionItemDetail: React.FC = ({ visible, onClose, data }) => { mime: 'application/pdf', title: `${fileName}.pdf`, description: 'Downloading document', - mediaScannable: true, // 👈 makes it visible instantly + mediaScannable: true, }, }).fetch('GET', downloadUrl, { Accept: 'application/pdf', }); - console.log('✅ Download completed'); - console.log('📦 Status:', response.info().status); - console.log('📦 Headers:', response.info().headers); - console.log('📍 Saved at:', path); - const stat = await ReactNativeBlobUtil.fs.stat(path); - console.log('📦 File size:', stat.size); + console.log(' File size:', stat.size); } catch (error: any) { - console.log('❌ Download failed'); - console.log('❌ Error:', error?.message || error); + console.log('Error:', error?.message || error); } finally { setAllBoolean((prev: any) => ({ ...prev, fileLoading: false })); } }; - console.log(data, 'kkkkk---'); return ( + diff --git a/src/Screens/Auction/PurchaseAuction.tsx b/src/Screens/Auction/PurchaseAuction.tsx index 194651d..da3969f 100644 --- a/src/Screens/Auction/PurchaseAuction.tsx +++ b/src/Screens/Auction/PurchaseAuction.tsx @@ -1,9 +1,9 @@ -import React, { useEffect, useState, useCallback, memo } from 'react'; -import { View, Text, StyleSheet, FlatList, RefreshControl } from 'react-native'; +import React, { useEffect, useState, useCallback, memo, useRef } from 'react'; +import { View, Text, StyleSheet, FlatList, RefreshControl, ActivityIndicator } from 'react-native'; import LiveAuctionTile from './LiveAuctionTile'; import { useNavigation } from '@react-navigation/native'; import moment from 'moment'; -import { useFetchPurchaseAuction } from '../../Services/BBPS/Hooks'; +import { useFetchLiveAuctionPage, useFetchPurchaseAuction } from '../../Services/BBPS/Hooks'; import PurchaseAuctionTile from './PurchaseAuctionTile'; import { useDispatch } from 'react-redux'; import { setAuction } from '../../Redux/Slices/SelectedAuction'; @@ -12,12 +12,14 @@ import { Skelton } from '../../Component/Index'; import { allBooleanProps } from './types/types'; import FilterModal from './Modal/FilterModal'; import NavigationString from '../../Constant/NavigationString'; +import colors from '../../Constant/Color'; const PurchaseAuction = () => { const navigation = useNavigation() as any; const Dispatch = useDispatch() - const { data = {}, isPending } = useFetchPurchaseAuction(); + const onEndReachedCalledDuringMomentum = useRef(true); + const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, isRefetching, refetch, isPending }: any = useFetchLiveAuctionPage(); const [allBoolean, setAllBoolean] = useState({ isShowFilter: false }) const format = 'DD-MM-YYYY HH:mm:ss'; @@ -40,28 +42,90 @@ const PurchaseAuction = () => { return now.isAfter(end); } + const loadMore = useCallback(() => { + if (onEndReachedCalledDuringMomentum.current) return; + + if (!hasNextPage || isFetchingNextPage) return; + + fetchNextPage(); + onEndReachedCalledDuringMomentum.current = true; + }, [hasNextPage, isFetchingNextPage, fetchNextPage]); + + const renderFooter = useCallback(() => { + if (!isFetchingNextPage) return null; + return ( + + + + ); + }, [isFetchingNextPage]); + return ( { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} /> - {isPending ? : index.toString()} - showsVerticalScrollIndicator={false} - contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }} - renderItem={({ item, index }) => ( - { - }} - onStartBidding={() => { - Dispatch(setAuction(item)) - navigation.navigate(NavigationString.Emd) - }} - buttonEnable={isAuctionActive(item)} - isAuctionEnd={isAuctionEnd(item)} - /> - )} - />} + {isPending ? + : + // index.toString()} + // showsVerticalScrollIndicator={false} + // contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }} + // renderItem={({ item, index }) => ( + // { + // }} + // onStartBidding={() => { + // Dispatch(setAuction(item)) + // navigation.navigate(NavigationString.Emd) + // }} + // buttonEnable={isAuctionActive(item)} + // isAuctionEnd={isAuctionEnd(item)} + // /> + // )} + // /> + ( + { + }} + onStartBidding={() => { + Dispatch(setAuction(item)) + navigation.navigate(NavigationString.Emd) + }} + buttonEnable={isAuctionActive(item)} + isAuctionEnd={isAuctionEnd(item)} + /> + )} + showsVerticalScrollIndicator={false} + contentContainerStyle={{ paddingBottom: 50, paddingTop: 10 }} + + onEndReached={loadMore} + onEndReachedThreshold={0.1} + + onMomentumScrollBegin={() => { + onEndReachedCalledDuringMomentum.current = false; + }} + + ListFooterComponent={renderFooter} + + refreshControl={ + + } + + initialNumToRender={6} + maxToRenderPerBatch={6} + windowSize={7} + removeClippedSubviews + /> + } {allBoolean.isShowFilter && { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: false })) }} onApply={() => { }} /> } diff --git a/src/Screens/Tender/utils/excelHtml.ts b/src/Screens/Tender/utils/excelHtml.ts deleted file mode 100644 index b5cc7c1..0000000 --- a/src/Screens/Tender/utils/excelHtml.ts +++ /dev/null @@ -1,63 +0,0 @@ -export const spreadHtml = ` - - - - - - - - - - - - - - - -
- - - - -`; diff --git a/src/Services/BBPS/ApiUrls.tsx b/src/Services/BBPS/ApiUrls.tsx index bb6adc2..7d88943 100644 --- a/src/Services/BBPS/ApiUrls.tsx +++ b/src/Services/BBPS/ApiUrls.tsx @@ -28,6 +28,7 @@ const GET_MASTER_DATA = `${BASE_URL}contractor/masterdata/all` const LOG_IN_URL = `${BASE_URL_Auction}auction/loginWithoutDecryption` const LIVE_TENDER = `${BASE_URL}liveTender/getAllLiveTenders` const LIVE_AUCTION = `${BASE_URL_Auction}api/auction/getLiveAuctionForMobile` +const PURCHASE_AUCTION_PAGE = `${BASE_URL_Auction}api/auction/getMyAuctionForMobile` const PROCEED_PURCHASE_AUCTION = `${BASE_URL_Auction}api/auction/proceedToPurchase` const PURCHASE_AUCTION = `${BASE_URL_Auction}api/auction/purchaseAuction` const PURCHASE_OFFLINE_AUCTION = `${BASE_URL_Auction}api/auction/purchaseAuctionOffline` @@ -83,6 +84,7 @@ const SUBMIT_ENVELOPE_FILE_B = `${BASE_URL}tenderBidding/addDocumentsEnvelopeB?r export { // Rohit + PURCHASE_AUCTION_PAGE, VIEW_AUCTION_ITEM_DETAIL, AUCTION_ITEM_DOCUMENT_DOWNLOAD, AUCTION_DOCUMENT_DOWNLOAD, diff --git a/src/Services/BBPS/Hooks.ts b/src/Services/BBPS/Hooks.ts index 94ea64c..64645d3 100644 --- a/src/Services/BBPS/Hooks.ts +++ b/src/Services/BBPS/Hooks.ts @@ -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({ + 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({ queryKey: ['fetchLiveAuction'], diff --git a/src/Services/BBPS/apis.ts b/src/Services/BBPS/apis.ts index c82c2f8..951faea 100644 --- a/src/Services/BBPS/apis.ts +++ b/src/Services/BBPS/apis.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { AUCTION_DOCUMENT_DOWNLOAD, DASHBOARD_COUNT, EMD_CHECK, FORARD_AUCTION_ITEM, GET_AUCTION_DETAILS, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIVE_AUCTION, LIVE_TENDER, LOG_IN_URL, PROCEED_PURCHASE_AUCTION, PROCEED_TO_BID, PURCHASE_TENDER_OFFLINE, TENDER_LOGIN, PURCHASE_AUCTION_LIST, PURCHASE_OFFLINE_AUCTION, REVERSE_AUCTION_ITEM, VIEW_AUCTION_DOCUMENTS, VIEW_AUCTION_ITEM_DETAIL } from "./ApiUrls"; +import { AUCTION_DOCUMENT_DOWNLOAD, DASHBOARD_COUNT, EMD_CHECK, FORARD_AUCTION_ITEM, GET_AUCTION_DETAILS, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIVE_AUCTION, LIVE_TENDER, LOG_IN_URL, PROCEED_PURCHASE_AUCTION, PROCEED_TO_BID, PURCHASE_TENDER_OFFLINE, TENDER_LOGIN, PURCHASE_AUCTION_LIST, PURCHASE_OFFLINE_AUCTION, REVERSE_AUCTION_ITEM, VIEW_AUCTION_DOCUMENTS, VIEW_AUCTION_ITEM_DETAIL, PURCHASE_AUCTION_PAGE } from "./ApiUrls"; import { apiCall } from "../../Axios/Axios"; // User @@ -23,6 +23,11 @@ export const fetchPurchaseAuction = async (): Promise => { const data = await apiCall('get', `${GET_MY_AUCTION}`); return data } +export const fetchPurchaseAuctionPage = async (payload: any): Promise => { + const data = await apiCall('get', `${PURCHASE_AUCTION_PAGE}`, {}, payload); + return data +} + export const fetchLiveAuction = async (payload: any): Promise => { const data = await apiCall('get', `${LIVE_AUCTION}`, {}, payload); return data