Browse Source

perf: 充电中不能访问订单详情

kuns 1 month ago
parent
commit
d768dd1d86
2 changed files with 31 additions and 13 deletions
  1. 3 1
      component/global/bookingTabViewComponent.tsx
  2. 28 12
      component/global/chargingRecord.tsx

+ 3 - 1
component/global/bookingTabViewComponent.tsx

@@ -114,7 +114,8 @@ const processReservations = (reservations: any [], allStations: string [], isFut
                 actual_fee: (reservation.total_fee || 0) - (reservation.withdraw_fee || 0),
                 current_price: snapshot_price?.current_price || 0,
                 total_power: reservation.total_power || 0,
-                id: reservation.id || ''
+                id: reservation.id || '',
+                status: reservation.status || {}
             } as TabItem;
         });
 };
@@ -152,6 +153,7 @@ const BookingTabViewComponentInner: React.FC<BookingTabViewComponentProps> = ({
     const completedReservations = processReservations(reservations, stations, false);
     const allReservationItems = [...futureReservations, ...completedReservations];
     // const allReservationItems = [...futureReservations];
+    console.log('All Reservation Items Processed:', allReservationItems);
     return (
         <TabViewComponent
             titles={titles}

+ 28 - 12
component/global/chargingRecord.tsx

@@ -33,6 +33,7 @@ export interface TabItem {
     actual_fee?: number;
     current_price?: number;
     id?: string;
+    status?: any
 }
 
 interface TabViewComponentProps {
@@ -167,18 +168,33 @@ const TabItem = ({ item, currentLocation }: { item: TabItem; currentLocation: Lo
                         {item.chargeStationName}
                     </Text>
                     <View className="flex flex-row space-x-2">
-                        <Text
-                            style={{
-                                fontWeight: '400',
-                                fontSize: 14,
-                                color: '#02677D'
-                            }}
-                            onPress={() => {
-                                router.push({ pathname: 'chargingDetailsPage', params: { id: item.id, chargeStationName: item.chargeStationName }})
-                            }}
-                        >
-                            訂單詳情 &gt;
-                        </Text>
+                        {
+                            item.status.id === 7 || item.status.id === 13? 
+                                <Text
+                                    style={{
+                                        fontWeight: '400',
+                                        fontSize: 14,
+                                        color: '#02677D'
+                                    }}
+                                >
+                                    訂單進行中
+                                </Text>
+                                : 
+                                <Text
+                                    style={{
+                                        fontWeight: '400',
+                                        fontSize: 14,
+                                        color: '#02677D'
+                                    }}
+                                    onPress={() => {
+                                        router.push({ pathname: 'chargingDetailsPage', params: { id: item.id, chargeStationName: item.chargeStationName }})
+                                    }}
+                                >
+                                    訂單詳情 &gt;
+                                </Text>
+    
+                            }
+                        
                     </View>
                 </View>
             </View>