Compare commits

...

4 Commits

Author SHA1 Message Date
3c6dde6204 Fix API notification to report comment
Fix:
- src/app/api/mobile/admin/forum/[id]/comment/route.ts
- src/app/api/mobile/admin/forum/[id]/route.ts
- src/app/api/mobile/forum/[id]/preview-report-posting/route.ts
- src/app/api/mobile/forum/[id]/report-commentar/route.ts
- src/app/api/mobile/forum/[id]/report-posting/route.ts
- src/lib/mobile/route-page-mobile.ts
- tsconfig.json

Deleted:
- src/app/api/mobile/forum/[id]/report-comment/route.ts

Add:
- src/app/api/mobile/forum/[id]/preview-report-comment/
- src/app/api/mobile/forum/[id]/report-comment-del-soon/

### No Issue
2026-01-19 17:38:15 +08:00
cb0845e264 Fix notification forum
Fix:
modified:   src/app/api/mobile/admin/forum/[id]/route.ts
modified:   src/app/api/mobile/forum/[id]/comment/route.ts
modified:   src/app/api/mobile/forum/[id]/report-posting/route.ts
modified:   src/app/api/mobile/forum/route.ts
modified:   src/lib/mobile/route-page-mobile.ts

Add:
src/app/api/mobile/forum/[id]/preview-report-posting/

### No Issue
2026-01-17 16:00:46 +08:00
d09e30c049 Voting notifikasi for mobile
Fix:
- src/app/api/mobile/admin/voting/[id]/route.ts
- src/app/api/mobile/event/route.ts
- src/app/api/mobile/voting/[id]/route.ts
- src/app/api/mobile/voting/route.ts
- src/lib/mobile/route-page-mobile.ts

### No Issue
2026-01-15 17:38:33 +08:00
c8bd928c33 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
2026-01-15 13:57:00 +08:00
17 changed files with 502 additions and 88 deletions

View File

@@ -1,6 +1,12 @@
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, PUT };
@@ -82,21 +88,43 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const data = await request.json();
console.log("SENDER Comment", data);
try {
const deleteData = await prisma.forum_Komentar.update({
const deactiveComment = await prisma.forum_Komentar.update({
where: {
id: id,
},
data: {
isActive: false,
},
select: {
authorId: true,
komentar: true,
},
});
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: deactiveComment?.authorId as string,
senderId: data?.senderId,
payload: {
title: "Penghapusan Komentar" as NotificationMobileTitleType,
body: `Komentar anda telah dilaporkan: ${deactiveComment?.komentar}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumPreviewReportComment({ id: id }),
},
});
console.log("[DEACTIVATE COMMENT]");
return NextResponse.json(
{
success: true,
message: "Success deactivate comment",
data: deleteData,
// data: deactiveComment,
},
{ status: 200 }
);

View File

@@ -1,6 +1,12 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import _ from "lodash";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, PUT };
@@ -78,14 +84,23 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const data = await request.json();
const { senderId } = data;
console.log("SENDER POSTING", data);
try {
const data = await prisma.forum_Posting.update({
const deactivePosting = await prisma.forum_Posting.update({
where: {
id: id,
},
data: {
isActive: false,
},
select: {
authorId: true,
diskusi: true,
},
});
const deactivateComment = await prisma.forum_Komentar.updateMany({
@@ -97,12 +112,25 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
});
console.log("[DEACTIVATE COMMENT]", deactivateComment);
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: deactivePosting?.authorId as string,
senderId: senderId,
payload: {
title: "Penghapusan Postingan" as NotificationMobileTitleType,
body: `Postingan anda telah dilaporkan: ${deactivePosting?.diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumPreviewReportPosting({ id: id }),
},
});
console.log("[DEACTIVATE POSTINGAN & COMMENT]", deactivateComment);
return NextResponse.json(
{
success: true,
message: "Success deactivate posting",
data: data,
data: deactivePosting,
},
{ status: 200 }
);

View File

@@ -1,8 +1,17 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
import _ from "lodash";
import {
sendNotificationMobileToManyUser,
sendNotificationMobileToOneUser,
} from "@/lib/mobile/notification/send-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../types/type-mobile-notification";
export { GET , PUT};
export { GET, PUT };
async function GET(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
@@ -41,12 +50,16 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
const { catatan, senderId } = data;
console.log("catatan", catatan);
console.log("senderId", senderId);
const { searchParams } = new URL(request.url);
const status = searchParams.get("status");
const fixStatus = _.startCase(status as string);
let fixData;
try {
const checkStatus = await prisma.voting_Status.findFirst({
where: {
@@ -71,9 +84,23 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
data: {
voting_StatusId: checkStatus.id,
catatan: data,
catatan: catatan,
},
});
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: updateStatus.authorId as any,
senderId: senderId,
payload: {
title: "Pengajuan Review Ditolak",
body: "Mohon perbaiki data sesuai catatan penolakan !",
type: "announcement",
kategoriApp: "VOTING",
deepLink: routeUserMobile.votingByStatus({ status: "reject" }),
},
});
fixData = updateStatus;
} else if (fixStatus === "Publish") {
const updateStatus = await prisma.voting.update({
@@ -84,6 +111,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
voting_StatusId: checkStatus.id,
},
});
await sendNotificationMobileToOneUser({
recipientId: updateStatus.authorId as any,
senderId: senderId,
payload: {
title: "Review Selesai",
body: "Voting kamu telah dipublikasikan !" as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "VOTING",
deepLink: routeUserMobile.votingByStatus({ status: "publish" }),
},
});
const adminUsers = await prisma.user.findMany({
where: {
masterUserRoleId: "1",
NOT: { id: updateStatus.authorId as any },
},
select: { id: true },
});
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: senderId,
payload: {
title: "Cek Voting Baru Terpublikasi" as NotificationMobileTitleType,
body: `${updateStatus.title}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "VOTING",
deepLink: routeUserMobile.votingDetailPublised({ id: id }),
},
});
fixData = updateStatus;
}

View File

@@ -1,5 +1,11 @@
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import prisma from "@/lib/prisma";
import { NextResponse } from "next/server";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, POST };
@@ -13,18 +19,28 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
eventId: id,
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(
{
success: true,

View File

@@ -38,6 +38,7 @@ async function POST(request: Request) {
select: { id: true },
});
// SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: data.authorId,

View File

@@ -1,11 +1,18 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { POST, GET, DELETE };
async function POST(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
const { comment, authorId } = data;
console.log("[ID COMMENT]", id);
console.log("[DATA COMMENT]", data);
@@ -14,8 +21,8 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
const createComment = await prisma.forum_Komentar.create({
data: {
forum_PostingId: id,
komentar: data.comment,
authorId: data.authorId,
komentar: comment,
authorId: authorId,
},
select: {
id: true,
@@ -38,6 +45,24 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
},
});
const findForum = await prisma.forum_Posting.findUnique({
where: { id: id },
select: { authorId: true, diskusi: true },
});
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: findForum?.authorId as string,
senderId: authorId,
payload: {
title: "Komentar Baru" as NotificationMobileTitleType,
body: `Ayo cek komentar pada postingan: ${findForum?.diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumDetail({ id: id }),
},
});
if (!createComment) {
return NextResponse.json({
status: 400,
@@ -52,7 +77,6 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
message: "Berhasil update data",
data: createComment,
});
} catch (error) {
console.log("[ERROR COMMENT]", error);
return NextResponse.json({
@@ -114,7 +138,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
}
}
async function DELETE(request: Request, { params }: { params: { id: string } }) {
async function DELETE(
request: Request,
{ params }: { params: { id: string } }
) {
const { id } = params;
try {

View File

@@ -0,0 +1,42 @@
import { NextResponse } from "next/server";
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
const { id } = params;
try {
const data = await prisma.forum_Komentar.findUnique({
where: {
id: id,
},
select: {
id: true,
komentar: true,
isActive: true,
createdAt: true,
Forum_ReportKomentar: {
select: {
deskripsi: true,
ForumMaster_KategoriReport: true,
},
},
},
});
return NextResponse.json({
status: 200,
success: true,
data: data,
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal mendapatkan data posting",
reason: (error as Error).message,
});
}
}

View File

@@ -0,0 +1,49 @@
import { NextResponse } from "next/server";
export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
const { id } = params;
try {
const data = await prisma.forum_Posting.findUnique({
where: {
id: id,
},
select: {
id: true,
diskusi: true,
isActive: true,
createdAt: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
},
},
Forum_ReportPosting: {
select: {
deskripsi: true,
ForumMaster_KategoriReport: true,
},
},
},
});
return NextResponse.json({
status: 200,
success: true,
data: data,
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal mendapatkan data posting",
reason: (error as Error).message,
});
}
}

View File

@@ -1,5 +1,11 @@
import { prisma } from "@/lib";
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
import { NextResponse } from "next/server";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../types/type-mobile-notification";
export { POST };
@@ -7,44 +13,70 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
const { authorId: reportedUserId, categoryId, description } = data;
try {
const content = await prisma.forum_Komentar.findUnique({
where: {
id: id,
},
// Komentar yang di report
const findComment = await prisma.forum_Komentar.findUnique({
where: { id: id },
select: { authorId: true, komentar: true },
});
const reportList = await prisma.forumMaster_KategoriReport.findUnique({
// List admin untuk dikirim notifikasi
const adminUsers = await prisma.user.findMany({
where: {
id: data.categoryId,
masterUserRoleId: "2",
NOT: { id: findComment?.authorId as any },
},
select: { id: true },
});
const msg = `Report Komentar: "${content?.komentar}" dengan kategori \n\n\n${reportList?.title} : \n\n${reportList?.deskripsi}`;
const res = await fetch(
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
{ cache: "no-cache" }
);
if (data.categoryId) {
fixData = await prisma.forum_ReportKomentar.create({
if (categoryId) {
const createdReport = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId as any,
userId: reportedUserId,
forumMaster_KategoriReportId: categoryId,
},
});
//SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: reportedUserId,
payload: {
title: "Laporan Dari User" as NotificationMobileTitleType,
body: `Report terhadap komentar, ${findComment?.komentar}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeAdminMobile.forumPreviewReportComment,
},
});
fixData = createdReport;
} else {
fixData = await prisma.forum_ReportKomentar.create({
const createdReport = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: id,
userId: data.authorId,
deskripsi: data.description,
userId: reportedUserId,
deskripsi: description,
},
});
//SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: reportedUserId,
payload: {
title: "Laporan Dari User" as NotificationMobileTitleType,
body: `Report terhadap komentar, ${findComment?.komentar}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeAdminMobile.forumPreviewReportComment,
},
});
fixData = createdReport;
}
if (!fixData) {

View File

@@ -1,5 +1,15 @@
import { NextResponse } from "next/server";
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 { POST };
@@ -7,38 +17,70 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
const { authorId: reportedUserId, categoryId, description } = data;
try {
const content = await prisma.forum_Posting.findUnique({
where: {
id: id,
},
// Postingan yang akan di report
const findPosting = await prisma.forum_Posting.findUnique({
where: { id: id },
select: { authorId: true, diskusi: true },
});
const msg = `Report Postingan: "${content?.diskusi}"`;
const res = await fetch(
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
{ cache: "no-cache" }
);
// List admin untuk dikirim notifikasi
const adminUsers = await prisma.user.findMany({
where: {
masterUserRoleId: "2",
NOT: { id: findPosting?.authorId as any },
},
select: { id: true },
});
if (data.categoryId) {
fixData = await prisma.forum_ReportPosting.create({
if (categoryId) {
const createReported = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId,
userId: reportedUserId,
forumMaster_KategoriReportId: categoryId,
},
});
//SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: reportedUserId,
payload: {
title: "Laporan Dari User" as NotificationMobileTitleType,
body: `Report terhadap postingan, ${findPosting?.diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeAdminMobile.forumPreviewReportPosting,
},
});
fixData = createReported;
} else {
fixData = await prisma.forum_ReportPosting.create({
const createReported = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
deskripsi: data.description,
userId: reportedUserId,
deskripsi: description,
},
});
//SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: reportedUserId,
payload: {
title: "Laporan Dari User" as NotificationMobileTitleType,
body: `Report terhadap postingan, ${findPosting?.diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeAdminMobile.forumPreviewReportPosting,
},
});
fixData = createReported;
}
if (!fixData) {

View File

@@ -1,22 +1,54 @@
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
import { NotificationMobileBodyType, NotificationMobileTitleType } from "../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { POST, GET };
async function POST(request: Request) {
const { data } = await request.json();
console.log("[DATA]", data);
const { diskusi, authorId } = data;
try {
const create = await prisma.forum_Posting.create({
data: {
diskusi: data.diskusi,
authorId: data.authorId,
diskusi: diskusi,
authorId: authorId,
forumMaster_StatusPostingId: 1,
},
});
if (!create) {
return NextResponse.json({
success: false,
message: "Gagal memposting",
status: 400,
});
}
const allUsers = await prisma.user.findMany({
where: {
id: { not: authorId },
},
select: { id: true },
});
// SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: allUsers.map((user) => user.id),
senderId: authorId,
payload: {
title: "Ada Diskusi Baru" as NotificationMobileTitleType,
body: `${diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumBeranda,
},
});
return NextResponse.json({
success: true,
message: "Berhasil membuat postingan",
@@ -43,7 +75,6 @@ async function GET(request: Request) {
const takeData = 5;
const skipData = (Number(page) - 1) * takeData;
// console.log("authorId", authorId);
// console.log("userLoginId", userLoginId);
// console.log("search", search);
@@ -128,13 +159,12 @@ async function GET(request: Request) {
fixData = newData;
} else if (category === "forumku") {
const count = await prisma.forum_Posting.count({
where: {
isActive: true,
authorId: authorId,
},
})
});
const data = await prisma.forum_Posting.findMany({
take: page ? takeData : undefined,
@@ -191,7 +221,7 @@ async function GET(request: Request) {
const dataFix = {
data: newData,
count,
}
};
fixData = dataFix;
} else {

View File

@@ -1,6 +1,12 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import _ from "lodash";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, DELETE, PUT, POST };
@@ -39,7 +45,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
const listNamaVote = data?.Voting_DaftarNamaVote || [];
for (let v of listNamaVote) {
const kontributor = await prisma.voting_Kontributor.findMany({
where: {
voting_DaftarNamaVoteId: v.id,
@@ -90,7 +95,6 @@ async function DELETE(
},
});
return NextResponse.json({
success: true,
message: "Berhasil menghapus data",
@@ -171,7 +175,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
},
});
if (!updateVoting)
return NextResponse.json({ status: 400, message: "Gagal Update" });
}
@@ -193,11 +196,12 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
async function POST(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
const { chooseId, userId } = data;
try {
const findData = await prisma.voting_DaftarNamaVote.findFirst({
const findDatapilihan = await prisma.voting_DaftarNamaVote.findFirst({
where: {
id: data.chooseId,
id: chooseId,
},
select: {
jumlah: true,
@@ -205,28 +209,32 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
},
});
if (!findData)
if (!findDatapilihan)
return NextResponse.json({
success: false,
message: "Data tidak ditemukan",
});
const updateData = await prisma.voting_DaftarNamaVote.update({
const updateDataPilihan = await prisma.voting_DaftarNamaVote.update({
where: {
id: data.chooseId,
},
data: {
jumlah: findData.jumlah + 1,
jumlah: findDatapilihan.jumlah + 1,
},
});
if (!updateData)
if (!updateDataPilihan)
return NextResponse.json({
success: false,
message: "Gagal Update Data",
});
const findVotingData = await prisma.voting.findUnique({
where: { id: id },
select: { authorId: true, title: true },
});
const createKontributor = await prisma.voting_Kontributor.create({
data: {
votingId: id,
@@ -250,6 +258,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
message: "Gagal Menjadi Kontributor",
});
// SEND NOTIFICATION
if (userId !== findVotingData?.authorId) {
await sendNotificationMobileToOneUser({
recipientId: findVotingData?.authorId as string,
senderId: userId,
payload: {
title: "User Melakukan Vote" as NotificationMobileTitleType,
body: `Salah satu user telah melakukan voting pada: ${findVotingData?.title}` as NotificationMobileBodyType,
type: "announcement",
deepLink: routeUserMobile.votingDetailPublised({ id: id }),
kategoriApp: "VOTING",
},
});
}
return NextResponse.json({
success: true,
message: "Berhasil Voting",

View File

@@ -1,6 +1,9 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import _ from "lodash";
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
export { POST, GET };
@@ -41,6 +44,24 @@ async function POST(request: Request) {
});
}
const adminUsers = await prisma.user.findMany({
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
select: { id: true },
});
// SEND NOTIFICATION
await sendNotificationMobileToManyUser({
recipientIds: adminUsers.map((user) => user.id),
senderId: data.authorId,
payload: {
title: "Pengajuan Review Baru",
body: create.title as NotificationMobileBodyType,
type: "announcement",
deepLink: routeAdminMobile.votingByStatus({ status: "review" }),
kategoriApp: "VOTING",
},
});
return NextResponse.json(
{
success: true,
@@ -125,8 +146,6 @@ async function GET(request: Request) {
});
fixData = data;
} else if (category === "contribution") {
const data = await prisma.voting_Kontributor.findMany({
orderBy: {

View File

@@ -1,13 +1,13 @@
[
{
"name": "default_user",
"name": "demo_user",
"nomor": "6282340374412",
"masterUserRoleId": "1",
"active": true,
"termsOfServiceAccepted": false
},
{
"name": "admin_911",
"name": "demo_admin",
"nomor": "6281339158911",
"masterUserRoleId": "3",
"active": true,

View File

@@ -5,14 +5,20 @@ type StatusApp = "review" | "draft" | "reject" | "publish";
const routeAdminMobile = {
userAccess: ({ id }: { id: string }) => `/admin/user-access/${id}`,
// JOB
jobDetail: ({ id, status }: { id: string; status: StatusApp }) =>
`/admin/job/${id}/${status}`,
jobByStatus: ({ status }: { status: StatusApp }) =>
`/admin/job/${status}/status`,
// EVENT
eventByStatus: ({ status }: { status: StatusApp }) =>
`/admin/event/${status}/status`,
// VOTING
votingByStatus: ({ status }: { status: StatusApp }) =>
`/admin/voting/${status}/status`,
// FORUM
forumPreviewReportPosting: `/admin/forum/report-posting`,
forumPreviewReportComment: `/admin/forum/report-comment`,
};
const routeUserMobile = {
@@ -26,4 +32,15 @@ const routeUserMobile = {
eventByStatus: ({ status }: { status?: StatusApp }) =>
`/event/(tabs)/status?status=${status}`,
eventDetailPublised: ({ id }: { id: string }) => `/event/${id}/publish`,
// VOTING
votingByStatus: ({ status }: { status?: StatusApp }) =>
`/voting/(tabs)/status?status=${status}`,
votingDetailPublised: ({ id }: { id: string }) => `/voting/${id}`,
// FORUM
forumBeranda: `/forum`,
forumDetail: ({ id }: { id: string }) => `/forum/${id}`,
forumPreviewReportPosting: ({ id }: { id: string }) => `/forum/${id}/preview-report-posting`,
forumPreviewReportComment: ({ id }: { id: string }) => `/forum/${id}/preview-report-comment`,
};

View File

@@ -23,6 +23,6 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app_modules/investasi/proses_transaksi/view.jsx", "src/app/api/investasi/midtrans/[id]/route.ts", "src/app_modules/job/create/TextEdit.tsx", "src/app/api/mobile/forum/[id]/report-comment/route.ts"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app_modules/investasi/proses_transaksi/view.jsx", "src/app/api/investasi/midtrans/[id]/route.ts", "src/app_modules/job/create/TextEdit.tsx", "src/app/api/mobile/forum/[id]/report-comment-del-soon/route.ts"],
"exclude": ["node_modules"]
}