Mobile notification & EULA route #40

Merged
bagasbanuna merged 21 commits from mobile-notification/9-jan-26 into staging 2026-01-09 17:47:41 +08:00
5 changed files with 28 additions and 4 deletions
Showing only changes of commit a54f8599b4 - Show all commits

View File

@@ -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;
}

View File

@@ -13,6 +13,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
include: {
Author: {
select: {
id: true,
username: true,
nomor: true,
Profile: {

View File

@@ -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 },
});

View File

@@ -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}`,
};

View File

@@ -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