Fix API notifikasi untuk job

### No Issue
This commit is contained in:
2026-01-08 10:14:35 +08:00
parent 87515ae19f
commit 2086692897
5 changed files with 67 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import _ from "lodash";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, PUT };
@@ -54,10 +56,14 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
const { catatan, senderId } = data;
const { searchParams } = new URL(request.url);
const status = searchParams.get("status");
const fixStatus = _.startCase(status as string);
let fixData;
try {
const checkStatus = await prisma.masterStatus.findFirst({
@@ -83,7 +89,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
data: {
masterStatusId: checkStatus.id,
catatan: data,
catatan: catatan,
},
select: {
id: true,
@@ -97,6 +103,18 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
});
await sendNotificationMobileToOneUser({
recipientId: updt.authorId as any,
senderId: senderId,
payload: {
title: "Pengajuan Review",
body: "Pengajuan data anda telah di tolak !",
type: "announcement",
kategoriApp: "JOB",
deepLink: routeUserMobile.jobByStatus({ status: "reject" }),
},
});
fixData = updt;
} else if (fixStatus === "Publish") {
const updt = await prisma.job.update({
@@ -118,6 +136,18 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
});
await sendNotificationMobileToOneUser({
recipientId: updt.authorId as any,
senderId: senderId,
payload: {
title: "Pengajuan Review",
body: "Selamat data anda telah terpublikasi",
type: "announcement",
kategoriApp: "JOB",
deepLink: routeUserMobile.jobByStatus({ status: "publish" }),
},
});
fixData = updt;
}