import React, { useEffect, useState } from 'react'; import { View, Text, ScrollView, TouchableOpacity } from 'react-native'; import { useAppTheme } from '@theme'; import { OrderCard, EmptyState } from '@components'; import { useAppDispatch, useAppSelector } from '@store'; import { ClipboardIcon } from '@icons'; import { getStyles } from './jobsScreen.styles'; import { getAllActiveDeliveries } from './thunk'; import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { AppStackParamList } from '@navigation/navigationTypes'; import { RouteNames } from '@utils/constants'; export const JobsScreen: React.FC = () => { const navigation = useNavigation>(); const { colors } = useAppTheme(); const styles = getStyles(colors); const dispatch = useAppDispatch(); const [activeTab, setActiveTab] = useState<'active' | 'history'>('active'); const { activeJob, jobHistory } = useAppSelector(state => state.job); const { activeDeliveries } = useAppSelector(state => state.deliveries); useEffect(() => { dispatch(getAllActiveDeliveries()); }, [dispatch]); // Default history mock jobs const defaultHistory = [ { pickupName: 'Cafe Coffee Day', pickupAddress: 'MG Road, Bengaluru', dropName: 'Rohit Sharma', dropAddress: 'Koramangala 4th Block, Bengaluru', amount: '78.0', distance: '1.2', itemCount: 2, paymentType: 'online', }, { pickupName: 'Pizza Hut', pickupAddress: 'Indiranagar, Bengaluru', dropName: 'Aishwarya Sen', dropAddress: 'Domlur Stage 2, Bengaluru', amount: '95.0', distance: '3.8', itemCount: 3, paymentType: 'cod', }, { pickupName: 'Burgers & Co', pickupAddress: 'Koramangala 5th Block', dropName: 'Sameer Khan', dropAddress: 'HSR Layout Sector 3, Bengaluru', amount: '110.0', distance: '4.5', itemCount: 1, paymentType: 'online', }, ]; return ( Jobs {/* Tabs Selector */} setActiveTab('active')} > Active / Upcoming setActiveTab('history')} > History {activeTab === 'active' ? ( // Active job tab activeDeliveries ? ( navigation.navigate(RouteNames.ArrivedAtStore, { jobId: activeDeliveries?.orderId, }) } /> ) : ( No active deliveries right now ) ) : ( // History tab {jobHistory.length > 0 ? jobHistory.map((job, idx) => ( )) : defaultHistory.map((job, idx) => ( ))} )} ); }; export default JobsScreen;