Merge pull request 'Mobile notification & EULA route' (#40) from mobile-notification/9-jan-26 into staging

Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/40
This commit is contained in:
2026-01-09 17:47:40 +08:00
10 changed files with 87 additions and 9 deletions

View File

@@ -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.5.34](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.33...v1.5.34) (2026-01-09)
## [1.5.33](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.32...v1.5.33) (2026-01-06)
## [1.5.32](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.31...v1.5.32) (2026-01-05)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.5.33",
"version": "1.5.34",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -0,0 +1,54 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const { nomor } = await req.json();
const user = await prisma.user.findUnique({
where: {
nomor: nomor,
},
});
if (!user)
return NextResponse.json({
success: false,
message: "User belum terdaftar",
status: 404,
});
const updateTerms = await prisma.user.update({
where: { nomor: nomor },
data: {
termsOfServiceAccepted: true,
acceptedTermsAt: new Date(),
},
});
if (!updateTerms) {
return NextResponse.json({
success: false,
message: "Gagal setujui syarat dan ketentuan",
status: 400,
});
}
return NextResponse.json(
{
success: true,
message: "Anda telah setujui syarat dan ketentuan",
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Terjadi masalah saat setujui syarat dan ketentuan",
reason: error as Error,
},
{ status: 500 }
);
}
}

View File

@@ -6,7 +6,6 @@ export async function POST(req: Request) {
try {
const codeOtp = randomOTP();
const body = await req.json();
console.log("[Masuk API]", body);
const { nomor } = body;
const user = await prisma.user.findUnique({
@@ -15,9 +14,6 @@ export async function POST(req: Request) {
},
});
console.log(["cek user", user]);
console.log(["cek nomor", nomor]);
if (!user)
return NextResponse.json({
success: false,
@@ -66,6 +62,7 @@ export async function POST(req: Request) {
success: true,
message: "Kode verifikasi terkirim",
kodeId: createOtpId.id,
isAcceptTerms: user.termsOfServiceAccepted,
},
{ status: 200 }
);

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

@@ -64,6 +64,7 @@ export async function sendNotificationMobileToOneUser({
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
id: notification.id,
deepLink: payload.deepLink,
recipientId: recipientId,
},
android: {
priority: "high" as const,

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