committed
This commit is contained in:
+79
-51
@@ -1,13 +1,15 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { View, Text, StyleSheet, Dimensions, FlatList, ActivityIndicator } from 'react-native';
|
||||
import { View, Text, StyleSheet, Dimensions, FlatList, ActivityIndicator, Alert } from 'react-native';
|
||||
import Animated, { useSharedValue, useAnimatedStyle, withDelay, withTiming } from 'react-native-reanimated';
|
||||
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 { log } from 'console';
|
||||
import { useSelector } from 'react-redux';
|
||||
import ConfirmDialog from '../../Constant/Dialog/ConfirmDialog';
|
||||
import { generateTransactionId } from '../../Helper/uniqueId';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import NavigationString from '../../Constant/NavigationString';
|
||||
|
||||
const { width } = Dimensions.get('window');
|
||||
const CARD_WIDTH = (width - 48) / 2;
|
||||
@@ -43,7 +45,6 @@ const StatCard = ({ item, index, isLoading }: any) => {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* VALUE / LOADER */}
|
||||
{isLoading ? (
|
||||
<ActivityIndicator
|
||||
size="small"
|
||||
@@ -61,34 +62,48 @@ const StatCard = ({ item, index, isLoading }: any) => {
|
||||
|
||||
const Home = () => {
|
||||
const { data, isLoading } = useDashboard();
|
||||
const Navigation: any = useNavigation();
|
||||
const user = useSelector((state: any) => state.token?.token);
|
||||
console.log("-=--",user)
|
||||
const { mutateAsync:eSetuAdharVarification } = useESetuAdharVarification();
|
||||
const { mutateAsync: eSetuAdharVarification, isPending } = useESetuAdharVarification();
|
||||
const dashboard = data?.data || {};
|
||||
const [esetu,setEsetu] = useState<boolean>();
|
||||
useEffect(()=>{
|
||||
if(user?.esetuVerified === 'Not Verified'){
|
||||
const payLoad= {
|
||||
contId: user,
|
||||
transactionId: "string",
|
||||
udf1: "string",
|
||||
udf2: "string",
|
||||
udf3: "string",
|
||||
udf4: "string",
|
||||
responseUrl: "string"
|
||||
}
|
||||
setEsetu(true)
|
||||
eSetuAdharVarification(payLoad, {
|
||||
onSuccess: (res) => {
|
||||
console.log(res)
|
||||
}, onError: (err) => {
|
||||
console.log(err, '-----auction item error');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
setEsetu(false)
|
||||
}
|
||||
},[user])
|
||||
const [showDialog, setShowDialog] = useState<boolean>(false);
|
||||
const [isNavigating, setIsNavigating] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.esetuVerified === 'Not Verified') {
|
||||
setShowDialog(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleProceedVerification = async () => {
|
||||
try {
|
||||
setIsNavigating(true);
|
||||
|
||||
const payload = {
|
||||
contId: user.id,
|
||||
transactionId: generateTransactionId(),
|
||||
udf1: "23.77",
|
||||
udf2: "77.34",
|
||||
udf3: "string",
|
||||
udf4: "string",
|
||||
responseUrl: "https://dev.procurelinc.in/"
|
||||
};
|
||||
|
||||
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 = [
|
||||
{
|
||||
@@ -119,7 +134,6 @@ console.log(res)
|
||||
icon: X,
|
||||
color: '#DC2626',
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Total Tenders',
|
||||
value: 0,
|
||||
@@ -153,18 +167,25 @@ console.log(res)
|
||||
return (
|
||||
<View style={styles.screen}>
|
||||
<Header title="Dashboard" />
|
||||
<ConfirmDialog
|
||||
visible={esetu as boolean}
|
||||
title="Aadhaar Verification Required"
|
||||
message="To access features, please complete your Aadhaar verification."
|
||||
confirmText="Proceed"
|
||||
cancelText="Cancel"
|
||||
onConfirm={() => {
|
||||
setEsetu(false);
|
||||
|
||||
<ConfirmDialog
|
||||
visible={showDialog}
|
||||
title="Aadhaar Verification Required"
|
||||
message="To access features, please complete your Aadhaar verification."
|
||||
confirmText={isPending || isNavigating ? "Processing..." : "Proceed"}
|
||||
cancelText="Cancel"
|
||||
onConfirm={handleProceedVerification}
|
||||
onClose={() => !isPending && !isNavigating && setShowDialog(false)}
|
||||
loading={isPending || isNavigating}
|
||||
/>
|
||||
|
||||
{isNavigating && (
|
||||
<View style={styles.navigationOverlay}>
|
||||
<ActivityIndicator size="large" color={colors.primary || '#2563EB'} />
|
||||
<Text style={styles.loadingText}>Loading verification...</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
}}
|
||||
onClose={() => setEsetu(false)}
|
||||
/>
|
||||
<FlatList
|
||||
data={DASHBOARD_CARDS}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
@@ -186,23 +207,19 @@ message="To access features, please complete your Aadhaar verification."
|
||||
|
||||
export default Home;
|
||||
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
screen: {
|
||||
flex: 1,
|
||||
backgroundColor: colors.white,
|
||||
},
|
||||
|
||||
list: {
|
||||
padding: 16,
|
||||
paddingBottom: 24,
|
||||
},
|
||||
|
||||
row: {
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: 16,
|
||||
},
|
||||
|
||||
card: {
|
||||
width: CARD_WIDTH,
|
||||
backgroundColor: '#FFFFFF',
|
||||
@@ -215,13 +232,11 @@ const styles = StyleSheet.create({
|
||||
shadowRadius: 8,
|
||||
elevation: 3,
|
||||
},
|
||||
|
||||
header: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'flex-start',
|
||||
},
|
||||
|
||||
title: {
|
||||
fontSize: 13,
|
||||
fontWeight: '600',
|
||||
@@ -229,7 +244,6 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
paddingRight: 8,
|
||||
},
|
||||
|
||||
badge: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
@@ -239,22 +253,36 @@ const styles = StyleSheet.create({
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 4,
|
||||
},
|
||||
|
||||
badgeText: {
|
||||
fontSize: 12,
|
||||
fontWeight: '700',
|
||||
},
|
||||
|
||||
value: {
|
||||
fontSize: 28,
|
||||
fontWeight: '800',
|
||||
color: '#111827',
|
||||
marginTop: 5,
|
||||
},
|
||||
|
||||
desc: {
|
||||
fontSize: 12,
|
||||
color: '#6B7280',
|
||||
marginTop: 6,
|
||||
},
|
||||
navigationOverlay: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.9)',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
zIndex: 999,
|
||||
},
|
||||
loadingText: {
|
||||
marginTop: 12,
|
||||
fontSize: 16,
|
||||
fontWeight: '600',
|
||||
color: '#374151',
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user