Fix: admin job

Deskripsi:
- Fix image job dari server wibu
## No Issue
This commit is contained in:
2024-11-05 13:49:06 +08:00
parent d624d61a33
commit 3aea046046
15 changed files with 276 additions and 180 deletions

View File

@@ -1,22 +1,22 @@
import { MainColor, AccentColor } from "@/app_modules/_global/color";
import { DIRECTORY_ID } from "@/app/lib";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import {
ComponentGlobal_NotifikasiBerhasil,
ComponentGlobal_NotifikasiGagal,
ComponentGlobal_NotifikasiPeringatan,
} from "@/app_modules/_global/notif_global";
import { Modal, Stack, Title, Group, Button } from "@mantine/core";
import { useDisclosure, useWindowScroll } from "@mantine/hooks";
import { Button, Group, Modal, Stack, Title } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { useAtom } from "jotai";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { job_EditById } from "../../fun/edit/fun_edit_by_id";
import { gs_job_hot_menu, gs_job_status } from "../../global_state";
import { gs_job_hot_menu } from "../../global_state";
import { MODEL_JOB } from "../../model/interface";
import {
funGlobal_DeleteFileById,
funGlobal_UploadToStorage,
} from "@/app_modules/_global/fun";
import { DIRECTORY_ID } from "@/app/lib";
export function Job_ComponentButtonUpdateData({
value,
@@ -30,7 +30,6 @@ export function Job_ComponentButtonUpdateData({
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
const [opened, { open, close }] = useDisclosure(false);
const [scroll, scrollTo] = useWindowScroll();
async function onUpdate() {
if (file === null) {
@@ -46,13 +45,15 @@ export function Job_ComponentButtonUpdateData({
});
if (!uploadFile.success)
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
const delFile = await funGlobal_DeleteFileById({
fileId: value.imageId,
});
if (!delFile.success)
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar lama");
if (value.imageId !== null) {
const delFile = await funGlobal_DeleteFileById({
fileId: value.imageId,
});
if (!delFile.success)
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar lama");
}
const updateWithFile = await job_EditById({
data: value,
@@ -126,7 +127,6 @@ export function Job_ComponentButtonUpdateData({
radius={"xl"}
onClick={() => {
open();
scrollTo({ y: 0 });
}}
>
Update

View File

@@ -4,15 +4,7 @@ import {
ComponentGlobal_CardStyles,
ComponentGlobal_LoadImage,
} from "@/app_modules/_global/component";
import {
Card,
Center,
Image,
Skeleton,
Stack,
Text,
Title,
} from "@mantine/core";
import { Box, Center, Skeleton, Stack, Text } from "@mantine/core";
import { MODEL_JOB } from "../../model/interface";
export default function ComponentJob_DetailData({
@@ -49,9 +41,20 @@ export default function ComponentJob_DetailData({
) : (
<ComponentGlobal_CardStyles>
<Stack spacing={"xl"}>
<Title order={3} align="center">
Data Not Found
</Title>
<Stack align="center">
<Skeleton h={250} w={200} radius="md" />
<Skeleton h={10} w={200} />
</Stack>
{Array.from(new Array(2)).map((e, i) => (
<Stack key={i}>
<Skeleton h={10} w={100} />
{Array.from({ length: 3 }).map((_, ii) => (
<Skeleton h={10} key={ii} />
))}
</Stack>
))}
</Stack>
</ComponentGlobal_CardStyles>
)}