Browse Source

small fix

Viktoriia 3 tuần trước cách đây
mục cha
commit
5269b18374

+ 25 - 3
src/screens/InAppScreens/TravelsScreen/EditCountryDataScreen/index.tsx

@@ -11,7 +11,11 @@ import { StoreType, storage } from 'src/storage';
 import { NmRegion } from '../utils/types';
 import { Colors } from 'src/theme';
 import { styles } from './styles';
-import { useGetRegionQeQuery, usePostSetTCCRegionMutation } from '@api/myRegions';
+import {
+  useGetRegionQeQuery,
+  useGetRegionsQuery,
+  usePostSetTCCRegionMutation
+} from '@api/myRegions';
 import { qualityOptions } from '../utils/constants';
 
 import { NAVIGATION_PAGES } from 'src/types';
@@ -30,7 +34,12 @@ const EditCountryDataScreen = ({ route }: { route: any }) => {
   const isSlowList = route?.params?.isSlowList;
 
   const token = storage.get('token', StoreType.STRING) as string;
-  const { data: regionsQe } = useGetRegionQeQuery(undefined, countryId, String(token), true);
+  const { data: regionsQe, refetch } = useGetRegionsQuery(
+    undefined,
+    countryId,
+    String(token),
+    true
+  );
   const [isEnabled11, setIsEnabled11] = useState(Boolean(slow11));
   const [isEnabled31, setIsEnabled31] = useState(Boolean(slow31));
   const [isEnabled101, setIsEnabled101] = useState(Boolean(slow101));
@@ -77,6 +86,7 @@ const EditCountryDataScreen = ({ route }: { route: any }) => {
   useFocusEffect(
     useCallback(() => {
       const refetchData = async () => {
+        refetch();
         await mutateCountriesData(
           { id: countryId, token },
           {
@@ -130,7 +140,19 @@ const EditCountryDataScreen = ({ route }: { route: any }) => {
 
   useEffect(() => {
     if (regionsQe && regionsQe.result === 'OK') {
-      setNmRegions(regionsQe.data.out_regs);
+      setNmRegions(
+        regionsQe.data.regions.map((region) => ({
+          id: region.id,
+          flag_1: region.flag1,
+          flag_2: region.flag2,
+          region_name: region.name,
+          essential: 0,
+          quality: region.best_visit_quality || null,
+          year: region.first_visited_in_year || null,
+          last: region.last_visited_in_year || null,
+          visits: region.no_of_visits || 0
+        }))
+      );
       setDataLoaded(true);
     }
   }, [regionsQe]);

+ 1 - 1
src/screens/InAppScreens/TravelsScreen/EditNmDataScreen/index.tsx

@@ -736,7 +736,7 @@ const EditNmDataScreen = ({ navigation, route }: { navigation: any; route: any }
         {visits.map(renderVisitItem)}
       </ScrollView>
 
-      <View style={styles.buttonContainer}>
+      <View style={[styles.buttonContainer, { marginBottom: 20 }]}>
         <Button onPress={handleSave} disabled={isLoading}>
           {isLoading ? 'Saving...' : 'Save'}
         </Button>