upd: api mobile
Deskripsi : - update api mobile calendar divisi load data - riwayat kalender - detail event calendar - mengeluarkan anggota - menambahkan anggota - menghapus data event kalendar - indikator kalender NO Issues
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import { funGetUserById } from "@/module/auth";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -9,26 +9,28 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
try {
|
||||
const { id } = context.params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const user = await funGetUserByCookies()
|
||||
const name = searchParams.get('search')
|
||||
if (user.id == undefined) {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
const user = searchParams.get('user')
|
||||
|
||||
const userMobile = await funGetUserById({ id: String(user) })
|
||||
|
||||
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||
}
|
||||
|
||||
|
||||
const data = await prisma.division.findUnique({
|
||||
where: {
|
||||
id: String(id),
|
||||
// isActive: true,
|
||||
}
|
||||
where: {
|
||||
id: String(id),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!data) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 404 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan" }, { status: 200 });
|
||||
}
|
||||
|
||||
const member = await prisma.divisionMember.findMany({
|
||||
where: {
|
||||
idDivision: String(id),
|
||||
idDivision: String(id),
|
||||
isActive: true,
|
||||
User: {
|
||||
name: {
|
||||
@@ -43,15 +45,15 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
isLeader: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true,
|
||||
img: true
|
||||
}
|
||||
select: {
|
||||
name: true,
|
||||
img: true
|
||||
}
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
},
|
||||
orderBy: {
|
||||
isAdmin: 'desc',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const fixMember = member.map((v: any) => ({
|
||||
@@ -59,8 +61,6 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
name: v.User.name,
|
||||
img: v.User.img
|
||||
}))
|
||||
|
||||
|
||||
|
||||
return NextResponse.json({ success: true, data: fixMember })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user