Explorar el Código

unauthorized fix

Viktoriia hace 3 días
padre
commit
fd6028d626

+ 2 - 1
src/components/WarningModal/index.tsx

@@ -48,7 +48,8 @@ export const WarningModal = ({
       ]
     },
     unauthorized: {
-      message: 'To use this feature you need to have an account with NomadMania.',
+      message:
+        'You have to be a NomadMania member to use this feature. Log in or Set up a free account.',
       buttons: [
         {
           text: 'Login',

+ 11 - 0
src/screens/InAppScreens/TravelsScreen/EventScreen/index.tsx

@@ -127,6 +127,7 @@ const EventScreen = ({ route }: { route: any }) => {
   const [currentImageIndex, setCurrentImageIndex] = useState(0);
   const [nmId, setNmId] = useState<number | null>(null);
   const [tooltipVisible, setTooltipVisible] = useState(false);
+  const [isWarningModalVisible, setIsWarningModalVisible] = useState<boolean>(false);
 
   const { data: photosData } = useGetPhotosForRegionQuery(nmId ?? 0, nmId !== null);
 
@@ -383,6 +384,11 @@ const EventScreen = ({ route }: { route: any }) => {
   };
 
   const handleJoinEvent = async () => {
+    if (!token) {
+      setIsWarningModalVisible(true);
+      return;
+    }
+
     if (event.settings.type !== 1) {
       setModalInfo({
         visible: true,
@@ -1538,6 +1544,11 @@ const EventScreen = ({ route }: { route: any }) => {
         backgroundColor={Colors.DARK_BLUE}
         onImageIndexChange={setActiveIndex}
       />
+      <WarningModal
+        type={'unauthorized'}
+        isVisible={isWarningModalVisible}
+        onClose={() => setIsWarningModalVisible(false)}
+      />
     </View>
   );
 };