Compare commits
23 Commits
mobile-not
...
mobile-not
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cdde6b5a9 | |||
| e77e5eb3ac | |||
| 8f3f27122a | |||
| d84a1d84ff | |||
| 40ba31edec | |||
| a54f8599b4 | |||
| 09825756f3 | |||
| 3552cf4f39 | |||
| d207b6feed | |||
| f1c8432fdc | |||
| 1cd4c3713e | |||
| 4307b383e3 | |||
| 0786d23336 | |||
| cb3511f973 | |||
| b4921c4e82 | |||
| a9325054eb | |||
| 819812149f | |||
| 75ba2b29ae | |||
| 54a4d15bdd | |||
| 1321f33da9 | |||
| fad0c33b9a | |||
| 565bab4998 | |||
| 7530a38c4d |
@@ -2,6 +2,10 @@
|
||||
|
||||
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.35](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.34...v1.5.35) (2026-01-12)
|
||||
|
||||
## [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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.5.33",
|
||||
"version": "1.5.35",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
|
||||
54
src/app/api/auth/mobile-eula/route.tsx
Normal file
54
src/app/api/auth/mobile-eula/route.tsx
Normal 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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 }
|
||||
);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import { adminMessaging } from "@/lib/firebase-admin";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../types/type-mobile-notification";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
@@ -84,12 +88,12 @@ export async function POST(req: Request) {
|
||||
|
||||
// =========== START SEND NOTIFICATION =========== //
|
||||
|
||||
const findAllUserBySendTo = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2" },
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
console.log("Users to notify:", findAllUserBySendTo);
|
||||
console.log("Users to notify:", adminUsers);
|
||||
|
||||
const dataNotification = {
|
||||
title: "Pendaftaran Baru",
|
||||
@@ -101,63 +105,17 @@ export async function POST(req: Request) {
|
||||
senderId: createUser.id,
|
||||
};
|
||||
|
||||
for (let a of findAllUserBySendTo) {
|
||||
const createdNotification = await prisma.notifikasi.create({
|
||||
data: {
|
||||
...dataNotification,
|
||||
recipientId: a.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (createdNotification) {
|
||||
const deviceToken = await prisma.tokenUserDevice.findMany({
|
||||
where: {
|
||||
userId: a.id,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let i of deviceToken) {
|
||||
const message = {
|
||||
token: i.token,
|
||||
notification: {
|
||||
title: dataNotification.title,
|
||||
body: dataNotification.pesan,
|
||||
},
|
||||
data: {
|
||||
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
|
||||
id: createdNotification.id,
|
||||
deepLink: dataNotification.deepLink,
|
||||
},
|
||||
// Konfigurasi Android untuk prioritas tinggi
|
||||
android: {
|
||||
priority: "high" as const, // Kirim secepatnya, bahkan di doze mode untuk notifikasi penting
|
||||
notification: {
|
||||
channelId: "default", // Sesuaikan dengan channel yang kamu buat di Android
|
||||
},
|
||||
ttl: 0 as const, // Kirim secepatnya, jangan tunda
|
||||
},
|
||||
// Opsional: tambahkan untuk iOS juga
|
||||
apns: {
|
||||
payload: {
|
||||
aps: {
|
||||
sound: "default" as const,
|
||||
// 'content-available': 1 as const, // jika butuh silent push
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await adminMessaging.send(message);
|
||||
console.log("✅ FCM sent successfully", "Response:", response);
|
||||
} catch (error: any) {
|
||||
console.error("❌ FCM send failed:", error);
|
||||
// Lanjutkan ke token berikutnya meski satu gagal
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Pendaftaran User Baru" as NotificationMobileTitleType,
|
||||
body: "User baru telah melakukan registrasi. Ayo cek dan verifikasi!" as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.userAccess({ id: createUser.id }),
|
||||
kategoriApp: "OTHER",
|
||||
},
|
||||
});
|
||||
|
||||
// =========== END SEND NOTIFICATION =========== //
|
||||
|
||||
|
||||
@@ -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 },
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,10 @@ export async function sendNotificationMobileToOneUser({
|
||||
}) {
|
||||
try {
|
||||
const kategoriToNormalCase = _.lowerCase(payload.kategoriApp);
|
||||
const titleFix = `${_.startCase(kategoriToNormalCase)}: ${payload.title}`;
|
||||
const titleFix =
|
||||
kategoriToNormalCase === "other"
|
||||
? payload.title
|
||||
: `${_.startCase(kategoriToNormalCase)}: ${payload.title}`;
|
||||
console.log("titleFix", titleFix);
|
||||
|
||||
// 1. Simpan notifikasi ke DB
|
||||
@@ -64,6 +67,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,
|
||||
|
||||
@@ -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