Fix Routing Folder API Admin

This commit is contained in:
2025-02-17 01:13:30 +08:00
parent 83ee4e257b
commit 0be007d25e
20 changed files with 38 additions and 37 deletions

View File

@@ -4,11 +4,11 @@ import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }:
{ params: { status: string } }
{ params: { name: string } }
) {
const { status } = params;
const { name } = params;
const { searchParams } = new URL(request.url);
const page = searchParams.get("page");
const takeData = 10;
@@ -16,7 +16,7 @@ export async function GET(request: Request, { params }:
try {
let fixData;
const fixStatus = _.startCase(status);
const fixStatus = _.startCase(name);
if (!page) {
fixData = await prisma.projectCollaboration.findMany({

View File

@@ -6,9 +6,9 @@ import moment from "moment";
import { NextResponse } from "next/server";
export async function GET(request: Request,
{ params }: { params: { status: string } }) {
{ params }: { params: { name: string } }) {
const { status } = params;
const { name } = params;
const { searchParams } = new URL(request.url);
const search = searchParams.get("search");
const page = searchParams.get("page");
@@ -17,7 +17,7 @@ export async function GET(request: Request,
try {
let fixData;
const fixStatus = _.startCase(status);
const fixStatus = _.startCase(name);
if (!page) {

View File

@@ -4,7 +4,7 @@ import moment from "moment";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: {
params: { status: string }
params: { name: string }
}
) {
const method = request.method;
@@ -17,7 +17,7 @@ export async function GET(request: Request, { params }: {
)
}
const { status } = params;
const { name } = params;
const { searchParams } = new URL(request.url);
const search = searchParams.get("search");
const page = searchParams.get("page");
@@ -26,7 +26,7 @@ export async function GET(request: Request, { params }: {
try {
let fixData;
const fixStatus = _.startCase(status);
const fixStatus = _.startCase(name);
if (!page) {

View File

@@ -6,7 +6,7 @@ import backendLogger from '@/util/backendLogger';
import moment from 'moment';
export async function GET(request: Request, { params }: {
params: { status: string }
params: { name: string }
}
) {
const method = request.method;
@@ -18,7 +18,7 @@ export async function GET(request: Request, { params }: {
{ status: 405 }
)
}
const { status } = params;
const { name } = params;
const { searchParams } = new URL(request.url);
const search = searchParams.get("search");
const page = searchParams.get("page");
@@ -28,7 +28,7 @@ export async function GET(request: Request, { params }: {
try {
let fixData;
const fixStatus = _.startCase(status);
const fixStatus = _.startCase(name);
if (!page) {
fixData = await prisma.job.findMany({

View File

@@ -4,7 +4,7 @@ import moment from "moment";
import { NextResponse } from "next/server";
export async function GET(request: Request,
{ params }: { params: { status: string } }
{ params }: { params: { name: string } }
) {
const method = request.method;
if (method !== "GET") {
@@ -16,7 +16,7 @@ export async function GET(request: Request,
)
}
const { status } = params;
const { name } = params;
const { searchParams } = new URL(request.url);
const search = searchParams.get("search");
const page = searchParams.get("page");
@@ -25,7 +25,7 @@ export async function GET(request: Request,
try {
let fixData;
const fixStatus = _.startCase(status);
const fixStatus = _.startCase(name);
if (!page && !search) {
fixData = await prisma.voting.findMany({

View File

@@ -25,8 +25,8 @@ const apiGetAdminCollaborationStatusCountDashboard = async ({
// console.log("Ini Response", await response.json());
return await response.json().catch(() => null);
}
const apiGetAdminCollaborationStatusById = async ({ status, page}: {
status: "Publish" | "Reject",
const apiGetAdminCollaborationStatusById = async ({ name, page}: {
name: "Publish" | "Reject",
page: string,
}) => {
@@ -35,7 +35,7 @@ const apiGetAdminCollaborationStatusById = async ({ status, page}: {
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
const response = await fetch(`/api/admin/collaboration/${status}${isPage}`, {
const response = await fetch(`/api/admin/collaboration/${name}${isPage}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",

View File

@@ -38,10 +38,10 @@ const apiGetAdminDonasiKategoriCountDashboard = async () => {
}
const apiGetAdminDonasiByStatus = async ({
status,
name,
page,
search }: {
status: "Publish" | "Review" | "Reject",
name: "Publish" | "Review" | "Reject",
page: string;
search: string;
}) => {
@@ -52,7 +52,7 @@ const apiGetAdminDonasiByStatus = async ({
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(
`/api/admin/donasi/${status}${isPage}${isSearch}`,
`/api/admin/donasi/status/${name}${isPage}${isSearch}`,
{
headers: {
"Content-Type": "application/json",

View File

@@ -54,7 +54,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminDonasiByStatus({
status: "Publish",
name: "Publish",
page: `${isActivePage}`,
search: isSearch
})

View File

@@ -56,7 +56,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminDonasiByStatus({
status: "Reject",
name: "Reject",
page: `${isActivePage}`,
search: isSearch
})

View File

@@ -68,7 +68,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminDonasiByStatus({
status: "Review",
name: "Review",
page: `${isActivePage}`,
search: isSearch
})

View File

@@ -27,8 +27,8 @@ const apiGetAdminInvestasiCountDashboard = async ({ name }:
return await response.json().catch(() => null);
};
const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
status: "Publish" | "Review" | "Reject",
const apiGetAdminInvestasiByStatus = async ({ name, page, search }: {
name: "Publish" | "Review" | "Reject",
page: string,
search: string
}) => {
@@ -40,7 +40,7 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/investasi/status/${status}${isPage}${isSearch}`, {
const response = await fetch(`/api/admin/investasi/status/${name}${isPage}${isSearch}`, {
method: "GET",
headers: {
"Content-Type": "application/json",

View File

@@ -241,6 +241,7 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
data={listStatus?.map(status => ({
value: status.id,
label: status.name,
})) || []}
onChange={(val: any) => {
console.log(val)

View File

@@ -62,7 +62,7 @@ function TableView() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminInvestasiByStatus({
status: "Publish",
name: "Publish",
page: `${activePage}`,
search: isSearch,
});

View File

@@ -130,7 +130,7 @@ function TableView() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminInvestasiByStatus({
status: "Reject",
name: "Reject",
page: `${activePage}`,
search: isSearch,
});

View File

@@ -66,7 +66,7 @@ function TableView() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminInvestasiByStatus({
status: "Review",
name: "Review",
page: `${activePage}`,
search: isSearch,
});

View File

@@ -76,7 +76,7 @@ export default function AdminJob_ViewTavleReview() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminJobByStatus({
status: "Review",
name: "Review",
page: `${activePage}`,
search: isSearch
})

View File

@@ -56,7 +56,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminJobByStatus({
status: "Publish",
name: "Publish",
page: `${activePage}`,
search: isSearch
})

View File

@@ -64,7 +64,7 @@ function TableStatus() {
const loadInitialData = async () => {
try {
const response = await apiGetAdminJobByStatus({
status: "Reject",
name: "Reject",
page: `${activePage}`,
search: isSearch
});

View File

@@ -39,11 +39,11 @@ const apiGetAdminJobArsipCount = async () => {
};
const apiGetAdminJobByStatus = async ({
status,
name,
page,
search
}: {
status: "Publish" | "Review" | "Reject";
name: "Publish" | "Review" | "Reject";
page: string;
search: string;
}) => {
@@ -53,7 +53,7 @@ const apiGetAdminJobByStatus = async ({
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(
`/api/admin/job/${status}${isPage}${isSearch}`,
`/api/admin/job/status/${name}${isPage}${isSearch}`,
{
headers: {
"Content-Type": "application/json",

View File

@@ -34,7 +34,7 @@ const middlewareConfig: MiddlewareConfig = {
// ADMIN API
// >> buat dibawah sini <<
"/api/admin/investasi/*",
"api/admin/job/*",
// Akses awal