Fix notifikasi join dari event
Fix:
modified: src/app/api/mobile/event/[id]/participants/route.ts
modified: src/bin/seeder/user_seeder.json
### No Issue
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
|
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import {
|
||||||
|
NotificationMobileBodyType,
|
||||||
|
NotificationMobileTitleType,
|
||||||
|
} from "../../../../../../../types/type-mobile-notification";
|
||||||
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
@@ -13,18 +19,28 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
eventId: id,
|
eventId: id,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
},
|
},
|
||||||
|
|
||||||
// select: {
|
|
||||||
// Event: {
|
|
||||||
// select: {
|
|
||||||
// id: true,
|
|
||||||
// title: true,
|
|
||||||
// authorId: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const findEvent = await prisma.event.findUnique({
|
||||||
|
where: { id: id },
|
||||||
|
select: { authorId: true, title: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
// SEND NOTIFICATION
|
||||||
|
if (userId !== findEvent?.authorId) {
|
||||||
|
await sendNotificationMobileToOneUser({
|
||||||
|
recipientId: findEvent?.authorId as string,
|
||||||
|
senderId: userId,
|
||||||
|
payload: {
|
||||||
|
title: "Peserta Baru Join" as NotificationMobileTitleType,
|
||||||
|
body: `Ada peserta baru dalam event: ${findEvent?.title}` as NotificationMobileBodyType,
|
||||||
|
type: "announcement",
|
||||||
|
deepLink: routeUserMobile.eventDetailPublised({ id: id }),
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "default_user",
|
"name": "demo_user",
|
||||||
"nomor": "6282340374412",
|
"nomor": "6282340374412",
|
||||||
"masterUserRoleId": "1",
|
"masterUserRoleId": "1",
|
||||||
"active": true,
|
"active": true,
|
||||||
"termsOfServiceAccepted": false
|
"termsOfServiceAccepted": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin_911",
|
"name": "demo_admin",
|
||||||
"nomor": "6281339158911",
|
"nomor": "6281339158911",
|
||||||
"masterUserRoleId": "3",
|
"masterUserRoleId": "3",
|
||||||
"active": true,
|
"active": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user