fix api job
This commit is contained in:
@@ -2,6 +2,7 @@ import backendLogger from "@/util/backendLogger";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ async function GET(request: Request) {
|
|||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
backendLogger.error("Error get data job");
|
backendLogger.error("Error get data job");
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import backendLogger from "@/util/backendLogger";
|
import backendLogger from "@/util/backendLogger";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export { GET };
|
|
||||||
|
|
||||||
async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Job_Arsip } from "@/app_modules/job";
|
import { Job_Arsip } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_Arsip />
|
<Job_Arsip />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export { apiGetJobByStatus, apiGetJob, apiGetJobArsip, apiGetJobById };
|
export { apiGetJob, apiGetJobArsip, apiGetJobById, apiGetJobByStatus };
|
||||||
|
|
||||||
const apiGetJobByStatus = async ({
|
const apiGetJobByStatus = async ({
|
||||||
status,
|
status,
|
||||||
@@ -30,7 +30,7 @@ const apiGetJobByStatus = async ({
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => null);
|
const errorData = await response.json().catch(() => null);
|
||||||
console.error(
|
console.error(
|
||||||
"Error updating portfolio logo:",
|
"Error respone data job:",
|
||||||
errorData?.message || "Unknown error"
|
errorData?.message || "Unknown error"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -39,12 +39,18 @@ const apiGetJobByStatus = async ({
|
|||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} 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
|
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 {
|
try {
|
||||||
// Fetch token from cookie
|
// Fetch token from cookie
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
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) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => null);
|
const errorData = await response.json().catch(() => null);
|
||||||
console.error(
|
console.error(
|
||||||
"Error updating portfolio logo:",
|
"Error respone data job:",
|
||||||
errorData?.message || "Unknown error"
|
errorData?.message || "Unknown error"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -78,16 +84,12 @@ const apiGetJob = async ({ page, search }: { page: string, search?: string }) =>
|
|||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} 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
|
throw error; // Re-throw the error to handle it in the calling function
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const apiGetJobArsip = async ({
|
const apiGetJobArsip = async ({ page }: { page: string }) => {
|
||||||
page,
|
|
||||||
}: {
|
|
||||||
page: string;
|
|
||||||
}) => {
|
|
||||||
try {
|
try {
|
||||||
// Fetch token from cookie
|
// Fetch token from cookie
|
||||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||||
@@ -107,20 +109,23 @@ const apiGetJobArsip = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Check if the response is OK
|
// Check if the response is OK
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => null);
|
const errorData = await response.json().catch(() => null);
|
||||||
console.error(
|
console.error(
|
||||||
"Error updating portfolio logo:",
|
"Error respone data arsip job:",
|
||||||
errorData?.message || "Unknown error"
|
errorData?.message || "Unknown error"
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} 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
|
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) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => null);
|
const errorData = await response.json().catch(() => null);
|
||||||
console.error(
|
console.error(
|
||||||
"Error updating portfolio logo:",
|
"Error get data job:",
|
||||||
errorData?.message || "Unknown error"
|
errorData?.message || "Unknown error"
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} 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
|
throw error; // Re-throw the error to handle it in the calling function
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user