Fix Job
Deskripsi: - Di beranda diganti menggunakan API - Skeleton beranda - V 1.2.25
This commit is contained in:
@@ -33,92 +33,101 @@ function Job_ComponentButtonSaveCreate({
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
|
||||
|
||||
async function onCreate() {
|
||||
if (file === null) {
|
||||
const createNoFile = await job_funCreateNoFile({
|
||||
data: value,
|
||||
});
|
||||
|
||||
if (createNoFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: createNoFile.data?.id as any,
|
||||
status: createNoFile.data?.MasterStatus?.name as any,
|
||||
userId: createNoFile.data?.authorId as any,
|
||||
pesan: createNoFile.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
try {
|
||||
setIsLoading(true);
|
||||
if (file === null) {
|
||||
const createNoFile = await job_funCreateNoFile({
|
||||
data: value,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
if (createNoFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: createNoFile.data?.id as any,
|
||||
status: createNoFile.data?.MasterStatus?.name as any,
|
||||
userId: createNoFile.data?.authorId as any,
|
||||
pesan: createNoFile.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(createNoFile.message);
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
ComponentGlobal_NotifikasiBerhasil(createNoFile.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(createNoFile.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(createNoFile.message);
|
||||
const uploadFile = await funGlobal_UploadToStorage({
|
||||
file: file,
|
||||
dirId: DIRECTORY_ID.job_image,
|
||||
});
|
||||
|
||||
if (!uploadFile.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||
return;
|
||||
}
|
||||
|
||||
const createWithFile = await job_funCreateWithFile({
|
||||
data: value,
|
||||
fileId: uploadFile.data.id,
|
||||
});
|
||||
|
||||
if (createWithFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: createWithFile.data?.id as any,
|
||||
status: createWithFile.data?.MasterStatus?.name as any,
|
||||
userId: createWithFile.data?.authorId as any,
|
||||
pesan: createWithFile.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
ComponentGlobal_NotifikasiBerhasil(createWithFile.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(createWithFile.message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const uploadFile = await funGlobal_UploadToStorage({
|
||||
file: file,
|
||||
dirId: DIRECTORY_ID.job_image,
|
||||
});
|
||||
|
||||
if (!uploadFile.success)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||
|
||||
const createWithFile = await job_funCreateWithFile({
|
||||
data: value,
|
||||
fileId: uploadFile.data.id,
|
||||
});
|
||||
|
||||
if (createWithFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: createWithFile.data?.id as any,
|
||||
status: createWithFile.data?.MasterStatus?.name as any,
|
||||
userId: createWithFile.data?.authorId as any,
|
||||
pesan: createWithFile.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
title: "Job baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(createWithFile.message);
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(createWithFile.message);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
if (window.location.pathname !== RouterJob.status({ id: "2" })) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ import Job_ComponentButtonSaveCreate from "./button/comp_button_save_create";
|
||||
import { Job_ComponentButtonUpdateBeranda } from "./button/comp_button_update_beranda";
|
||||
import { Job_ComponentButtonUpdateData } from "./button/comp_button_update_data";
|
||||
import { Job_ComponentBoxUploadImage } from "./detail/comp_box_upload_image";
|
||||
import Job_ComponentSkeletonBeranda from "./skeleton/comp_skeleton_beranda";
|
||||
|
||||
export { Job_ComponentButtonSaveCreate };
|
||||
export { Job_ComponentBoxUploadImage };
|
||||
export { Job_ComponentButtonUpdateData as Job_ComponentButtonUpdate };
|
||||
export { Job_ComponentButtonUpdateBeranda };
|
||||
export { Job_ComponentSkeletonBeranda };
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import { Box, Center, Group, Skeleton, Stack } from "@mantine/core";
|
||||
|
||||
export default function Job_ComponentSkeletonBeranda() {
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
{Array.from(new Array(10)).map((e, i) => (
|
||||
<ComponentGlobal_CardStyles key={i} marginBottom={"15px"}>
|
||||
<Stack>
|
||||
<Group position="left">
|
||||
<Skeleton height={40} width={40} circle />
|
||||
<Skeleton height={20} width={200} />
|
||||
</Group>
|
||||
|
||||
<Center my={"md"}>
|
||||
<Skeleton height={20} width={300} />
|
||||
</Center>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
))}
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -24,19 +24,10 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
const [origin, setOrigin] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadOrigin(setOrigin);
|
||||
// if (typeof window !== "undefined") {
|
||||
// setOrigin(window.location.origin);
|
||||
// }
|
||||
|
||||
}, [setOrigin]);
|
||||
|
||||
async function onLoadOrigin(setOrigin: any) {
|
||||
const res = await fetch("/api/origin-url");
|
||||
const result = await res.json();
|
||||
console.log(result);
|
||||
setOrigin(result.origin);
|
||||
}
|
||||
if (typeof window !== "undefined") {
|
||||
setOrigin(window.location.origin);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -4,20 +4,24 @@ import { gs_jobTiggerBeranda } from "@/app/lib/global_state";
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { Center, Loader, Stack, TextInput } from "@mantine/core";
|
||||
import { Box, Center, Loader, Stack, TextInput } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Job_ComponentButtonUpdateBeranda,
|
||||
Job_ComponentSkeletonBeranda,
|
||||
} from "../../component";
|
||||
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
|
||||
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { Job_ComponentButtonUpdateBeranda } from "../../component";
|
||||
import { API_RouteJob } from "@/app/lib/api_user_router/route_api_job";
|
||||
|
||||
export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
const [data, setData] = useState(listData);
|
||||
export function Job_UiBeranda() {
|
||||
const [data, setData] = useState<MODEL_JOB[] | null>(null);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setIsSearch] = useState("");
|
||||
|
||||
@@ -26,19 +30,16 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
const [isTriggerJob, setIsTriggerJob] = useAtom(gs_jobTiggerBeranda);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadNewData({
|
||||
onLoad(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
}, [setData]);
|
||||
if (isTriggerJob == true) {
|
||||
setIsShowUpdate(true);
|
||||
}
|
||||
}, [isTriggerJob]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isTriggerJob) {
|
||||
setIsShowUpdate(true);
|
||||
// setIsTriggerJob(false);
|
||||
}
|
||||
}, [isTriggerJob, setIsShowUpdate]);
|
||||
setIsTriggerJob(false);
|
||||
setIsShowUpdate(false);
|
||||
onLoadNewData();
|
||||
}, []);
|
||||
|
||||
async function onSearch(text: string) {
|
||||
setIsSearch(text);
|
||||
@@ -50,9 +51,11 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
setActivePage(1);
|
||||
}
|
||||
|
||||
async function onLoadNewData({ onLoad }: { onLoad: (val: any) => void }) {
|
||||
const loadData = await job_getAllListPublish({ page: 1 });
|
||||
onLoad(loadData);
|
||||
async function onLoadNewData() {
|
||||
const loadData = await fetch(API_RouteJob.get_all({ page: activePage }));
|
||||
const res = await loadData.json();
|
||||
|
||||
setData(res.data);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -62,6 +65,7 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
<Job_ComponentButtonUpdateBeranda
|
||||
onSetIsNewPost={(val) => {
|
||||
setIsShowUpdate(val);
|
||||
setIsTriggerJob(val);
|
||||
}}
|
||||
onSetData={(val: any[]) => {
|
||||
setData(val);
|
||||
@@ -85,7 +89,9 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
}}
|
||||
/>
|
||||
|
||||
{_.isEmpty(data) ? (
|
||||
{_.isNull(data) ? (
|
||||
<Job_ComponentSkeletonBeranda />
|
||||
) : _.isEmpty(data) ? (
|
||||
<ComponentGlobal_IsEmptyData />
|
||||
) : (
|
||||
// --- Main component --- //
|
||||
@@ -97,7 +103,7 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
setData={setData as any}
|
||||
moreData={async () => {
|
||||
const loadData = await job_getAllListPublish({
|
||||
page: activePage + 1,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { Job_UiBeranda } from "./ui_beranda";
|
||||
|
||||
export default function Job_ViewBeranda({ listJob }: { listJob: MODEL_JOB[] }) {
|
||||
export default function Job_ViewBeranda() {
|
||||
return (
|
||||
<>
|
||||
<Job_UiBeranda listData={listJob} />
|
||||
<Job_UiBeranda />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user