Mobile notification & EULA route #40
@@ -1,8 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
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 { NotificationMobileBodyType } from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -63,7 +67,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const status = searchParams.get("status");
|
||||
const fixStatus = _.startCase(status as string);
|
||||
|
||||
|
||||
let fixData;
|
||||
try {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
include: {
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: {
|
||||
|
||||
@@ -22,7 +22,7 @@ async function POST(request: Request) {
|
||||
// kirim notifikasi ke semua admin untuk mengetahui ada job baru yang harus di review
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2" },
|
||||
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ const routeAdminMobile = {
|
||||
const routeUserMobile = {
|
||||
home: `/(user)/home`,
|
||||
// JOB
|
||||
jobDetailPublised: ({ id }: { id: string }) => `/job/${id}`,
|
||||
jobByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/job/(tabs)/status?status=${status}`,
|
||||
};
|
||||
|
||||
@@ -14,7 +14,9 @@ export type NotificationMobilePayload = {
|
||||
export type NotificationMobileTitleType =
|
||||
| (string & { __type: "NotificationMobileTitleType" })
|
||||
| "Pengajuan Review"
|
||||
| "Review Selesai";
|
||||
| "Review Selesai"
|
||||
// to ALL user
|
||||
| "Ada lowongan kerja baru"
|
||||
|
||||
export type NotificationMobileBodyType =
|
||||
// USER
|
||||
|
||||
Reference in New Issue
Block a user