Fix API mobile Investment
API – Investment (Mobile) - src/app/api/mobile/investment/route.ts - src/app/api/mobile/investment/[id]/[status]/route.ts - src/app/api/mobile/investment/[id]/invoice/route.ts - src/app/api/mobile/investment/[id]/document/route.ts Docs - PROMPT-AI.md ### No issue
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
File utama: src/app/api/mobile/voting/[id]/contribution/route.ts
|
||||
File utama: src/app/api/mobile/investment/[id]/invoice/route.ts
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -9,6 +10,10 @@ async function GET(
|
||||
{ params }: { params: { id: string; status: string } }
|
||||
) {
|
||||
const { id, status } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page ? page * takeData - takeData : 0;
|
||||
const fixStatusName = _.startCase(status);
|
||||
|
||||
try {
|
||||
@@ -22,6 +27,8 @@ async function GET(
|
||||
name: fixStatusName,
|
||||
},
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile, routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
@@ -98,6 +99,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE
|
||||
const skipData = page * takeData - takeData
|
||||
|
||||
try {
|
||||
let fixData;
|
||||
@@ -117,6 +121,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
investasiId: id,
|
||||
active: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
NotificationMobileTitleType,
|
||||
NotificationMobileBodyType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET, PUT };
|
||||
|
||||
@@ -53,6 +54,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page ? page * takeData - takeData : 0;
|
||||
|
||||
console.log("[ID INVOICE]", id);
|
||||
|
||||
@@ -103,6 +107,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
statusInvoiceId: "1",
|
||||
isActive: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
@@ -129,6 +135,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
where: {
|
||||
authorId: authorId,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
statusInvoiceId: true,
|
||||
|
||||
@@ -5,6 +5,7 @@ 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";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
@@ -73,6 +74,9 @@ async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE
|
||||
const skipData = page ? page * takeData - takeData : 0;
|
||||
|
||||
console.log("[CATEGORY]", category);
|
||||
console.log("[AUTHOR ID]", authorId);
|
||||
@@ -132,6 +136,8 @@ async function GET(request: Request) {
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
@@ -156,6 +162,8 @@ async function GET(request: Request) {
|
||||
authorId: authorId,
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
investasiId: true,
|
||||
|
||||
Reference in New Issue
Block a user