rev: calender
Deskripsi: - check jika ada acara di tgl yg sama di beda divisi 1 grup No Issues
This commit is contained in:
@@ -193,4 +193,44 @@ export async function POST(request: Request) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal membuat acara kalender, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CEK TGL AVAILABLE
|
||||
export async function PUT(request: Request) {
|
||||
try {
|
||||
const user = await funGetUserByCookies();
|
||||
if (user.id == undefined) {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { idDivision, title, desc, timeStart, timeEnd, dateStart, dateEnd, repeatEventTyper, member, linkMeet, repeatValue } = (await request.json());
|
||||
const division = await prisma.division.findUnique({
|
||||
where: {
|
||||
id: idDivision
|
||||
}
|
||||
})
|
||||
|
||||
const cek = await prisma.divisionCalendarReminder.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
dateStart: new Date(dateStart),
|
||||
Division: {
|
||||
idGroup: division?.idGroup
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (cek > 0) {
|
||||
return NextResponse.json({ success: false, message: "Tidak dapat membuat acara kalender, acara kalender sudah ada pada tanggal tersebut" }, { status: 400 });
|
||||
} else {
|
||||
return NextResponse.json({ success: true, message: "Berhasil membuat acara kalender" }, { status: 200 });
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return NextResponse.json({ success: false, message: "Gagal membuat acara kalender, coba lagi nanti (error: 500)" }, { status: 404 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user