fix : job
deskripsi: - menghapus asycn pada page dan meneraplan userloginid di useeffect
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
import { LayoutJob_Create } from "@/app_modules/job";
|
import { LayoutJob_Create } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutJob_Create>{children}</LayoutJob_Create>
|
<LayoutJob_Create>{children}</LayoutJob_Create>
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { Job_Create } from "@/app_modules/job";
|
import { Job_Create } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_Create userLoginId={userLoginId} />
|
<Job_Create />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { LayoutJob_DetailArsip } from "@/app_modules/job";
|
import { LayoutJob_DetailArsip } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutJob_DetailArsip>{children}</LayoutJob_DetailArsip>
|
<LayoutJob_DetailArsip>{children}</LayoutJob_DetailArsip>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_DetailArsip } from "@/app_modules/job";
|
import { Job_DetailArsip } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_DetailArsip />
|
<Job_DetailArsip />
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
import { LayoutJob_DetailDraft } from "@/app_modules/job";
|
import { LayoutJob_DetailDraft } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
params
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: {id: string}
|
|
||||||
}) {
|
}) {
|
||||||
let jobId = params.id
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutJob_DetailDraft jobId={jobId}>{children}</LayoutJob_DetailDraft>
|
<LayoutJob_DetailDraft >{children}</LayoutJob_DetailDraft>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import Job_DetailDraft from "@/app_modules/job/detail/draft/view";
|
import Job_DetailDraft from "@/app_modules/job/detail/draft/view";
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
export default async function Page() {
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_DetailDraft />
|
<Job_DetailDraft />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutJob_MainDetail } from "@/app_modules/job";
|
import { LayoutJob_MainDetail } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Job_MainDetail } from "@/app_modules/job";
|
import { Job_MainDetail } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_MainDetail />
|
<Job_MainDetail />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutJob_DetailPublish } from "@/app_modules/job";
|
import { LayoutJob_DetailPublish } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_DetailPublish } from "@/app_modules/job";
|
import { Job_DetailPublish } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_DetailPublish />
|
<Job_DetailPublish />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutJob_DetailReject } from "@/app_modules/job";
|
import { LayoutJob_DetailReject } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
import Job_DetailReject from "@/app_modules/job/detail/reject/view";
|
import Job_DetailReject from "@/app_modules/job/detail/reject/view";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_DetailReject />
|
<Job_DetailReject />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LayoutJob_DetailReview } from "@/app_modules/job";
|
import { LayoutJob_DetailReview } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Job_DetailReview from "@/app_modules/job/detail/review/view";
|
import Job_DetailReview from "@/app_modules/job/detail/review/view";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_DetailReview />
|
<Job_DetailReview />
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { LayoutJob_Edit } from "@/app_modules/job";
|
import { LayoutJob_Edit } from "@/app_modules/job";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutJob_Edit>{children}</LayoutJob_Edit>
|
<LayoutJob_Edit>{children}</LayoutJob_Edit>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { Job_Edit } from "@/app_modules/job";
|
import { Job_Edit } from "@/app_modules/job";
|
||||||
import { job_getOneById } from "@/app_modules/job/fun/get/get_one_by_id";
|
|
||||||
|
|
||||||
export default async function Page() {
|
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_Edit />
|
<Job_Edit />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_Arsip } from "@/app_modules/job";
|
import { Job_Arsip } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_Arsip />
|
<Job_Arsip />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_ViewBeranda } from "@/app_modules/job";
|
import { Job_ViewBeranda } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_ViewBeranda />
|
<Job_ViewBeranda />
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { LayoutJob_Main } from "@/app_modules/job";
|
|
||||||
import NewLayoutJob_Main from "@/app_modules/job/main/new_layout";
|
import NewLayoutJob_Main from "@/app_modules/job/main/new_layout";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_Status } from "@/app_modules/job";
|
import { Job_Status } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_Status />
|
<Job_Status />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Job_ViewSplash } from "@/app_modules/job";
|
import { Job_ViewSplash } from "@/app_modules/job";
|
||||||
|
|
||||||
export default async function Page() {
|
export default function Page() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Job_ViewSplash />
|
<Job_ViewSplash />
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { DIRECTORY_ID } from "@/lib";
|
|
||||||
import { IRealtimeData } from "@/lib/global_state";
|
|
||||||
import { RouterJob } from "@/lib/router_hipmi/router_job";
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||||
import {
|
import {
|
||||||
@@ -11,6 +8,9 @@ import {
|
|||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||||
|
import { DIRECTORY_ID } from "@/lib";
|
||||||
|
import { IRealtimeData } from "@/lib/global_state";
|
||||||
|
import { RouterJob } from "@/lib/router_hipmi/router_job";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { Button } from "@mantine/core";
|
import { Button } from "@mantine/core";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
@@ -20,13 +20,6 @@ import { WibuRealtime } from "wibu-pkg";
|
|||||||
import { job_funCreateNoFile, job_funCreateWithFile } from "../../fun";
|
import { job_funCreateNoFile, job_funCreateWithFile } from "../../fun";
|
||||||
import { gs_job_hot_menu } from "../../global_state";
|
import { gs_job_hot_menu } from "../../global_state";
|
||||||
import { MODEL_JOB } from "../../model/interface";
|
import { MODEL_JOB } from "../../model/interface";
|
||||||
import { apiCreatedJob } from "../../lib/api_fetch_job";
|
|
||||||
import {
|
|
||||||
apiCreatedNotificationToAdmin,
|
|
||||||
apiGetSeasonUserId,
|
|
||||||
} from "@/app_modules/_global/lib/api_fetch_global";
|
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
|
||||||
import { apiGetUserId } from "@/app_modules/_global/lib/api_user";
|
|
||||||
|
|
||||||
function Job_ComponentButtonSaveCreate({
|
function Job_ComponentButtonSaveCreate({
|
||||||
value,
|
value,
|
||||||
@@ -35,13 +28,18 @@ function Job_ComponentButtonSaveCreate({
|
|||||||
}: {
|
}: {
|
||||||
value: MODEL_JOB;
|
value: MODEL_JOB;
|
||||||
file: File;
|
file: File;
|
||||||
userLoginId: string;
|
userLoginId: string | null;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
|
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
|
||||||
|
|
||||||
async function onCreate() {
|
async function onCreate() {
|
||||||
|
if (!userLoginId) {
|
||||||
|
ComponentGlobal_NotifikasiGagal("User tidak ditemukan");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
if (file === null) {
|
if (file === null) {
|
||||||
|
|||||||
@@ -26,10 +26,13 @@ import {
|
|||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
ComponentGlobal_InputCountDown,
|
ComponentGlobal_InputCountDown,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
|
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
|
||||||
|
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { Job_ComponentButtonSaveCreate } from "../component";
|
import { Job_ComponentButtonSaveCreate } from "../component";
|
||||||
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
||||||
|
|
||||||
export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
export default function Job_Create() {
|
||||||
const [value, setValue] = useState({
|
const [value, setValue] = useState({
|
||||||
title: "",
|
title: "",
|
||||||
content: "",
|
content: "",
|
||||||
@@ -37,10 +40,28 @@ export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
|||||||
});
|
});
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [img, setImg] = useState<any | null>();
|
const [img, setImg] = useState<any | null>();
|
||||||
|
const [userLoginId, setUserLoginId] = useState<string | null>(null);
|
||||||
|
|
||||||
// useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
// if (window && window.document) setReload(true);
|
handleGetUserLoginId();
|
||||||
// }, []);
|
}, []);
|
||||||
|
|
||||||
|
async function handleGetUserLoginId() {
|
||||||
|
try {
|
||||||
|
const response = await apiNewGetUserIdByToken();
|
||||||
|
if (response.success) {
|
||||||
|
setUserLoginId(response.userId);
|
||||||
|
} else {
|
||||||
|
setUserLoginId(null);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setUserLoginId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userLoginId) {
|
||||||
|
return <CustomSkeleton height={300} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -175,7 +196,7 @@ export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
|||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
|
|
||||||
<Job_ComponentButtonSaveCreate
|
<Job_ComponentButtonSaveCreate
|
||||||
userLoginId={userLoginId}
|
userLoginId={userLoginId as string}
|
||||||
value={value as any}
|
value={value as any}
|
||||||
file={file as any}
|
file={file as any}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ import { RouterJob } from "@/lib/router_hipmi/router_job";
|
|||||||
import { ActionIcon } from "@mantine/core";
|
import { ActionIcon } from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { IconDotsVertical, IconEdit } from "@tabler/icons-react";
|
import { IconDotsVertical, IconEdit } from "@tabler/icons-react";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function LayoutJob_DetailDraft({
|
export default function LayoutJob_DetailDraft({
|
||||||
children,
|
children,
|
||||||
jobId,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
jobId: string;
|
|
||||||
}) {
|
}) {
|
||||||
|
const { id } = useParams();
|
||||||
const [opened, { open, close }] = useDisclosure();
|
const [opened, { open, close }] = useDisclosure();
|
||||||
|
|
||||||
const listComponent = [
|
const listComponent = [
|
||||||
@@ -26,28 +26,12 @@ export default function LayoutJob_DetailDraft({
|
|||||||
id: "1",
|
id: "1",
|
||||||
name: "Edit Job",
|
name: "Edit Job",
|
||||||
icon: <IconEdit />,
|
icon: <IconEdit />,
|
||||||
path: RouterJob.edit + jobId,
|
path: RouterJob.edit + id,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<UIGlobal_LayoutHeaderTamplate
|
|
||||||
title="Detail Draft"
|
|
||||||
iconRight={
|
|
||||||
<ActionIcon variant="transparent" onClick={() => open()}>
|
|
||||||
<IconDotsVertical color="white" />
|
|
||||||
</ActionIcon>
|
|
||||||
}
|
|
||||||
// routerRight={}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Component_Header
|
<Component_Header
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user