|
|
@@ -21,11 +21,8 @@ import { chargeStationService } from '../../service/chargeStationService';
|
|
|
|
|
|
const chooseCarPageComponent = () => {
|
|
|
const [isChecked, setChecked] = useState(false);
|
|
|
- const { height: deviceHeight, width: deviceWidth } =
|
|
|
- Dimensions.get('window');
|
|
|
- const [brandNameDropdownOptions, setBrandNameDropdownOptions] = useState(
|
|
|
- []
|
|
|
- );
|
|
|
+ const { height: deviceHeight, width: deviceWidth } = Dimensions.get('window');
|
|
|
+ const [brandNameDropdownOptions, setBrandNameDropdownOptions] = useState([]);
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
const [licensePlate, setLicensePlate] = useState('');
|
|
|
const [selectedBrandID, setSelectedBrandID] = useState('');
|
|
|
@@ -43,12 +40,7 @@ const chooseCarPageComponent = () => {
|
|
|
const handleSubmit = async () => {
|
|
|
setIsLoading(true);
|
|
|
try {
|
|
|
- const result = await chargeStationService.addCar(
|
|
|
- licensePlate,
|
|
|
- selectedBrandID,
|
|
|
- selectedTypeID,
|
|
|
- isChecked
|
|
|
- );
|
|
|
+ const result = await chargeStationService.addCar(licensePlate, selectedBrandID, selectedTypeID, isChecked);
|
|
|
if (result) {
|
|
|
router.push({
|
|
|
pathname: 'addVehicleSuccessfulPage',
|
|
|
@@ -92,9 +84,7 @@ const chooseCarPageComponent = () => {
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (selectedBrandID) {
|
|
|
- const selectedBrand = brandData.find(
|
|
|
- (brand) => brand.id === selectedBrandID
|
|
|
- );
|
|
|
+ const selectedBrand = brandData.find((brand) => brand.id === selectedBrandID);
|
|
|
|
|
|
if (selectedBrand && selectedBrand.car_types) {
|
|
|
const typeOptions = selectedBrand.car_types.map((carType) => ({
|
|
|
@@ -111,14 +101,8 @@ const chooseCarPageComponent = () => {
|
|
|
}, [selectedBrandID, brandData]);
|
|
|
|
|
|
return (
|
|
|
- <SafeAreaView
|
|
|
- className="flex-1 bg-white"
|
|
|
- edges={['top', 'right', 'left']}
|
|
|
- >
|
|
|
- <ScrollView
|
|
|
- showsVerticalScrollIndicator={false}
|
|
|
- className="flex-1 mx-[5%]"
|
|
|
- >
|
|
|
+ <SafeAreaView className="flex-1 bg-white" edges={['top', 'right', 'left']}>
|
|
|
+ <ScrollView showsVerticalScrollIndicator={false} className="flex-1 mx-[5%]">
|
|
|
<View style={{ marginTop: 25 }}>
|
|
|
<Pressable
|
|
|
className="self-start"
|
|
|
@@ -180,12 +164,13 @@ const chooseCarPageComponent = () => {
|
|
|
<TextInput
|
|
|
style={styles.fakeTextInput}
|
|
|
onChangeText={(text) => {
|
|
|
- setLicensePlate(text);
|
|
|
+ setLicensePlate(text.toUpperCase());
|
|
|
// console.log(licensePlate);
|
|
|
}}
|
|
|
value={licensePlate}
|
|
|
placeholder="車輛牌照號碼"
|
|
|
placeholderTextColor="#888"
|
|
|
+ autoCapitalize="characters"
|
|
|
/>
|
|
|
</View>
|
|
|
|