Explorar o código

redirect to the "wp_url"

Viktoriia hai 4 semanas
pai
achega
9db51c827a

+ 1 - 0
src/modules/api/events/events-api.ts

@@ -43,6 +43,7 @@ export type SingleEvent = {
   nm_event: 0 | 1;
   star: 0 | 1;
   date_tentative: 0 | 1;
+  wp_url?: string | null;
 };
 
 export type Participants = {

+ 11 - 6
src/screens/InAppScreens/TravelsScreen/EventsScreen/index.tsx

@@ -1,6 +1,6 @@
 import React, { useCallback, useEffect, useRef, useState } from 'react';
-import { View, Text, Image, TouchableOpacity, LayoutAnimation, Modal } from 'react-native';
-import { FlashList } from '@shopify/flash-list';
+import { View, Text, Image, TouchableOpacity, LayoutAnimation, Modal, Linking } from 'react-native';
+import { FlashList, FlashListRef } from '@shopify/flash-list';
 import { CommonActions, useFocusEffect, useNavigation } from '@react-navigation/native';
 import { popupStyles, styles } from './styles';
 import Animated, {
@@ -99,7 +99,7 @@ const EventsScreen = () => {
     local_meetings: false
   });
 
-  const scrollViewRefs = useRef<Record<string, FlashList<SingleEvent> | null>>({
+  const scrollViewRefs = useRef<Record<string, FlashListRef<SingleEvent> | null>>({
     nm: null,
     shared_trips: null,
     local_meetings: null
@@ -332,9 +332,14 @@ const EventsScreen = () => {
               ? { backgroundColor: Colors.FILL_LIGHT }
               : { backgroundColor: Colors.WHITE }
           ]}
-          onPress={() =>
-            navigation.navigate(...([NAVIGATION_PAGES.EVENT, { url: item.url }] as never))
-          }
+          onPress={() => {
+            if (index === 0 && item.wp_url) {
+              const eventUrl = `${API_HOST}/${item.url}`;
+              Linking.openURL(eventUrl).catch((err) => console.error('Failed to event URL:', err));
+            } else {
+              navigation.navigate(...([NAVIGATION_PAGES.EVENT, { url: item.url }] as never));
+            }
+          }}
           disabled={item.active === 0}
         >
           <View style={styles.imageWrapper}>