Compare commits
11 Commits
mobile-not
...
mobile-not
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c9459dcf3 | |||
| 8b54f5ca65 | |||
| c94da645f3 | |||
| da0477102e | |||
| 70db97f5bb | |||
| 8ccf1f2b6e | |||
| 048b7b6094 | |||
| fc23e01275 | |||
| 20d05c1cc7 | |||
| 2c269db250 | |||
| fea94df7bb |
@@ -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.38](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.37...v1.5.38) (2026-01-27)
|
||||
|
||||
## [1.5.37](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.36...v1.5.37) (2026-01-23)
|
||||
|
||||
## [1.5.36](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.35...v1.5.36) (2026-01-13)
|
||||
|
||||
## [1.5.35](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.34...v1.5.35) (2026-01-12)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.5.36",
|
||||
"version": "1.5.38",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
<p>You have the right to request access to the personal information we collect from you, details about how we have processed it, correct inaccuracies, or delete your personal information. You may also have the right to withdraw your consent to our processing of your personal information. These rights may be limited in some circumstances by applicable law.</p>
|
||||
<p>To make a request, please contact us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
|
||||
<hr style="margin: 30px 0; border: 0; border-top: 1px solid #eee;">
|
||||
<p>© 2025 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
<p>© 2026 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -104,7 +104,7 @@
|
||||
</p>
|
||||
|
||||
<footer>
|
||||
<p>© 2025 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
<p>© 2026 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,12 +2,13 @@ import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method Not Allowed" },
|
||||
{ status: 405 }
|
||||
{ status: 405 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,29 +27,21 @@ export async function POST(req: Request) {
|
||||
if (!createOtpId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mengirim kode OTP" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
// const encodedMsg = encodeURIComponent(msg);
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -57,7 +50,7 @@ export async function POST(req: Request) {
|
||||
message: "Kode verifikasi terkirim",
|
||||
kodeId: createOtpId.id,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.log("Error Login", error);
|
||||
@@ -67,7 +60,7 @@ export async function POST(req: Request) {
|
||||
message: "Terjadi masalah saat login",
|
||||
reason: error as Error,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
@@ -31,30 +32,21 @@ export async function POST(req: Request) {
|
||||
if (!createOtpId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mengirim kode OTP" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
// const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPAADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n\n> Kode OTP anda: ${codeOtp}.`;
|
||||
// const encodedMsg = encodeURIComponent(msg);
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -64,7 +56,7 @@ export async function POST(req: Request) {
|
||||
kodeId: createOtpId.id,
|
||||
isAcceptTerms: user.termsOfServiceAccepted,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -73,7 +65,7 @@ export async function POST(req: Request) {
|
||||
message: "Terjadi masalah saat login",
|
||||
reason: error as Error,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../types/type-mobile-notification";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
@@ -69,23 +70,21 @@ export async function POST(req: Request) {
|
||||
{ status: 400 }
|
||||
);
|
||||
|
||||
// const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPAADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n\n> Kode OTP anda: ${codeOtp}.`;
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
// // const encodedMsg = encodeURIComponent(msg);
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor: data.nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://wa.wibudev.com/code?nom=${data.nomor}&text=${msg}`,
|
||||
{ cache: "no-cache" }
|
||||
);
|
||||
|
||||
const sendWa = await res.json();
|
||||
|
||||
if (sendWa.status !== "success")
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
|
||||
// =========== START SEND NOTIFICATION =========== //
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
|
||||
@@ -2,12 +2,13 @@ import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method Not Allowed" },
|
||||
{ status: 405 }
|
||||
{ status: 405 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,25 +17,18 @@ export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const { nomor } = body;
|
||||
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
const createOtpId = await prisma.kodeOtp.create({
|
||||
@@ -50,7 +44,7 @@ export async function POST(req: Request) {
|
||||
success: false,
|
||||
message: "Gagal Membuat Kode OTP",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -59,7 +53,7 @@ export async function POST(req: Request) {
|
||||
message: "Kode Verifikasi Dikirim",
|
||||
kodeId: createOtpId.id,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error(" Error Resend OTP", error);
|
||||
@@ -68,7 +62,7 @@ export async function POST(req: Request) {
|
||||
success: false,
|
||||
message: "Server Whatsapp Error !!",
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import { funFindDonaturList } from "@/lib/mobile/donation/find-donatur-list";
|
||||
import {
|
||||
sendNotificationMobileToManyUser,
|
||||
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 { POST, GET };
|
||||
|
||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { title, nominalCair, deskripsi, imageId, authorId } = data;
|
||||
|
||||
try {
|
||||
const dataDonasi = await prisma.donasi.findUnique({
|
||||
@@ -22,19 +33,19 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Pencarian Donasi Gagal",
|
||||
reason: "Pencarian Donasi Gagal",
|
||||
message: "DataPencarian Donasi Gagal",
|
||||
reason: "Data Pencarian Donasi Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const createPencairan = await prisma.donasi_PencairanDana.create({
|
||||
data: {
|
||||
donasiId: id,
|
||||
nominalCair: +data.nominalCair,
|
||||
deskripsi: data.deskripsi,
|
||||
title: data.title,
|
||||
imageId: data.imageId,
|
||||
nominalCair: +nominalCair,
|
||||
deskripsi: deskripsi,
|
||||
title: title,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -45,11 +56,11 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Gagal",
|
||||
reason: "Pencairan Dana Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const hasilTotalPencairan =
|
||||
Number(dataDonasi.totalPencairan) + Number(data.nominalCair);
|
||||
Number(dataDonasi.totalPencairan) + Number(nominalCair);
|
||||
// const hasilAkumulasiPencairan = Number(dataDonasi.akumulasiPencairan) + 1;
|
||||
|
||||
const countPencairan = await prisma.donasi_PencairanDana.count({
|
||||
@@ -66,8 +77,47 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
akumulasiPencairan: countPencairan,
|
||||
totalPencairan: hasilTotalPencairan,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
title: true,
|
||||
},
|
||||
});
|
||||
|
||||
// ================= START SEND NOTIFICATION =================
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateDonasi?.authorId!,
|
||||
senderId: authorId,
|
||||
payload: {
|
||||
title: "Pencairan Dana Berhasil" as NotificationMobileTitleType,
|
||||
body: `Telah dilaksanakan pencairan dana untuk ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({
|
||||
id: id,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const recipientIds = await funFindDonaturList(id);
|
||||
|
||||
if (recipientIds.length > 0) {
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds,
|
||||
senderId: authorId,
|
||||
payload: {
|
||||
title: "Pencarian Dana" as NotificationMobileTitleType,
|
||||
body: `Update pencarian dana pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({
|
||||
id: id,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ================= END SEND NOTIFICATION =================
|
||||
|
||||
if (!updateDonasi)
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -75,7 +125,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Update Donasi Gagal",
|
||||
reason: "Update Donasi Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -84,7 +134,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Berhasil",
|
||||
// data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[ERROR]", error);
|
||||
@@ -94,7 +144,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Gagal",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -110,7 +160,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
console.log("[CATEGORY]", category);
|
||||
let fixData;
|
||||
try {
|
||||
|
||||
if (category === "get-all") {
|
||||
fixData = await prisma.donasi_PencairanDana.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
@@ -140,7 +189,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Category tidak ditemukan",
|
||||
reason: "Category tidak ditemukan",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,7 +199,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Success get data disbursement",
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[ERROR]", error);
|
||||
@@ -160,7 +209,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Gagal mendapatkan data disbursement",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
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 };
|
||||
|
||||
@@ -50,6 +53,7 @@ async function GET(req: Request, { params }: { params: { id: string } }) {
|
||||
interface DataType {
|
||||
donationId: string;
|
||||
nominal: number;
|
||||
senderId: string;
|
||||
}
|
||||
|
||||
async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
@@ -111,6 +115,9 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
donasiMaster_StatusInvoiceId: checkStatusTransaksi.id,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updateInvoice) {
|
||||
@@ -154,6 +161,38 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
);
|
||||
}
|
||||
|
||||
// SEND NOTIFICATION: to donatur
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateInvoice?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Berhasil" as NotificationMobileTitleType,
|
||||
body: `Selamat anda menjadi donatur pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION: to creator
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateDonasi?.authorId as any,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Ada Donatur Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek daftar donatur pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({
|
||||
id: updateDonasi?.id as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import {
|
||||
sendNotificationMobileToManyUser,
|
||||
sendNotificationMobileToOneUser,
|
||||
} from "@/lib/mobile/notification/send-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -48,7 +57,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
DonasiMaster_StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -60,7 +69,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
donatur: successInvoice,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -69,7 +78,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error get detail Investasi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +86,10 @@ 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("[PUT CATATAN]", catatan);
|
||||
console.log("[PUT SENDER ID]", senderId);
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
const fixStatus = _.startCase(status as string);
|
||||
@@ -102,7 +115,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error update data event",
|
||||
reason: "Status not found",
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
|
||||
if (fixStatus === "Reject") {
|
||||
@@ -111,11 +124,24 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
catatan: data,
|
||||
catatan: catatan,
|
||||
donasiMaster_StatusDonasiId: checkStatus.id,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Ditolak",
|
||||
body: "Mohon perbaiki data sesuai catatan penolakan !",
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationByStatus({ status: "reject" }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateData;
|
||||
} else if (fixStatus === "Publish") {
|
||||
const updateData = await prisma.donasi.update({
|
||||
@@ -128,6 +154,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Review Selesai",
|
||||
body: `Donasi kamu telah dipublikasikan ! ${updateData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationByStatus({ status: "publish" }),
|
||||
},
|
||||
});
|
||||
|
||||
const allUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
NOT: { id: updateData.authorId as any },
|
||||
active: true,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: allUsers.map((user) => user.id),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Ayo Cek Donasi Terbaru" as NotificationMobileTitleType,
|
||||
body: `${updateData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateData;
|
||||
}
|
||||
|
||||
@@ -137,7 +196,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Data Donasi Berhasil Diambil",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -146,7 +205,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error get detail Investasi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
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 };
|
||||
|
||||
@@ -65,19 +71,39 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
statusInvoiceId: "4",
|
||||
},
|
||||
// select: {
|
||||
// StatusInvoice: true,
|
||||
// authorId: true,
|
||||
// },
|
||||
select: {
|
||||
Investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updt?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Tertolak" as NotificationMobileTitleType,
|
||||
body: `Maaf transaksi kamu telah ditolak ! ${updt?.Investasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updt;
|
||||
} else if (category === "accept") {
|
||||
const dataInvestasi: any = await prisma.investasi.findFirst({
|
||||
const findInvestasi = await prisma.investasi.findFirst({
|
||||
where: {
|
||||
id: data.investasiId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
totalLembar: true,
|
||||
sisaLembar: true,
|
||||
lembarTerbeli: true,
|
||||
@@ -85,30 +111,33 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
});
|
||||
|
||||
// Hitung TOTAL SISA LEMBAR
|
||||
const investasi_sisaLembar = Number(dataInvestasi?.sisaLembar);
|
||||
const investasi_sisaLembar = Number(findInvestasi?.sisaLembar);
|
||||
const invoice_lembarTerbeli = Number(data.lembarTerbeli);
|
||||
const resultSisaLembar = investasi_sisaLembar - invoice_lembarTerbeli;
|
||||
|
||||
// TAMBAH LEMBAR TERBELI
|
||||
const investasi_lembarTerbeli = Number(dataInvestasi?.lembarTerbeli);
|
||||
const investasi_lembarTerbeli = Number(findInvestasi?.lembarTerbeli);
|
||||
const resultLembarTerbeli =
|
||||
investasi_lembarTerbeli + invoice_lembarTerbeli;
|
||||
|
||||
// Progress
|
||||
const investasi_totalLembar = Number(dataInvestasi?.totalLembar);
|
||||
const investasi_totalLembar = Number(findInvestasi?.totalLembar);
|
||||
const progress = (resultLembarTerbeli / investasi_totalLembar) * 100;
|
||||
const resultProgres = Number(progress).toFixed(2);
|
||||
|
||||
const updt = await prisma.investasi_Invoice.update({
|
||||
const updateInvoice = await prisma.investasi_Invoice.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) {
|
||||
if (!updateInvoice) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
@@ -144,7 +173,35 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
);
|
||||
}
|
||||
|
||||
fixData = updt;
|
||||
// SEND NOTIFICATION: to investor
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateInvoice?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Berhasil" as NotificationMobileTitleType,
|
||||
body: `Selamat anda menjadi investor pada investasi ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION: to creator
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: findInvestasi?.authorId as any,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Ada Investor Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek daftar investor pada ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: findInvestasi?.id as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateInvoice;
|
||||
} else {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
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 };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
|
||||
|
||||
try {
|
||||
const data = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
@@ -78,14 +87,19 @@ 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("[DATA]", data);
|
||||
console.log("[CATATAN]", catatan);
|
||||
console.log("[SENDER ID]", senderId);
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
|
||||
console.log("[=======Start Investment console=======]");
|
||||
console.log("[ID]", id);
|
||||
console.log("[DATA]", data);
|
||||
console.log("[STATUS]", status);
|
||||
console.log("[=======End Investment console=======]");
|
||||
// console.log("[=======Start Investment console=======]");
|
||||
// console.log("[ID]", id);
|
||||
// console.log("[STATUS]", status);
|
||||
// console.log("[=======End Investment console=======]");
|
||||
|
||||
const publishTime = new Date();
|
||||
|
||||
@@ -96,9 +110,26 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
catatan: data,
|
||||
catatan: catatan,
|
||||
masterStatusInvestasiId: "4",
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
title: true,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updatedData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Ditolak",
|
||||
body: "Mohon perbaiki data sesuai catatan penolakan !",
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentPortofolioByStatus({ status: "reject" }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE REJECT]", updatedData);
|
||||
@@ -114,6 +145,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updatedData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Review Selesai",
|
||||
body: `Investasi kamu telah dipublikasikan ! ${updatedData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentPortofolioByStatus({ status: "publish" }),
|
||||
},
|
||||
});
|
||||
|
||||
const allUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
NOT: { id: updatedData.authorId as any },
|
||||
active: true,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: allUsers.map((user) => user.id),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Ayo Cek Investasi Terbaru" as NotificationMobileTitleType,
|
||||
body: `${updatedData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE PUBLISH]", updatedData);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -50,8 +51,25 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
active: data.active,
|
||||
},
|
||||
select: {
|
||||
nomor: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (data.active) {
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor: updateData.nomor,
|
||||
newMessage:
|
||||
"Halo sahabat HIConnect, \nSelamat akun anda telah aktif ! \n\n*Pesan ini di kirim secara otomatis, tidak perlu di balas.",
|
||||
});
|
||||
} else {
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor: updateData.nomor,
|
||||
newMessage:
|
||||
"Halo sahabat HIConnect, \nMohon maaf akun anda telah dinonaktifkan ! Hubungi admin untuk informasi lebih lanjut. \n\n*Pesan ini di kirim secara otomatis, tidak perlu di balas.",
|
||||
});
|
||||
}
|
||||
|
||||
console.log("[Update Active Berhasil]", updateData);
|
||||
} else if (category === "role") {
|
||||
const fixName = _.startCase(data.role.replace(/_/g, " "));
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
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 { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET, PUT };
|
||||
|
||||
@@ -33,6 +39,14 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) {
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal membuat invoice",
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
@@ -48,7 +62,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
try {
|
||||
@@ -65,7 +79,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
createdAt: true,
|
||||
donasiMaster_BankId: true,
|
||||
donasiMaster_StatusInvoiceId: true,
|
||||
MasterBank: true,
|
||||
MasterBank: true,
|
||||
Donasi: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -139,7 +153,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
});
|
||||
}
|
||||
|
||||
const update = await prisma.donasi_Invoice.update({
|
||||
const updated = await prisma.donasi_Invoice.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
@@ -164,7 +178,40 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE INVOICE]", update);
|
||||
if (!updated) {
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal memperbarui data",
|
||||
});
|
||||
}
|
||||
|
||||
const findUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
active: true,
|
||||
NOT: { id: updated?.Donasi?.authorId as string },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Ada Donasi Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek data investor pada ${updated?.Donasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeAdminMobile.donationDetailPublish({
|
||||
id: updated?.Donasi?.id as string,
|
||||
status: "publish",
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE INVOICE]", updated);
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { funFindDonaturList } from "@/lib/mobile/donation/find-donatur-list";
|
||||
|
||||
export { POST, GET, PUT, DELETE };
|
||||
|
||||
async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { title, deskripsi, imageId } = data;
|
||||
|
||||
const senderId = await prisma.donasi.findUnique({
|
||||
where: { id: id },
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
if (data && data?.imageId) {
|
||||
const createWithFile = await prisma.donasi_Kabar.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
deskripsi: data.deskripsi,
|
||||
title: title,
|
||||
deskripsi: deskripsi,
|
||||
donasiId: id,
|
||||
imageId: data.imageId,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,8 +42,8 @@ async function POST(
|
||||
} else {
|
||||
const create = await prisma.donasi_Kabar.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
deskripsi: data.deskripsi,
|
||||
title: title,
|
||||
deskripsi: deskripsi,
|
||||
donasiId: id,
|
||||
},
|
||||
});
|
||||
@@ -38,6 +52,25 @@ async function POST(
|
||||
return NextResponse.json({ status: 400, message: "Gagal disimpan" });
|
||||
}
|
||||
|
||||
const recipientIds = await funFindDonaturList(id);
|
||||
|
||||
// SEND NOTIFICATION
|
||||
if (recipientIds.length > 0) {
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds,
|
||||
senderId: senderId?.authorId!,
|
||||
payload: {
|
||||
title: "Berita terbaru" as NotificationMobileTitleType,
|
||||
body: `Ada berita terupdate pada ${title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({
|
||||
id: id,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
@@ -56,7 +89,7 @@ async function POST(
|
||||
|
||||
async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
@@ -178,7 +211,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
try {
|
||||
@@ -198,7 +231,7 @@ async function DELETE(
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!deleteImage) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST };
|
||||
export { POST, GET };
|
||||
|
||||
async function POST(request: Request) {
|
||||
const { data } = await request.json();
|
||||
@@ -49,6 +52,26 @@ async function POST(request: Request) {
|
||||
|
||||
console.log("[DATA DONASI]", dataDonasi);
|
||||
|
||||
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: data.title as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.donationByStatus({ status: "review" }),
|
||||
kategoriApp: "DONASI",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (!dataDonasi)
|
||||
return NextResponse.json({
|
||||
status: 400,
|
||||
@@ -98,7 +121,7 @@ async function POST(request: Request) {
|
||||
}
|
||||
|
||||
// GET ALL DATA DONASI
|
||||
export async function GET(request: Request) {
|
||||
async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
|
||||
@@ -90,9 +90,15 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = 5
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Komentar.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile, routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
@@ -10,7 +16,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
console.log("[POST DOCUMENT DATA]", data);
|
||||
|
||||
try {
|
||||
const create = await prisma.dokumenInvestasi.upsert({
|
||||
const createdDocs = await prisma.dokumenInvestasi.upsert({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
@@ -23,9 +29,49 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
title: data.title,
|
||||
fileId: data.fileId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!create)
|
||||
console.log("[CREATED DOCS]", createdDocs);
|
||||
|
||||
const findInvestor = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: id,
|
||||
StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[FIND INVESTOR]", findInvestor);
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findInvestor.map((e) => e.authorId!),
|
||||
senderId: createdDocs.investasi?.authorId as string,
|
||||
payload: {
|
||||
title: "Cek Dokumen" as NotificationMobileTitleType,
|
||||
body: `Ada dokumen terupdate pada ${createdDocs.investasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: createdDocs.investasiId as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!createdDocs)
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
@@ -93,7 +139,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
|
||||
@@ -111,9 +157,9 @@ async function DELETE(
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileTitleType,
|
||||
NotificationMobileBodyType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { POST, GET, PUT };
|
||||
|
||||
@@ -49,7 +55,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const authorId = searchParams.get("authorId");
|
||||
|
||||
console.log("[ID INVOICE]", id);
|
||||
|
||||
|
||||
let fixData;
|
||||
|
||||
@@ -198,8 +203,49 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
statusInvoiceId: checkStatus.id,
|
||||
imageId: data.imageId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (fixStatus === "Proses") {
|
||||
// kirim notif ke author investasi
|
||||
const findInvestasi = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
id: update.investasiId as any,
|
||||
},
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const findUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
active: true,
|
||||
NOT: { id: findInvestasi?.authorId as any },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Ada Investor Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek data investor pada ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeAdminMobile.investmentDetailPublish({
|
||||
id: update.investasiId as string,
|
||||
status: "publish",
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("[UPDATE]", update);
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from "lodash";
|
||||
import { prisma } from "@/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
import { sendNotificationInvestmentAddNews } from "@/lib/mobile/notification/notification-add-news-investment";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
@@ -21,6 +22,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
deskripsi: data.deskripsi,
|
||||
imageId: data.imageId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await sendNotificationInvestmentAddNews({
|
||||
invesmentId: createWithFile.investasiId,
|
||||
senderId: createWithFile.investasi.authorId as string,
|
||||
title: createWithFile.investasi.title,
|
||||
});
|
||||
|
||||
fixData = createWithFile;
|
||||
@@ -31,6 +47,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await sendNotificationInvestmentAddNews({
|
||||
invesmentId: createWitOutFile.investasiId,
|
||||
senderId: createWitOutFile.investasi.authorId as string,
|
||||
title: createWitOutFile.investasi.title,
|
||||
});
|
||||
|
||||
fixData = createWitOutFile;
|
||||
@@ -111,7 +142,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
console.log("id", id);
|
||||
|
||||
@@ -2,6 +2,9 @@ import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import moment from "moment";
|
||||
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 };
|
||||
|
||||
@@ -9,12 +12,14 @@ async function POST(request: Request) {
|
||||
const { data } = await request.json();
|
||||
console.log(["DATA INVESTASI"], data);
|
||||
|
||||
const fixTitle = _.startCase(data.title)
|
||||
|
||||
try {
|
||||
const create = await prisma.investasi.create({
|
||||
data: {
|
||||
masterStatusInvestasiId: "2",
|
||||
authorId: data.authorId,
|
||||
title: _.startCase(data.title),
|
||||
title: fixTitle,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: data.totalLembar,
|
||||
@@ -30,6 +35,24 @@ async function POST(request: Request) {
|
||||
|
||||
console.log("[CREATE INVESTASI]", create);
|
||||
|
||||
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: fixTitle as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.investmentByStatus({ status: "review" }),
|
||||
kategoriApp: "INVESTASI",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
|
||||
@@ -5,8 +5,16 @@ export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get("search");
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
console.log("SEARCH", search);
|
||||
console.log("PAGE", page);
|
||||
|
||||
const data = await prisma.user.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
orderBy: {
|
||||
username: "asc",
|
||||
},
|
||||
@@ -43,16 +51,12 @@ export async function GET(request: Request) {
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
status: 200,
|
||||
}
|
||||
);
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -62,7 +66,7 @@ export async function GET(request: Request) {
|
||||
},
|
||||
{
|
||||
status: 500,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
31
src/lib/code-otp-sender.ts
Normal file
31
src/lib/code-otp-sender.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
const sendCodeOtp = async ({
|
||||
nomor,
|
||||
codeOtp,
|
||||
newMessage,
|
||||
}: {
|
||||
nomor: string;
|
||||
codeOtp?: string;
|
||||
newMessage?: string;
|
||||
}) => {
|
||||
const msg = newMessage || `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||
const enCode = encodeURIComponent(msg);
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${enCode}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
// const res = await fetch(
|
||||
// `https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
|
||||
// \n
|
||||
// >> Kode OTP anda: ${codeOtp}.
|
||||
// `,
|
||||
// );
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export { sendCodeOtp as funSendToWhatsApp };
|
||||
25
src/lib/mobile/donation/find-donatur-list.tsx
Normal file
25
src/lib/mobile/donation/find-donatur-list.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const funFindDonaturList = async (donasiId: string) => {
|
||||
const finDonatur = await prisma.donasi_Invoice.findMany({
|
||||
where: {
|
||||
donasiId: donasiId,
|
||||
DonasiMaster_StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
distinct: ["authorId"], // Ambil hanya authorId unik dari DB
|
||||
});
|
||||
|
||||
// Filter null safety (jika diperlukan)
|
||||
const recipientIds = finDonatur
|
||||
.map((e) => e.authorId)
|
||||
.filter((id): id is string => id !== null && id !== undefined);
|
||||
|
||||
console.log("[FIND DONATUR UNIK]", recipientIds);
|
||||
|
||||
return recipientIds;
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../types/type-mobile-notification";
|
||||
import { sendNotificationMobileToManyUser } from "./send-notification";
|
||||
import { routeUserMobile } from "../route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const sendNotificationInvestmentAddNews = async ({
|
||||
invesmentId,
|
||||
senderId,
|
||||
title,
|
||||
}: {
|
||||
invesmentId: string;
|
||||
senderId: string;
|
||||
title: string;
|
||||
}) => {
|
||||
const findInvestor = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: invesmentId,
|
||||
StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[FIND INVESTOR]", findInvestor);
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findInvestor.map((e) => e.authorId!),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Berita terbaru" as NotificationMobileTitleType,
|
||||
body: `Ada berita yang terupdate pada ${title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: invesmentId,
|
||||
}),
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -19,8 +19,29 @@ const routeAdminMobile = {
|
||||
// FORUM
|
||||
forumPreviewReportPosting: `/admin/forum/report-posting`,
|
||||
forumPreviewReportComment: `/admin/forum/report-comment`,
|
||||
|
||||
// INVESTMENT
|
||||
investmentByStatus: ({ status }: { status: StatusApp }) => `/admin/investment/${status}/status`,
|
||||
investmentDetailPublish: ({
|
||||
id,
|
||||
status,
|
||||
}: {
|
||||
id: string;
|
||||
status: StatusApp;
|
||||
}) => `/admin/investment/${id}/${status}`,
|
||||
|
||||
// DONATION
|
||||
donationByStatus: ({ status }: { status: StatusApp }) => `/admin/donation/${status}/status`,
|
||||
donationDetailPublish: ({
|
||||
id,
|
||||
status,
|
||||
}: {
|
||||
id: string;
|
||||
status: StatusApp;
|
||||
}) => `/admin/donation/${id}/${status}`,
|
||||
};
|
||||
|
||||
// ================ ROUTER USER =================
|
||||
const routeUserMobile = {
|
||||
home: `/(user)/home`,
|
||||
// JOB
|
||||
@@ -41,6 +62,20 @@ const routeUserMobile = {
|
||||
// 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`,
|
||||
forumPreviewReportPosting: ({ id }: { id: string }) =>
|
||||
`/forum/${id}/preview-report-posting`,
|
||||
forumPreviewReportComment: ({ id }: { id: string }) =>
|
||||
`/forum/${id}/preview-report-comment`,
|
||||
|
||||
// INVESTMENT
|
||||
investmentPortofolioByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/investment/(tabs)/portofolio?status=${status}`,
|
||||
investmentDetailPublish: ({ id }: { id: string }) => `/investment/${id}`,
|
||||
investmentTransaction: `/investment/(tabs)/transaction`,
|
||||
|
||||
// DONATION
|
||||
donationByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/donation/(tabs)/status?status=${status}`,
|
||||
donationDetailPublish: ({ id }: { id: string }) => `/donation/${id}`,
|
||||
donationTransaction: `/donation/(tabs)/my-donation`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user