API Mobile notifikasi job
Fix: modified: src/app/api/mobile/admin/job/[id]/route.ts modified: src/app/api/mobile/job/[id]/route.ts modified: src/app/api/mobile/job/route.ts modified: src/lib/mobile/route-page-mobile.ts modified: types/type-mobile-notification.ts ### No Issue
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
import {
|
||||||
|
sendNotificationMobileToManyUser,
|
||||||
|
sendNotificationMobileToOneUser,
|
||||||
|
} from "@/lib/mobile/notification/send-notification";
|
||||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { NotificationMobileBodyType } from "../../../../../../../types/type-mobile-notification";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -63,7 +67,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const fixStatus = _.startCase(status as string);
|
const fixStatus = _.startCase(status as string);
|
||||||
|
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
const checkStatus = await prisma.masterStatus.findFirst({
|
const checkStatus = await prisma.masterStatus.findFirst({
|
||||||
@@ -148,6 +151,23 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const adminUsers = await prisma.user.findMany({
|
||||||
|
where: { masterUserRoleId: "1", NOT: { id: updt.authorId as any } },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
await sendNotificationMobileToManyUser({
|
||||||
|
recipientIds: adminUsers.map((user) => user.id),
|
||||||
|
senderId: data.authorId,
|
||||||
|
payload: {
|
||||||
|
title: "Ada lowongan kerja baru",
|
||||||
|
body: `${updt.title}` as NotificationMobileBodyType,
|
||||||
|
type: "announcement",
|
||||||
|
deepLink: routeUserMobile.jobDetailPublised({ id: id }),
|
||||||
|
kategoriApp: "JOB",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
fixData = updt;
|
fixData = updt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
include: {
|
include: {
|
||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
username: true,
|
username: true,
|
||||||
nomor: true,
|
nomor: true,
|
||||||
Profile: {
|
Profile: {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ async function POST(request: Request) {
|
|||||||
// kirim notifikasi ke semua admin untuk mengetahui ada job baru yang harus di review
|
// kirim notifikasi ke semua admin untuk mengetahui ada job baru yang harus di review
|
||||||
|
|
||||||
const adminUsers = await prisma.user.findMany({
|
const adminUsers = await prisma.user.findMany({
|
||||||
where: { masterUserRoleId: "2" },
|
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||||
select: { id: true },
|
select: { id: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const routeAdminMobile = {
|
|||||||
const routeUserMobile = {
|
const routeUserMobile = {
|
||||||
home: `/(user)/home`,
|
home: `/(user)/home`,
|
||||||
// JOB
|
// JOB
|
||||||
|
jobDetailPublised: ({ id }: { id: string }) => `/job/${id}`,
|
||||||
jobByStatus: ({ status }: { status?: StatusApp }) =>
|
jobByStatus: ({ status }: { status?: StatusApp }) =>
|
||||||
`/job/(tabs)/status?status=${status}`,
|
`/job/(tabs)/status?status=${status}`,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ export type NotificationMobilePayload = {
|
|||||||
export type NotificationMobileTitleType =
|
export type NotificationMobileTitleType =
|
||||||
| (string & { __type: "NotificationMobileTitleType" })
|
| (string & { __type: "NotificationMobileTitleType" })
|
||||||
| "Pengajuan Review"
|
| "Pengajuan Review"
|
||||||
| "Review Selesai";
|
| "Review Selesai"
|
||||||
|
// to ALL user
|
||||||
|
| "Ada lowongan kerja baru"
|
||||||
|
|
||||||
export type NotificationMobileBodyType =
|
export type NotificationMobileBodyType =
|
||||||
// USER
|
// USER
|
||||||
|
|||||||
Reference in New Issue
Block a user