upd: api mobile
Deskripsi: - tambah member project - mengeluarkan anggota project - fix tanggal tambah task project No Issues
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import { funGetUserById } from "@/module/auth";
|
||||
import { createLogUserMobile } from "@/module/user";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
@@ -168,7 +169,8 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
const { id } = context.params;
|
||||
const { user } = (await request.json());
|
||||
const { searchParams } = new URL(request.url);
|
||||
const user = searchParams.get("user");
|
||||
const userMobile = await funGetUserById({ id: String(user) })
|
||||
|
||||
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||
@@ -182,6 +184,8 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
}
|
||||
})
|
||||
|
||||
const fixData = { ...data, dateStart: moment(data?.dateStart).format('YYYY-MM-DD'), dateEnd: moment(data?.dateEnd).format('YYYY-MM-DD') }
|
||||
|
||||
if (!data) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -191,7 +195,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data }, { status: 200 });
|
||||
return NextResponse.json({ success: true, message: "Detail kegiatan berhasil ditemukan", data: fixData }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
|
||||
Reference in New Issue
Block a user