amalia/22-apr-26 #40
@@ -16,7 +16,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { LinearGradient } from "expo-linear-gradient";
|
||||
import { Stack } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Dimensions, Platform, RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Alert, Dimensions, Platform, RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -55,6 +55,26 @@ export default function Home() {
|
||||
}
|
||||
}, [isError, signOut])
|
||||
|
||||
useEffect(() => {
|
||||
if (profile && profile.isActive === false) {
|
||||
Alert.alert(
|
||||
'Akun Dinonaktifkan',
|
||||
'Akun kamu telah dinonaktifkan. Silahkan hubungi admin untuk informasi lebih lanjut.',
|
||||
[{ text: 'OK', onPress: signOut }]
|
||||
)
|
||||
}
|
||||
}, [profile, signOut])
|
||||
|
||||
useEffect(() => {
|
||||
if (profile && profile.villageIsActive === false) {
|
||||
Alert.alert(
|
||||
'Desa Dinonaktifkan',
|
||||
'Desa kamu saat ini telah dinonaktifkan. Silahkan hubungi pengelola sistem untuk informasi lebih lanjut.',
|
||||
[{ text: 'OK', onPress: signOut }]
|
||||
)
|
||||
}
|
||||
}, [profile, signOut])
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setRefreshing(true)
|
||||
// Invalidate all queries related to the home screen
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ConstEnv } from '@/constants/ConstEnv';
|
||||
import { apiRegisteredToken, apiUnregisteredToken } from '@/lib/api';
|
||||
import { getToken } from '@/lib/useNotification';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import CryptoES from "crypto-es";
|
||||
import { router } from "expo-router";
|
||||
import { createContext, MutableRefObject, ReactNode, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
@@ -30,6 +31,7 @@ export function useAuthSession() {
|
||||
export default function AuthProvider({ children }: { children: ReactNode }): ReactNode {
|
||||
const tokenRef = useRef<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
useEffect(() => {
|
||||
(async (): Promise<void> => {
|
||||
@@ -87,6 +89,7 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
|
||||
} finally {
|
||||
await AsyncStorage.setItem('@token', '');
|
||||
tokenRef.current = null;
|
||||
queryClient.clear();
|
||||
router.replace('/');
|
||||
}
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user