Ver código fonte

Merge branch 'names-fix' of Viktoriia/nomadmania-app into dev

Viktoriia 1 ano atrás
pai
commit
5fcd5f6ea7

+ 7 - 3
src/components/RegionPopup/index.tsx

@@ -8,6 +8,8 @@ import RotateSvg from 'assets/icons/travels-screens/rotate.svg';
 import { styles } from './style';
 import React from 'react';
 import { Colors } from 'src/theme';
+import { useNavigation } from '@react-navigation/native';
+import { NAVIGATION_PAGES } from 'src/types';
 
 interface Region {
   id: number;
@@ -36,6 +38,7 @@ const RegionPopup: React.FC<RegionPopupProps> = ({
   disabled
 }) => {
   const fadeAnim = useRef(new Animated.Value(0)).current;
+  const navigation = useNavigation();
 
   useEffect(() => {
     Animated.timing(fadeAnim, {
@@ -46,10 +49,11 @@ const RegionPopup: React.FC<RegionPopupProps> = ({
   }, [fadeAnim]);
 
   const splitRegionName = (fullName: string) => {
-    const parts = fullName.split(/ – | - /);
+    const [name, ...rest] = fullName?.split(/ – | - /);
+    const subname = rest?.join(' - ');
     return {
-      regionTitle: parts[0],
-      regionSubtitle: parts.length > 1 ? parts[1] : ''
+      regionTitle: name,
+      regionSubtitle: subname ? subname : ''
     };
   };
 

+ 4 - 3
src/screens/InAppScreens/MapScreen/UniversalSearch/index.tsx

@@ -39,7 +39,8 @@ const SearchModal = ({
   const [warningVisible, setWarningVisible] = useState(false);
 
   const renderItem = ({ item }: { item: any }) => {
-    const name = item.name?.split(/ – | - /);
+    const [name, ...rest] = item.name?.split(/ – | - /);
+    const subname = rest?.join(' - ');
 
     return index === 0 ? (
       <TouchableOpacity
@@ -109,8 +110,8 @@ const SearchModal = ({
             />
           )}
           <View style={styles.textContainer}>
-            <Text style={styles.title}>{name[0]}</Text>
-            <Text style={styles.subTitle}>{name[1]}</Text>
+            <Text style={styles.title}>{name}</Text>
+            <Text style={styles.subTitle}>{subname}</Text>
           </View>
         </View>
       </TouchableOpacity>

+ 4 - 3
src/screens/InAppScreens/TravelsScreen/Components/MyRegionsItems/NmRegionItem.tsx

@@ -31,7 +31,8 @@ export const NmRegionItem = React.memo(
     ) => void;
     token: string;
   }) => {
-    const name = item.region_name.split(/ – | - /);
+    const [name, ...rest] = item.region_name?.split(/ – | - /);
+    const subname = rest?.join(' - ');
     const { regionData, avatars } = useRegionData(item.id);
 
     const regionImg = regionData ? JSON.parse(regionData?.region_photos)[0] : '';
@@ -44,8 +45,8 @@ export const NmRegionItem = React.memo(
             <Image source={{ uri: regionImg, cache: 'force-cache' }} style={styles.regionImage} />
           )}
           <View style={{ gap: 6, flex: 1 }}>
-            <Text style={styles.regionItemName}>{name[0]}</Text>
-            <Text style={styles.regionItemSubname}>{name[1]}</Text>
+            <Text style={styles.regionItemName}>{name}</Text>
+            <Text style={styles.regionItemSubname}>{subname}</Text>
           </View>
           <View style={{ flexDirection: 'row', alignSelf: 'flex-start' }}>
             <Image

+ 4 - 3
src/screens/InAppScreens/TravelsScreen/Components/MyRegionsItems/RegionItem.tsx

@@ -21,7 +21,8 @@ export const RegionItem = React.memo(
     dare?: boolean;
     token: string;
   }) => {
-    const name = item.name.split(/ – | - /);
+    const [name, ...rest] = item.name?.split(/ – | - /);
+    const subname = rest?.join(' - ');
     const { regionData, avatars } = useRegionData(item.id, dare);
 
     const regionImg = regionData ? JSON.parse(regionData?.region_photos)[0] : '';
@@ -34,8 +35,8 @@ export const RegionItem = React.memo(
             <Image source={{ uri: regionImg, cache: 'force-cache' }} style={styles.regionImage} />
           )}
           <View style={{ gap: 6, flex: 1 }}>
-            <Text style={styles.regionItemName}>{name[0]}</Text>
-            <Text style={styles.regionItemSubname}>{name[1]}</Text>
+            <Text style={styles.regionItemName}>{name}</Text>
+            <Text style={styles.regionItemSubname}>{subname}</Text>
           </View>
           <View style={{ flexDirection: 'row', alignSelf: 'flex-start' }}>
             <Image

+ 4 - 3
src/screens/InAppScreens/TravelsScreen/Components/RegionItem/index.tsx

@@ -31,7 +31,8 @@ const RegionItem = ({
   endDate: string | null;
   isEditing: boolean;
 }) => {
-  const name = region.region_name.split(/ – | - /);
+  const [name, ...rest] = region.region_name?.split(/ – | - /);
+  const subname = rest?.join(' - ');
   const qualityName = region.quality
     ? qualityOptions.find((q) => q.id === region.quality)?.name
     : 'Good Visit';
@@ -64,8 +65,8 @@ const RegionItem = ({
             />
           )}
           <View style={styles.nameContainer}>
-            <Text style={styles.regionName}>{name[0]}</Text>
-            <Text style={styles.regionSubname}>{name[1]}</Text>
+            <Text style={styles.regionName}>{name}</Text>
+            <Text style={styles.regionSubname}>{subname}</Text>
           </View>
         </View>
         <TouchableOpacity style={styles.trashBtn} onPress={onDelete}>

+ 4 - 3
src/screens/InAppScreens/TravelsScreen/Components/TripItem/index.tsx

@@ -65,7 +65,8 @@ const TripItem = ({ item }: { item: TripsData }) => {
         nestedScrollEnabled={true}
       >
         {item.regions.map((region) => {
-          const name = region.region_name.split(/ – | - /);
+          const [name, ...rest] = region.region_name?.split(/ – | - /);
+          const subname = rest?.join(' - ');
 
           return (
             <View key={region.id} style={styles.regionItem}>
@@ -77,8 +78,8 @@ const TripItem = ({ item }: { item: TripsData }) => {
                 />
               )}
               <View style={styles.nameContainer}>
-                <Text style={styles.regionName}>{name[0]}</Text>
-                <Text style={styles.regionSubname}>{name[1]}</Text>
+                <Text style={styles.regionName}>{name}</Text>
+                <Text style={styles.regionSubname}>{subname}</Text>
               </View>
             </View>
           );