Deskripsi:
- Di beranda diganti menggunakan API
- Skeleton beranda
- V 1.2.25
This commit is contained in:
2024-12-12 14:46:06 +08:00
parent 80b6d35fe9
commit d1f7966123
15 changed files with 253 additions and 168 deletions

View File

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

View File

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

View File

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