Merge pull request #324 from bipproduction/bagas/21-feb-25

fix api and prisma import
This commit is contained in:
Bagasbanuna02
2025-02-21 17:07:25 +08:00
committed by GitHub
38 changed files with 94 additions and 86 deletions

View File

@@ -1 +1 @@
bun --env-file=.env.local run --bun dev
bun --env-file=.env.local run --bun build

View File

@@ -1 +1 @@
bun --env-file=.env run --bun dev
bun --env-file=.env run --bun dev -p 3005

View File

@@ -1 +1 @@
nice -n 19 bun --env-file=.env run --bun start
bun --env-file=.env run --bun start

View File

@@ -1,6 +1,5 @@
import { prisma } from "@/lib";
import backendLogger from "@/util/backendLogger";
import { data } from "autoprefixer";
import _ from "lodash";
import { NextResponse } from "next/server";

View File

@@ -1,8 +1,6 @@
import { prisma } from "@/lib";
import backendLogger from "@/util/backendLogger";
import { data } from "autoprefixer";
import _, { take } from "lodash";
import moment from "moment";
import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET(request: Request,

View File

@@ -1,6 +1,7 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(request: Request,
{ params }: { params: { id: string } }) {

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(req: Request,
{ params }: { params: { id: string } }) {

View File

@@ -1,6 +1,8 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(request: Request,
{ params }: { params: { id: string } }

View File

@@ -19,14 +19,11 @@ export async function GET(request: Request,
if (!page) {
fixData = await prisma.forum_ReportPosting.findMany({
orderBy: {
createdAt: "desc",
},
where: {
forum_PostingId: postingId,
},
select: {
id: true,
@@ -50,7 +47,6 @@ export async function GET(request: Request,
deskripsi: true,
},
},
},
});
} else {
@@ -90,14 +86,13 @@ export async function GET(request: Request,
const nCount = await prisma.forum_ReportPosting.count({
where: {
isActive: true,
}
})
},
});
fixData = {
data: data,
nPage: _.ceil(nCount / takeData)
}
nPage: _.ceil(nCount / takeData),
};
}
return NextResponse.json({
success: true,

View File

@@ -1,8 +1,7 @@
import { count } from 'console';
import { prisma } from "@/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import _ from 'lodash';
import { NextResponse } from "next/server";
export async function GET(request: Request) {

View File

@@ -1,6 +1,7 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET( request: Request,
{ params }: { params: { id: string,} }) {

View File

@@ -1,6 +1,8 @@
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(request: Request, { params }: { params: { id: string } }) {
try {

View File

@@ -1,6 +1,5 @@
import { prisma } from "@/lib";
import _ from "lodash";
import moment from "moment";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: {

View File

@@ -1,9 +1,7 @@
import { Job_Status } from '@/app_modules/job';
import { prisma } from "@/lib";
import _, { take } from "lodash";
import { NextResponse } from "next/server";
import backendLogger from '@/util/backendLogger';
import moment from 'moment';
import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: {
params: { name: string }

View File

@@ -1,6 +1,6 @@
import { prisma } from "@/lib";
import backendLogger from "@/util/backendLogger";
import { NextRequest, NextResponse } from "next/server";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function GET(

View File

@@ -1,4 +1,3 @@
import { decrypt } from "@/app/(auth)/_lib/decrypt";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";

View File

@@ -1,6 +1,7 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -1,5 +1,4 @@
import { event_newGetListPesertaById } from "@/app_modules/event/fun";
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
import { toNumber } from "lodash";
import { NextResponse } from "next/server";

View File

@@ -1,6 +1,7 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -2,6 +2,7 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(
request: Request,

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -1,4 +1,5 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { GET };

View File

@@ -2,6 +2,7 @@ import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
export const dynamic = "force-dynamic";
export { GET };
@@ -84,6 +85,7 @@ async function GET(request: Request) {
message: "Berhasil mendapatkan data",
data: fixData,
});
} catch (error) {
backendLogger.error("Error get data job");
return NextResponse.json({

View File

@@ -1,10 +1,10 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export const dynamic = "force-dynamic";
export { GET };
async function GET(request: Request) {
export async function GET(request: Request) {
try {
let fixData;
const { searchParams } = new URL(request.url);

View File

@@ -1,8 +1,8 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
import { redirect } from "next/navigation";
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export async function GET(
request: Request,
{ params }: { params: { name: string } }

View File

@@ -1,4 +1,3 @@
import { headers } from "next/headers";
import { NextResponse } from "next/server";
export async function GET(req: Request) {
const origin = new URL(req.url).origin;

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function PUT(
request: Request,

View File

@@ -1,5 +1,4 @@
import { prisma } from "@/lib";
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";

View File

@@ -1,6 +1,5 @@
import { decrypt } from "@/app/(auth)/_lib/decrypt";
import { prisma } from "@/lib";
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic";

View File

@@ -1,5 +1,6 @@
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export async function GET(
request: Request,
@@ -7,6 +8,7 @@ export async function GET(
) {
try {
const { id } = params;
const data = await prisma.user.findUnique({
where: {
id: id,
@@ -25,7 +27,7 @@ export async function GET(
return NextResponse.json(
{
success: false,
message: "Gagal mendapatkan data, coba lagi nanti ",
message: "Error get data from API ",
reason: (error as Error).message,
},
{ status: 500 }

View File

@@ -1,4 +1,3 @@
import { headers } from "next/headers";
import { NextResponse } from "next/server";
export async function GET(
req: Request) {

View File

@@ -1,11 +1,9 @@
import { Job_Arsip } from "@/app_modules/job";
import { job_getAllArsipById } from "@/app_modules/job/fun/get/get_all_arsip";
export default async function Page() {
return (
<>
<Job_Arsip />
<Job_Arsip />
</>
);
}

View File

@@ -12,8 +12,6 @@ export const apiGetUserId = async () => {
},
});
console.log("Ini di pemanggilan API", await response.json());
if (!response.ok) return null;
const data: Record<string, any> = await response.json();
return data;

View File

@@ -5,28 +5,37 @@ import { MODEL_EVENT_PESERTA } from "../../_lib/interface";
import { revalidatePath } from "next/cache";
export async function Event_funJoinEvent(data: MODEL_EVENT_PESERTA) {
const res = await prisma.event_Peserta.create({
data: {
eventId: data.eventId,
userId: data.userId,
},
try {
console.log("Data >", data)
const res = await prisma.event_Peserta.create({
data: {
eventId: data.eventId,
userId: data.userId,
},
select: {
Event: {
select: {
id: true,
title: true,
authorId: true,
select: {
Event: {
select: {
id: true,
title: true,
authorId: true,
},
},
},
},
});
});
if (!res) return { status: 400, message: "Gagal Join" };
revalidatePath("/dev/event/detail/main");
return {
data: res,
status: 200,
message: "Berhasil Join",
};
if (!res) return { status: 400, message: "Gagal Join" };
revalidatePath("/dev/event/detail/main");
return {
data: res,
status: 200,
message: "Berhasil Join",
};
} catch (error) {
return {
status: 500,
message: "Error Join",
error: (error as Error).message,
};
}
}

View File

@@ -1,21 +1,18 @@
"use client";
import { RouterEvent } from "@/lib/router_hipmi/router_event";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
import { globalStatusApp } from "@/app_modules/_global/lib";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { RouterEvent } from "@/lib/router_hipmi/router_event";
import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Stack } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useParams } from "next/navigation";
import { useState } from "react";
import ComponentEvent_BoxListStatus from "../../component/box_list_status";
import { event_getAllByStatusId } from "../../fun";
import { MODEL_EVENT } from "../../_lib/interface";
import { useParams } from "next/navigation";
import { globalStatusApp } from "@/app_modules/_global/lib";
import { apiGetJobByStatus } from "@/app_modules/job/component/api_fetch_job";
import { clientLogger } from "@/util/clientLogger";
import { useShallowEffect } from "@mantine/hooks";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { apiGetEventByStatus } from "../../component/button/api_fetch_event";
export default function Event_ViewStatus() {

View File

@@ -1,4 +1,4 @@
export { apiGetJobByStatus, apiGetJob, apiGetJobArsip, apiGetJobById };
export { apiGetJob, apiGetJobArsip, apiGetJobById, apiGetJobByStatus };
const apiGetJobByStatus = async ({
status,
@@ -30,7 +30,7 @@ const apiGetJobByStatus = async ({
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
"Error respone data job:",
errorData?.message || "Unknown error"
);
@@ -39,12 +39,18 @@ const apiGetJobByStatus = async ({
return await response.json();
} catch (error) {
console.error("Error updating portfolio medsos:", error);
console.error("Error get data job:", error);
throw error; // Re-throw the error to handle it in the calling function
}
};
const apiGetJob = async ({ page, search }: { page: string, search?: string }) => {
const apiGetJob = async ({
page,
search,
}: {
page: string;
search?: string;
}) => {
try {
// Fetch token from cookie
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
@@ -69,7 +75,7 @@ const apiGetJob = async ({ page, search }: { page: string, search?: string }) =>
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
"Error respone data job:",
errorData?.message || "Unknown error"
);
@@ -78,16 +84,12 @@ const apiGetJob = async ({ page, search }: { page: string, search?: string }) =>
return await response.json();
} catch (error) {
console.error("Error updating portfolio logo:", error);
console.error("Error get data job:", error);
throw error; // Re-throw the error to handle it in the calling function
}
};
const apiGetJobArsip = async ({
page,
}: {
page: string;
}) => {
const apiGetJobArsip = async ({ page }: { page: string }) => {
try {
// Fetch token from cookie
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
@@ -107,20 +109,23 @@ const apiGetJobArsip = async ({
},
});
// Check if the response is OK
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
"Error respone data arsip job:",
errorData?.message || "Unknown error"
);
return null;
}
return await response.json();
const result = await response.json();
return result;
} catch (error) {
console.error("Error updating portfolio logo:", error);
console.error("Error get data arsip job:", (error as Error).message);
throw error; // Re-throw the error to handle it in the calling function
}
};
@@ -148,16 +153,16 @@ const apiGetJobById = async ({ id }: { id: string }) => {
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
"Error get data job:",
errorData?.message || "Unknown error"
);
return null;
}
}
return await response.json();
} catch (error) {
console.error("Error updating portfolio logo:", error);
console.error("Error get data job:", error);
throw error; // Re-throw the error to handle it in the calling function
}
};
};