Fix: voting status

Deskripsi:
- Perubahan router status & riwayat
This commit is contained in:
2024-10-29 14:10:46 +08:00
parent 8f76067380
commit e5e36a3889
35 changed files with 455 additions and 281 deletions

View File

@@ -4,11 +4,7 @@ import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
import {
Button,
SimpleGrid,
Stack
} from "@mantine/core";
import { Button, SimpleGrid, Stack } from "@mantine/core";
import { useAtom } from "jotai";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -17,21 +13,21 @@ import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id";
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
import { gs_vote_status } from "../../global_state";
import { MODEL_VOTING } from "../../model/interface";
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
export default function Vote_DetailReject({
dataVote,
}: {
dataVote: MODEL_VOTING;
}) {
const [data, setData] = useState(dataVote);
return (
<>
<Stack spacing={"xl"}>
<ComponentGlobal_BoxInformation
isReport
informasi={dataVote?.catatan}
/>
<ComponentVote_DetailDataSebelumPublish data={dataVote as any} />
<ButtonAction voteId={dataVote.id} />
<ComponentGlobal_BoxInformation isReport informasi={data?.catatan} />
<ComponentVote_DetailDataSebelumPublish data={data as any} />
<ButtonAction voteId={data.id} />
</Stack>
</>
);
@@ -39,8 +35,6 @@ export default function Vote_DetailReject({
function ButtonAction({ voteId }: { voteId: string }) {
const router = useRouter();
const [tabsStatus, setTabsStatus] = useAtom(gs_vote_status);
const [openModal1, setOpenModal1] = useState(false);
const [openModal2, setOpenModal2] = useState(false);
const [isLoading, setIsLoading] = useState(false);
@@ -48,9 +42,9 @@ function ButtonAction({ voteId }: { voteId: string }) {
async function onUpdate() {
await Vote_funEditStatusByStatusId(voteId, "3").then((res) => {
if (res.status === 200) {
setTabsStatus("Draft");
setIsLoading(true);
ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000);
router.back();
router.replace(RouterVote.status({ id: "3" }));
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
@@ -60,9 +54,9 @@ function ButtonAction({ voteId }: { voteId: string }) {
async function onDelete() {
await Vote_funDeleteById(voteId).then((res) => {
if (res.status === 200) {
setTabsStatus("Draft");
setOpenModal2(false);
ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
router.back();
router.replace(RouterVote.status({ id: "4" }));
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}