Admin Collaboration Done

# feat
- Detail Project
- Report Project
## No Issuue
This commit is contained in:
2024-05-10 15:16:09 +08:00
parent c34f9a9b75
commit dc41a5f9af
47 changed files with 2110 additions and 83 deletions

View File

@@ -0,0 +1,20 @@
"use server";
import prisma from "@/app/lib/prisma";
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
import { revalidatePath } from "next/cache";
export default async function colab_funUpdateIsReadByNotifId(notifId: string) {
const updtRead = await prisma.projectCollaboration_Notifikasi.update({
where: {
id: notifId,
},
data: {
isRead: true,
},
});
if (!updtRead) return { status: 400, message: "Gagal Update" };
revalidatePath(RouterColab.notifikasi);
return { status: 200, message: "Berhasil Udpate" };
}

View File

@@ -0,0 +1,24 @@
"use server";
import prisma from "@/app/lib/prisma";
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
export default async function colab_CekNotifikasi() {
const authorId = await user_getOneUserId();
const cekNotif = await prisma.projectCollaboration_Notifikasi.findMany({
where: {
userId: authorId,
isRead: false,
},
select: {
isRead: true,
},
});
if (cekNotif.length > 0) {
return true;
} else {
return false;
}
}

View File

@@ -0,0 +1,31 @@
"use server";
import prisma from "@/app/lib/prisma";
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
export default async function colab_getListNotifikasiByUserId() {
const authorId = await user_getOneUserId();
const get = await prisma.projectCollaboration_Notifikasi.findMany({
orderBy: {
createdAt: "desc",
},
where: {
userId: authorId,
},
select: {
id:true,
createdAt: true,
isRead: true,
note: true,
ProjectCollaboration: {
select: {
id: true,
report: true,
},
},
},
});
return get;
}

View File

@@ -0,0 +1,46 @@
"use server";
import prisma from "@/app/lib/prisma";
export default async function colab_getOneNotifikasiById({
notifId,
}: {
notifId: string;
}) {
const get = await prisma.projectCollaboration_Notifikasi.findFirst({
where: {
id: notifId,
},
select: {
id: true,
createdAt: true,
note: true,
ProjectCollaboration: {
select: {
id: true,
isActive: true,
title: true,
lokasi: true,
purpose: true,
benefit: true,
createdAt: true,
report: true,
Author: {
select: {
id: true,
Profile: true,
},
},
ProjectCollaborationMaster_Industri: true,
ProjectCollaboration_Partisipasi: {
where: {
isActive: true,
},
},
},
},
},
});
return get;
}

View File

@@ -3,13 +3,15 @@
import prisma from "@/app/lib/prisma";
import _ from "lodash";
export default async function colab_getMessageByRoomId(
roomId: string,
page: number
) {
// console.log(page)
const lewat = page * 5 - 5;
const ambil = 5;
export default async function colab_getMessageByRoomId({
roomId,
page,
}: {
roomId: string;
page: number;
}) {
const lewat = page * 6 - 6;
const ambil = 6;
const getList = await prisma.projectCollaboration_Message.findMany({
orderBy: {
createdAt: "desc",
@@ -39,7 +41,5 @@ export default async function colab_getMessageByRoomId(
},
});
const dataRevers = _.reverse(getList);
return getList;
}