api : add api
Deskripsi: - add gorup - add position - village No issue
This commit is contained in:
109
api.http
109
api.http
@@ -4,4 +4,113 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"phone": "6287701790942"
|
||||
}
|
||||
|
||||
// GROUP
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/group/get?path=list-group HTTP/1.1
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/group/post?path=create-group HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "amalia2",
|
||||
"idVillage": "121212"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/group/post?path=update-group HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "1",
|
||||
"name": "LPD2",
|
||||
"idVillage": "121212"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/group/post?path=delete-group HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "1",
|
||||
"idVillage": "121212"
|
||||
}
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/group/get?path=get-one-group HTTP/1.1
|
||||
|
||||
|
||||
// VILLAGE
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/village/get?path=get-all-village HTTP/1.1
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/village/get?path=get-one-village HTTP/1.1
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/village/post?path=create-village HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "nama satu satu ",
|
||||
"desc": "description data"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/village/post?path=update-village HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "11",
|
||||
"name": "nama satu new",
|
||||
"desc": "description data new"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/village/post?path=delete-village HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "11"
|
||||
}
|
||||
|
||||
|
||||
// POSITION
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/position/get?path=get-all-position HTTP/1.1
|
||||
|
||||
###
|
||||
GET http://localhost:3000/api/position/get?path=get-one-position HTTP/1.1
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/position/post?path=create-position HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "Wakil Bendahara 10",
|
||||
"idGroup": "2"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/position/post?path=update-position HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Wakil Sekertaris",
|
||||
"idGroup": "2"
|
||||
}
|
||||
|
||||
###
|
||||
POST http://localhost:3000/api/position/post?path=delete-position HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "1"
|
||||
}
|
||||
5
src/app/api/group/get/route.ts
Normal file
5
src/app/api/group/get/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiGroup } from "@/module/group";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
return apiGroup(req, "GET")
|
||||
}
|
||||
5
src/app/api/group/post/route.ts
Normal file
5
src/app/api/group/post/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiGroup } from "@/module/group";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
return apiGroup(req, "POST")
|
||||
}
|
||||
5
src/app/api/position/get/route.ts
Normal file
5
src/app/api/position/get/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiPosition } from "@/module/position";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
return apiPosition(req, "GET");
|
||||
}
|
||||
5
src/app/api/position/post/route.ts
Normal file
5
src/app/api/position/post/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiPosition } from "@/module/position";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
return apiPosition(req, "POST");
|
||||
}
|
||||
5
src/app/api/village/get/route.ts
Normal file
5
src/app/api/village/get/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiViilage } from "@/module/village";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
return apiViilage(req, "GET");
|
||||
}
|
||||
5
src/app/api/village/post/route.ts
Normal file
5
src/app/api/village/post/route.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { apiViilage } from "@/module/village";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
return apiViilage(req, "POST");
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export async function createProject(req: Request) {
|
||||
const data = await req.json()
|
||||
return Response.json({ message: "success create projects" })
|
||||
}
|
||||
13
src/module/group/api/api_group.ts
Normal file
13
src/module/group/api/api_group.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { API_INDEX_GROUP } from "./api_index";
|
||||
|
||||
type Method = "GET" | "POST";
|
||||
export async function apiGroup(req: Request, method: Method) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const path = searchParams.get("path");
|
||||
const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method);
|
||||
if (!path)
|
||||
return Response.json({ message: "page not found" }, { status: 404 });
|
||||
if (act) return act.bin(req);
|
||||
|
||||
return Response.json({ message: "404" });
|
||||
}
|
||||
33
src/module/group/api/api_index.ts
Normal file
33
src/module/group/api/api_index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { getOneGroup } from "./get/getOneGroup";
|
||||
import { listGroup } from "./get/listGroup";
|
||||
import { createGroup } from "./post/createGroup";
|
||||
import { deleteGroup } from "./post/deleteGroup";
|
||||
import { updateGroup } from "./post/updateGroup";
|
||||
|
||||
export const API_INDEX_GROUP = [
|
||||
{
|
||||
path: "list-group",
|
||||
method: "GET",
|
||||
bin: listGroup,
|
||||
},
|
||||
{
|
||||
path: "create-group",
|
||||
method: "POST",
|
||||
bin: createGroup,
|
||||
},
|
||||
{
|
||||
path: "update-group",
|
||||
method: "POST",
|
||||
bin: updateGroup,
|
||||
},
|
||||
{
|
||||
path: "delete-group",
|
||||
method: "POST",
|
||||
bin: deleteGroup,
|
||||
},
|
||||
{
|
||||
path: "get-one-group",
|
||||
method: "GET",
|
||||
bin: getOneGroup,
|
||||
},
|
||||
];
|
||||
32
src/module/group/api/get/getOneGroup.ts
Normal file
32
src/module/group/api/get/getOneGroup.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function getOneGroup(req: Request): Promise<Response> {
|
||||
try {
|
||||
// const groupId = req.params.id;
|
||||
const groupId = "clz0v4kce0009e6mukfhzmyzb";
|
||||
const getOne = await prisma.group.findUnique({
|
||||
where: {
|
||||
id: groupId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!getOne) {
|
||||
return Response.json(
|
||||
{ message: "Grup tidak ditemukan", success: false },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
return Response.json(getOne);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
20
src/module/group/api/get/listGroup.ts
Normal file
20
src/module/group/api/get/listGroup.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function listGroup(req: Request): Promise<Response> {
|
||||
try {
|
||||
const groups = await prisma.group.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(groups);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
32
src/module/group/api/post/createGroup.ts
Normal file
32
src/module/group/api/post/createGroup.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function createGroup(req: Request){
|
||||
try {
|
||||
const data = await req.json();
|
||||
|
||||
|
||||
if (!data || !data.name) {
|
||||
return Response.json(
|
||||
{ message: "Nama grup harus diisi" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const group = await prisma.group.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
isActive: true,
|
||||
idVillage: data.idVillage,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(group, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
19
src/module/group/api/post/deleteGroup.ts
Normal file
19
src/module/group/api/post/deleteGroup.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function deleteGroup(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
const update = await prisma.group.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
return Response.json({ success: true, message: "Sukses Delete Grup" }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error", success: false }, { status: 500 });
|
||||
}
|
||||
}
|
||||
21
src/module/group/api/post/updateGroup.ts
Normal file
21
src/module/group/api/post/updateGroup.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function updateGroup(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
|
||||
const update = await prisma.group.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
name: data.name,
|
||||
idVillage: data.idVillage,
|
||||
},
|
||||
});
|
||||
return Response.json({ success: true, message: "Sukses Update Grup" }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error", success: false }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { apiGroup } from "./api/api_group";
|
||||
import ViewGroup from "./view/view_group";
|
||||
|
||||
export {ViewGroup}
|
||||
export { ViewGroup };
|
||||
export { apiGroup };
|
||||
|
||||
34
src/module/position/api/api_index.ts
Normal file
34
src/module/position/api/api_index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { getAllPosition } from "./get/getAllPosition";
|
||||
import { getOnePosition } from "./get/getOnePosition";
|
||||
import { createlPosition } from "./post/createPosition";
|
||||
import { deletePosition } from "./post/deletePosition";
|
||||
import { updatePosition } from "./post/updatePosition";
|
||||
|
||||
export const API_INDEX_POSITION = [
|
||||
{
|
||||
path: "get-all-position",
|
||||
method: "GET",
|
||||
bin: getAllPosition,
|
||||
},
|
||||
{
|
||||
path: "create-position",
|
||||
method: "POST",
|
||||
bin: createlPosition,
|
||||
},
|
||||
{
|
||||
path: "update-position",
|
||||
method: "POST",
|
||||
bin: updatePosition,
|
||||
},
|
||||
{
|
||||
path: "delete-position",
|
||||
method: "POST",
|
||||
bin: deletePosition,
|
||||
},
|
||||
{
|
||||
path: "get-one-position",
|
||||
method: "GET",
|
||||
bin: getOnePosition,
|
||||
},
|
||||
];
|
||||
|
||||
14
src/module/position/api/api_position.ts
Normal file
14
src/module/position/api/api_position.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { API_INDEX_POSITION } from "./api_index";
|
||||
|
||||
|
||||
type Method = "GET" | "POST";
|
||||
export async function apiPosition(req: Request, method: Method) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const path = searchParams.get("path");
|
||||
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
|
||||
if (!path)
|
||||
return Response.json({ message: "page not found" }, { status: 404 });
|
||||
if (act) return act.bin(req);
|
||||
|
||||
return Response.json({ message: "404" });
|
||||
}
|
||||
20
src/module/position/api/get/getAllPosition.ts
Normal file
20
src/module/position/api/get/getAllPosition.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function getAllPosition(req: Request) {
|
||||
try {
|
||||
const positions = await prisma.position.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(positions);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
24
src/module/position/api/get/getOnePosition.ts
Normal file
24
src/module/position/api/get/getOnePosition.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function getOnePosition(req: Request) {
|
||||
try {
|
||||
const positionId = "2";
|
||||
const getOne = await prisma.position.findUnique({
|
||||
where: {
|
||||
id: positionId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(getOne);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
24
src/module/position/api/post/createPosition.ts
Normal file
24
src/module/position/api/post/createPosition.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function createlPosition(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
|
||||
const positions = await prisma.position.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
isActive: true,
|
||||
idGroup: data.idGroup,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(positions, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
27
src/module/position/api/post/deletePosition.ts
Normal file
27
src/module/position/api/post/deletePosition.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function deletePosition(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
|
||||
const update = await prisma.position.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(
|
||||
{ success: true, message: "Sukses Delete Position" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
22
src/module/position/api/post/updatePosition.ts
Normal file
22
src/module/position/api/post/updatePosition.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { prisma } from "@/module/_global"
|
||||
|
||||
export async function updatePosition(req: Request) {
|
||||
try {
|
||||
const data = await req.json()
|
||||
|
||||
const update = await prisma.position.update({
|
||||
where: {
|
||||
id: data.id
|
||||
},
|
||||
data: {
|
||||
name: data.name,
|
||||
idGroup: data.idGroup
|
||||
}
|
||||
})
|
||||
|
||||
return Response.json({ success: true, message: "Sukses Update Position" }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error", success: false }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { apiPosition } from "./api/api_position";
|
||||
import ViewListPosition from "./view/view_list_position";
|
||||
|
||||
export { ViewListPosition }
|
||||
export { ViewListPosition };
|
||||
export { apiPosition };
|
||||
|
||||
36
src/module/village/api/api_index.ts
Normal file
36
src/module/village/api/api_index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
import { getAllVillage } from "./get/getAllVillage";
|
||||
import { getOneVillage } from "./get/getOneVillage";
|
||||
import { createVillage } from "./post/createVillage";
|
||||
import { deleteVillage } from "./post/deleteVillage";
|
||||
import { updateVillage } from "./post/updateVillage";
|
||||
|
||||
export const API_INDEX_VILLAGE = [
|
||||
{
|
||||
path: "get-all-village",
|
||||
method: "GET",
|
||||
bin: getAllVillage,
|
||||
},
|
||||
{
|
||||
path: "create-village",
|
||||
method: "POST",
|
||||
bin: createVillage,
|
||||
},
|
||||
{
|
||||
path: "update-village",
|
||||
method: "POST",
|
||||
bin: updateVillage,
|
||||
},
|
||||
{
|
||||
path: "delete-village",
|
||||
method: "POST",
|
||||
bin: deleteVillage,
|
||||
},
|
||||
{
|
||||
path: "get-one-village",
|
||||
method: "GET",
|
||||
bin: getOneVillage,
|
||||
},
|
||||
];
|
||||
|
||||
15
src/module/village/api/api_village.ts
Normal file
15
src/module/village/api/api_village.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { API_INDEX_VILLAGE } from "./api_index";
|
||||
|
||||
type Method = "GET" | "POST";
|
||||
export async function apiViilage(req: Request, method: Method) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const path = searchParams.get("path");
|
||||
const act = API_INDEX_VILLAGE.find(
|
||||
(v) => v.path === path && v.method === method
|
||||
);
|
||||
if (!path)
|
||||
return Response.json({ message: "page not found" }, { status: 404 });
|
||||
if (act) return act.bin(req);
|
||||
|
||||
return Response.json({ message: "404" });
|
||||
}
|
||||
21
src/module/village/api/get/getAllVillage.ts
Normal file
21
src/module/village/api/get/getAllVillage.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function getAllVillage(req: Request) {
|
||||
try {
|
||||
const villages = await prisma.village.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
desc: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(villages);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
32
src/module/village/api/get/getOneVillage.ts
Normal file
32
src/module/village/api/get/getOneVillage.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function getOneVillage(req: Request) {
|
||||
try {
|
||||
const village = "11";
|
||||
const getOne = await prisma.village.findUnique({
|
||||
where: {
|
||||
id: village,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
desc: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!getOne) {
|
||||
return Response.json(
|
||||
{ message: "Village tidak ditemukan", success: false },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
return Response.json(getOne);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
24
src/module/village/api/post/createVillage.ts
Normal file
24
src/module/village/api/post/createVillage.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function createVillage(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
const village = await prisma.village.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
desc: data.desc,
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
desc: true,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(village, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json({ message: "Internal Server Error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
25
src/module/village/api/post/deleteVillage.ts
Normal file
25
src/module/village/api/post/deleteVillage.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function deleteVillage(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
const update = await prisma.village.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
return Response.json(
|
||||
{ success: true, message: "Sukses Delete Village" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
28
src/module/village/api/post/updateVillage.ts
Normal file
28
src/module/village/api/post/updateVillage.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
|
||||
export async function updateVillage(req: Request) {
|
||||
try {
|
||||
const data = await req.json();
|
||||
|
||||
const update = await prisma.village.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
name: data.name,
|
||||
desc: data.desc,
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(
|
||||
{ success: true, message: "Sukses Update Village" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return Response.json(
|
||||
{ message: "Internal Server Error", success: false },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { apiViilage } from "./api/api_village";
|
||||
|
||||
export { apiViilage };
|
||||
|
||||
@@ -2,5 +2,9 @@ import { Login } from '@/types/auth/login';
|
||||
import { Verification } from './auth/varification';
|
||||
|
||||
|
||||
export type ILogin = Login
|
||||
export type ILogin = {
|
||||
phone: string
|
||||
id: string,
|
||||
}
|
||||
|
||||
export type IVerification = Verification
|
||||
Reference in New Issue
Block a user