Files
mobile-darmasaba/components/home/headerRightHome.tsx
amel 32908e1362 upd: notifikasi
Deskripsi:
- update notifikasi push routing ketika di klik

No Issues
2025-06-26 14:30:40 +08:00

38 lines
1.5 KiB
TypeScript

import Styles from "@/constants/Styles";
import { apiGetDataHome } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import Feather from '@expo/vector-icons/Feather';
import { router } from "expo-router";
import { useEffect, useState } from "react";
import { View } from "react-native";
import { useSelector } from "react-redux";
import { ButtonHeader } from "../buttonHeader";
export function HeaderRightHome() {
const { decryptToken, token } = useAuthSession()
const [notification, setNotification] = useState(0)
const updateNotification = useSelector((state: any) => state.notificationUpdate)
async function handleData() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetDataHome({ cat: "header", user: hasil })
setNotification(response.data.totalNotif)
} catch (error) {
console.error(error)
}
}
useEffect(() => {
handleData()
}, [updateNotification]);
return (
<View style={[Styles.rowSpaceBetween, { width: 140 }]}>
<ButtonHeader item={<Feather name="search" size={20} color="white" />} onPress={() => { router.push('/search') }} />
<ButtonHeader valueTop={notification > 0 ? true : false} item={<Feather name="bell" size={20} color="white" />} onPress={() => { router.push('/notification') }} />
<ButtonHeader item={<Feather name="user" size={20} color="white" />} onPress={() => { router.push('/profile') }} />
</View>
)
}