diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc05142..2e6fc685 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.4.37](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.36...v1.4.37) (2025-09-16) + ## [1.4.36](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.35...v1.4.36) (2025-09-15) ## [1.4.35](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.34...v1.4.35) (2025-09-12) diff --git a/package.json b/package.json index 18d6a8ac..5b7c47cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.4.36", + "version": "1.4.37", "private": true, "prisma": { "seed": "bun prisma/seed.ts" diff --git a/src/app/api/mobile/job/[id]/[status]/route.ts b/src/app/api/mobile/job/[id]/[status]/route.ts new file mode 100644 index 00000000..15d78713 --- /dev/null +++ b/src/app/api/mobile/job/[id]/[status]/route.ts @@ -0,0 +1,132 @@ +import prisma from "@/lib/prisma"; +import _ from "lodash"; +import { NextResponse } from "next/server"; + +export { GET, PUT }; + +async function GET( + request: Request, + { params }: { params: { id: string; status: string } } +) { + try { + const { id, status } = params; + const fixStatusName = _.startCase(status); + + const data = await prisma.job.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + isActive: true, + authorId: id, + isArsip: false, + MasterStatus: { + name: fixStatusName, + }, + }, + select: { + id: true, + title: true, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Success get job", + data: data, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error get job", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} + +async function PUT( + request: Request, + { params }: { params: { id: string; status: string } } +) { + try { + const { id, status } = params; + const fixStatusName = _.startCase(status); + + const checkData = await prisma.job.findUnique({ + where: { + id: id, + }, + select: { + id: true, + MasterStatus: { + select: { + name: true, + }, + }, + }, + }); + + if (!checkData) { + return NextResponse.json({ + success: false, + message: "Data tidak ditemukan", + status: 404, + }); + } + + if (checkData?.MasterStatus?.name === "Publish") { + return NextResponse.json({ + success: false, + message: "Job telah terpublish", + status: 400, + }); + } + + const checkStatus = await prisma.masterStatus.findFirst({ + where: { + name: fixStatusName, + }, + }); + + if (!checkStatus) { + return NextResponse.json({ + success: false, + message: "Status tidak ditemukan", + status: 404, + }); + } + + const updateData = await prisma.job.update({ + where: { + id: id, + }, + data: { + masterStatusId: checkStatus.id, + }, + }); + + + return NextResponse.json( + { + success: true, + message: "Update berhasil", + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error update job", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/job/[id]/route.ts b/src/app/api/mobile/job/[id]/route.ts new file mode 100644 index 00000000..2b5956c5 --- /dev/null +++ b/src/app/api/mobile/job/[id]/route.ts @@ -0,0 +1,122 @@ +import { NextResponse } from "next/server"; +import prisma from "@/lib/prisma"; + +export { GET, DELETE, PUT }; + +async function GET(request: Request, { params }: { params: { id: string } }) { + try { + const { id } = params; + const data = await prisma.job.findUnique({ + where: { + id: id, + }, + include: { + Author: { + select: { + username: true, + nomor: true, + Profile: { + select: { + name: true, + alamat: true, + }, + }, + }, + }, + MasterStatus: { + select: { + name: true, + }, + }, + }, + }); + return NextResponse.json( + { + success: true, + message: "Success get data job-vacancy", + data: data, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error get data job-vacancy", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} + +async function DELETE( + request: Request, + { params }: { params: { id: string } } +) { + try { + const { id } = params; + const deleteData = await prisma.job.delete({ + where: { + id: id, + }, + }); + + console.log("[DELETE DATA JOB]", deleteData); + + return NextResponse.json( + { + success: true, + message: "Data berhasil dihapus", + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Gagal menghapus data", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} + +async function PUT(request: Request, { params }: { params: { id: string } }) { + try { + const { id } = params; + const { data } = await request.json(); + + const updateData = await prisma.job.update({ + where: { + id: id, + }, + data: { + title: data.title, + content: data.content, + deskripsi: data.deskripsi, + // authorId: data.authorId, + imageId: data.imageId || null, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Berhasil update data", + data: updateData, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Gagal update data", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/job/route.ts b/src/app/api/mobile/job/route.ts new file mode 100644 index 00000000..dd7bb105 --- /dev/null +++ b/src/app/api/mobile/job/route.ts @@ -0,0 +1,103 @@ +import prisma from "@/lib/prisma"; +import { NextResponse } from "next/server"; + +export { POST, GET }; + +async function POST(request: Request) { + try { + const { data } = await request.json(); + + const create = await prisma.job.create({ + data: { + title: data.title, + content: data.content, + deskripsi: data.deskripsi, + authorId: data.authorId, + imageId: data.imageId || null, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Berhasil disimpan", + data: create, + }, + { status: 201 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error create job", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} + +async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const search = searchParams.get("search"); + + try { + const data = await prisma.job.findMany({ + where: { + isActive: true, + isArsip: false, + 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, + }, + }, + }, + }, + }, + }); + return NextResponse.json( + { + success: true, + message: "Success get data job-vacancy", + data: data, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error get data job-vacancy", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app_modules/job/_view/view_not_user_view_job.tsx b/src/app_modules/job/_view/view_not_user_view_job.tsx index 4cd6139d..78371b94 100644 --- a/src/app_modules/job/_view/view_not_user_view_job.tsx +++ b/src/app_modules/job/_view/view_not_user_view_job.tsx @@ -40,13 +40,32 @@ export function Job_ViewNotUserJobVacany() { {data.title} - - -
- - -
- + + + + + Syarat & Ketentuan + + +
"), + }} + /> + + + + + Deskripsi + + +
"), + }} + /> + +