import React, { useEffect } from 'react'; import { View, Text, ScrollView, Linking, Platform, } from 'react-native'; import { RouteProp, useRoute, useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { useTheme } from '@theme'; import { useAppDispatch, useAppSelector, RootState } from '@store'; import { getLeadDetails } from './thunk'; import { getStyles } from './leadDetails.styles'; import { LeadsStackParamList } from '../../navigation/leadsStack'; import { Loader, LeadDetailHeader, ActionCard } from '@components'; import { handleEmailPress, handlePhonePress } from '@utils'; import { route as routes } from '@utils'; type LeadDetailsRouteProp = RouteProp; type LeadDetailsNavigationProp = NativeStackNavigationProp< LeadsStackParamList, 'leadDetails' >; export const LeadDetailsScreen = () => { const route = useRoute(); const navigation = useNavigation(); const dispatch = useAppDispatch(); const { theme: colors } = useTheme(); const styles = getStyles(colors); // Get lead ID from route params const leadId = route.params?.lead?.id; // Get data from Redux store const { item: lead, loading, error } = useAppSelector( (state: RootState) => state.leadDetails, ); const user_data = useAppSelector((state: RootState) => state.auth.user_data); // Fetch lead details on mount useEffect(() => { if (leadId && user_data?.staffid) { dispatch(getLeadDetails({ leadId, staffid: user_data.staffid })); } }, [dispatch, leadId, user_data]); // Show loader while loading if (loading) { return ; } // Show error if any if (error) { return ( {error} ); } if (!lead) { return ( No lead data available ); } // Handle status press (for future status change functionality) const handleStatusPress = () => { // TODO: Show status list modal/picker console.log('Status pressed - show status list'); }; // Proposals handlers const handleAddProposal = () => { // TODO: Navigate to add proposal screen navigation.navigate(routes.leadProposals, { leadId: lead.id }); }; const handleViewAllProposals = () => { console.log('view Proposal pressed'); }; // Tasks handlers const handleAddTask = () => { // TODO: Navigate to add task screen navigation.navigate(routes.leadTasks, { leadId: lead.id }); }; const handleViewAllTasks = () => { console.log('view Add Task pressed'); }; // Notes handlers const handleAddNote = () => { // TODO: Navigate to add note screen navigation.navigate(routes.leadNotes, { leadId: lead.id }); }; const handleViewAllNotes = () => { console.log('view Add Note pressed'); }; return ( {/* Header with Avatar */} handleEmailPress(lead.email)} onPhonePress={() => handlePhonePress(lead.phonenumber)} /> {/* Action Cards Section */} ); };