Add: - screens/Admin/AdminNotificationBell.tsx Fix: - app.config.js - app/(application)/(user)/home.tsx - app/(application)/(user)/test-notifications.tsx - app/(application)/admin/_layout.tsx - app/_layout.tsx - components/Notification/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
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import {
|
|
ButtonCustom,
|
|
NewWrapper,
|
|
StackCustom,
|
|
TextInputCustom,
|
|
} from "@/components";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { apiNotificationsSend } from "@/service/api-notifications";
|
|
import { useState } from "react";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function TestNotification() {
|
|
const { user } = useAuth();
|
|
const [data, setData] = useState("");
|
|
|
|
const handleSubmit = async () => {
|
|
console.log("[Data Dikirim]", data);
|
|
const response = await apiNotificationsSend({
|
|
data: {
|
|
title: "Test dari Backend (App Router)!",
|
|
body: data,
|
|
userLoginId: user?.id || "",
|
|
appId: "hipmi",
|
|
status: "publish",
|
|
kategoriApp: "EVENT",
|
|
type: "announcement",
|
|
deepLink: "event/23189913801",
|
|
},
|
|
});
|
|
|
|
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 (
|
|
<>
|
|
<NewWrapper>
|
|
<StackCustom>
|
|
<TextInputCustom
|
|
required
|
|
label="Nama"
|
|
placeholder="Masukkan nama"
|
|
value={data}
|
|
onChangeText={(text) => setData(text)}
|
|
/>
|
|
<ButtonCustom
|
|
onPress={() => {
|
|
handleSubmit();
|
|
}}
|
|
>
|
|
Kirim
|
|
</ButtonCustom>
|
|
</StackCustom>
|
|
</NewWrapper>
|
|
</>
|
|
);
|
|
}
|