Create Proyek Kolaborasi
# feat - Create proyek - Edit proyek - User lain join proyek - Buat gruo diskusi ## No issue
This commit is contained in:
@@ -6,16 +6,18 @@ import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function colab_funCreatePartisipan(
|
||||
colabId: string,
|
||||
userId: string
|
||||
userId: string,
|
||||
deskripsi: string
|
||||
) {
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: userId,
|
||||
deskripsi_diri: deskripsi
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + colabId);
|
||||
return { status: 201, message: "Berhasil menambahkan partisipan" };
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import _ from "lodash";
|
||||
|
||||
export default async function colab_funCreateProyek(
|
||||
value: MODEL_COLLABORATION
|
||||
@@ -19,11 +20,12 @@ export default async function colab_funCreateProyek(
|
||||
benefit: value.benefit,
|
||||
projectCollaborationMaster_IndustriId:
|
||||
value.projectCollaborationMaster_IndustriId,
|
||||
userId: AuthorId
|
||||
userId: AuthorId,
|
||||
// jumlah_partisipan: + value.jumlah_partisipan,
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||
revalidatePath(RouterColab.beranda)
|
||||
revalidatePath(RouterColab.beranda);
|
||||
return { status: 201, message: "Berhasil Membuar Proyek" };
|
||||
}
|
||||
|
||||
60
src/app_modules/colab/fun/create/fun_create_room_chat.ts
Normal file
60
src/app_modules/colab/fun/create/fun_create_room_chat.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_funCreateRoomChat(
|
||||
nameRoom: string,
|
||||
value: any[],
|
||||
colabId: string
|
||||
) {
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const createRoom = await prisma.projectCollaboration_RoomChat.create({
|
||||
data: {
|
||||
name: nameRoom,
|
||||
userId: authorId,
|
||||
projectCollaborationId: colabId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createRoom) return { status: 400, message: "Gagal Membuat Room" };
|
||||
|
||||
for (let v of value) {
|
||||
// console.log(v);
|
||||
const createAnggota =
|
||||
await prisma.projectCollaboration_AnggotaRoomChat.create({
|
||||
data: {
|
||||
userId: v,
|
||||
projectCollaboration_RoomChatId: createRoom.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createAnggota)
|
||||
return { status: 400, message: "Gagal Menambah Anggota" };
|
||||
}
|
||||
|
||||
const createForAuthor =
|
||||
await prisma.projectCollaboration_AnggotaRoomChat.create({
|
||||
data: {
|
||||
userId: authorId,
|
||||
projectCollaboration_RoomChatId: createRoom.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createForAuthor)
|
||||
return { status: 400, message: "Gagal Menambahkan Author" };
|
||||
|
||||
// const hideProyek = await prisma.projectCollaboration.update({
|
||||
// where: {
|
||||
// id: colabId,
|
||||
// },
|
||||
// data: {
|
||||
// isActive: false,
|
||||
// },
|
||||
// });
|
||||
|
||||
// if (!hideProyek) return { status: 400, message: "Gagal Menyimpan Proyek" };
|
||||
|
||||
return { status: 201, message: "Berhasil Membuat Room" };
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_funCreateMessageByUserId(
|
||||
message: string,
|
||||
roomId: string
|
||||
) {
|
||||
const userLoginId = await user_getOneUserId();
|
||||
const msg = await prisma.projectCollaboration_Message.create({
|
||||
data: {
|
||||
userId: userLoginId,
|
||||
message: message,
|
||||
projectCollaboration_RoomChatId: roomId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!msg) return { status: 400, message: "Pesan Gagal Dikirim" };
|
||||
return { status: 200, message: "Pesan Berhasil Dikirim" };
|
||||
}
|
||||
@@ -16,6 +16,7 @@ export default async function colab_funEditById(value: MODEL_COLLABORATION) {
|
||||
lokasi: value.lokasi,
|
||||
purpose: value.purpose,
|
||||
benefit: value.benefit,
|
||||
// jumlah_partisipan: value.jumlah_partisipan,
|
||||
projectCollaborationMaster_IndustriId: value
|
||||
.ProjectCollaborationMaster_Industri.id as any,
|
||||
},
|
||||
@@ -23,6 +24,6 @@ export default async function colab_funEditById(value: MODEL_COLLABORATION) {
|
||||
|
||||
if (!updt) return { status: 400, message: "Gagal update" };
|
||||
revalidatePath(RouterColab.beranda);
|
||||
revalidatePath(RouterColab.main_detail)
|
||||
revalidatePath(RouterColab.main_detail);
|
||||
return { status: 200, message: "Berhasil update" };
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import prisma from "@/app/lib/prisma";
|
||||
export default async function colab_getListAllProyek() {
|
||||
const data = await prisma.projectCollaboration.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
projectCollaborationMaster_StatusId: 1,
|
||||
@@ -33,6 +33,5 @@ export default async function colab_getListAllProyek() {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export default async function colab_getListPartisipanById(colabId: string) {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
deskripsi_diri: true
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ export default async function colab_getListPartisipasiByAuthorId() {
|
||||
const AuthorId = await user_getOneUserId();
|
||||
|
||||
const get = await prisma.projectCollaboration_Partisipasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: AuthorId,
|
||||
isActive: true,
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_getListAllProyekByAuthorId() {
|
||||
export default async function colab_getListAllProyekSayaByAuthorId() {
|
||||
const AuthorId = await user_getOneUserId();
|
||||
const get = await prisma.projectCollaboration.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
where: { userId: AuthorId, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
@@ -14,6 +15,7 @@ export default async function colab_getListAllProyekByAuthorId() {
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
// jumlah_partisipan: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -15,6 +15,7 @@ export default async function colab_getOneCollaborationById(colabId: string) {
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
createdAt: true,
|
||||
// jumlah_partisipan: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getListAnggotaByRoomId(roomId: string) {
|
||||
const get = await prisma.projectCollaboration_RoomChat.findMany({
|
||||
where: {
|
||||
id: roomId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
ProjectCollaboration: true,
|
||||
ProjectCollaboration_AnggotaRoomChat: {
|
||||
select: {
|
||||
User: {
|
||||
select: {
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return get;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_getListRoomChatByAuthorId() {
|
||||
const userLoginId = await user_getOneUserId();
|
||||
|
||||
const listRoom = await prisma.projectCollaboration_AnggotaRoomChat.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration_RoomChat: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
isActive: true,
|
||||
ProjectCollaboration_AnggotaRoomChat: {
|
||||
select: {
|
||||
User: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// console.log(listRoom);
|
||||
|
||||
return listRoom;
|
||||
// const get = await prisma.projectCollaboration_RoomChat.findMany({
|
||||
// where: {
|
||||
// userId: userLoginId,
|
||||
// AND: [
|
||||
// {
|
||||
// ProjectCollaboration_AnggotaRoomChat: {
|
||||
// every: {
|
||||
// userId: userLoginId,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// select: {
|
||||
// id: true,
|
||||
// name: true,
|
||||
// // isActive: true,
|
||||
// // Author: true,
|
||||
// // userId: true,
|
||||
// // ProjectCollaboration: true,
|
||||
// // projectCollaborationId: true,
|
||||
// ProjectCollaboration_AnggotaRoomChat: {
|
||||
// select: {
|
||||
// userId: true,
|
||||
// User: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// return get;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getMessageByRoomId(roomId: string) {
|
||||
const getList = await prisma.projectCollaboration_Message.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
projectCollaboration_RoomChatId: roomId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
createdAt: true,
|
||||
isActive: true,
|
||||
message: true,
|
||||
isFile: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return getList;
|
||||
}
|
||||
Reference in New Issue
Block a user