From 6c9623954c4a7cc54e741e126685de08ee0e23f8 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Wed, 22 Apr 2026 15:17:21 +0800 Subject: [PATCH 1/2] feat: tambah pengecekan isActive dan bersihkan cache saat logout - Tampilkan Alert jika admin menonaktifkan akun user yang sedang login - Clear React Query cache saat signOut agar data akun lama tidak bocor ke sesi berikutnya Co-Authored-By: Claude Sonnet 4.6 --- app/(application)/home.tsx | 12 +++++++++++- providers/AuthProvider.tsx | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/(application)/home.tsx b/app/(application)/home.tsx index b45163c..0b0a95f 100644 --- a/app/(application)/home.tsx +++ b/app/(application)/home.tsx @@ -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,16 @@ 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]) + const handleRefresh = async () => { setRefreshing(true) // Invalidate all queries related to the home screen diff --git a/providers/AuthProvider.tsx b/providers/AuthProvider.tsx index 1087f55..a1793cd 100644 --- a/providers/AuthProvider.tsx +++ b/providers/AuthProvider.tsx @@ -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(null); const [isLoading, setIsLoading] = useState(true); + const queryClient = useQueryClient(); useEffect(() => { (async (): Promise => { @@ -87,6 +89,7 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea } finally { await AsyncStorage.setItem('@token', ''); tokenRef.current = null; + queryClient.clear(); router.replace('/'); } }, []); -- 2.49.1 From 0bad792ce86cbe25812bfd7536c9ef7d6c751688 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Wed, 22 Apr 2026 16:42:59 +0800 Subject: [PATCH 2/2] feat: tambah pengecekan villageIsActive saat desa dinonaktifkan Co-Authored-By: Claude Sonnet 4.6 --- app/(application)/home.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/(application)/home.tsx b/app/(application)/home.tsx index 0b0a95f..7da9162 100644 --- a/app/(application)/home.tsx +++ b/app/(application)/home.tsx @@ -65,6 +65,16 @@ export default function Home() { } }, [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.49.1