Project Collaboration
## feat - Buat proyek baru - Tampilan list data pada beranda - Partisipasi user lain ### No issuee
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"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_funCreatePartisipan(
|
||||
colabId: string,
|
||||
userId: string
|
||||
) {
|
||||
const create = await prisma.projectCollaboration_Partisipasi.create({
|
||||
data: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal menambahkan partisipan" };
|
||||
revalidatePath(RouterColab.main_detail + colabId);
|
||||
return { status: 201, message: "Berhasil menambahkan partisipan" };
|
||||
}
|
||||
@@ -3,12 +3,13 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
|
||||
export default async function colab_funCreateProyek(
|
||||
value: MODEL_COLLABORATION
|
||||
) {
|
||||
const Author = await User_getUserId();
|
||||
console.log(Author);
|
||||
const AuthorId = await User_getUserId();
|
||||
|
||||
const create = await prisma.projectCollaboration.create({
|
||||
data: {
|
||||
@@ -18,10 +19,11 @@ export default async function colab_funCreateProyek(
|
||||
benefit: value.benefit,
|
||||
projectCollaborationMaster_IndustriId:
|
||||
value.projectCollaborationMaster_IndustriId,
|
||||
userId: Author
|
||||
userId: AuthorId
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal Membuat Proyek" };
|
||||
revalidatePath(RouterColab.beranda)
|
||||
return { status: 201, message: "Berhasil Membuar Proyek" };
|
||||
}
|
||||
|
||||
22
src/app_modules/colab/fun/get/cek_partisipasi_by_user_id.ts
Normal file
22
src/app_modules/colab/fun/get/cek_partisipasi_by_user_id.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_funCekPartisipasiById(colabId: string) {
|
||||
const UserLoginId = await User_getUserId();
|
||||
|
||||
const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
|
||||
where: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: UserLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (cek === null) {
|
||||
return (false);
|
||||
} else {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,36 @@
|
||||
"use server"
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getListAllProyek() {
|
||||
|
||||
}
|
||||
const data = await prisma.projectCollaboration.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
projectCollaborationMaster_StatusId: 1,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
5
src/app_modules/colab/fun/get/get_list_by_status_id.ts
Normal file
5
src/app_modules/colab/fun/get/get_list_by_status_id.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
"use server"
|
||||
|
||||
export default async function colab_getListByStatusId(statusId: string, colabId: string) {
|
||||
|
||||
}
|
||||
22
src/app_modules/colab/fun/get/get_list_partisipan_by_id.ts
Normal file
22
src/app_modules/colab/fun/get/get_list_partisipan_by_id.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getListPartisipanById(colabId: string) {
|
||||
const data = await prisma.projectCollaboration_Partisipasi.findMany({
|
||||
where: {
|
||||
projectCollaborationId: colabId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data
|
||||
}
|
||||
33
src/app_modules/colab/fun/get/get_one_by_id.ts
Normal file
33
src/app_modules/colab/fun/get/get_one_by_id.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function colab_getOneCollaborationById(colabId: string) {
|
||||
const data = await prisma.projectCollaboration.findFirst({
|
||||
where: {
|
||||
id: colabId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
title: true,
|
||||
lokasi: true,
|
||||
purpose: true,
|
||||
benefit: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
ProjectCollaborationMaster_Industri: true,
|
||||
ProjectCollaboration_Partisipasi: {
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user