interface CarModel { name: string; year: number; id: string; } import React, { useEffect, useState } from 'react'; import { View, Text, Image, Pressable, StyleSheet, ScrollView } from 'react-native'; import { FlashList } from '@shopify/flash-list'; import { router, useLocalSearchParams } from 'expo-router'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useNavigation } from '@react-navigation/native'; import { set } from 'date-fns'; import useVehicleStore from '../../providers/vehicle_store'; import { PreviousPageBlackSvg } from '../../component/global/SVG'; interface CarType { id: number; name: string; } const RegisterChooseVehiclesTwo = () => { const { brandId, brandName, carTypes } = useLocalSearchParams<{ brandId: string; brandName: string; carTypes: string; }>(); const [parsedCarTypes, setParsedCarTypes] = useState([]); useEffect(() => { if (carTypes) { const parsed = JSON.parse(carTypes); setParsedCarTypes(parsed); } }, [carTypes]); const { vehicleBrand, vehicleModel, BrandID, ModelID, licensePlate, setVehicleBrand, setVehicleModel, setBrandID, setModelID, setLicensePlate } = useVehicleStore(); const logoPath = `../../../../../assets/${vehicleBrand.toLowerCase()}.png`; const [carModels, setCarModels] = useState([]); const navigation = useNavigation(); const renderModelItem = ({ item: model }: { item: CarModel }) => ( <> { setVehicleModel(model.name); setModelID(model.id); navigation.pop(2); }} > {model.year} {model.name} ); return ( { if (router.canGoBack()) { router.back(); } else { router.replace('/accountMainPage'); } }} > 選擇車輛型號 {/* */} {vehicleBrand} item.name} numColumns={1} /> ); }; const styles = StyleSheet.create({ modelItem: { flex: 1, height: 100, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F0F0F0', margin: 5, borderRadius: 10 }, modelName: { fontSize: 16, fontWeight: 'bold' }, modelYear: { fontSize: 14, color: '#666' } }); export default RegisterChooseVehiclesTwo;