Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ab25655f2 | |||
| 9d17b442e2 | |||
| b3410a5804 | |||
| 2cdc57d844 | |||
| 695046583f | |||
| 6ee0b98f07 |
@@ -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.
|
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.26](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.25...v1.5.26) (2025-12-10)
|
||||||
|
|
||||||
|
## [1.5.25](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.24...v1.5.25) (2025-12-09)
|
||||||
|
|
||||||
## [1.5.24](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.22...v1.5.24) (2025-12-08)
|
## [1.5.24](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.22...v1.5.24) (2025-12-08)
|
||||||
|
|
||||||
## [1.5.22](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.21...v1.5.22) (2025-12-03)
|
## [1.5.22](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.21...v1.5.22) (2025-12-03)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.24",
|
"version": "1.5.26",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User" ADD COLUMN "acceptedForumTermsAt" TIMESTAMP(3),
|
||||||
|
ADD COLUMN "acceptedTermsAt" TIMESTAMP(3);
|
||||||
@@ -55,6 +55,9 @@ model User {
|
|||||||
|
|
||||||
blockedUsers BlockedUser[] @relation("Blocking")
|
blockedUsers BlockedUser[] @relation("Blocking")
|
||||||
blockedBy BlockedUser[] @relation("BlockedBy")
|
blockedBy BlockedUser[] @relation("BlockedBy")
|
||||||
|
|
||||||
|
acceptedTermsAt DateTime?
|
||||||
|
acceptedForumTermsAt DateTime?
|
||||||
}
|
}
|
||||||
|
|
||||||
model MasterUserRole {
|
model MasterUserRole {
|
||||||
|
|||||||
1098
prisma/schema.prisma.backup
Normal file
1098
prisma/schema.prisma.backup
Normal file
File diff suppressed because it is too large
Load Diff
@@ -41,6 +41,7 @@ export async function POST(req: Request) {
|
|||||||
nomor: data.nomor,
|
nomor: data.nomor,
|
||||||
active: false,
|
active: false,
|
||||||
termsOfServiceAccepted: data.termsOfServiceAccepted,
|
termsOfServiceAccepted: data.termsOfServiceAccepted,
|
||||||
|
acceptedTermsAt: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
select: {
|
select: {
|
||||||
User: {
|
User: {
|
||||||
select: {
|
select: {
|
||||||
|
nomor: true,
|
||||||
username: true,
|
username: true,
|
||||||
id: true,
|
id: true,
|
||||||
Profile: {
|
Profile: {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
reportComment,
|
reportComment,
|
||||||
};
|
};
|
||||||
} else if (category === "posting") {
|
} else if (category === "posting") {
|
||||||
fixData = await prisma.forum_Posting.findMany({
|
const data = await prisma.forum_Posting.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
skip: page ? skipData : undefined,
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -75,10 +76,24 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
Profile: true,
|
Profile: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
_count: {
|
||||||
|
select: {
|
||||||
|
Forum_ReportPosting: true,
|
||||||
|
Forum_Komentar: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixData = data.map((item) => ({
|
||||||
|
..._.omit(item, "_count"),
|
||||||
|
reportPosting: item._count.Forum_ReportPosting,
|
||||||
|
komentar: item._count.Forum_Komentar,
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.log("fixData >>", fixData);
|
||||||
} else if (category === "report_posting") {
|
} else if (category === "report_posting") {
|
||||||
fixData = await prisma.forum_ReportPosting.findMany({
|
const data = await prisma.forum_ReportPosting.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
skip: page ? skipData : undefined,
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -123,8 +138,25 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filterLatest = (data: any) =>
|
||||||
|
Object.values(
|
||||||
|
data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Posting?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
if (
|
||||||
|
!acc[key] ||
|
||||||
|
new Date(item.createdAt) > new Date(acc[key].createdAt)
|
||||||
|
) {
|
||||||
|
acc[key] = item;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
);
|
||||||
|
|
||||||
|
fixData = filterLatest(data);
|
||||||
} else if (category === "report_comment") {
|
} else if (category === "report_comment") {
|
||||||
fixData = await prisma.forum_ReportKomentar.findMany({
|
const data = await prisma.forum_ReportKomentar.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
skip: page ? skipData : undefined,
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -160,6 +192,23 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filterLatest = (data: any) =>
|
||||||
|
Object.values(
|
||||||
|
data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Komentar?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
if (
|
||||||
|
!acc[key] ||
|
||||||
|
new Date(item.createdAt) > new Date(acc[key].createdAt)
|
||||||
|
) {
|
||||||
|
acc[key] = item;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
);
|
||||||
|
|
||||||
|
fixData = filterLatest(data);
|
||||||
} else {
|
} else {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -171,7 +220,6 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -4,19 +4,55 @@ import { prisma } from "@/lib";
|
|||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
let fixData;
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const data = await prisma.masterBidangBisnis.findUnique({
|
const { searchParams } = new URL(request.url);
|
||||||
where: {
|
const category = searchParams.get("category");
|
||||||
id: id,
|
const subBidangId = searchParams.get("subBidangId");
|
||||||
},
|
|
||||||
});
|
if (category === "all") {
|
||||||
|
const bidang = await prisma.masterBidangBisnis.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const subBidang = await prisma.masterSubBidangBisnis.findMany({
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
masterBidangBisnisId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
bidang,
|
||||||
|
subBidang,
|
||||||
|
};
|
||||||
|
} else if (category === "bidang") {
|
||||||
|
const bidang = await prisma.masterBidangBisnis.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = bidang;
|
||||||
|
} else if (category === "sub-bidang") {
|
||||||
|
const subBidang = await prisma.masterSubBidangBisnis.findUnique({
|
||||||
|
where: {
|
||||||
|
id: subBidangId as any,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = subBidang;
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: data,
|
data: fixData,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error Get Master Bank >>", error);
|
console.error("Error Get Master Bank >>", error);
|
||||||
@@ -32,17 +68,34 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
|
console.log("category", category);
|
||||||
|
console.log("data", data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updateData = await prisma.masterBidangBisnis.update({
|
if (category === "bidang") {
|
||||||
where: {
|
const updateData = await prisma.masterBidangBisnis.update({
|
||||||
id: id,
|
where: {
|
||||||
},
|
id: id,
|
||||||
data: {
|
},
|
||||||
name: data.name,
|
data: {
|
||||||
active: data.active,
|
name: data.name,
|
||||||
},
|
active: data.active,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
} else if (category === "sub-bidang") {
|
||||||
|
const updateData = await prisma.masterSubBidangBisnis.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
name: data.name,
|
||||||
|
isActive: data.isActive,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { Prisma } from "@prisma/client";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
@@ -31,35 +33,191 @@ async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BidangInput = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SubBidangInput = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type RequestBody = {
|
||||||
|
data: {
|
||||||
|
bidang: BidangInput;
|
||||||
|
subBidang: SubBidangInput[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ---------------------------
|
||||||
|
POST handler
|
||||||
|
- body: { bidang: { name }, subBidang: [{ name }, ...] }
|
||||||
|
- buat masterBidangBisnis (id incremental dari count + 1)
|
||||||
|
- generate id untuk tiap subBidang, cek unik, dan createMany via transaction
|
||||||
|
--------------------------- */
|
||||||
async function POST(request: Request) {
|
async function POST(request: Request) {
|
||||||
const { data } = await request.json();
|
|
||||||
try {
|
try {
|
||||||
const count = await prisma.masterBidangBisnis.count();
|
const { data } = (await request.json()) as RequestBody;
|
||||||
const createNewId = count + 1;
|
|
||||||
|
|
||||||
const slugName = data.name.toLowerCase().replace(/\s+/g, "_");
|
console.log("body >>", data.bidang.name);
|
||||||
|
|
||||||
const create = await prisma.masterBidangBisnis.create({
|
if (!data.bidang.name || !Array.isArray(data.subBidang)) {
|
||||||
data: {
|
return NextResponse.json(
|
||||||
id: createNewId.toString(),
|
{
|
||||||
name: data.name,
|
status: 400,
|
||||||
slug: slugName,
|
success: false,
|
||||||
},
|
message:
|
||||||
|
"Invalid payload. Expect { bidang: { name }, subBidang: [] }",
|
||||||
|
},
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// run in transaction to avoid race conditions
|
||||||
|
const result = await prisma.$transaction(async (tx) => {
|
||||||
|
// ambil last id numerik dengan cast (Postgres)
|
||||||
|
const rows = await tx.$queryRaw<{ id: string }[]>`
|
||||||
|
SELECT id FROM "MasterBidangBisnis" ORDER BY (id::int) DESC LIMIT 1;
|
||||||
|
`;
|
||||||
|
const lastId = rows[0]?.id ?? null;
|
||||||
|
const bidangId = lastId ? String(Number(lastId) + 1) : "1";
|
||||||
|
console.log("bidangId >>", bidangId);
|
||||||
|
|
||||||
|
const slugName = data.bidang.name.toLowerCase().replace(/\s+/g, "_");
|
||||||
|
|
||||||
|
const createdBidang = await tx.masterBidangBisnis.create({
|
||||||
|
data: {
|
||||||
|
id: bidangId,
|
||||||
|
name: data.bidang.name,
|
||||||
|
slug: slugName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2) hitung existing sub bidang untuk bidang ini
|
||||||
|
const existingSubCount = await tx.masterSubBidangBisnis.count({
|
||||||
|
where: { masterBidangBisnisId: createdBidang.id },
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("existingSubCount >>", existingSubCount);
|
||||||
|
|
||||||
|
// 3) generate unique ids satu-per-satu (cek ke DB via tx)
|
||||||
|
const subBidangToCreate: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
masterBidangBisnisId: string;
|
||||||
|
}[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < data.subBidang.length; i++) {
|
||||||
|
const seqNumber = existingSubCount + i + 1; // 1-based
|
||||||
|
const uniqueId = await generateUniqueSubBidangId(
|
||||||
|
data.bidang.name,
|
||||||
|
seqNumber,
|
||||||
|
tx
|
||||||
|
);
|
||||||
|
|
||||||
|
// push object to array
|
||||||
|
subBidangToCreate.push({
|
||||||
|
id: uniqueId,
|
||||||
|
name: data.subBidang[i].name,
|
||||||
|
masterBidangBisnisId: createdBidang.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4) createMany (batched) -- note: createMany doesn't return created rows
|
||||||
|
if (subBidangToCreate.length > 0) {
|
||||||
|
await tx.masterSubBidangBisnis.createMany({
|
||||||
|
data: subBidangToCreate,
|
||||||
|
skipDuplicates: false, // kita sudah memastikan unik, so false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { createdBidang, subBidang: subBidangToCreate };
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil menambahkan data",
|
message: "Berhasil menambahkan bidang dan sub bidang",
|
||||||
data: create,
|
data: result,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error Post Master Business Field >>", error);
|
console.error("Error Post Master Business Field >>", error);
|
||||||
return NextResponse.json({
|
const msg = error instanceof Error ? error.message : String(error);
|
||||||
status: 500,
|
return NextResponse.json(
|
||||||
success: false,
|
{
|
||||||
message: "API Error Post Data",
|
status: 500,
|
||||||
reason: (error as Error).message,
|
success: false,
|
||||||
});
|
message: "API Error Post Data",
|
||||||
|
reason: msg,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------
|
||||||
|
Helper: generate base code
|
||||||
|
- mengabaikan stop words: 'dan', 'atau', '&'
|
||||||
|
- ambil dua kata pertama yang tersisa
|
||||||
|
- ambil 3 huruf pertama tiap kata (jika ada)
|
||||||
|
--------------------------- */
|
||||||
|
function generateBaseCode(name: string) {
|
||||||
|
const stopWords = new Set(["dan", "atau", "&"]);
|
||||||
|
// keep only letters and spaces, normalize spaces
|
||||||
|
const cleaned = name
|
||||||
|
.normalize("NFD")
|
||||||
|
.replace(/[\u0300-\u036f]/g, "") // remove diacritics
|
||||||
|
.replace(/[^a-zA-Z\s&]/g, " ")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
|
||||||
|
const words = cleaned
|
||||||
|
.split(" ")
|
||||||
|
.filter((w) => w.length > 0 && !stopWords.has(w));
|
||||||
|
|
||||||
|
const primary = (words[0] ?? "xxx").substring(0, 3).toUpperCase();
|
||||||
|
const secondary = words[1] ? words[1].substring(0, 3).toUpperCase() : "";
|
||||||
|
|
||||||
|
return { primary, secondary };
|
||||||
|
}
|
||||||
|
|
||||||
|
function padNumber(n: number) {
|
||||||
|
return String(n).padStart(2, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------
|
||||||
|
generateUniqueSubBidangId
|
||||||
|
- cek urutan strategi:
|
||||||
|
1) PRIMARY-<NN>
|
||||||
|
2) PRIMARY-SECONDARY-<NN> (jika secondary ada)
|
||||||
|
3) PRIMARYSECONDARY-<NN> (jika secondary ada)
|
||||||
|
4) fallback: PRIMARY + last4Timestamp -<NN>
|
||||||
|
- menggunakan tx (Prisma.TransactionClient) untuk cek di DB
|
||||||
|
--------------------------- */
|
||||||
|
async function generateUniqueSubBidangId(
|
||||||
|
bidangName: string,
|
||||||
|
number: number,
|
||||||
|
tx: Prisma.TransactionClient
|
||||||
|
): Promise<string> {
|
||||||
|
const { primary, secondary } = generateBaseCode(bidangName);
|
||||||
|
const num = padNumber(number);
|
||||||
|
|
||||||
|
const candidates: string[] = [];
|
||||||
|
candidates.push(`${primary}-${num}`);
|
||||||
|
if (secondary) candidates.push(`${primary}-${secondary}-${num}`);
|
||||||
|
if (secondary) candidates.push(`${primary}${secondary}-${num}`);
|
||||||
|
// final fallback
|
||||||
|
candidates.push(`${primary}${String(Date.now()).slice(-4)}-${num}`);
|
||||||
|
|
||||||
|
for (const id of candidates) {
|
||||||
|
// findUnique requires unique field; assuming `id` is the PK/unique
|
||||||
|
const found = await tx.masterSubBidangBisnis.findUnique({
|
||||||
|
where: { id },
|
||||||
|
select: { id: true },
|
||||||
|
});
|
||||||
|
if (!found) return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// theoretically unreachable, but return a final deterministic fallback
|
||||||
|
return `${primary}-${String(Math.floor(Math.random() * 9000) + 1000)}-${num}`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ async function GET(request: Request) {
|
|||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
username: true,
|
||||||
Profile: true,
|
Profile: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -141,6 +142,7 @@ async function GET(request: Request) {
|
|||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
username: true,
|
||||||
Profile: true,
|
Profile: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
const msg = `Report Komentar: "${content?.komentar}" dengan kategori \n\n\n${reportList?.title} : \n\n${reportList?.deskripsi}`;
|
const msg = `Report Komentar: "${content?.komentar}" dengan kategori \n\n\n${reportList?.title} : \n\n${reportList?.deskripsi}`;
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://wa.wibudev.com/code?nom=6282340374412&text=${msg}`,
|
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
|
||||||
{ cache: "no-cache" }
|
{ cache: "no-cache" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
const msg = `Report Postingan: "${content?.diskusi}"`;
|
const msg = `Report Postingan: "${content?.diskusi}"`;
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://wa.wibudev.com/code?nom=6282340374412&text=${msg}`,
|
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
|
||||||
{ cache: "no-cache" }
|
{ cache: "no-cache" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
68
src/app/api/mobile/user/[id]/terms-of-app/route.ts
Normal file
68
src/app/api/mobile/user/[id]/terms-of-app/route.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { POST };
|
||||||
|
|
||||||
|
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
|
console.log("[ID USER", id);
|
||||||
|
console.log("[SEARCH PARAMS", category);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "User not found",
|
||||||
|
},
|
||||||
|
{ status: 404 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateUser = await prisma.user.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
acceptedForumTermsAt: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateUser) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mengupdate data",
|
||||||
|
},
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Syarat dan Ketentuan berhasil diterima",
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error update data from API ",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -123,6 +123,10 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixData = data;
|
||||||
|
|
||||||
|
|
||||||
} else if (category === "contribution") {
|
} else if (category === "contribution") {
|
||||||
const data = await prisma.voting_Kontributor.findMany({
|
const data = await prisma.voting_Kontributor.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
|
|||||||
Reference in New Issue
Block a user