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 React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<LayoutJob_Create>{children}</LayoutJob_Create>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Job_Create } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_Create userLoginId={userLoginId} />
|
||||
<Job_Create />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { LayoutJob_DetailArsip } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<LayoutJob_DetailArsip>{children}</LayoutJob_DetailArsip>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_DetailArsip } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_DetailArsip />
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { LayoutJob_DetailDraft } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
params
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: {id: string}
|
||||
}) {
|
||||
let jobId = params.id
|
||||
return (
|
||||
<>
|
||||
<LayoutJob_DetailDraft jobId={jobId}>{children}</LayoutJob_DetailDraft>
|
||||
<LayoutJob_DetailDraft >{children}</LayoutJob_DetailDraft>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import Job_DetailDraft from "@/app_modules/job/detail/draft/view";
|
||||
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_DetailDraft />
|
||||
<Job_DetailDraft />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LayoutJob_MainDetail } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Job_MainDetail } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_MainDetail />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LayoutJob_DetailPublish } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_DetailPublish } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_DetailPublish />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LayoutJob_DetailReject } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
import Job_DetailReject from "@/app_modules/job/detail/reject/view";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_DetailReject />
|
||||
<Job_DetailReject />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LayoutJob_DetailReview } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Job_DetailReview from "@/app_modules/job/detail/review/view";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_DetailReview />
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { LayoutJob_Edit } from "@/app_modules/job";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<LayoutJob_Edit>{children}</LayoutJob_Edit>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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 (
|
||||
<>
|
||||
<Job_Edit />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_Arsip } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_Arsip />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_ViewBeranda } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_ViewBeranda />
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { LayoutJob_Main } from "@/app_modules/job";
|
||||
import NewLayoutJob_Main from "@/app_modules/job/main/new_layout";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_Status } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_Status />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Job_ViewSplash } from "@/app_modules/job";
|
||||
|
||||
export default async function Page() {
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Job_ViewSplash />
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
"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 { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import {
|
||||
@@ -11,6 +8,9 @@ import {
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
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 { Button } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
@@ -20,13 +20,6 @@ import { WibuRealtime } from "wibu-pkg";
|
||||
import { job_funCreateNoFile, job_funCreateWithFile } from "../../fun";
|
||||
import { gs_job_hot_menu } from "../../global_state";
|
||||
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({
|
||||
value,
|
||||
@@ -35,13 +28,18 @@ function Job_ComponentButtonSaveCreate({
|
||||
}: {
|
||||
value: MODEL_JOB;
|
||||
file: File;
|
||||
userLoginId: string;
|
||||
userLoginId: string | null;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
|
||||
|
||||
async function onCreate() {
|
||||
if (!userLoginId) {
|
||||
ComponentGlobal_NotifikasiGagal("User tidak ditemukan");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (file === null) {
|
||||
|
||||
@@ -26,10 +26,13 @@ import {
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_InputCountDown,
|
||||
} 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 { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
||||
|
||||
export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
||||
export default function Job_Create() {
|
||||
const [value, setValue] = useState({
|
||||
title: "",
|
||||
content: "",
|
||||
@@ -37,10 +40,28 @@ export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
||||
});
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [img, setImg] = useState<any | null>();
|
||||
const [userLoginId, setUserLoginId] = useState<string | null>(null);
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// if (window && window.document) setReload(true);
|
||||
// }, []);
|
||||
useShallowEffect(() => {
|
||||
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 (
|
||||
<Stack>
|
||||
@@ -175,7 +196,7 @@ export default function Job_Create({userLoginId}: {userLoginId: string}) {
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
<Job_ComponentButtonSaveCreate
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
value={value as any}
|
||||
file={file as any}
|
||||
/>
|
||||
|
||||
@@ -10,15 +10,15 @@ import { RouterJob } from "@/lib/router_hipmi/router_job";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconDotsVertical, IconEdit } from "@tabler/icons-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import React from "react";
|
||||
|
||||
export default function LayoutJob_DetailDraft({
|
||||
children,
|
||||
jobId,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
jobId: string;
|
||||
}) {
|
||||
const { id } = useParams();
|
||||
const [opened, { open, close }] = useDisclosure();
|
||||
|
||||
const listComponent = [
|
||||
@@ -26,28 +26,12 @@ export default function LayoutJob_DetailDraft({
|
||||
id: "1",
|
||||
name: "Edit Job",
|
||||
icon: <IconEdit />,
|
||||
path: RouterJob.edit + jobId,
|
||||
path: RouterJob.edit + id,
|
||||
},
|
||||
];
|
||||
|
||||
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_NewHeader>
|
||||
<Component_Header
|
||||
|
||||
@@ -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