Ver código fonte

statistics nullable

Viktoriia 1 mês atrás
pai
commit
9121c21106

+ 1 - 1
src/modules/api/trips/trips-api.tsx

@@ -49,7 +49,7 @@ export interface PostGetTripsForYearReturn extends ResponseType {
         region: string;
       }[];
     };
-  };
+  } | null;
 }
 
 export interface RegionData {

+ 4 - 6
src/screens/InAppScreens/TravelsScreen/Trips2025Screen/index.tsx

@@ -99,16 +99,14 @@ const TripsScreen = ({ route }: { route: any }) => {
 
   useEffect(() => {
     if (tripsData && tripsData.trips) {
-      setStatistics(tripsData.statistics);
+      setStatistics(tripsData.statistics ?? null);
       setTrips(tripsData.trips);
     }
   }, [tripsData]);
 
   const renderItem = useCallback(
-    ({ item }: { item: TripsData }) => (
-      <TripItem item={item} isNew={Number(selectedYear) >= 2025} />
-    ),
-    [selectedYear]
+    ({ item }: { item: TripsData }) => <TripItem item={item} isNew={!!statistics} />,
+    [statistics]
   );
 
   const onAddNewTripPress = useCallback(() => {
@@ -173,7 +171,7 @@ const TripsScreen = ({ route }: { route: any }) => {
           contentContainerStyle={styles.tripsListContentContainer}
           showsVerticalScrollIndicator={false}
           ListHeaderComponent={
-            Number(selectedYear) >= 2025 ? (
+            statistics ? (
               <View
                 style={{
                   marginTop: 12,