fix : job
deskripsi: - page: job-vacancy untuk non user sudah bisa di akses kembali - tidak menggunakan use server lagi melainkan API
This commit is contained in:
16
src/app_modules/_global/lib/api_fetch_not_user.tsx
Normal file
16
src/app_modules/_global/lib/api_fetch_not_user.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
export async function apiGetNotUserForJob({ id }: { id: string }) {
|
||||
try {
|
||||
const response = await fetch(`/api/not-user/job/${id}`);
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error("Failed to get job", response.statusText, errorData);
|
||||
throw new Error(errorData?.message || "Failed to get job");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get job:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -7,23 +7,16 @@ import UI_NewLayoutTamplate, {
|
||||
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||
import { Job_ViewNotUserJobVacany } from "../_view";
|
||||
|
||||
export function Job_UiNotUserView({ data }: { data: any }) {
|
||||
export function Job_UiNotUserView() {
|
||||
return (
|
||||
<>
|
||||
{/* <UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate title="Job Vacancy" hideButtonLeft />
|
||||
}
|
||||
>
|
||||
<Job_ViewNotUserJobVacany data={data} />
|
||||
</UIGlobal_LayoutTamplate> */}
|
||||
|
||||
<UI_NewLayoutTamplate>
|
||||
<UI_NewHeader>
|
||||
<Component_Header title="Job Vacancy" hideButtonLeft />
|
||||
</UI_NewHeader>
|
||||
<UI_NewChildren>
|
||||
<Job_ViewNotUserJobVacany data={data} />
|
||||
<Job_ViewNotUserJobVacany/>
|
||||
</UI_NewChildren>
|
||||
</UI_NewLayoutTamplate>
|
||||
</>
|
||||
|
||||
@@ -2,9 +2,29 @@ import {
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_NotUserLoadImage,
|
||||
} from "@/app_modules/_global/component";
|
||||
import { Center, Stack, Text, Title } from "@mantine/core";
|
||||
import { apiGetNotUserForJob } from "@/app_modules/_global/lib/api_fetch_not_user";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { Center, Stack, Text } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Job_ViewNotUserJobVacany() {
|
||||
const { id } = useParams();
|
||||
const [data, setData] = useState<any>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const data = await apiGetNotUserForJob({ id: id as string });
|
||||
setData(data);
|
||||
} catch (error) {
|
||||
console.error("Error fetching job data:", error);
|
||||
}
|
||||
};
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
export function Job_ViewNotUserJobVacany({ data }: { data: any }) {
|
||||
return (
|
||||
<>
|
||||
{data ? (
|
||||
@@ -32,13 +52,7 @@ export function Job_ViewNotUserJobVacany({ data }: { data: any }) {
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
) : (
|
||||
<ComponentGlobal_CardStyles>
|
||||
<Stack spacing={"xl"}>
|
||||
<Title order={3} align="center">
|
||||
Data Not Found
|
||||
</Title>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
<CustomSkeleton height={400} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -44,13 +44,13 @@ export default function Job_MainDetail() {
|
||||
<Stack>
|
||||
<ComponentJob_DetailData data={data as any} />
|
||||
|
||||
{/* {!data ? (
|
||||
{!data ? (
|
||||
<Center>
|
||||
<CustomSkeleton height={40} width={"50%"} radius={"xl"} />
|
||||
</Center>
|
||||
) : (
|
||||
<ButtonAction jobId={param.id} />
|
||||
)} */}
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user