Fix: Job
Deskripsi: - Fix router status job - Fix hapus job beserta image di server
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.1.1",
|
||||
"version": "1.0.9",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "npx tsx prisma/seed.ts"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { LayoutDetailDraftInvestasi } from "@/app_modules/investasi";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({children, params}: {children: React.ReactNode, params: {id: string}}) {
|
||||
return<>
|
||||
<LayoutDetailDraftInvestasi id={params.id}>{children}</LayoutDetailDraftInvestasi>
|
||||
</>
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { DetailDraftInvestasi } from "@/app_modules/investasi";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
|
||||
|
||||
const dataInvestasi = await getOneInvestasiById(params.id)
|
||||
|
||||
return<>
|
||||
<DetailDraftInvestasi dataInvestasi={dataInvestasi as any}/>
|
||||
|
||||
</>
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { LayoutDetailPublishInvestasi } from "@/app_modules/investasi";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({children}: {children: React.ReactNode}) {
|
||||
return<>
|
||||
<LayoutDetailPublishInvestasi>{children}</LayoutDetailPublishInvestasi>
|
||||
|
||||
</>
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { DetailPublishInvestasi } from "@/app_modules/investasi";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const dataInvestasi = await getOneInvestasiById(params.id);
|
||||
return (
|
||||
<>
|
||||
<DetailPublishInvestasi dataInvestasi={dataInvestasi as any} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { LayoutDetailRejectInvestasi } from "@/app_modules/investasi";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: { id: string };
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<LayoutDetailRejectInvestasi idInves={params.id}>
|
||||
{children}
|
||||
</LayoutDetailRejectInvestasi>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { DetailRejectInvestasi } from "@/app_modules/investasi";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
const dataInvestasi = await getOneInvestasiById(params.id)
|
||||
// console.log(dataInvestasi)
|
||||
return<>
|
||||
<DetailRejectInvestasi dataInvestasi={dataInvestasi as any}/>
|
||||
</>
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { LayoutDetailReviewInvestasi } from "@/app_modules/investasi";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({children}: {children: React.ReactNode}) {
|
||||
return<>
|
||||
<LayoutDetailReviewInvestasi>{children}</LayoutDetailReviewInvestasi>
|
||||
</>
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { DetailReviewInvestasi } from "@/app_modules/investasi";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
|
||||
export default async function Page({params}:{params : {id: string}}) {
|
||||
|
||||
const dataInvestasi = await getOneInvestasiById(params.id)
|
||||
// console.log(dataInvestasi)
|
||||
|
||||
return<>
|
||||
<DetailReviewInvestasi dataInvestasi={dataInvestasi as any}/>
|
||||
</>
|
||||
}
|
||||
23
src/app/dev/job/main/status/[id]/page.tsx
Normal file
23
src/app/dev/job/main/status/[id]/page.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Job_Status } from "@/app_modules/job";
|
||||
import { job_funGetAllByStatusId } from "@/app_modules/job/fun";
|
||||
import { job_funGetMasterStatus } from "@/app_modules/job/fun/get/get_master_status";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let statusId = params.id;
|
||||
|
||||
const dataJob = await job_funGetAllByStatusId({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
const listStatus = await job_funGetMasterStatus();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Job_Status
|
||||
statusId={statusId}
|
||||
dataJob={dataJob}
|
||||
listStatus={listStatus as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Job_Status } from "@/app_modules/job";
|
||||
import job_getAllStatusDraft from "@/app_modules/job/fun/get/status/get_list_draft";
|
||||
import job_getAllStatusPublish from "@/app_modules/job/fun/get/status/get_list_publish";
|
||||
import job_getAllStatusReject from "@/app_modules/job/fun/get/status/get_list_reject";
|
||||
import job_getAllStatusReview from "@/app_modules/job/fun/get/status/get_list_review";
|
||||
|
||||
export default async function Page() {
|
||||
const listPublish = await job_getAllStatusPublish({page: 1});
|
||||
const listReview = await job_getAllStatusReview({ page: 1 });
|
||||
const listDraft = await job_getAllStatusDraft({ page: 1 });
|
||||
const listReject = await job_getAllStatusReject({page: 1});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Job_Status
|
||||
listDraft={listDraft as any}
|
||||
listPublish={listPublish as any}
|
||||
listReject={listReject as any}
|
||||
listReview={listReview as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,12 @@ export const RouterJob = {
|
||||
|
||||
// main
|
||||
beranda: "/dev/job/main/beranda",
|
||||
status: "/dev/job/main/status",
|
||||
/**
|
||||
*
|
||||
* @param statusId | 1 - 4 | 1: Publish, 2: Review, 3: Draft, 4: Reject
|
||||
* @returns
|
||||
*/
|
||||
status: ({ id }: { id?: string }) => `/dev/job/main/status/${id}`,
|
||||
arsip: "/dev/job/main/arsip",
|
||||
|
||||
// create & edit
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React from "react";
|
||||
import { gs_event_hotMenu } from "../global_state";
|
||||
import { IconReservedLine } from "@tabler/icons-react";
|
||||
|
||||
export default function LayoutEvent_Main({
|
||||
children,
|
||||
@@ -38,7 +39,7 @@ export default function LayoutEvent_Main({
|
||||
id: "2",
|
||||
name: "Status",
|
||||
path: RouterEvent.status({ id: "1" }),
|
||||
icon: <IconTimelineEventText />,
|
||||
icon: <IconReservedLine />,
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
|
||||
@@ -61,7 +61,7 @@ function Job_ComponentButtonSaveCreate({
|
||||
);
|
||||
setHotMenu(2);
|
||||
setStatus("Review");
|
||||
router.replace(RouterJob.status);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(createNoFile.message);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ function Job_ComponentButtonSaveCreate({
|
||||
);
|
||||
setHotMenu(2);
|
||||
setStatus("Review");
|
||||
router.replace(RouterJob.status);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(createWithFile.message);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,10 @@ 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 { MODEL_JOB } from "../../model/interface";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import {
|
||||
funGlobal_DeleteFileById,
|
||||
funGlobal_UploadToStorage,
|
||||
} from "@/app_modules/_global/fun";
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
|
||||
export function Job_ComponentButtonUpdateData({
|
||||
@@ -26,7 +29,6 @@ export function Job_ComponentButtonUpdateData({
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_job_hot_menu);
|
||||
const [status, setStatus] = useAtom(gs_job_status);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
|
||||
@@ -44,7 +46,13 @@ 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");
|
||||
|
||||
const updateWithFile = await job_EditById({
|
||||
data: value,
|
||||
@@ -55,7 +63,6 @@ export function Job_ComponentButtonUpdateData({
|
||||
}
|
||||
|
||||
setHotMenu(2);
|
||||
setStatus("Draft");
|
||||
setIsLoading(true);
|
||||
router.back();
|
||||
return ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
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 { useAtom } from "jotai";
|
||||
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
@@ -16,37 +15,43 @@ import { useState } from "react";
|
||||
import ComponentJob_DetailData from "../../component/detail/detail_data";
|
||||
import { Job_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
||||
import { Job_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_status_id";
|
||||
import { gs_job_status } from "../../global_state";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
|
||||
export default function Job_DetailDraft({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [data, setData] = useState(dataJob);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
{dataJob.catatan ? (
|
||||
{data.catatan ? (
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={dataJob.catatan}
|
||||
informasi={data.catatan}
|
||||
isReport={true}
|
||||
/>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<ComponentJob_DetailData data={dataJob} />
|
||||
<ButtonAction jobId={dataJob.id} />
|
||||
<ComponentJob_DetailData data={data} />
|
||||
<ButtonAction jobId={data.id} imageId={data.imageId} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ jobId }: { jobId: string }) {
|
||||
function ButtonAction({ jobId, imageId }: { jobId: string; imageId: string }) {
|
||||
const router = useRouter();
|
||||
const [status, setStatus] = useAtom(gs_job_status);
|
||||
const [opened, { open, close }] = useDisclosure();
|
||||
const [isAjukan, setAjukan] = useState(false);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||
|
||||
async function onAjukan() {
|
||||
const update = await Job_funEditStatusByStatusId(jobId, "2");
|
||||
if (update.status === 200) {
|
||||
setLoading(true);
|
||||
|
||||
const dataNotif = {
|
||||
appId: update.data?.id as any,
|
||||
status: update.data?.MasterStatus?.name as any,
|
||||
@@ -64,108 +69,38 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
}
|
||||
|
||||
setStatus("Review");
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
||||
router.push(RouterJob.status);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
|
||||
setLoading(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(update.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
await Job_funDeleteById(jobId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setStatus("Draft");
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(RouterJob.status);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
const res = await Job_funDeleteById(jobId);
|
||||
if (res.status === 200) {
|
||||
setLoadingDelete(true);
|
||||
|
||||
if (imageId) {
|
||||
const delFile = await funGlobal_DeleteFileById({ fileId: imageId });
|
||||
if (!delFile.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar lama");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.replace(RouterJob.status({ id: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
setLoadingDelete(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* HAPUS */}
|
||||
{/* <Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
styles={{
|
||||
content: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={6} c={"white"} align="center">
|
||||
Yakin ingin menghapus ini ?
|
||||
</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal> */}
|
||||
|
||||
{/* AJUKAN KEMBALI */}
|
||||
{/* <Modal
|
||||
opened={isAjukan}
|
||||
onClose={() => {
|
||||
setAjukan(false);
|
||||
}}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
styles={{
|
||||
content: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={6} c={"white"} align="center">
|
||||
Anda yakin akan melakukan pengajuan review kembali ?
|
||||
</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setAjukan(false);
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="yellow"
|
||||
onClick={() => {
|
||||
onAjukan();
|
||||
}}
|
||||
>
|
||||
Ajukan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal> */}
|
||||
|
||||
{/* Ajukan */}
|
||||
<UIGlobal_Modal
|
||||
opened={isAjukan}
|
||||
@@ -183,6 +118,8 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loading={isLoading}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="orange"
|
||||
onClick={() => {
|
||||
@@ -211,13 +148,15 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingDelete}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
hapus
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -3,44 +3,46 @@
|
||||
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 { useAtom } from "jotai";
|
||||
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentJob_DetailData from "../../component/detail/detail_data";
|
||||
import { Job_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
||||
import { Job_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_status_id";
|
||||
import { gs_job_status } from "../../global_state";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
export default function Job_DetailReject({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [data, setData] = useState(dataJob);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentGlobal_BoxInformation
|
||||
informasi={dataJob.catatan}
|
||||
informasi={data.catatan}
|
||||
isReport={true}
|
||||
/>
|
||||
<ComponentJob_DetailData data={dataJob} />
|
||||
<ButtonAction jobId={dataJob.id} />
|
||||
<ComponentJob_DetailData data={data} />
|
||||
<ButtonAction jobId={data.id} imageId={data.imageId} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ jobId }: { jobId: string }) {
|
||||
function ButtonAction({ jobId, imageId }: { jobId: string; imageId: string }) {
|
||||
const router = useRouter();
|
||||
const [status, setStatus] = useAtom(gs_job_status);
|
||||
const [opened, { open, close }] = useDisclosure();
|
||||
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||
|
||||
async function onEditKembali() {
|
||||
await Job_funEditStatusByStatusId(jobId, "3").then((res) => {
|
||||
if (res.status === 200) {
|
||||
router.push(RouterJob.status);
|
||||
setStatus("Draft");
|
||||
router.replace(RouterJob.status({ id: "3" }));
|
||||
ComponentGlobal_NotifikasiBerhasil("Masuk Draft");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
@@ -49,15 +51,23 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
await Job_funDeleteById(jobId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
router.push(RouterJob.status);
|
||||
setStatus("Reject");
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Job");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
const res = await Job_funDeleteById(jobId);
|
||||
if (res.status === 200) {
|
||||
setLoadingDelete(true);
|
||||
|
||||
if (imageId) {
|
||||
const delFile = await funGlobal_DeleteFileById({ fileId: imageId });
|
||||
if (!delFile.success) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar lama");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
router.replace(RouterJob.status({ id: "4" }));
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Job");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
setLoadingDelete(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -78,6 +88,8 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loading={isLoadingDelete}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
@@ -89,44 +101,6 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
/>
|
||||
|
||||
{/* <Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
styles={{
|
||||
content: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={6} c={"white"} align="center">
|
||||
Yakin ingin menghapus ini ?
|
||||
</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal> */}
|
||||
|
||||
<Group grow my={"xl"}>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { Button, Card, Image, Skeleton, Stack, Text } from "@mantine/core";
|
||||
import ComponentJob_DetailData from "../../component/detail/detail_data";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_job_status } from "../../global_state";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { Job_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_status_id";
|
||||
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 UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentJob_DetailData from "../../component/detail/detail_data";
|
||||
import { Job_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_status_id";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
export default function Job_DetailReview({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
return (
|
||||
@@ -29,13 +27,14 @@ export default function Job_DetailReview({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
|
||||
function ButtonAction({ jobId }: { jobId: string }) {
|
||||
const router = useRouter();
|
||||
const [status, setStatus] = useAtom(gs_job_status);
|
||||
const [opened, { open, close }] = useDisclosure();
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onAction() {
|
||||
const update = await Job_funEditStatusByStatusId(jobId, "3");
|
||||
if (update.status === 200) {
|
||||
setLoading(true);
|
||||
|
||||
const dataNotif = {
|
||||
appId: update.data?.id as any,
|
||||
kategoriApp: "JOB",
|
||||
@@ -53,11 +52,13 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
}
|
||||
|
||||
setStatus("Draft");
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Dibatalkan");
|
||||
router.push(RouterJob.status);
|
||||
router.replace(RouterJob.status({ id: "3" }));
|
||||
|
||||
setLoading(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(update.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
@@ -78,6 +79,8 @@ function ButtonAction({ jobId }: { jobId: string }) {
|
||||
}
|
||||
buttonKanan={
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
color="orange"
|
||||
onClick={() => {
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
import {
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_LoadImage,
|
||||
ComponentGlobal_LoadImageCustom,
|
||||
} from "@/app_modules/_global/component";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||
import dynamic from "next/dynamic";
|
||||
@@ -39,7 +41,6 @@ const ReactQuill = dynamic(
|
||||
|
||||
export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [value, setValue] = useState(dataJob);
|
||||
const [reload, setReload] = useState(false);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [img, setImg] = useState<any | null>();
|
||||
|
||||
@@ -52,15 +53,17 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
<Stack>
|
||||
<Stack spacing={"xs"}>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{value.imageId ? (
|
||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mt={5} maw={300} mx={"auto"}>
|
||||
<Image
|
||||
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||
style={{ maxHeight: 250 }}
|
||||
alt="Foto"
|
||||
height={250}
|
||||
src={img ? img : APIs.GET({ fileId: value.imageId })}
|
||||
src={img}
|
||||
/>
|
||||
</AspectRatio>
|
||||
) : value.imageId ? (
|
||||
<ComponentGlobal_LoadImage fileId={value.imageId} />
|
||||
) : (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconUpload color="white" />
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function job_funCreateNoFile({ data }: { data: MODEL_JOB }) {
|
||||
});
|
||||
|
||||
if (!createNoImage) return { status: 400, message: "Gagal Disimpan" };
|
||||
revalidatePath("/dev/job/main/status");
|
||||
revalidatePath("/dev/job/main/status/2");
|
||||
return {
|
||||
status: 201,
|
||||
message: "Berhasil Disimpan",
|
||||
|
||||
@@ -4,16 +4,13 @@ import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Job_funDeleteById(jobId: string) {
|
||||
const del = await prisma.job.update({
|
||||
const del = await prisma.job.delete({
|
||||
where: {
|
||||
id: jobId,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (!del) return { status: 400, message: "Gagal hapus" };
|
||||
revalidatePath("/dev/job/main/status");
|
||||
revalidatePath("/dev/job/main/status/");
|
||||
return { status: 200, message: "Berhasil hapus" };
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function job_EditById({
|
||||
},
|
||||
});
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterJob.status);
|
||||
revalidatePath("/dev/job/detail/draft");
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
@@ -43,7 +43,7 @@ export async function job_EditById({
|
||||
},
|
||||
});
|
||||
if (!updtWithFile) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterJob.status);
|
||||
revalidatePath("/dev/job/detail/draft");
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
|
||||
9
src/app_modules/job/fun/get/get_master_status.ts
Normal file
9
src/app_modules/job/fun/get/get_master_status.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function job_funGetMasterStatus() {
|
||||
const data = await prisma.masterStatus.findMany({});
|
||||
|
||||
return data
|
||||
}
|
||||
50
src/app_modules/job/fun/get/status/get_all_by_status_id.ts
Normal file
50
src/app_modules/job/fun/get/status/get_all_by_status_id.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function job_funGetAllByStatusId({
|
||||
page,
|
||||
statusId,
|
||||
}: {
|
||||
page: number;
|
||||
statusId: string;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
if (statusId == "1") {
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
} else {
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { job_funCreateNoFile } from "./create/fun_create_no_file";
|
||||
import { job_funCreateWithFile } from "./create/fun_create_with_file";
|
||||
import { job_funGetAllByStatusId } from "./get/status/get_all_by_status_id";
|
||||
|
||||
export { job_funCreateWithFile };
|
||||
export { job_funCreateNoFile };
|
||||
export { job_funGetAllByStatusId };
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function LayoutJob_Main({
|
||||
{
|
||||
id: 2,
|
||||
name: "Status",
|
||||
path: RouterJob.status,
|
||||
path: RouterJob.status({ id: "1" }),
|
||||
icon: <IconReservedLine />,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Tabs, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_job_status } from "../../global_state";
|
||||
import Job_Draft from "./draft";
|
||||
import Job_Publish from "./publish";
|
||||
import Job_Reject from "./reject";
|
||||
import Job_Review from "./review";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function Job_UiStatus({
|
||||
listPublish,
|
||||
listReview,
|
||||
listDraft,
|
||||
listReject,
|
||||
}: {
|
||||
listPublish: any[];
|
||||
listReview: any[];
|
||||
listDraft: any[];
|
||||
listReject: any[];
|
||||
}) {
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_job_status);
|
||||
const listTabs = [
|
||||
{
|
||||
id: 1,
|
||||
path: <Job_Publish listPublish={listPublish} />,
|
||||
value: "Publish",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
path: <Job_Review listReview={listReview} />,
|
||||
value: "Review",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
path: <Job_Draft listDraft={listDraft} />,
|
||||
value: "Draft",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
path: <Job_Reject listReject={listReject} />,
|
||||
value: "Reject",
|
||||
},
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
mt={1}
|
||||
color="yellow"
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
defaultValue={"Publish"}
|
||||
value={tabsStatus}
|
||||
onTabChange={setTabsStatus}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
zIndex: 99,
|
||||
},
|
||||
panel: {
|
||||
paddingTop: 10
|
||||
}
|
||||
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.value}
|
||||
fw={"bold"}
|
||||
color={tabsStatus === e.value ? "black" : "white"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
tabsStatus === e.value ? MainColor.yellow : "white",
|
||||
border:
|
||||
tabsStatus === e.value
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
>
|
||||
{e.value}
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Panel key={e.id} value={e.value}>
|
||||
{e.path}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +1,107 @@
|
||||
import Job_UiStatus from "./ui_status";
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import Job_Draft from "./draft";
|
||||
import Job_Publish from "./publish";
|
||||
import Job_Reject from "./reject";
|
||||
import Job_Review from "./review";
|
||||
|
||||
export default function Job_ViewStatus({
|
||||
listPublish,
|
||||
listReview,
|
||||
listDraft,
|
||||
listReject,
|
||||
statusId,
|
||||
dataJob,
|
||||
listStatus,
|
||||
}: {
|
||||
listPublish: any[];
|
||||
listReview: any[];
|
||||
listDraft: any[];
|
||||
listReject: any[];
|
||||
statusId: string;
|
||||
dataJob: any[];
|
||||
listStatus: MODEL_NEW_DEFAULT_MASTER[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
// const listTabs = [
|
||||
// {
|
||||
// id: 1,
|
||||
// path: <Job_Publish listPublish={listPublish} />,
|
||||
// value: "Publish",
|
||||
// },
|
||||
// {
|
||||
// id: 2,
|
||||
// path: <Job_Review listReview={listReview} />,
|
||||
// value: "Review",
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// path: <Job_Draft listDraft={listDraft} />,
|
||||
// value: "Draft",
|
||||
// },
|
||||
// {
|
||||
// id: 4,
|
||||
// path: <Job_Reject listReject={listReject} />,
|
||||
// value: "Reject",
|
||||
// },
|
||||
// ];
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.replace(RouterJob.status({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Job_UiStatus
|
||||
listPublish={listPublish}
|
||||
listDraft={listDraft}
|
||||
listReject={listReject}
|
||||
listReview={listReview}
|
||||
/>
|
||||
<Tabs
|
||||
mt={1}
|
||||
color="yellow"
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
zIndex: 99,
|
||||
},
|
||||
panel: {
|
||||
paddingTop: 10,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listStatus.map((e) => (
|
||||
<Tabs.Tab
|
||||
key={e.id}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
color={statusId === e.id ? "black" : "white"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
statusId === e.id ? MainColor.yellow : "white",
|
||||
border:
|
||||
statusId === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
>
|
||||
{e.name}
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{statusId === "1" && <Job_Publish listPublish={dataJob} />}
|
||||
{statusId === "2" && <Job_Review listReview={dataJob} />}
|
||||
{statusId === "3" && <Job_Draft listDraft={dataJob} />}
|
||||
{statusId === "4" && <Job_Reject listReject={dataJob} />}
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export function redirectJobPage({
|
||||
router: AppRouterInstance;
|
||||
onSetPage: (val: any) => void;
|
||||
}) {
|
||||
const path = RouterJob.status;
|
||||
const path = RouterJob.status({id: "1"});
|
||||
|
||||
if (data.status === "Publish") {
|
||||
onSetPage({
|
||||
|
||||
Reference in New Issue
Block a user