upd: notifikasi
Deskripsi: - update notifikasi push routing ketika di klik No Issues
This commit is contained in:
@@ -3,11 +3,13 @@ import SkeletonTwoItem from "@/components/skeletonTwoItem";
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetNotification, apiReadOneNotification } from "@/lib/api";
|
||||
import { setUpdateNotification } from "@/lib/notificationSlice";
|
||||
import { pushToPage } from "@/lib/pushToPage";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import { router } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, Text, View, VirtualizedList } from "react-native";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -26,6 +28,8 @@ export default function Notification() {
|
||||
const [page, setPage] = useState(1)
|
||||
const [waiting, setWaiting] = useState(false)
|
||||
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||
const dispatch = useDispatch()
|
||||
const updateNotification = useSelector((state: any) => state.notificationUpdate)
|
||||
|
||||
async function handleLoad(loading: boolean, thisPage: number) {
|
||||
try {
|
||||
@@ -77,37 +81,38 @@ export default function Notification() {
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiReadOneNotification({ user: hasil, id: id })
|
||||
pushToPage(category, idContent)
|
||||
dispatch(setUpdateNotification(!updateNotification))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
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}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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}`)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
return (
|
||||
@@ -140,7 +145,10 @@ export default function Notification() {
|
||||
rightTopInfo={item.createdAt}
|
||||
desc={item.desc}
|
||||
textColor={item.isRead ? 'gray' : 'black'}
|
||||
onPress={() => handleReadNotification(item.id, item.category, item.idContent)}
|
||||
onPress={() => {
|
||||
handleReadNotification(item.id, item.category, item.idContent)
|
||||
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user