fix : notification page

Deskripsi:
- load refresh notification page

No Issues
This commit is contained in:
2025-09-09 11:09:19 +08:00
parent 5fa364be24
commit c8de5d185a

View File

@@ -9,7 +9,7 @@ import { pushToPage } from "@/lib/pushToPage";
import { useAuthSession } from "@/providers/AuthProvider";
import { Feather } from "@expo/vector-icons";
import { useEffect, useState } from "react";
import { SafeAreaView, View, VirtualizedList } from "react-native";
import { RefreshControl, SafeAreaView, View, VirtualizedList } from "react-native";
import { useDispatch, useSelector } from "react-redux";
type Props = {
@@ -31,6 +31,7 @@ export default function Notification() {
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
const dispatch = useDispatch()
const updateNotification = useSelector((state: any) => state.notificationUpdate)
const [refreshing, setRefreshing] = useState(false)
async function handleLoad(loading: boolean, thisPage: number) {
try {
@@ -88,33 +89,12 @@ export default function Notification() {
}
}
// function pushToPage(category: string, idContent: string) {
// const cat = category.split('/')
// if (cat.length > 1) {
// if (cat[2] == 'calendar') {
// router.push(`/division/${cat[1]}/calendar/${idContent}`)
// } else if (cat[2] == 'discussion') {
// router.push(`/division/${cat[1]}/discussion/${idContent}`)
// } else if (cat[2] == 'document') {
// router.push(`/division/${cat[1]}/document/${idContent}`)
// } else if (cat[2] == 'task') {
// router.push(`/division/${cat[1]}/task/${idContent}`)
// }
// } else {
// if (cat[0] == 'announcement') {
// router.push(`/announcement/${idContent}`)
// } else if (cat[0] == 'discussion-general') {
// router.push(`/discussion/${idContent}`)
// } else if (cat[0] == 'division') {
// router.push(`/division/${idContent}`)
// } else if (cat[0] == 'member') {
// router.push(`/member/${idContent}`)
// } else if (cat[0] == 'project') {
// router.push(`/project/${idContent}`)
// }
// }
// }
const handleRefresh = async () => {
setRefreshing(true)
handleLoad(false, 1)
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
};
return (
<SafeAreaView>
@@ -156,6 +136,12 @@ export default function Notification() {
onEndReached={loadMoreData}
onEndReachedThreshold={0.5}
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
/>
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>