Notifikasi terhubung ke DB

Add:
- components/Notification/
- hooks/use-notification-store.tsx.back

Fix:
- app.config.js
- app/(application)/(user)/_layout.tsx
- app/(application)/(user)/home.tsx
- app/(application)/(user)/test-notifications.tsx
- app/(application)/_layout.tsx
- app/_layout.tsx
- components/_Icon/IconComponent.tsx
- components/_Icon/IconPlus.tsx
- components/_ShareComponent/NotificationInitializer.tsx
- context/AuthContext.tsx
- hooks/use-notification-store.tsx
- ios/HIPMIBadungConnect/Info.plist
- screens/Home/HeaderBell.tsx
- service/api-device-token.ts
- service/api-notifications.ts

### No Issue
This commit is contained in:
2025-12-19 17:54:49 +08:00
parent a01a9bd93f
commit 1503707eed
16 changed files with 352 additions and 97 deletions

View File

@@ -1,4 +1,6 @@
import { BackButton } from "@/components";
import { IconPlus } from "@/components/_Icon";
import { IconDot } from "@/components/_Icon/IconComponent";
import LeftButtonCustom from "@/components/Button/BackButton";
import { MainColor } from "@/constants/color-palet";
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
@@ -56,6 +58,12 @@ export default function UserLayout() {
options={{
title: "Notifikasi",
headerLeft: () => <BackButton />,
headerRight: () => (
<IconPlus
color={MainColor.yellow}
onPress={() => router.push("/test-notifications")}
/>
),
}}
/>

View File

@@ -3,7 +3,6 @@
import { ButtonCustom, StackCustom, ViewWrapper } from "@/components";
import { MainColor } from "@/constants/color-palet";
import { useAuth } from "@/hooks/use-auth";
import { useNotificationStore } from "@/hooks/use-notification-store";
import Home_BottomFeatureSection from "@/screens/Home/bottomFeatureSection";
import HeaderBell from "@/screens/Home/HeaderBell";
import Home_ImageSection from "@/screens/Home/imageSection";
@@ -14,8 +13,8 @@ import { apiUser } from "@/service/api-client/api-user";
import { apiVersion } from "@/service/api-config";
import { Ionicons } from "@expo/vector-icons";
import { Redirect, router, Stack, useFocusEffect } from "expo-router";
import { useCallback, useEffect, useState } from "react";
import { RefreshControl, Text, View } from "react-native";
import { useCallback, useState } from "react";
import { RefreshControl } from "react-native";
export default function Application() {
const { token, user, userData } = useAuth();
@@ -99,7 +98,9 @@ export default function Application() {
}
>
<StackCustom>
{/* <ButtonCustom onPress={() => router.push("./test-notifications")}>Test Notif</ButtonCustom> */}
{/* <ButtonCustom onPress={() => router.push("./test-notifications")}>
Test Notif
</ButtonCustom> */}
<Home_ImageSection />

View File

@@ -6,10 +6,9 @@ import {
} from "@/components";
import { useAuth } from "@/hooks/use-auth";
import { apiGetAllTokenDevice } from "@/service/api-device-token";
import {
apiNotificationsSend,
} from "@/service/api-notifications";
import { apiNotificationsSend } from "@/service/api-notifications";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function TestNotification() {
const { user } = useAuth();
@@ -39,7 +38,18 @@ export default function TestNotification() {
},
});
console.log("[RES SEND NOTIF]", JSON.stringify(response.data, null, 2));
if (response.success) {
console.log("[RES SEND NOTIF]", JSON.stringify(response, null, 2));
Toast.show({
type: "success",
text1: "Notifikasi berhasil dikirim",
});
} else {
Toast.show({
type: "error",
text1: "Gagal mengirim notifikasi",
});
}
};
return (

View File

@@ -1,15 +1,26 @@
import { BackButton } from "@/components";
import NotificationInitializer from "@/components/Notification/NotificationInitializer";
import { NotificationProvider } from "@/hooks/use-notification-store";
import { HeaderStyles } from "@/styles/header-styles";
import { Stack } from "expo-router";
export default function ApplicationLayout() {
return (
<>
<NotificationProvider>
<NotificationInitializer />
<ApplicationStack />
</NotificationProvider>
</>
);
}
function ApplicationStack() {
return (
<>
<Stack screenOptions={HeaderStyles}>
<Stack.Screen name="(user)" options={{ headerShown: false }} />
<Stack.Screen name="admin" options={{ headerShown: false }} />
{/* Take Picture */}
<Stack.Screen

View File

@@ -1,8 +1,6 @@
import NotificationInitializer from "@/components/_ShareComponent/NotificationInitializer";
import NotificationInitializer from "@/components/Notification/NotificationInitializer";
import { AuthProvider } from "@/context/AuthContext";
import {
NotificationProvider
} from "@/hooks/use-notification-store";
import { NotificationProvider } from "@/hooks/use-notification-store";
import AppRoot from "@/screens/RootLayout/AppRoot";
import "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
@@ -11,15 +9,12 @@ import Toast from "react-native-toast-message";
export default function RootLayout() {
return (
<>
<NotificationProvider>
<SafeAreaProvider>
<AuthProvider>
<NotificationInitializer />
<AppRoot />
</AuthProvider>
</SafeAreaProvider>
<Toast />
</NotificationProvider>
<SafeAreaProvider>
<AuthProvider>
<AppRoot />
</AuthProvider>
</SafeAreaProvider>
<Toast />
</>
);
}