fix : job

deskripsi:
- menghapus asycn pada page dan meneraplan userloginid di useeffect
This commit is contained in:
2025-05-26 11:11:32 +08:00
parent 963b5c9cea
commit 857354c9f6
25 changed files with 65 additions and 88 deletions

View File

@@ -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) {

View File

@@ -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}
/>

View File

@@ -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

View File

@@ -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>
</>
);