deskripsi:
- fix api job
This commit is contained in:
2025-02-20 10:20:54 +08:00
parent d474d7611b
commit 57d04450e1
15 changed files with 373 additions and 115 deletions

View File

@@ -1,4 +1,4 @@
export { apiGetJobByStatus };
export { apiGetJobByStatus, apiGetJob, apiGetJobArsip };
const apiGetJobByStatus = async ({
status,
@@ -15,10 +15,8 @@ const apiGetJobByStatus = async ({
return null;
}
console.log("status > ", status);
// Send PUT request to update portfolio logo
const isPage = `?page=${page}`
const isPage = `?page=${page}`;
const response = await fetch(`/api/job/status/${status}${isPage}`, {
method: "GET",
headers: {
@@ -45,3 +43,84 @@ const apiGetJobByStatus = async ({
throw error; // Re-throw the error to handle it in the calling function
}
};
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());
if (!token) {
console.error("No token found");
return null;
}
// Send PUT request to update portfolio logo
const isPage = `?page=${page}`;
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/job${isPage}${isSearch}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
},
});
// Check if the response is OK
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
errorData?.message || "Unknown error"
);
return null;
}
return await response.json();
} catch (error) {
console.error("Error updating portfolio logo:", error);
throw error; // Re-throw the error to handle it in the calling function
}
};
const apiGetJobArsip = async ({
page,
}: {
page: string;
}) => {
try {
// Fetch token from cookie
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) {
console.error("No token found");
return null;
}
// Send PUT request to update portfolio logo
const isPage = `?page=${page}`;
const response = await fetch(`/api/job/arsip${isPage}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
},
});
// Check if the response is OK
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error updating portfolio logo:",
errorData?.message || "Unknown error"
);
return null;
}
return await response.json();
} catch (error) {
console.error("Error updating portfolio logo:", error);
throw error; // Re-throw the error to handle it in the calling function
}
};

View File

@@ -1,20 +1,21 @@
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { Box, Center, Group, Skeleton, Stack } from "@mantine/core";
export default function Job_ComponentSkeletonBeranda() {
return (
<>
<Box>
{Array.from(new Array(10)).map((e, i) => (
{Array.from(new Array(3)).map((e, i) => (
<ComponentGlobal_CardStyles key={i} marginBottom={"15px"}>
<Stack>
<Group position="left">
<Skeleton height={40} width={40} circle />
<Skeleton height={20} width={200} />
<CustomSkeleton height={40} width={40} circle />
<CustomSkeleton height={20} width={200} />
</Group>
<Center my={"md"}>
<Skeleton height={20} width={300} />
<CustomSkeleton height={20} width={300} />
</Center>
</Stack>
</ComponentGlobal_CardStyles>