|
@@ -3,6 +3,7 @@ import { ActivityIndicator, View, RefreshControl } from 'react-native';
|
|
|
import { useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
import TabViewComponent, { TabItem } from './chargingRecord';
|
|
import TabViewComponent, { TabItem } from './chargingRecord';
|
|
|
import { chargeStationService } from '../../service/chargeStationService';
|
|
import { chargeStationService } from '../../service/chargeStationService';
|
|
|
|
|
+import { useTranslation } from '../../util/hooks/useTranslation';
|
|
|
|
|
|
|
|
const queryClient = new QueryClient();
|
|
const queryClient = new QueryClient();
|
|
|
|
|
|
|
@@ -38,7 +39,8 @@ const fetchReservationsAndStations = async () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const processReservations = (reservations: any [], allStations: string [], isFuture: boolean): TabItem[] => {
|
|
|
|
|
|
|
+const processReservations = (reservations: any [], allStations: string [], isFuture: boolean, isEn: boolean): TabItem[] => {
|
|
|
|
|
+
|
|
|
// 确保参数是数组类型
|
|
// 确保参数是数组类型
|
|
|
const validReservations = Array.isArray(reservations) ? reservations : [];
|
|
const validReservations = Array.isArray(reservations) ? reservations : [];
|
|
|
const validStations = Array.isArray(allStations) ? allStations : [];
|
|
const validStations = Array.isArray(allStations) ? allStations : [];
|
|
@@ -98,7 +100,7 @@ const processReservations = (reservations: any [], allStations: string [], isFut
|
|
|
minute: '2-digit',
|
|
minute: '2-digit',
|
|
|
hour12: false
|
|
hour12: false
|
|
|
}),
|
|
}),
|
|
|
- chargeStationName: stationInfo?.snapshot?.StationName || 'Unknown Station',
|
|
|
|
|
|
|
+ chargeStationName: (isEn? stationInfo?.snapshoten?.StationName : stationInfo?.snapshot?.StationName) || 'Unknown Station',
|
|
|
chargeStationAddress: stationInfo?.snapshot?.Address || 'Unknown Address',
|
|
chargeStationAddress: stationInfo?.snapshot?.Address || 'Unknown Address',
|
|
|
stationLng: stationInfo?.snapshot?.StationLng || '',
|
|
stationLng: stationInfo?.snapshot?.StationLng || '',
|
|
|
stationLat: stationInfo?.snapshot?.StationLat || '',
|
|
stationLat: stationInfo?.snapshot?.StationLat || '',
|
|
@@ -116,6 +118,8 @@ const processReservations = (reservations: any [], allStations: string [], isFut
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
const BookingTabViewComponentInner: React.FC = () => {
|
|
const BookingTabViewComponentInner: React.FC = () => {
|
|
|
|
|
+ const { t, getCurrentLanguageConfig } = useTranslation(); // 使用翻译钩子
|
|
|
|
|
+ const isEn = getCurrentLanguageConfig()?.code === 'en';
|
|
|
const { data, isLoading, error } = useQuery({
|
|
const { data, isLoading, error } = useQuery({
|
|
|
queryKey: ['reservationsAndStations'],
|
|
queryKey: ['reservationsAndStations'],
|
|
|
queryFn: fetchReservationsAndStations,
|
|
queryFn: fetchReservationsAndStations,
|
|
@@ -145,8 +149,8 @@ const BookingTabViewComponentInner: React.FC = () => {
|
|
|
const reservations = Array.isArray(data?.reservations) ? data.reservations : [];
|
|
const reservations = Array.isArray(data?.reservations) ? data.reservations : [];
|
|
|
const stations = Array.isArray(data?.stations) ? data.stations : [];
|
|
const stations = Array.isArray(data?.stations) ? data.stations : [];
|
|
|
|
|
|
|
|
- const futureReservations = processReservations(reservations, stations, true);
|
|
|
|
|
- const completedReservations = processReservations(reservations, stations, false);
|
|
|
|
|
|
|
+ const futureReservations = processReservations(reservations, stations, true, isEn);
|
|
|
|
|
+ const completedReservations = processReservations(reservations, stations, false, isEn);
|
|
|
const allReservationItems = [...futureReservations, ...completedReservations];
|
|
const allReservationItems = [...futureReservations, ...completedReservations];
|
|
|
return (
|
|
return (
|
|
|
<TabViewComponent
|
|
<TabViewComponent
|