|
@@ -117,87 +117,6 @@ const HomePage: React.FC<HomePageProps> = () => {
|
|
|
};
|
|
};
|
|
|
fetchWithAllSettled();
|
|
fetchWithAllSettled();
|
|
|
}, []);
|
|
}, []);
|
|
|
- // useEffect(() => {
|
|
|
|
|
- // // Set to light mode on component mount
|
|
|
|
|
- // if (colorScheme === 'dark') {
|
|
|
|
|
- // toggleColorScheme();
|
|
|
|
|
- // }
|
|
|
|
|
- // }, []);
|
|
|
|
|
-
|
|
|
|
|
- // useEffect(() => {
|
|
|
|
|
- // const fetchCurrentPrice = async () => {
|
|
|
|
|
- // try {
|
|
|
|
|
- // const response = await chargeStationService.getCurrentPrice();
|
|
|
|
|
- // if (response) {
|
|
|
|
|
- // // console.log('main page fetch current price', response);
|
|
|
|
|
- // setCurrentPrice(response);
|
|
|
|
|
- // }
|
|
|
|
|
- // } catch (error) {
|
|
|
|
|
- // console.log('main page fetch current price error', error);
|
|
|
|
|
- // }
|
|
|
|
|
- // };
|
|
|
|
|
- // fetchCurrentPrice();
|
|
|
|
|
- // }, []);
|
|
|
|
|
-
|
|
|
|
|
- // Add new state for modal visibility
|
|
|
|
|
-
|
|
|
|
|
- // useEffect(() => {
|
|
|
|
|
- // const fetchMainPromotion = async () => {
|
|
|
|
|
- // try {
|
|
|
|
|
- // const response = await chargeStationService.getAdvertise();
|
|
|
|
|
- // if (response) {
|
|
|
|
|
- // const mainPromo = response.filter((item: any) => item.is_main)[0];
|
|
|
|
|
- // setMainPromotion(mainPromo);
|
|
|
|
|
-
|
|
|
|
|
- // if (mainPromo) {
|
|
|
|
|
- // const mainPromoImage = await chargeStationService.getProcessedImageUrl(mainPromo.image_url);
|
|
|
|
|
- // if (mainPromoImage) {
|
|
|
|
|
- // setMainPromotionImage(mainPromoImage);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // } catch (error) {
|
|
|
|
|
- // console.log('Error fetching promotion:', error);
|
|
|
|
|
- // }
|
|
|
|
|
- // };
|
|
|
|
|
- // fetchMainPromotion();
|
|
|
|
|
- // }, []);
|
|
|
|
|
-
|
|
|
|
|
- // useFocusEffect(
|
|
|
|
|
- // useCallback(() => {
|
|
|
|
|
- // let isActive = true;
|
|
|
|
|
-
|
|
|
|
|
- // const fetchData = async () => {
|
|
|
|
|
- // setIsLoadingReservations(true); // Start loading
|
|
|
|
|
- // try {
|
|
|
|
|
- // const response = await chargeStationService.fetchReservationHistories();
|
|
|
|
|
- // if (!isActive) return; // Don't update state if component is unfocused
|
|
|
|
|
-
|
|
|
|
|
- // if (response) {
|
|
|
|
|
- // const year2025 = new Date('2025-02-01T00:00:00.000Z');
|
|
|
|
|
- // const reservationAfter2025 = response.filter((r: any) => {
|
|
|
|
|
- // const date = new Date(r.createdAt);
|
|
|
|
|
- // return date > year2025;
|
|
|
|
|
- // });
|
|
|
|
|
- // setReservationAfter2025(reservationAfter2025);
|
|
|
|
|
- // }
|
|
|
|
|
- // } catch (error) {
|
|
|
|
|
- // if (!isActive) return;
|
|
|
|
|
- // Alert.alert('error fetching reservation');
|
|
|
|
|
- // } finally {
|
|
|
|
|
- // if (isActive) {
|
|
|
|
|
- // setIsLoadingReservations(false); // End loading
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // };
|
|
|
|
|
-
|
|
|
|
|
- // fetchData();
|
|
|
|
|
-
|
|
|
|
|
- // return () => {
|
|
|
|
|
- // isActive = false;
|
|
|
|
|
- // };
|
|
|
|
|
- // }, [])
|
|
|
|
|
- // );
|
|
|
|
|
|
|
|
|
|
useFocusEffect(
|
|
useFocusEffect(
|
|
|
useCallback(() => {
|
|
useCallback(() => {
|
|
@@ -409,7 +328,7 @@ const HomePage: React.FC<HomePageProps> = () => {
|
|
|
<View className="pl-2 flex-1 flex-column ">
|
|
<View className="pl-2 flex-1 flex-column ">
|
|
|
<View className="flex-row justify-between mr-[10%]">
|
|
<View className="flex-row justify-between mr-[10%]">
|
|
|
<Text className="text-lg text-left pb-1">你好!</Text>
|
|
<Text className="text-lg text-left pb-1">你好!</Text>
|
|
|
- <View className="relative">
|
|
|
|
|
|
|
+ <View className="relative z-5">
|
|
|
<Pressable
|
|
<Pressable
|
|
|
onPress={() =>
|
|
onPress={() =>
|
|
|
router.push({
|
|
router.push({
|
|
@@ -422,7 +341,7 @@ const HomePage: React.FC<HomePageProps> = () => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
disabled={isLoadingReservations}
|
|
disabled={isLoadingReservations}
|
|
|
- className="z-20 w-10 items-center justify-center"
|
|
|
|
|
|
|
+ className="z-10 w-10 items-center justify-center"
|
|
|
hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
|
|
hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
|
|
|
>
|
|
>
|
|
|
<View className="w-6 h-6">
|
|
<View className="w-6 h-6">
|