Notifikasi
# feat: - Notifikasi di bagian admin ## No issue
This commit is contained in:
17
src/app_modules/admin/notifikasi/fun/count/count_is_read.ts
Normal file
17
src/app_modules/admin/notifikasi/fun/count/count_is_read.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function adminNotifikasi_countNotifikasi() {
|
||||
const userId = await user_getOneUserId();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
where: {
|
||||
adminId: userId,
|
||||
isRead: false,
|
||||
},
|
||||
});
|
||||
|
||||
return data.length;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function adminNotifikasi_getByUserId() {
|
||||
const adminId = await user_getOneUserId();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
orderBy:{
|
||||
createdAt: "desc"
|
||||
},
|
||||
where: {
|
||||
adminId: adminId,
|
||||
userRoleId: "2",
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function adminNotifikasi_funUpdateIsReadById({
|
||||
notifId,
|
||||
}: {
|
||||
notifId: string;
|
||||
}) {
|
||||
const updt = await prisma.notifikasi.update({
|
||||
where: {
|
||||
id: notifId,
|
||||
},
|
||||
data: {
|
||||
isRead: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400 };
|
||||
return { status: 200 };
|
||||
}
|
||||
5
src/app_modules/admin/notifikasi/index.ts
Normal file
5
src/app_modules/admin/notifikasi/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// test notif
|
||||
|
||||
import Notifikasi_MainView from "./main";
|
||||
|
||||
export { Notifikasi_MainView };
|
||||
25
src/app_modules/admin/notifikasi/main/index.tsx
Normal file
25
src/app_modules/admin/notifikasi/main/index.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import AppComponentGlobal_LayoutTamplate from "@/app_modules/component_global/component_layout_tamplate";
|
||||
import ComponentGlobal_HeaderTamplate from "@/app_modules/component_global/header_tamplate";
|
||||
import { Text } from "@mantine/core";
|
||||
|
||||
export default function Notifikasi_MainView() {
|
||||
return (
|
||||
<>
|
||||
<AppComponentGlobal_LayoutTamplate
|
||||
header={<ComponentGlobal_HeaderTamplate title="Notifikasi" />}
|
||||
>
|
||||
<MainView />
|
||||
</AppComponentGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MainView() {
|
||||
return (
|
||||
<>
|
||||
<Text>notif</Text>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user