Api Mobile Job

Fix:
- api/mobile/job

### No Issue
This commit is contained in:
2025-09-17 14:27:47 +08:00
parent 1e0a1c83ba
commit 5f88fb9a39
3 changed files with 119 additions and 52 deletions

View File

@@ -111,7 +111,6 @@ async function PUT(
}, },
}); });
return NextResponse.json( return NextResponse.json(
{ {
success: true, success: true,

View File

@@ -62,8 +62,6 @@ async function DELETE(
}, },
}); });
console.log("[DELETE DATA JOB]", deleteData);
return NextResponse.json( return NextResponse.json(
{ {
success: true, success: true,
@@ -87,7 +85,22 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
try { try {
const { id } = params; const { id } = params;
const { data } = await request.json(); const { data } = await request.json();
const { searchParams } = new URL(request.url);
const category = searchParams.get("category");
let fixData;
if (category === "archive") {
const updateData = await prisma.job.update({
where: {
id: id,
},
data: {
isArsip: data,
},
});
fixData = updateData;
} else if (category === "edit") {
const updateData = await prisma.job.update({ const updateData = await prisma.job.update({
where: { where: {
id: id, id: id,
@@ -101,11 +114,14 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
}, },
}); });
fixData = updateData;
}
return NextResponse.json( return NextResponse.json(
{ {
success: true, success: true,
message: "Berhasil update data", message: "Berhasil update data",
data: updateData, data: fixData,
}, },
{ status: 200 } { status: 200 }
); );

View File

@@ -40,8 +40,56 @@ async function POST(request: Request) {
async function GET(request: Request) { async function GET(request: Request) {
const { searchParams } = new URL(request.url); const { searchParams } = new URL(request.url);
const search = searchParams.get("search"); const search = searchParams.get("search");
const category = searchParams.get("category");
const authorId = searchParams.get("authorId");
let fixData;
try { try {
if (category === "archive") {
const data = await prisma.job.findMany({
where: {
authorId: authorId,
isActive: true,
isArsip: true,
MasterStatus: {
name: "Publish",
},
// title: {
// contains: search || "",
// mode: "insensitive",
// },
},
orderBy: {
createdAt: "desc",
},
select: {
id: true,
title: true,
deskripsi: true,
authorId: true,
MasterStatus: {
select: {
name: true,
},
},
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
imageId: true,
},
},
},
},
},
});
fixData = data;
} else if (category === "beranda") {
const data = await prisma.job.findMany({ const data = await prisma.job.findMany({
where: { where: {
isActive: true, isActive: true,
@@ -82,11 +130,15 @@ async function GET(request: Request) {
}, },
}, },
}); });
fixData = data;
}
return NextResponse.json( return NextResponse.json(
{ {
success: true, success: true,
message: "Success get data job-vacancy", message: "Success get data job-vacancy",
data: data, data: fixData,
}, },
{ status: 200 } { status: 200 }
); );