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:
@@ -1,13 +1,10 @@
|
|||||||
import { Job_UiNotUserView } from "@/app_modules/job/_ui";
|
import { Job_UiNotUserView } from "@/app_modules/job/_ui";
|
||||||
import { job_getOneById } from "@/app_modules/job/fun/get/get_one_by_id";
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const jobId = params.id;
|
|
||||||
const dataJob = await job_getOneById(jobId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_UiNotUserView data={dataJob} />
|
<Job_UiNotUserView />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/app/api/not-user/job/[id]/route.ts
Normal file
25
src/app/api/not-user/job/[id]/route.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export async function GET(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
const data = await prisma.job.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching job data:", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Failed to fetch job data" },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
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";
|
} from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||||
import { Job_ViewNotUserJobVacany } from "../_view";
|
import { Job_ViewNotUserJobVacany } from "../_view";
|
||||||
|
|
||||||
export function Job_UiNotUserView({ data }: { data: any }) {
|
export function Job_UiNotUserView() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<UIGlobal_LayoutHeaderTamplate title="Job Vacancy" hideButtonLeft />
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Job_ViewNotUserJobVacany data={data} />
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header title="Job Vacancy" hideButtonLeft />
|
<Component_Header title="Job Vacancy" hideButtonLeft />
|
||||||
</UI_NewHeader>
|
</UI_NewHeader>
|
||||||
<UI_NewChildren>
|
<UI_NewChildren>
|
||||||
<Job_ViewNotUserJobVacany data={data} />
|
<Job_ViewNotUserJobVacany/>
|
||||||
</UI_NewChildren>
|
</UI_NewChildren>
|
||||||
</UI_NewLayoutTamplate>
|
</UI_NewLayoutTamplate>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -2,9 +2,29 @@ import {
|
|||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
ComponentGlobal_NotUserLoadImage,
|
ComponentGlobal_NotUserLoadImage,
|
||||||
} from "@/app_modules/_global/component";
|
} 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{data ? (
|
{data ? (
|
||||||
@@ -32,13 +52,7 @@ export function Job_ViewNotUserJobVacany({ data }: { data: any }) {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
) : (
|
) : (
|
||||||
<ComponentGlobal_CardStyles>
|
<CustomSkeleton height={400} />
|
||||||
<Stack spacing={"xl"}>
|
|
||||||
<Title order={3} align="center">
|
|
||||||
Data Not Found
|
|
||||||
</Title>
|
|
||||||
</Stack>
|
|
||||||
</ComponentGlobal_CardStyles>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ export default function Job_MainDetail() {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<ComponentJob_DetailData data={data as any} />
|
<ComponentJob_DetailData data={data as any} />
|
||||||
|
|
||||||
{/* {!data ? (
|
{!data ? (
|
||||||
<Center>
|
<Center>
|
||||||
<CustomSkeleton height={40} width={"50%"} radius={"xl"} />
|
<CustomSkeleton height={40} width={"50%"} radius={"xl"} />
|
||||||
</Center>
|
</Center>
|
||||||
) : (
|
) : (
|
||||||
<ButtonAction jobId={param.id} />
|
<ButtonAction jobId={param.id} />
|
||||||
)} */}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const CONFIG: MiddlewareConfig = {
|
|||||||
userPath: "/dev/home",
|
userPath: "/dev/home",
|
||||||
publicRoutes: [
|
publicRoutes: [
|
||||||
"/",
|
"/",
|
||||||
|
"/api/not-user/*",
|
||||||
"/api/voting/*",
|
"/api/voting/*",
|
||||||
"/api/collaboration/*",
|
"/api/collaboration/*",
|
||||||
"/api/notifikasi/*",
|
"/api/notifikasi/*",
|
||||||
@@ -36,7 +37,7 @@ const CONFIG: MiddlewareConfig = {
|
|||||||
"/validasi",
|
"/validasi",
|
||||||
"/splash",
|
"/splash",
|
||||||
"/invalid-user",
|
"/invalid-user",
|
||||||
"/job-vacancy",
|
"/job-vacancy/*",
|
||||||
"/preview-image",
|
"/preview-image",
|
||||||
"/auth/login",
|
"/auth/login",
|
||||||
"/auth/api/login",
|
"/auth/api/login",
|
||||||
|
|||||||
Reference in New Issue
Block a user