Fix: admin job
Deskripsi: - Fix image job dari server wibu ## No Issue
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { Button, Group, Stack } from "@mantine/core";
|
||||
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentJob_DetailData from "../../component/detail/detail_data";
|
||||
@@ -18,23 +17,43 @@ import { Job_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_s
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { job_getOneById } from "../../fun/get/get_one_by_id";
|
||||
|
||||
export default function Job_DetailDraft({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [data, setData] = useState(dataJob);
|
||||
export default function Job_DetailDraft({
|
||||
dataJob,
|
||||
jobId,
|
||||
}: {
|
||||
dataJob: MODEL_JOB;
|
||||
jobId: string;
|
||||
}) {
|
||||
const [data, setData] = useState<MODEL_JOB | null>(dataJob);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadData({
|
||||
loadData(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
}, [setData]);
|
||||
|
||||
async function onLoadData({ loadData }: { loadData: (val: any) => void }) {
|
||||
const dataJob = await job_getOneById(jobId);
|
||||
loadData(dataJob as any);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
{data.catatan ? (
|
||||
{data?.catatan ? (
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={data.catatan}
|
||||
informasi={data?.catatan}
|
||||
isReport={true}
|
||||
/>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<ComponentJob_DetailData data={data} />
|
||||
<ButtonAction jobId={data.id} imageId={data.imageId} />
|
||||
<ComponentJob_DetailData data={data as any} />
|
||||
<ButtonAction jobId={data?.id as any} imageId={data?.imageId as any} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ const ReactQuill = dynamic(
|
||||
);
|
||||
|
||||
export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [value, setValue] = useState(dataJob);
|
||||
const [data, setData] = useState(dataJob);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [img, setImg] = useState<any | null>();
|
||||
|
||||
@@ -62,8 +62,8 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
src={img}
|
||||
/>
|
||||
</AspectRatio>
|
||||
) : value.imageId ? (
|
||||
<ComponentGlobal_LoadImage fileId={value.imageId} />
|
||||
) : data.imageId ? (
|
||||
<ComponentGlobal_LoadImage fileId={data.imageId} />
|
||||
) : (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconUpload color="white" />
|
||||
@@ -118,11 +118,11 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
withAsterisk
|
||||
label="Judul"
|
||||
placeholder="Masukan judul lowongan kerja"
|
||||
value={value.title}
|
||||
value={data.title}
|
||||
maxLength={100}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setData({
|
||||
...data,
|
||||
title: val.currentTarget.value,
|
||||
});
|
||||
}}
|
||||
@@ -151,17 +151,17 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
],
|
||||
}}
|
||||
theme="snow"
|
||||
value={value.content}
|
||||
value={data.content}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setData({
|
||||
...data,
|
||||
content: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
maxInput={500}
|
||||
lengthInput={value.content.length}
|
||||
lengthInput={data.content.length}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -188,24 +188,24 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
],
|
||||
}}
|
||||
theme="snow"
|
||||
value={value.deskripsi}
|
||||
value={data.deskripsi}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setData({
|
||||
...data,
|
||||
deskripsi: val,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
maxInput={500}
|
||||
lengthInput={value.deskripsi.length}
|
||||
lengthInput={data.deskripsi.length}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
<Job_ComponentButtonUpdate value={value as any} file={file as any} />
|
||||
<Job_ComponentButtonUpdate value={data as any} file={file as any} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user