|
@@ -6,12 +6,16 @@ import { useEffect, useMemo, useState, useRef } from 'react';
|
|
|
import { chargeStationService } from '../../service/chargeStationService';
|
|
import { chargeStationService } from '../../service/chargeStationService';
|
|
|
import { ChargingDetails, Remark, ElectricityPrice, Special } from '../../service/type/chargeStationType';
|
|
import { ChargingDetails, Remark, ElectricityPrice, Special } from '../../service/type/chargeStationType';
|
|
|
import { format, parseISO } from 'date-fns';
|
|
import { format, parseISO } from 'date-fns';
|
|
|
|
|
+import { useTranslation } from '../../util/hooks/useTranslation';
|
|
|
|
|
+
|
|
|
const ChargingDetailsPageComponent = () => {
|
|
const ChargingDetailsPageComponent = () => {
|
|
|
const screenHeight = Dimensions.get('window').height;
|
|
const screenHeight = Dimensions.get('window').height;
|
|
|
const params = useLocalSearchParams();
|
|
const params = useLocalSearchParams();
|
|
|
const [list, setList] = useState<ChargingDetails>({} as ChargingDetails);
|
|
const [list, setList] = useState<ChargingDetails>({} as ChargingDetails);
|
|
|
const [remark, setRemark] = useState<Remark>({} as Remark);
|
|
const [remark, setRemark] = useState<Remark>({} as Remark);
|
|
|
const [time, setTime] = useState<string>('');
|
|
const [time, setTime] = useState<string>('');
|
|
|
|
|
+ const { t } = useTranslation();
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const fetchData = async () => {
|
|
const fetchData = async () => {
|
|
|
const res = await chargeStationService.fetchChargingDetails(params.id.toString())
|
|
const res = await chargeStationService.fetchChargingDetails(params.id.toString())
|
|
@@ -40,13 +44,14 @@ const ChargingDetailsPageComponent = () => {
|
|
|
// 格式化为指定格式
|
|
// 格式化为指定格式
|
|
|
formattedDate = `${format(startTime, 'yyyy/MM/dd HH:mm:ss')}-${format(endTime, 'HH:mm:ss')}`;
|
|
formattedDate = `${format(startTime, 'yyyy/MM/dd HH:mm:ss')}-${format(endTime, 'HH:mm:ss')}`;
|
|
|
} else {
|
|
} else {
|
|
|
- formattedDate = 'Invalid Time';
|
|
|
|
|
|
|
+ formattedDate = t('chargingHistory.charging_details.invalid_time');
|
|
|
}
|
|
}
|
|
|
setTime(formattedDate)
|
|
setTime(formattedDate)
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
fetchData();
|
|
fetchData();
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
+
|
|
|
const totalPrice = useMemo(() => {
|
|
const totalPrice = useMemo(() => {
|
|
|
if (list.promotion_name) {
|
|
if (list.promotion_name) {
|
|
|
const price = list?.connector?.EquipmentID?.StationID?.price
|
|
const price = list?.connector?.EquipmentID?.StationID?.price
|
|
@@ -63,12 +68,14 @@ const ChargingDetailsPageComponent = () => {
|
|
|
return '0';
|
|
return '0';
|
|
|
}
|
|
}
|
|
|
}, [list]);
|
|
}, [list]);
|
|
|
|
|
+
|
|
|
const couponPrice = useMemo(() => {
|
|
const couponPrice = useMemo(() => {
|
|
|
if (list.promotion_name) {
|
|
if (list.promotion_name) {
|
|
|
let actual_fee = (list.total_fee - list.withdraw_fee) > 0 ? (list.total_fee - list.withdraw_fee) : 0;
|
|
let actual_fee = (list.total_fee - list.withdraw_fee) > 0 ? (list.total_fee - list.withdraw_fee) : 0;
|
|
|
return actual_fee.toFixed(1)
|
|
return actual_fee.toFixed(1)
|
|
|
}
|
|
}
|
|
|
}, [list])
|
|
}, [list])
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<SafeAreaView className="flex-1 bg-white" edges={['top']}>
|
|
<SafeAreaView className="flex-1 bg-white" edges={['top']}>
|
|
|
<ScrollView>
|
|
<ScrollView>
|
|
@@ -82,6 +89,7 @@ const ChargingDetailsPageComponent = () => {
|
|
|
router.replace('/accountMainPage');
|
|
router.replace('/accountMainPage');
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
|
|
+ className='ml-2'
|
|
|
>
|
|
>
|
|
|
<CrossLogoSvg />
|
|
<CrossLogoSvg />
|
|
|
</Pressable>
|
|
</Pressable>
|
|
@@ -97,20 +105,20 @@ const ChargingDetailsPageComponent = () => {
|
|
|
<Text style={styles.totalPrice}>{list.promotion_name? couponPrice:totalPrice}</Text>
|
|
<Text style={styles.totalPrice}>{list.promotion_name? couponPrice:totalPrice}</Text>
|
|
|
<View style={styles.viewLine}></View>
|
|
<View style={styles.viewLine}></View>
|
|
|
<View className='w-full flex-row justify-between mt-6'>
|
|
<View className='w-full flex-row justify-between mt-6'>
|
|
|
- <Text style={styles.leftLable}>訂單编號: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.order_number')}: </Text>
|
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
|
<Text style={styles.rightLable}>{list.format_order_id}</Text>
|
|
<Text style={styles.rightLable}>{list.format_order_id}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
|
- <Text style={styles.leftLable}>充電時間: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.charging_time')}: </Text>
|
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
|
<Text style={styles.rightLable}>{time}</Text>
|
|
<Text style={styles.rightLable}>{time}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between mb-4'>
|
|
<View className='w-full flex-row justify-between mb-4'>
|
|
|
- <Text style={styles.leftLable}>充電站位置:</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.charging_station')}:</Text>
|
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
<View style={{ flex: 1, marginLeft: 5 }}>
|
|
|
<Text style={styles.rightLable}>{params.chargeStationName}</Text>
|
|
<Text style={styles.rightLable}>{params.chargeStationName}</Text>
|
|
|
</View>
|
|
</View>
|
|
@@ -120,8 +128,8 @@ const ChargingDetailsPageComponent = () => {
|
|
|
<View style={styles.viewLine}></View>
|
|
<View style={styles.viewLine}></View>
|
|
|
<View className='w-full flex-row justify-between mt-6'>
|
|
<View className='w-full flex-row justify-between mt-6'>
|
|
|
<View>
|
|
<View>
|
|
|
- <Text style={styles.leftLable}>實付:</Text>
|
|
|
|
|
- {list.promotion_name ? <Text style={{fontSize: 12, color:'#888888'}}>優惠券支付</Text>: null}
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.amount_paid')}:</Text>
|
|
|
|
|
+ {list.promotion_name ? <Text style={{fontSize: 12, color:'#888888'}}>{t('chargingHistory.charging_details.coupon_payment')}</Text>: null}
|
|
|
</View>
|
|
</View>
|
|
|
<Text style={styles.rightLable}>${list.promotion_name? couponPrice:totalPrice}</Text>
|
|
<Text style={styles.rightLable}>${list.promotion_name? couponPrice:totalPrice}</Text>
|
|
|
</View>
|
|
</View>
|
|
@@ -132,11 +140,13 @@ const ChargingDetailsPageComponent = () => {
|
|
|
</SafeAreaView>
|
|
</SafeAreaView>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
interface ChargingDataComponentProps {
|
|
interface ChargingDataComponentProps {
|
|
|
list: ChargingDetails;
|
|
list: ChargingDetails;
|
|
|
totalPrice: string;
|
|
totalPrice: string;
|
|
|
remark: Remark;
|
|
remark: Remark;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
list,
|
|
list,
|
|
|
totalPrice,
|
|
totalPrice,
|
|
@@ -146,6 +156,8 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
const [rush, setRush] = useState<Special>({} as Special)
|
|
const [rush, setRush] = useState<Special>({} as Special)
|
|
|
const [elses, setElses ] = useState<Special>({} as Special)
|
|
const [elses, setElses ] = useState<Special>({} as Special)
|
|
|
const [off, setOff] = useState<Special>({} as Special)
|
|
const [off, setOff] = useState<Special>({} as Special)
|
|
|
|
|
+ const { t } = useTranslation();
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!list.promotion_name && !hasFetchedPrice.current && list.actual_start_time) {
|
|
if (!list.promotion_name && !hasFetchedPrice.current && list.actual_start_time) {
|
|
|
chargeStationService.fetchElectricityPrice(list.pricemodel_id || 'a').then(res => {
|
|
chargeStationService.fetchElectricityPrice(list.pricemodel_id || 'a').then(res => {
|
|
@@ -176,15 +188,15 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
{(remark.RushKwh) ?
|
|
{(remark.RushKwh) ?
|
|
|
<View>
|
|
<View>
|
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
|
- <Text style={styles.leftLable}>峰時總電量: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.peak_electricity')}: </Text>
|
|
|
<Text style={styles.rightLable}>{remark.RushKwh?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>{remark.RushKwh?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
|
- <Text style={styles.leftLable}>峰時電價({rush.from}-{rush.to}):</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.peak_rate')}({rush.from}-{rush.to}):</Text>
|
|
|
<Text style={styles.rightLable}>${rush.price}</Text>
|
|
<Text style={styles.rightLable}>${rush.price}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
|
- <Text style={styles.leftLable}>峰時總電費:</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.peak_fee')}:</Text>
|
|
|
|
|
|
|
|
<Text style={styles.rightLable}>${remark.RushCharge?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>${remark.RushCharge?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
@@ -192,16 +204,16 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
{(remark.ElseKwh) ?
|
|
{(remark.ElseKwh) ?
|
|
|
<View>
|
|
<View>
|
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
|
- <Text style={styles.leftLable}>平時總電量: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.flat_electricity')}: </Text>
|
|
|
<Text style={styles.rightLable}>{remark.ElseKwh?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>{remark.ElseKwh?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
|
- <Text style={styles.leftLable}>平時電價({elses.from}-{elses.to}):</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.flat_rate')}({elses.from}-{elses.to}):</Text>
|
|
|
|
|
|
|
|
<Text style={styles.rightLable}>${elses.price}</Text>
|
|
<Text style={styles.rightLable}>${elses.price}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
|
- <Text style={styles.leftLable}>平時總電費:</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.flat_fee')}:</Text>
|
|
|
|
|
|
|
|
<Text style={styles.rightLable}>${remark.ElseCharge?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>${remark.ElseCharge?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
@@ -209,15 +221,15 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
{(remark.OffKwh) ?
|
|
{(remark.OffKwh) ?
|
|
|
<View>
|
|
<View>
|
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
|
- <Text style={styles.leftLable}>穀時總電量: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.valley_electricity')}: </Text>
|
|
|
<Text style={styles.rightLable}>{remark.OffKwh?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>{remark.OffKwh?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
|
- <Text style={styles.leftLable}>穀時電價({off.from}-{off.to}): </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.valley_rate')}({off.from}-{off.to}): </Text>
|
|
|
<Text style={styles.rightLable}>${off.price}</Text>
|
|
<Text style={styles.rightLable}>${off.price}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
|
- <Text style={styles.leftLable}>穀時總電費:</Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.valley_fee')}:</Text>
|
|
|
<Text style={styles.rightLable}>${remark.OffCharge?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>${remark.OffCharge?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
</View>: null }
|
|
</View>: null }
|
|
@@ -227,15 +239,15 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
return (
|
|
return (
|
|
|
<View>
|
|
<View>
|
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
<View className='w-full flex-row justify-between mt-4'>
|
|
|
- <Text style={styles.leftLable}>總電量: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.total_electricity')}: </Text>
|
|
|
<Text style={styles.rightLable}>{remark.TotalPower?.toFixed(1)}</Text>
|
|
<Text style={styles.rightLable}>{remark.TotalPower?.toFixed(1)}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
<View className='w-full flex-row justify-between my-3'>
|
|
|
- <Text style={styles.leftLable}>電價: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.electricity_rate')}: </Text>
|
|
|
<Text style={styles.rightLable}>${list?.connector?.EquipmentID?.StationID?.price}</Text>
|
|
<Text style={styles.rightLable}>${list?.connector?.EquipmentID?.StationID?.price}</Text>
|
|
|
</View>
|
|
</View>
|
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
<View className='w-full flex-row justify-between mb-3'>
|
|
|
- <Text style={styles.leftLable}>總電費: </Text>
|
|
|
|
|
|
|
+ <Text style={styles.leftLable}>{t('chargingHistory.charging_details.total_fee')}: </Text>
|
|
|
|
|
|
|
|
<Text style={styles.rightLable}>${totalPrice}</Text>
|
|
<Text style={styles.rightLable}>${totalPrice}</Text>
|
|
|
</View>
|
|
</View>
|
|
@@ -244,6 +256,7 @@ const ChargingDataComponent: React.FC<ChargingDataComponentProps> = ({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|
|
|
viewLine: {
|
|
viewLine: {
|
|
|
width: '100%',
|
|
width: '100%',
|
|
@@ -266,4 +279,5 @@ const styles = StyleSheet.create({
|
|
|
textAlign: 'right',
|
|
textAlign: 'right',
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
-export default ChargingDetailsPageComponent;
|
|
|
|
|
|
|
+
|
|
|
|
|
+export default ChargingDetailsPageComponent;
|