Compare commits
14 Commits
fixed-bug/
...
v1.6.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 935e519662 | |||
| c6dbd152d5 | |||
| 714cf5cd5a | |||
| a68343599d | |||
| 419b87fc92 | |||
| 0271c87ba9 | |||
| 5551f30721 | |||
| 00d36454d1 | |||
| a762fbe9b1 | |||
| a98ab18423 | |||
| 1c227a2850 | |||
| 5bdb998d2e | |||
| b585aa3024 | |||
| a8f9d2ac0d |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
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.6.3](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.2...v1.6.3) (2026-03-03)
|
||||||
|
|
||||||
|
## [1.6.2](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.1...v1.6.2) (2026-02-25)
|
||||||
|
|
||||||
|
## [1.6.1](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.0...v1.6.1) (2026-02-25)
|
||||||
|
|
||||||
|
## [1.6.0](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.40...v1.6.0) (2026-02-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Implementasi pagination pada endpoint mobile donation ([e89886e](https://wibugit.wibudev.com/wibu/hipmi/commit/e89886e1dbc8cb4d95e6cc7c2787fb22a1dcaf56))
|
||||||
|
* Tambahkan pagination pada API mobile investasi ([a7694bd](https://wibugit.wibudev.com/wibu/hipmi/commit/a7694bd7d5d72b6499443faf99301faca730d3ed))
|
||||||
|
* update mobile donation API and related dependencies ([934d6a3](https://wibugit.wibudev.com/wibu/hipmi/commit/934d6a3ef1015367bee85779796df4f11c5e779c))
|
||||||
|
|
||||||
## [1.5.40](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.39...v1.5.40) (2026-02-06)
|
## [1.5.40](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.39...v1.5.40) (2026-02-06)
|
||||||
|
|
||||||
## [1.5.39](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.38...v1.5.39) (2026-01-30)
|
## [1.5.39](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.38...v1.5.39) (2026-01-30)
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
# Changelog for Branch: fixed-bug/12-feb-26
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
This branch contains several bug fixes and performance improvements, primarily focusing on:
|
|
||||||
- Database connection management
|
|
||||||
- MQTT client stability
|
|
||||||
- Logging optimization
|
|
||||||
- API enhancements
|
|
||||||
|
|
||||||
## Detailed Changes
|
|
||||||
|
|
||||||
### Fixed Issues
|
|
||||||
1. **Database Connection Management**
|
|
||||||
- Removed `prisma.$disconnect()` from user-validate API route to prevent connection pool exhaustion
|
|
||||||
- Added proper connection handling in global Prisma setup
|
|
||||||
- Reduced logging verbosity in production environments
|
|
||||||
|
|
||||||
2. **MQTT Client Improvements**
|
|
||||||
- Enhanced MQTT client initialization with proper error handling
|
|
||||||
- Added reconnection logic with configurable intervals
|
|
||||||
- Implemented cleanup functions to prevent memory leaks
|
|
||||||
- Added separate initialization logic for server and client-side code
|
|
||||||
|
|
||||||
3. **Logging Optimization**
|
|
||||||
- Removed excessive logging in middleware that was causing high CPU usage
|
|
||||||
- Configured appropriate log levels for development and production
|
|
||||||
|
|
||||||
4. **Component Stability**
|
|
||||||
- Added safety checks in text editor component to prevent MQTT operations on the server side
|
|
||||||
- Improved MQTT publishing logic with client availability checks
|
|
||||||
|
|
||||||
### New Files
|
|
||||||
- `src/lib/prismaUtils.ts` - Utility functions for safe database operations
|
|
||||||
|
|
||||||
### Modified Files
|
|
||||||
1. `src/app/api/user-validate/route.ts`
|
|
||||||
- Removed problematic `prisma.$disconnect()` call
|
|
||||||
|
|
||||||
2. `src/lib/prisma.ts`
|
|
||||||
- Configured different logging levels for dev/prod
|
|
||||||
- Removed process listeners that were causing disconnections
|
|
||||||
- Exported prisma instance separately
|
|
||||||
|
|
||||||
3. `src/middleware.tsx`
|
|
||||||
- Removed excessive logging statements
|
|
||||||
|
|
||||||
4. `src/util/mqtt_client.ts`
|
|
||||||
- Enhanced initialization with error handling
|
|
||||||
- Added reconnection and timeout configurations
|
|
||||||
|
|
||||||
5. `src/util/mqtt_loader.tsx`
|
|
||||||
- Added proper cleanup functions
|
|
||||||
- Improved connection handling
|
|
||||||
|
|
||||||
6. `src/app_modules/_global/component/new/comp_V3_text_editor_stiker.tsx`
|
|
||||||
- Added MQTT client availability checks
|
|
||||||
- Prevented server-side MQTT operations
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
- Reduced database connection overhead
|
|
||||||
- Optimized MQTT connection handling
|
|
||||||
- Eliminated unnecessary logging in production
|
|
||||||
- Better memory management with proper cleanup functions
|
|
||||||
39
CHANGELOG_COMMIT.md
Normal file
39
CHANGELOG_COMMIT.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## Catatan Perubahan untuk Commit
|
||||||
|
|
||||||
|
### Fitur: Penambahan Pagination pada Endpoint Admin Mobile
|
||||||
|
|
||||||
|
#### Deskripsi Umum
|
||||||
|
Telah dilakukan penambahan fitur pagination pada beberapa endpoint admin mobile untuk meningkatkan kinerja dan pengalaman pengguna saat mengakses data dalam jumlah besar.
|
||||||
|
|
||||||
|
#### File yang Diubah
|
||||||
|
|
||||||
|
1. **src/app/api/mobile/admin/job/route.ts**
|
||||||
|
- Ditambahkan parameter `page` dari `searchParams`
|
||||||
|
- Diterapkan logika pagination dengan `takeData` (default 10) dan `skipData`
|
||||||
|
- Query `prisma.job.findMany` telah dimodifikasi untuk mendukung pagination
|
||||||
|
|
||||||
|
2. **src/app/api/mobile/admin/event/route.ts**
|
||||||
|
- Diperbaiki definisi variabel `page` untuk memastikan tipe data yang konsisten
|
||||||
|
- Ditambahkan default value 1 untuk parameter `page`
|
||||||
|
- Perhitungan `skipData` disesuaikan agar lebih efisien
|
||||||
|
|
||||||
|
3. **src/app/api/mobile/admin/event/[id]/participants/route.ts**
|
||||||
|
- Ditambahkan parameter `page` dari `searchParams`
|
||||||
|
- Diterapkan logika pagination dengan `takeData` (default 10) dan `skipData`
|
||||||
|
- Query `prisma.event_Peserta.findMany` telah dimodifikasi untuk mendukung pagination
|
||||||
|
|
||||||
|
#### Tujuan Perubahan
|
||||||
|
- Meningkatkan kinerja aplikasi saat mengambil data dalam jumlah besar
|
||||||
|
- Memungkinkan pengguna untuk mengakses data secara bertahap melalui halaman-halaman
|
||||||
|
- Mengurangi beban server saat mengambil data dalam jumlah besar
|
||||||
|
- Memberikan pengalaman pengguna yang lebih baik saat mengakses data admin
|
||||||
|
|
||||||
|
#### Cara Penggunaan
|
||||||
|
Untuk menggunakan fitur pagination, cukup tambahkan parameter `page` pada query string saat melakukan permintaan ke endpoint yang telah dimodifikasi. Contoh:
|
||||||
|
```
|
||||||
|
GET /api/mobile/admin/job?page=2
|
||||||
|
GET /api/mobile/admin/event?page=3
|
||||||
|
GET /api/mobile/admin/event/{id}/participants?page=1
|
||||||
|
```
|
||||||
|
|
||||||
|
Default jumlah data per halaman adalah 10 item.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
File utama: src/app/api/mobile/donation/[id]/donatur/route.ts
|
File utama: src/app/api/mobile/admin/forum/[id]/comment/route.ts
|
||||||
|
|
||||||
Terapkan pagination pada file "File utama" pada method GET
|
Terapkan pagination pada file "File utama" pada method GET
|
||||||
Analisa juga file "File utama", jika belum memiliki page dari seachParams maka terapkan. Juga pastikan take dan skip sudah sesuai dengan pagination. Buat default nya menjadi 10 untuk take data
|
Analisa juga file "File utama", jika belum memiliki page dari seachParams maka terapkan. Juga pastikan take dan skip sudah sesuai dengan pagination. Buat default nya menjadi 10 untuk take data
|
||||||
|
|||||||
2
QWEN.md
2
QWEN.md
@@ -198,4 +198,4 @@ References: #issue-number
|
|||||||
### Data Protection
|
### Data Protection
|
||||||
- Encrypted tokens
|
- Encrypted tokens
|
||||||
- Secure API routes
|
- Secure API routes
|
||||||
- Proper CORS configuration
|
- Proper CORS configuration
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.40",
|
"version": "1.6.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --experimental-https",
|
"dev": "next dev --experimental-https",
|
||||||
"build": "next build",
|
"build": "prisma generate && next build",
|
||||||
"build:dev": "next build",
|
"build:dev": "prisma generate && next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
"postbuild": "node scripts/postbuild.js",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"ver": "bunx commit-and-tag-version -- --prerelease"
|
"ver": "bunx commit-and-tag-version -- --prerelease"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ export async function POST(req: Request) {
|
|||||||
try {
|
try {
|
||||||
const { data } = await req.json();
|
const { data } = await req.json();
|
||||||
|
|
||||||
console.log("data >>", data);
|
|
||||||
|
|
||||||
const cekUsername = await prisma.user.findUnique({
|
const cekUsername = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
username: data.username,
|
username: data.username,
|
||||||
@@ -29,12 +27,12 @@ export async function POST(req: Request) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ✅ Validasi wajib setuju Terms
|
// ✅ Validasi wajib setuju Terms
|
||||||
if (data.termsOfServiceAccepted !== true) {
|
// if (data.termsOfServiceAccepted !== true) {
|
||||||
return NextResponse.json({
|
// return NextResponse.json({
|
||||||
success: false,
|
// success: false,
|
||||||
message: "You must agree to the Terms of Service",
|
// message: "You must agree to the Terms of Service",
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const createUser = await prisma.user.create({
|
const createUser = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../../types/type-mobile-notification";
|
||||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
@@ -154,7 +155,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
console.log("[CATEGORY]", category);
|
||||||
@@ -174,6 +175,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
id: true,
|
id: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
nominalCair: true,
|
nominalCair: true,
|
||||||
|
title: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (category === "get-one") {
|
} else if (category === "get-one") {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ async function GET(req: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(req.url);
|
const { searchParams } = new URL(req.url);
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
const fixStatus = _.startCase(status || "");
|
const fixStatus = _.startCase(status || "");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,11 +10,10 @@ async function GET(request: Request) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
const publish = await prisma.donasi.count({
|
const publish = await prisma.donasi.count({
|
||||||
@@ -48,7 +48,7 @@ async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const categoryDonation = countCategoryDonation.length;
|
const categoryDonation = countCategoryDonation.length;
|
||||||
@@ -68,7 +68,6 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[STATUS]", checkStatus);
|
|
||||||
|
|
||||||
if (!checkStatus) {
|
if (!checkStatus) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -77,7 +76,7 @@ async function GET(request: Request) {
|
|||||||
message: "Failed to get data donation",
|
message: "Failed to get data donation",
|
||||||
reason: "Status not found",
|
reason: "Status not found",
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +99,12 @@ async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
target: true,
|
||||||
|
DonasiMaster_Durasi: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -109,7 +114,6 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[LIST]", fixData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -118,7 +122,7 @@ async function GET(request: Request) {
|
|||||||
message: `Success get data donation ${category}`,
|
message: `Success get data donation ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get data donation:", error);
|
console.error("Error get data donation:", error);
|
||||||
@@ -128,7 +132,7 @@ async function GET(request: Request) {
|
|||||||
message: "Failed to get data donation",
|
message: "Failed to get data donation",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
|
||||||
@@ -12,6 +18,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
eventId: id,
|
eventId: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
eventId: true,
|
eventId: true,
|
||||||
userId: true,
|
userId: true,
|
||||||
isPresent: true,
|
isPresent: true,
|
||||||
@@ -35,6 +42,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import _ from "lodash";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { NextResponse } from "next/server";
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -11,13 +12,12 @@ async function GET(request: Request) {
|
|||||||
const fixStatus = _.startCase(category || "");
|
const fixStatus = _.startCase(category || "");
|
||||||
|
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
// console.log("[FIX STATUS]", fixStatus);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
@@ -71,7 +71,6 @@ async function GET(request: Request) {
|
|||||||
typeOfEvent,
|
typeOfEvent,
|
||||||
};
|
};
|
||||||
} else if (category === "history") {
|
} else if (category === "history") {
|
||||||
console.log("[HISTORY HERE]");
|
|
||||||
|
|
||||||
const data = await prisma.event.findMany({
|
const data = await prisma.event.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -151,21 +150,22 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
tanggal: true,
|
tanggal: true,
|
||||||
Author: {
|
tanggalSelesai: true,
|
||||||
select: {
|
Author: {
|
||||||
id: true,
|
select: {
|
||||||
username: true,
|
id: true,
|
||||||
Profile: {
|
username: true,
|
||||||
select: {
|
Profile: {
|
||||||
name: true,
|
select: {
|
||||||
},
|
name: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
@@ -177,7 +177,7 @@ async function GET(request: Request) {
|
|||||||
message: `Success get data event ${category}`,
|
message: `Success get data event ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`[ERROR GET DATA EVENT: ${category}]`, error);
|
console.log(`[ERROR GET DATA EVENT: ${category}]`, error);
|
||||||
@@ -187,7 +187,7 @@ async function GET(request: Request) {
|
|||||||
message: `Error get data event ${category}`,
|
message: `Error get data event ${category}`,
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../../types/type-mobile-notification";
|
||||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -14,9 +15,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page"));
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ export async function GET(
|
|||||||
message: "Success get list report posting",
|
message: "Success get list report posting",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ERROR GET LIST REPORT POSTING]", error);
|
console.error("[ERROR GET LIST REPORT POSTING]", error);
|
||||||
@@ -70,7 +71,7 @@ export async function GET(
|
|||||||
message: "Error get list report posting",
|
message: "Error get list report posting",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
@@ -79,7 +80,11 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
_count: {
|
_count: {
|
||||||
select: {
|
select: {
|
||||||
Forum_ReportPosting: true,
|
Forum_ReportPosting: true,
|
||||||
Forum_Komentar: true,
|
Forum_Komentar: {
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -139,6 +144,14 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung count report untuk setiap Forum_Posting id
|
||||||
|
const countByPostingId = data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Posting?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
acc[key] = (acc[key] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const filterLatest = (data: any) =>
|
const filterLatest = (data: any) =>
|
||||||
Object.values(
|
Object.values(
|
||||||
data.reduce((acc: any, item: any) => {
|
data.reduce((acc: any, item: any) => {
|
||||||
@@ -151,10 +164,16 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
acc[key] = item;
|
acc[key] = item;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
fixData = filterLatest(data);
|
const filteredData = filterLatest(data);
|
||||||
|
|
||||||
|
// Tambahkan count ke setiap item
|
||||||
|
fixData = filteredData.map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
count: countByPostingId[item.Forum_Posting?.id] || 0,
|
||||||
|
}));
|
||||||
} else if (category === "report_comment") {
|
} else if (category === "report_comment") {
|
||||||
const data = await prisma.forum_ReportKomentar.findMany({
|
const data = await prisma.forum_ReportKomentar.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -193,6 +212,14 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung count report untuk setiap Forum_Komentar id
|
||||||
|
const countByKomentarId = data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Komentar?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
acc[key] = (acc[key] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const filterLatest = (data: any) =>
|
const filterLatest = (data: any) =>
|
||||||
Object.values(
|
Object.values(
|
||||||
data.reduce((acc: any, item: any) => {
|
data.reduce((acc: any, item: any) => {
|
||||||
@@ -205,10 +232,16 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
acc[key] = item;
|
acc[key] = item;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
fixData = filterLatest(data);
|
const filteredData = filterLatest(data);
|
||||||
|
|
||||||
|
// Tambahkan count ke setiap item
|
||||||
|
fixData = filteredData.map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
count: countByKomentarId[item.Forum_Komentar?.id] || 0,
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -216,7 +249,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: "Invalid category",
|
message: "Invalid category",
|
||||||
reason: "Invalid category",
|
reason: "Invalid category",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +259,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: `Success get data forum ${category}`,
|
message: `Success get data forum ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -235,7 +268,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: `Error get data forum ${category}`,
|
message: `Error get data forum ${category}`,
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page"));
|
||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const fixStatus = _.startCase(status ? status : "");
|
const fixStatus = _.startCase(status ? status : "");
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ export async function GET(
|
|||||||
id: true,
|
id: true,
|
||||||
Author: true,
|
Author: true,
|
||||||
StatusInvoice: true,
|
StatusInvoice: true,
|
||||||
|
nominal: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ export async function GET(
|
|||||||
message: "Success get status transaksi",
|
message: "Success get status transaksi",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Eror get status transaksi", error);
|
console.error("Eror get status transaksi", error);
|
||||||
@@ -64,7 +66,7 @@ export async function GET(
|
|||||||
message: "Error get status transaksi",
|
message: "Error get status transaksi",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,12 +10,9 @@ async function GET(request: Request) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
console.log("[PAGE]", page);
|
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
@@ -49,7 +47,6 @@ async function GET(request: Request) {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const fixCategoryToStatus = _.startCase(category || "");
|
const fixCategoryToStatus = _.startCase(category || "");
|
||||||
console.log("[STATUS]", fixCategoryToStatus);
|
|
||||||
|
|
||||||
const data = await prisma.investasi.findMany({
|
const data = await prisma.investasi.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -70,6 +67,12 @@ async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
targetDana: true,
|
||||||
|
MasterPencarianInvestor: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
author: {
|
author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -8,6 +9,9 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -66,6 +70,8 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
title: true,
|
title: true,
|
||||||
Author: true,
|
Author: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET() {
|
async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.masterBank.findMany({
|
const data = await prisma.masterBank.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -11,6 +12,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const subBidangId = searchParams.get("subBidangId");
|
const subBidangId = searchParams.get("subBidangId");
|
||||||
|
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
if (category === "all") {
|
if (category === "all") {
|
||||||
const bidang = await prisma.masterBidangBisnis.findUnique({
|
const bidang = await prisma.masterBidangBisnis.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -45,6 +50,16 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixData = subBidang;
|
||||||
|
} else if (category === "only-sub-bidang") {
|
||||||
|
const subBidang = await prisma.masterSubBidangBisnis.findMany({
|
||||||
|
where: {
|
||||||
|
masterBidangBisnisId: id,
|
||||||
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
});
|
||||||
|
|
||||||
fixData = subBidang;
|
fixData = subBidang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,9 +86,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
console.log("category", category);
|
|
||||||
console.log("data", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "bidang") {
|
if (category === "bidang") {
|
||||||
const updateData = await prisma.masterBidangBisnis.update({
|
const updateData = await prisma.masterBidangBisnis.update({
|
||||||
|
|||||||
@@ -2,15 +2,24 @@ import { NextResponse } from "next/server";
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
|
||||||
const data = await prisma.masterBidangBisnis.findMany({
|
const data = await prisma.masterBidangBisnis.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "asc",
|
createdAt: "asc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: NextRequest) {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
// const category = searchParams.get("category");
|
// const category = searchParams.get("category");
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -13,6 +17,8 @@ async function GET(request: Request) {
|
|||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "asc",
|
createdAt: "asc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (category === "category") {
|
// if (category === "category") {
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.eventMaster_TipeAcara.findMany({
|
const data = await prisma.eventMaster_TipeAcara.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -7,10 +8,16 @@ async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
console.log("SEARCH", search);
|
||||||
|
console.log("PAGE", page);
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
if(category === "only-user"){
|
if (category === "only-user") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -22,8 +29,10 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
} else if(category === "only-admin"){
|
} else if (category === "only-admin") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -35,8 +44,10 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
} else if (category === "all-role"){
|
} else if (category === "all-role") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -48,13 +59,15 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
masterUserRoleId: "2",
|
masterUserRoleId: "2",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
username: {
|
username: {
|
||||||
contains: search || "",
|
contains: search || "",
|
||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +78,11 @@ async function GET(request: Request) {
|
|||||||
data: fixData,
|
data: fixData,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json({
|
||||||
{
|
status: 500,
|
||||||
status: 500,
|
success: false,
|
||||||
success: false,
|
message: "Error get data user access",
|
||||||
message: "Error get data user access",
|
reason: (error as Error).message,
|
||||||
reason: (error as Error).message,
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import _ from "lodash";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ async function GET(request: Request) {
|
|||||||
|
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,10 @@ export default function Login({ version }: { version: string }) {
|
|||||||
const [countryCode, setCountryCode] = useState<string>("62"); // default ke Indonesia
|
const [countryCode, setCountryCode] = useState<string>("62"); // default ke Indonesia
|
||||||
|
|
||||||
async function onLogin() {
|
async function onLogin() {
|
||||||
console.log("phone >>", phone);
|
|
||||||
|
|
||||||
const nomor = phone;
|
const nomor = phone;
|
||||||
if (nomor.length <= 4) return setError(true);
|
if (nomor.length <= 4) return setError(true);
|
||||||
|
|
||||||
const fixPhone = `${countryCode}${nomor}`;
|
const fixPhone = `${countryCode}${nomor}`;
|
||||||
console.log("fixPhone >>", fixPhone);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -46,7 +43,6 @@ export default function Login({ version }: { version: string }) {
|
|||||||
router.push("/validasi", { scroll: false });
|
router.push("/validasi", { scroll: false });
|
||||||
} else {
|
} else {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
console.log("respone >>", respone);
|
|
||||||
ComponentGlobal_NotifikasiPeringatan(respone?.message);
|
ComponentGlobal_NotifikasiPeringatan(respone?.message);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -108,9 +104,6 @@ export default function Login({ version }: { version: string }) {
|
|||||||
// Simpan hasil akhir
|
// Simpan hasil akhir
|
||||||
setCountryCode(dialCode);
|
setCountryCode(dialCode);
|
||||||
setPhone(localNumber);
|
setPhone(localNumber);
|
||||||
|
|
||||||
// console.log("Country Code:", dialCode);
|
|
||||||
// console.log("Clean Local Number:", localNumber);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,21 @@ export default function WaitingRoom_View({
|
|||||||
const [isLoadingHome, setIsLoadingHome] = useState(false);
|
const [isLoadingHome, setIsLoadingHome] = useState(false);
|
||||||
|
|
||||||
async function onClickLogout() {
|
async function onClickLogout() {
|
||||||
setLoading(true);
|
try {
|
||||||
const res = await fetch(`/api/auth/logout?id=${userLoginId}`, {
|
setLoading(true);
|
||||||
method: "GET",
|
const res = await fetch(`/api/auth/logout?id=${userLoginId}`, {
|
||||||
});
|
method: "GET",
|
||||||
|
});
|
||||||
|
|
||||||
const result = await res.json();
|
const result = await res.json();
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(result.message);
|
ComponentGlobal_NotifikasiBerhasil(result.message);
|
||||||
router.push("/", { scroll: false });
|
router.push("/", { scroll: false });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error button to home", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +89,8 @@ export default function WaitingRoom_View({
|
|||||||
</Text>
|
</Text>
|
||||||
<Text fw={"bold"} c={"white"} align="center">
|
<Text fw={"bold"} c={"white"} align="center">
|
||||||
Harap tunggu, Anda akan menerima pemberitahuan melalui
|
Harap tunggu, Anda akan menerima pemberitahuan melalui
|
||||||
Whatsapp setelah disetujui.
|
Whatsapp setelah disetujui, untuk sementara anda bisa
|
||||||
|
menunggu pada halaman ini atau keluar.
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
{isAccess && (
|
{isAccess && (
|
||||||
@@ -110,6 +117,10 @@ export default function WaitingRoom_View({
|
|||||||
Home
|
Home
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Button color="red" loading={loading} onClick={onClickLogout}>
|
||||||
|
Keluar
|
||||||
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export const middleware = async (req: NextRequest) => {
|
|||||||
|
|
||||||
const { pathname } = req.nextUrl;
|
const { pathname } = req.nextUrl;
|
||||||
|
|
||||||
const apiBaseUrl = new URL(req.url).origin || process.env.NEXT_PUBLIC_API_URL;
|
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || new URL(req.url).origin;
|
||||||
// Removed excessive logging that was causing high CPU usage
|
// Removed excessive logging that was causing high CPU usage
|
||||||
// const dbUrl = process.env.DATABASE_URL;
|
// const dbUrl = process.env.DATABASE_URL;
|
||||||
// console.log("DATABASE_URL >>", dbUrl);
|
// console.log("DATABASE_URL >>", dbUrl);
|
||||||
|
|||||||
4
types/env.d.ts
vendored
4
types/env.d.ts
vendored
@@ -11,5 +11,9 @@ declare namespace NodeJS {
|
|||||||
NEXT_PUBLIC_BASE_SESSION_KEY?: string;
|
NEXT_PUBLIC_BASE_SESSION_KEY?: string;
|
||||||
RESEND_APIKEY?: string;
|
RESEND_APIKEY?: string;
|
||||||
WA_SERVER_TOKEN?: string;
|
WA_SERVER_TOKEN?: string;
|
||||||
|
FIREBASE_ADMIN_PRIVATE_KEY?: string;
|
||||||
|
FIREBASE_ADMIN_CLIENT_EMAIL?: string;
|
||||||
|
FIREBASE_ADMIN_PROJECT_ID?: string;
|
||||||
|
NEXT_PUBLIC_API_URL?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user