Merge pull request #70 from bipproduction/amalia/29-jul-24

Amalia/29 jul 24
This commit is contained in:
Amalia
2024-07-29 12:29:47 +08:00
committed by GitHub
13 changed files with 60 additions and 58 deletions

View File

@@ -280,28 +280,30 @@ model DivisionProjectFile {
} }
model DivisionDisscussion { model DivisionDisscussion {
id String @id @default(cuid()) id String @id @default(cuid())
Division Division @relation(fields: [idDivision], references: [id]) Division Division @relation(fields: [idDivision], references: [id])
idDivision String idDivision String
title String title String
desc String @db.Text desc String @db.Text
status Int @default(1) // 1 = open, 2 = close status Int @default(1) // 1 = open, 2 = close
isActive Boolean @default(true) isActive Boolean @default(true)
User User @relation(fields: [createdBy], references: [id]) User User @relation(fields: [createdBy], references: [id])
createdBy String createdBy String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
DivisionDisscussionComment DivisionDisscussionComment[]
} }
model DivisionDisscussionComment { model DivisionDisscussionComment {
id String @id @default(cuid()) id String @id @default(cuid())
idDisscussion String DivisionDisscussion DivisionDisscussion @relation(fields: [idDisscussion], references: [id])
comment String @db.Text idDisscussion String
isActive Boolean @default(true) comment String @db.Text
User User @relation(fields: [createdBy], references: [id]) isActive Boolean @default(true)
createdBy String User User @relation(fields: [createdBy], references: [id])
createdAt DateTime @default(now()) createdBy String
updatedAt DateTime @updatedAt createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
} }
model DivisionDocumentFolderFile { model DivisionDocumentFolderFile {

View File

@@ -3,12 +3,12 @@ import { API_INDEX_GROUP } from "./api_index";
type Method = "GET" | "POST"; type Method = "GET" | "POST";
export async function apiGroup(req: NextRequest, method: Method) { export async function apiGroup(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url); const { searchParams } = new URL(req.url);
const path = searchParams.get("path"); const path = searchParams.get("path");
const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method); const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method);
if (!path) if (!path)
return Response.json({ message: "page not found" }, { status: 404 }); return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req); if (act) return act.bin(req);
return Response.json({ message: "404" }); return Response.json({ success: false, message: "404" });
} }

View File

@@ -2,7 +2,7 @@ import { prisma } from "@/module/_global";
import { NextRequest } from "next/server"; import { NextRequest } from "next/server";
export async function listGroups(req: NextRequest): Promise<Response> { export async function listGroups(req: NextRequest): Promise<Response> {
try { try {
const searchParams = req.nextUrl.searchParams const searchParams = req.nextUrl.searchParams
const villaId = searchParams.get('villageId'); const villaId = searchParams.get('villageId');
@@ -20,6 +20,6 @@ export async function listGroups(req: NextRequest): Promise<Response> {
return Response.json(groups); return Response.json(groups);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -1,13 +1,13 @@
import { prisma } from "@/module/_global"; import { prisma } from "@/module/_global";
export async function createGroup(req: Request){ export async function createGroup(req: Request) {
try { try {
const data = await req.json(); const data = await req.json();
if (!data || !data.name) { if (!data || !data.name) {
return Response.json( return Response.json(
{ message: "Nama grup harus diisi" }, { success: false, message: "Nama grup harus diisi" },
{ status: 400 } { status: 400 }
); );
} }
@@ -27,6 +27,6 @@ export async function createGroup(req: Request){
return Response.json(group, { status: 201 }); return Response.json(group, { status: 201 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -4,12 +4,12 @@ import { API_INDEX_POSITION } from "./api_index";
type Method = "GET" | "POST"; type Method = "GET" | "POST";
export async function apiPosition(req: NextRequest, method: Method) { export async function apiPosition(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url); const { searchParams } = new URL(req.url);
const path = searchParams.get("path"); const path = searchParams.get("path");
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method); const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
if (!path) if (!path)
return Response.json({ message: "page not found" }, { status: 404 }); return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req); if (act) return act.bin(req);
return Response.json({ message: "404" }); return Response.json({ success: false, message: "404" });
} }

View File

@@ -19,6 +19,6 @@ export async function getAllPosition(req: NextRequest) {
return Response.json(positions); return Response.json(positions);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -19,6 +19,6 @@ export async function createlPosition(req: Request) {
return Response.json(positions, { status: 201 }); return Response.json(positions, { status: 201 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -4,12 +4,12 @@ import { API_INDEX_USER } from "./api_index";
type Method = "GET" | "POST"; type Method = "GET" | "POST";
export async function apiUser(req: NextRequest, method: Method) { export async function apiUser(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url); const { searchParams } = new URL(req.url);
const path = searchParams.get("path"); const path = searchParams.get("path");
const act = API_INDEX_USER.find((v) => v.path === path && v.method === method); const act = API_INDEX_USER.find((v) => v.path === path && v.method === method);
if (!path) if (!path)
return Response.json({ message: "page not found" }, { status: 404 }); return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req); if (act) return act.bin(req);
return Response.json({ message: "404" }); return Response.json({ success: false, message: "404" });
} }

View File

@@ -31,6 +31,6 @@ export async function getAllUser(req: NextRequest) {
return Response.json(users); return Response.json(users);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -30,6 +30,6 @@ export async function createUser(req: NextRequest) {
return Response.json(users, { status: 200 }); return Response.json(users, { status: 200 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -8,8 +8,8 @@ export async function apiViilage(req: Request, method: Method) {
(v) => v.path === path && v.method === method (v) => v.path === path && v.method === method
); );
if (!path) if (!path)
return Response.json({ message: "page not found" }, { status: 404 }); return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req); if (act) return act.bin(req);
return Response.json({ message: "404" }); return Response.json({ success: false, message: "404" });
} }

View File

@@ -16,6 +16,6 @@ export async function getAllVillage(req: Request) {
return Response.json(villages); return Response.json(villages);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }

View File

@@ -19,6 +19,6 @@ export async function createVillage(req: Request) {
return Response.json(village, { status: 201 }); return Response.json(village, { status: 201 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 }); return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
} }
} }