commit
This commit is contained in:
+41
-25
@@ -4,7 +4,7 @@ import Animated, { useSharedValue, useAnimatedStyle, withDelay, withTiming } fro
|
||||
import { Layers, Clock, ShoppingCart, X, FileText } from 'lucide-react-native';
|
||||
import { Header } from '../../Component/Index';
|
||||
import colors from '../../Constant/Color';
|
||||
import { useDashboard, useESetuAdharVarification } from '../../Services/BBPS/Hooks';
|
||||
import { useDashboard, useESetuAdharVarification, useTenderDashboard } from '../../Services/BBPS/Hooks';
|
||||
import { useSelector } from 'react-redux';
|
||||
import ConfirmDialog from '../../Constant/Dialog/ConfirmDialog';
|
||||
import { generateTransactionId } from '../../Helper/uniqueId';
|
||||
@@ -62,13 +62,16 @@ const StatCard = ({ item, index, isLoading }: any) => {
|
||||
|
||||
const Home = () => {
|
||||
const { data, isLoading } = useDashboard();
|
||||
const { data: tenderData, isLoading: tenderLoading } = useTenderDashboard();
|
||||
|
||||
const Navigation: any = useNavigation();
|
||||
const user = useSelector((state: any) => state.token?.token);
|
||||
const { mutateAsync: eSetuAdharVarification, isPending } = useESetuAdharVarification();
|
||||
const dashboard = data?.data || {};
|
||||
const [showDialog, setShowDialog] = useState<boolean>(false);
|
||||
const [isNavigating, setIsNavigating] = useState<boolean>(false);
|
||||
useFocusEffect(()=>{
|
||||
const [DASHBOARD_CARDS,setDASHBOARD_CARDS]=useState<any>([])
|
||||
useFocusEffect(() => {
|
||||
setIsNavigating(false)
|
||||
})
|
||||
useEffect(() => {
|
||||
@@ -80,7 +83,7 @@ const Home = () => {
|
||||
const handleProceedVerification = async () => {
|
||||
try {
|
||||
setIsNavigating(true);
|
||||
|
||||
|
||||
const payload = {
|
||||
contId: user.id,
|
||||
transactionId: generateTransactionId(),
|
||||
@@ -91,84 +94,95 @@ const Home = () => {
|
||||
};
|
||||
|
||||
console.log("Payload:", payload);
|
||||
|
||||
|
||||
const res = await eSetuAdharVarification(payload);
|
||||
console.log("Verification response:", res);
|
||||
|
||||
|
||||
setShowDialog(false);
|
||||
|
||||
|
||||
Navigation.navigate(NavigationString.KycWebViewScreen, { res });
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log("Verification error:", err);
|
||||
Alert.alert('Error', 'Failed to initiate verification. Please try again.');
|
||||
setIsNavigating(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const DASHBOARD_CARDS = [
|
||||
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if (user?.userType === "auction") {
|
||||
setDASHBOARD_CARDS([
|
||||
{
|
||||
title: 'Total Auctions',
|
||||
value: dashboard.myAuctionCount ?? 0,
|
||||
value: dashboard?.myAuctionCount ?? 0,
|
||||
desc: 'Auctions purchased by you',
|
||||
icon: Layers,
|
||||
color: '#2563EB',
|
||||
},
|
||||
{
|
||||
title: 'Live Auctions',
|
||||
value: dashboard.liveAuctionCount ?? 0,
|
||||
value: dashboard?.liveAuctionCount ?? 0,
|
||||
desc: 'Currently live',
|
||||
icon: Clock,
|
||||
color: '#0284C7',
|
||||
},
|
||||
{
|
||||
title: 'Participated Auctions',
|
||||
value: dashboard.currentBiddingCount ?? 0,
|
||||
value: dashboard?.currentBiddingCount ?? 0,
|
||||
desc: 'Participated in auction',
|
||||
icon: ShoppingCart,
|
||||
color: '#7C3AED',
|
||||
},
|
||||
{
|
||||
title: 'Cancelled Auctions',
|
||||
value: dashboard.cancelledAuctionCount ?? 0,
|
||||
value: dashboard?.cancelledAuctionCount ?? 0,
|
||||
desc: 'Cancelled by department',
|
||||
icon: X,
|
||||
color: '#DC2626',
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
setDASHBOARD_CARDS([
|
||||
{
|
||||
title: 'Total Tenders',
|
||||
value: 0,
|
||||
value: tenderData?.data?.[0]?.totalTender ?? 0,
|
||||
desc: 'Tenders assigned',
|
||||
icon: FileText,
|
||||
color: '#16A34A',
|
||||
},
|
||||
{
|
||||
title: 'Live Tenders',
|
||||
value: 0,
|
||||
value: tenderData?.data?.[0]?.liveTender ?? 0,
|
||||
desc: 'Currently live',
|
||||
icon: Clock,
|
||||
color: '#059669',
|
||||
},
|
||||
{
|
||||
title: 'Participated Tenders',
|
||||
value: 0,
|
||||
value: tenderData?.data?.[0]?.totalParticipate ?? 0,
|
||||
desc: 'Participated in tender',
|
||||
icon: ShoppingCart,
|
||||
color: '#0EA5E9',
|
||||
},
|
||||
{
|
||||
title: 'Cancelled Tenders',
|
||||
value: 0,
|
||||
value: tenderData?.data?.[0]?.cancelledTender ?? 0,
|
||||
desc: 'Cancelled by authority',
|
||||
icon: X,
|
||||
color: '#EF4444',
|
||||
},
|
||||
];
|
||||
]);
|
||||
}
|
||||
},[tenderData,dashboard])
|
||||
|
||||
return (
|
||||
<View style={styles.screen}>
|
||||
<Header title="Dashboard" />
|
||||
|
||||
|
||||
<ConfirmDialog
|
||||
visible={showDialog}
|
||||
title="Aadhaar Verification Required"
|
||||
@@ -193,13 +207,15 @@ const Home = () => {
|
||||
numColumns={2}
|
||||
columnWrapperStyle={styles.row}
|
||||
contentContainerStyle={styles.list}
|
||||
renderItem={({ item, index }) => (
|
||||
<StatCard
|
||||
item={item}
|
||||
index={index}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
)}
|
||||
renderItem={({ item, index }) => {
|
||||
return (
|
||||
<StatCard
|
||||
item={item}
|
||||
index={index}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user