Merge pull request #314 from bipproduction/Nico/17-feb-25
Fix Routing Folder API Admin
This commit is contained in:
@@ -4,11 +4,11 @@ import _ from "lodash";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request, { params }:
|
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 { searchParams } = new URL(request.url);
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = 10;
|
||||||
@@ -16,7 +16,7 @@ export async function GET(request: Request, { params }:
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(name);
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
fixData = await prisma.projectCollaboration.findMany({
|
fixData = await prisma.projectCollaboration.findMany({
|
||||||
@@ -6,9 +6,9 @@ import moment from "moment";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request,
|
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 { 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");
|
||||||
@@ -17,7 +17,7 @@ export async function GET(request: Request,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(name);
|
||||||
|
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
@@ -4,7 +4,7 @@ import moment from "moment";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request, { params }: {
|
export async function GET(request: Request, { params }: {
|
||||||
params: { status: string }
|
params: { name: string }
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const method = request.method;
|
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 { 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");
|
||||||
@@ -26,7 +26,7 @@ export async function GET(request: Request, { params }: {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(name);
|
||||||
|
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
@@ -6,7 +6,7 @@ import backendLogger from '@/util/backendLogger';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export async function GET(request: Request, { params }: {
|
export async function GET(request: Request, { params }: {
|
||||||
params: { status: string }
|
params: { name: string }
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const method = request.method;
|
const method = request.method;
|
||||||
@@ -18,7 +18,7 @@ export async function GET(request: Request, { params }: {
|
|||||||
{ status: 405 }
|
{ status: 405 }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const { status } = params;
|
const { name } = 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");
|
||||||
@@ -28,7 +28,7 @@ export async function GET(request: Request, { params }: {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(name);
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
fixData = await prisma.job.findMany({
|
fixData = await prisma.job.findMany({
|
||||||
@@ -4,7 +4,7 @@ import moment from "moment";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request,
|
export async function GET(request: Request,
|
||||||
{ params }: { params: { status: string } }
|
{ params }: { params: { name: string } }
|
||||||
) {
|
) {
|
||||||
const method = request.method;
|
const method = request.method;
|
||||||
if (method !== "GET") {
|
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 { 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");
|
||||||
@@ -25,7 +25,7 @@ export async function GET(request: Request,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(name);
|
||||||
|
|
||||||
if (!page && !search) {
|
if (!page && !search) {
|
||||||
fixData = await prisma.voting.findMany({
|
fixData = await prisma.voting.findMany({
|
||||||
@@ -25,8 +25,8 @@ const apiGetAdminCollaborationStatusCountDashboard = async ({
|
|||||||
// console.log("Ini Response", await response.json());
|
// console.log("Ini Response", await response.json());
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
}
|
}
|
||||||
const apiGetAdminCollaborationStatusById = async ({ status, page}: {
|
const apiGetAdminCollaborationStatusById = async ({ name, page}: {
|
||||||
status: "Publish" | "Reject",
|
name: "Publish" | "Reject",
|
||||||
page: string,
|
page: string,
|
||||||
|
|
||||||
}) => {
|
}) => {
|
||||||
@@ -35,7 +35,7 @@ const apiGetAdminCollaborationStatusById = async ({ status, page}: {
|
|||||||
if (!token) return await token.json().catch(() => null);
|
if (!token) return await token.json().catch(() => null);
|
||||||
|
|
||||||
const isPage = page ? `?page=${page}` : "";
|
const isPage = page ? `?page=${page}` : "";
|
||||||
const response = await fetch(`/api/admin/collaboration/${status}${isPage}`, {
|
const response = await fetch(`/api/admin/collaboration/${name}${isPage}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ const apiGetAdminDonasiKategoriCountDashboard = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const apiGetAdminDonasiByStatus = async ({
|
const apiGetAdminDonasiByStatus = async ({
|
||||||
status,
|
name,
|
||||||
page,
|
page,
|
||||||
search }: {
|
search }: {
|
||||||
status: "Publish" | "Review" | "Reject",
|
name: "Publish" | "Review" | "Reject",
|
||||||
page: string;
|
page: string;
|
||||||
search: string;
|
search: string;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -52,7 +52,7 @@ const apiGetAdminDonasiByStatus = async ({
|
|||||||
const isPage = page ? `?page=${page}` : "";
|
const isPage = page ? `?page=${page}` : "";
|
||||||
const isSearch = search ? `&search=${search}` : "";
|
const isSearch = search ? `&search=${search}` : "";
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/api/admin/donasi/${status}${isPage}${isSearch}`,
|
`/api/admin/donasi/status/${name}${isPage}${isSearch}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function TableStatus() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminDonasiByStatus({
|
const response = await apiGetAdminDonasiByStatus({
|
||||||
status: "Publish",
|
name: "Publish",
|
||||||
page: `${isActivePage}`,
|
page: `${isActivePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ function TableStatus() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminDonasiByStatus({
|
const response = await apiGetAdminDonasiByStatus({
|
||||||
status: "Reject",
|
name: "Reject",
|
||||||
page: `${isActivePage}`,
|
page: `${isActivePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ function TableStatus() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminDonasiByStatus({
|
const response = await apiGetAdminDonasiByStatus({
|
||||||
status: "Review",
|
name: "Review",
|
||||||
page: `${isActivePage}`,
|
page: `${isActivePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ const apiGetAdminInvestasiCountDashboard = async ({ name }:
|
|||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
const apiGetAdminInvestasiByStatus = async ({ name, page, search }: {
|
||||||
status: "Publish" | "Review" | "Reject",
|
name: "Publish" | "Review" | "Reject",
|
||||||
page: string,
|
page: string,
|
||||||
search: string
|
search: string
|
||||||
}) => {
|
}) => {
|
||||||
@@ -40,7 +40,7 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
|||||||
|
|
||||||
const isPage = page ? `?page=${page}` : "";
|
const isPage = page ? `?page=${page}` : "";
|
||||||
const isSearch = search ? `&search=${search}` : "";
|
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",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
|||||||
data={listStatus?.map(status => ({
|
data={listStatus?.map(status => ({
|
||||||
value: status.id,
|
value: status.id,
|
||||||
label: status.name,
|
label: status.name,
|
||||||
|
|
||||||
})) || []}
|
})) || []}
|
||||||
onChange={(val: any) => {
|
onChange={(val: any) => {
|
||||||
console.log(val)
|
console.log(val)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function TableView() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminInvestasiByStatus({
|
const response = await apiGetAdminInvestasiByStatus({
|
||||||
status: "Publish",
|
name: "Publish",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch,
|
search: isSearch,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function TableView() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminInvestasiByStatus({
|
const response = await apiGetAdminInvestasiByStatus({
|
||||||
status: "Reject",
|
name: "Reject",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch,
|
search: isSearch,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function TableView() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminInvestasiByStatus({
|
const response = await apiGetAdminInvestasiByStatus({
|
||||||
status: "Review",
|
name: "Review",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch,
|
search: isSearch,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export default function AdminJob_ViewTavleReview() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminJobByStatus({
|
const response = await apiGetAdminJobByStatus({
|
||||||
status: "Review",
|
name: "Review",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ function TableStatus() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminJobByStatus({
|
const response = await apiGetAdminJobByStatus({
|
||||||
status: "Publish",
|
name: "Publish",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function TableStatus() {
|
|||||||
const loadInitialData = async () => {
|
const loadInitialData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiGetAdminJobByStatus({
|
const response = await apiGetAdminJobByStatus({
|
||||||
status: "Reject",
|
name: "Reject",
|
||||||
page: `${activePage}`,
|
page: `${activePage}`,
|
||||||
search: isSearch
|
search: isSearch
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ const apiGetAdminJobArsipCount = async () => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
const apiGetAdminJobByStatus = async ({
|
const apiGetAdminJobByStatus = async ({
|
||||||
status,
|
name,
|
||||||
page,
|
page,
|
||||||
search
|
search
|
||||||
}: {
|
}: {
|
||||||
status: "Publish" | "Review" | "Reject";
|
name: "Publish" | "Review" | "Reject";
|
||||||
page: string;
|
page: string;
|
||||||
search: string;
|
search: string;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -53,7 +53,7 @@ const apiGetAdminJobByStatus = async ({
|
|||||||
const isPage = page ? `?page=${page}` : "";
|
const isPage = page ? `?page=${page}` : "";
|
||||||
const isSearch = search ? `&search=${search}` : "";
|
const isSearch = search ? `&search=${search}` : "";
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/api/admin/job/${status}${isPage}${isSearch}`,
|
`/api/admin/job/status/${name}${isPage}${isSearch}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const middlewareConfig: MiddlewareConfig = {
|
|||||||
|
|
||||||
// ADMIN API
|
// ADMIN API
|
||||||
// >> buat dibawah sini <<
|
// >> buat dibawah sini <<
|
||||||
"/api/admin/investasi/*",
|
"api/admin/job/*",
|
||||||
|
|
||||||
|
|
||||||
// Akses awal
|
// Akses awal
|
||||||
|
|||||||
Reference in New Issue
Block a user