From 509785982a1b4ac9ab145bac90d97be7044228c4 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Fri, 30 Aug 2024 21:21:17 +0200 Subject: Init alert list page --- app/(tabs)/alerts.tsx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/(tabs)/alerts.tsx (limited to 'app/(tabs)/alerts.tsx') diff --git a/app/(tabs)/alerts.tsx b/app/(tabs)/alerts.tsx new file mode 100644 index 0000000..135771f --- /dev/null +++ b/app/(tabs)/alerts.tsx @@ -0,0 +1,46 @@ +import { Alert, Platform, Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; +import ParallaxScrollView from '@/components/ParallaxScrollView'; +import { ThemedText } from '@/components/ThemedText'; +import { ThemedView } from '@/components/ThemedView'; +import React, { useState, useEffect, useRef } from 'react'; +import AsyncStorage from '@react-native-async-storage/async-storage'; +import MapView, { Marker } from 'react-native-maps'; +import { useFocusEffect } from '@react-navigation/native'; +import { router } from 'expo-router'; + +export default function AlertsScreen() { + const [token, setToken] = useState(''); + const [userId, setUserId] = useState(''); + + const checkAuth = async () => { + const storedToken = Platform.OS === 'web' ? localStorage.getItem('token') : await AsyncStorage.getItem('token'); + const storedUserId = Platform.OS === 'web' ? localStorage.getItem('userId') : await AsyncStorage.getItem('userId'); + + setToken(storedToken || ''); + setUserId(storedUserId || ''); + + if (!storedToken || !storedUserId) { + Alert.alert('Login required', 'You must log in to the system if you want to see alerts list', [ + { + text: 'Ok', + onPress: () => router.push('/') + } + ]); + } + }; + + useFocusEffect( + React.useCallback(() => { + checkAuth(); + }, []) + ); + + + return ( + + + ); +} + +const styles = StyleSheet.create({ +}); -- cgit v1.2.3-18-g5258