import React, { useEffect } from 'react'; import { View, StyleSheet, Text } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import Ionicons from '@react-native-vector-icons/ionicons'; import Animated, { FadeInUp } from 'react-native-reanimated'; import { ScreenShell, Input, Button, KeyboardAwareScrollView } from '../../../components'; import { useTheme } from '../../../theme'; import { TAB_BAR_HEIGHT } from '../../../utils/layoutConstants'; import { useAppSelector } from '../../../app/hooks'; import { selectCustomerById } from '../store/agentSelectors'; import type { AgentCustomersStackParamList } from '../navigation/agentNavigationTypes'; import { useCustomerForm } from '../hooks/useCustomerForm'; type Props = NativeStackScreenProps; const FormSection = ({ title, icon, children }: { title: string, icon: string, children: React.ReactNode }) => { const theme = useTheme(); return ( {title} {children} ); }; export default function AddEditCustomerScreen({ route, navigation }: Props) { const { customerId } = route.params; const theme = useTheme(); const existingCustomer = useAppSelector(state => customerId ? selectCustomerById(customerId)(state) : null ); const { data, errors, updateField, submit, isSubmitting } = useCustomerForm(existingCustomer || undefined); const isEdit = !!existingCustomer; const handleSubmit = async () => { const res = await submit(); if (res) { navigation.goBack(); } }; return ( updateField('name', v)} error={errors.name} /> updateField('phone', v)} keyboardType="number-pad" maxLength={10} error={errors.phone} leftAccessory={+91} /> updateField('email', v)} keyboardType="email-address" autoCapitalize="none" error={errors.email} /> updateField('aadhaarNumber', v)} keyboardType="number-pad" maxLength={12} error={errors.aadhaarNumber} /> updateField('panNumber', v)} autoCapitalize="characters" maxLength={10} error={errors.panNumber} /> updateField('address', v)} error={errors.address} /> updateField('city', v)} error={errors.city} /> updateField('state', v)} error={errors.state} /> updateField('pincode', v)} keyboardType="number-pad" maxLength={6} error={errors.pincode} />