Merge pull request #116 from bipproduction/voting/fix-status
Voting/fix status
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "npx tsx prisma/seed.ts"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Event_DetailDraft } from "@/app_modules/event"
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id"
|
||||
import { Event_DetailDraft } from "@/app_modules/event";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id
|
||||
const dataEvent = await event_getOneById(eventId)
|
||||
return <Event_DetailDraft dataEvent={dataEvent as any} />
|
||||
let eventId = params.id;
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
return (
|
||||
<Event_DetailDraft eventId={eventId as any} dataEvent={dataEvent as any} />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Event_Edit } from "@/app_modules/event";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
import { Event_getMasterTipeAcara } from "@/app_modules/event/fun/master/get_tipe_acara";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/model/interface";
|
||||
import _ from "lodash";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
@@ -15,7 +14,6 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
"updatedAt",
|
||||
"active",
|
||||
]);
|
||||
// console.log(dataEvent)
|
||||
|
||||
const listTipeAcara = await Event_getMasterTipeAcara()
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Event_StatusPage } from "@/app_modules/event";
|
||||
import {
|
||||
event_getAllByStatusId,
|
||||
event_getMasterStatus,
|
||||
event_getAllByStatusId,
|
||||
event_getMasterStatus,
|
||||
} from "@/app_modules/event/fun";
|
||||
import React from "react";
|
||||
|
||||
async function Page({ params }: { params: { id: string } }) {
|
||||
let statusId = params.id;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Event_StatusPage } from "@/app_modules/event";
|
||||
import { event_getAllDraft } from "@/app_modules/event/fun/get/status/get_all_draft";
|
||||
import { event_getAllReject } from "@/app_modules/event/fun/get/status/get_all_reject";
|
||||
import { event_getAllReview } from "@/app_modules/event/fun/get/status/get_all_review";
|
||||
import { event_funGetAllStatusPublish } from "@/app_modules/event/fun/get/status/get_all_status_publish";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const listPublish = await event_funGetAllStatusPublish({ page: 1 });
|
||||
const listReview = await event_getAllReview({ page: 1 });
|
||||
const listDraft = await event_getAllDraft({ page: 1 });
|
||||
const listReject = await event_getAllReject({ page: 1 });
|
||||
|
||||
return (
|
||||
<>maintenace</>
|
||||
// <Event_StatusPage
|
||||
// authorId={userLoginId}
|
||||
// listPublish={listPublish}
|
||||
// listReview={listReview}
|
||||
// listDraft={listDraft}
|
||||
// listReject={listReject}
|
||||
// />
|
||||
);
|
||||
}
|
||||
41
src/app/dev/vote/main/riwayat/[id]/page.tsx
Normal file
41
src/app/dev/vote/main/riwayat/[id]/page.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Vote_Riwayat } from "@/app_modules/vote";
|
||||
import { vote_getAllListRiwayat } from "@/app_modules/vote/fun/get/get_all_list_riwayat";
|
||||
import { Vote_getAllListRiwayatSaya as vote_getAllListRiwayatSaya } from "@/app_modules/vote/fun/get/get_all_list_riwayat_saya";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let statusRiwayatId = params.id;
|
||||
|
||||
const listRiwayat = await vote_getAllListRiwayat({ page: 1 });
|
||||
const listRiwayatSaya = await vote_getAllListRiwayatSaya({ page: 1 });
|
||||
|
||||
if (statusRiwayatId == "1") {
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat
|
||||
riwayatId={statusRiwayatId}
|
||||
listRiwayat={listRiwayat as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (statusRiwayatId == "2") {
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat
|
||||
riwayatId={statusRiwayatId}
|
||||
listRiwayatSaya={listRiwayatSaya as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <Vote_Riwayat
|
||||
// riwayatId={statusRiwayatId}
|
||||
// listRiwayat={listRiwayat as any}
|
||||
// listRiwayatSaya={listRiwayatSaya as any}
|
||||
// />
|
||||
// </>
|
||||
// );
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Vote_Riwayat } from "@/app_modules/vote";
|
||||
import { vote_getAllListRiwayat } from "@/app_modules/vote/fun/get/get_all_list_riwayat";
|
||||
import { Vote_getAllListRiwayatSaya as vote_getAllListRiwayatSaya } from "@/app_modules/vote/fun/get/get_all_list_riwayat_saya";
|
||||
|
||||
export default async function Page() {
|
||||
const listRiwayat = await vote_getAllListRiwayat({ page: 1 });
|
||||
const listRiwayatSaya = await vote_getAllListRiwayatSaya({ page: 1 });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat
|
||||
listRiwayat={listRiwayat as any}
|
||||
listRiwayatSaya={listRiwayatSaya as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
25
src/app/dev/vote/main/status/[id]/page.tsx
Normal file
25
src/app/dev/vote/main/status/[id]/page.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Vote_Status } from "@/app_modules/vote";
|
||||
import {
|
||||
vote_funGetAllByStatusId,
|
||||
voting_getMasterStatus,
|
||||
} from "@/app_modules/vote/fun";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const statusId = params.id;
|
||||
|
||||
const listStatus = await voting_getMasterStatus();
|
||||
const dataVoting = await vote_funGetAllByStatusId({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Vote_Status
|
||||
statusId={statusId}
|
||||
dataVoting={dataVoting as any}
|
||||
listStatus={listStatus as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Vote_Status } from "@/app_modules/vote";
|
||||
import { vote_getAllDraft } from "@/app_modules/vote/fun/get/status/get_all_draft";
|
||||
import { vote_getAllPublish } from "@/app_modules/vote/fun/get/status/get_all_publish";
|
||||
import { vote_getAllReject } from "@/app_modules/vote/fun/get/status/get_all_reject";
|
||||
import { vote_getAllReview } from "@/app_modules/vote/fun/get/status/get_all_review";
|
||||
|
||||
export default async function Page() {
|
||||
const listPublish = await vote_getAllPublish({page: 1});
|
||||
const listReview = await vote_getAllReview({page: 1});
|
||||
const listDraft = await vote_getAllDraft({page: 1});
|
||||
const listReject = await vote_getAllReject({page: 1});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Vote_Status
|
||||
listPublish={listPublish as any}
|
||||
listReview={listReview as any}
|
||||
listDraft={listDraft as any}
|
||||
listReject={listReject as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -2,9 +2,15 @@ export const RouterVote = {
|
||||
// main
|
||||
splash: "/dev/vote/splash",
|
||||
beranda: "/dev/vote/main/beranda",
|
||||
status: "/dev/vote/main/status",
|
||||
status: ({ id }: { id?: string }) => `/dev/vote/main/status/${id}`,
|
||||
kontribusi: "/dev/vote/main/kontribusi",
|
||||
riwayat: "/dev/vote/main/riwayat",
|
||||
|
||||
/**
|
||||
*
|
||||
* @param riwayatId | 1 & 2 | 1: Semua, 2: Saya
|
||||
* @type string
|
||||
*/
|
||||
riwayat: ({ id }: { id?: string }) => `/dev/vote/main/riwayat/${id}`,
|
||||
|
||||
// create
|
||||
create: "/dev/vote/create",
|
||||
|
||||
@@ -336,6 +336,7 @@ async function onReject(
|
||||
|
||||
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||
if (res.status === 200) {
|
||||
setSaveLoading(true);
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
@@ -358,7 +359,7 @@ async function onReject(
|
||||
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
setSaveLoading(true);
|
||||
setSaveLoading(false);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
});
|
||||
|
||||
3
src/app_modules/event/component/index.ts
Normal file
3
src/app_modules/event/component/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
||||
|
||||
export { Event_ComponentSkeletonDetailData };
|
||||
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import { Stack, Title, Grid, Text, Center, Skeleton } from "@mantine/core";
|
||||
import { data } from "autoprefixer";
|
||||
|
||||
export function Event_ComponentSkeletonDetailData() {
|
||||
return (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles marginBottom={"16px"}>
|
||||
<Stack px={"sm"} spacing={"lg"}>
|
||||
<Center>
|
||||
<Skeleton radius={"xl"} h={20} />
|
||||
</Center>
|
||||
{Array.from(new Array(4)).map((e, i) => (
|
||||
<Grid key={i}>
|
||||
<Grid.Col span={4}>
|
||||
<Skeleton radius={"xl"} h={20} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={1}>:</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Skeleton radius={"xl"} h={20} />
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
<Skeleton radius={"xl"} h={20} w={200} />
|
||||
<Skeleton radius={"xl"} h={20} />
|
||||
</Stack>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { Button, Group, Stack } from "@mantine/core";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Event_ComponentSkeletonDetailData } from "../../component";
|
||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
|
||||
@@ -19,19 +20,29 @@ import { MODEL_EVENT } from "../../model/interface";
|
||||
|
||||
export default function Event_DetailDraft({
|
||||
dataEvent,
|
||||
eventId,
|
||||
}: {
|
||||
dataEvent: MODEL_EVENT;
|
||||
eventId: string;
|
||||
}) {
|
||||
const [data, setData] = useState(dataEvent);
|
||||
const [data, setData] = useState<MODEL_EVENT | null>(dataEvent);
|
||||
|
||||
console.log(data, "ini data dipage");
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<>
|
||||
<Event_ComponentSkeletonDetailData />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(dataEvent.tanggal)}</pre> */}
|
||||
<Stack spacing={"lg"}>
|
||||
{dataEvent?.catatan ? (
|
||||
<ComponentGlobal_BoxInformation
|
||||
isReport
|
||||
informasi={dataEvent?.catatan}
|
||||
/>
|
||||
{data?.catatan ? (
|
||||
<ComponentGlobal_BoxInformation isReport informasi={data?.catatan} />
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
@@ -200,6 +200,7 @@ export default function Event_Edit({
|
||||
onClick={() => onUpdate(router, value, setLoading)}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
@@ -216,13 +217,14 @@ async function onUpdate(
|
||||
if (_.values(value).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
|
||||
await Event_funEditById(value).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoading(true);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
const res = await Event_funEditById(value);
|
||||
setLoading(true);
|
||||
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
setLoading(false);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function Event_funEditById(data: MODEL_EVENT) {
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||
revalidatePath(RouterEvent.detail_draft + data.id);
|
||||
revalidatePath(`/dev/event/detail/draft/`, "page");
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Update",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function event_getOneById(eventId: string) {
|
||||
const data = await prisma.event.findFirst({
|
||||
@@ -31,5 +32,7 @@ export async function event_getOneById(eventId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath("/dev/event/detail/draft/");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -15,24 +15,50 @@ export async function event_getAllByStatusId({
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
if (statusId == "1") {
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
} else {
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ export default function Event_Riwayat({
|
||||
dataRiwayatSaya?: MODEL_EVENT[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
// const [tabsRiwayat, setTabsRiwayat] = useAtom(gs_event_riwayat)
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
const listTabs = [
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function Event_StatusPage({
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.push(RouterEvent.status({ id: statusId }));
|
||||
router.replace(RouterEvent.status({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -36,7 +36,6 @@ export default function Event_StatusPage({
|
||||
variant="pills"
|
||||
radius="xl"
|
||||
mt={1}
|
||||
// defaultValue={"1"}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function redirectVotingPage({
|
||||
router: AppRouterInstance;
|
||||
onSetPage: (val: any) => void;
|
||||
}) {
|
||||
const path = RouterVote.status;
|
||||
const path = RouterVote.status({ id: "" });
|
||||
|
||||
if (data.status === "Publish") {
|
||||
onSetPage({
|
||||
|
||||
@@ -5,6 +5,8 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/noti
|
||||
import { Badge, Card, Group, Stack, Text } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { MODEL_VOTING } from "../model/interface";
|
||||
import { useState } from "react";
|
||||
import { ComponentGlobal_CardLoadingOverlay, ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
|
||||
export default function ComponentVote_CardViewStatus({
|
||||
path,
|
||||
@@ -14,59 +16,53 @@ export default function ComponentVote_CardViewStatus({
|
||||
data?: MODEL_VOTING;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
p={30}
|
||||
mb={"lg"}
|
||||
style={{
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
borderRadius: "10px",
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
color: "white",
|
||||
}}
|
||||
onClick={() => {
|
||||
<ComponentGlobal_CardStyles
|
||||
onClickHandler={() => {
|
||||
if (data?.id === undefined) {
|
||||
ComponentGlobal_NotifikasiPeringatan("Path tidak ditemukan");
|
||||
} else {
|
||||
setVisible(true);
|
||||
router.push((path as string) + data?.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{/* Isi deskripsi */}
|
||||
<Card.Section>
|
||||
<Stack px={"xs"} align="center">
|
||||
<Text fw={"bold"} lineClamp={1} align="center">
|
||||
{data?.title}
|
||||
</Text>
|
||||
<Badge
|
||||
// size="md"
|
||||
styles={{
|
||||
root: {
|
||||
backgroundColor: AccentColor.blue,
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
color: "white",
|
||||
width: "80%",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Group>
|
||||
<Text>
|
||||
{data?.awalVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{data?.akhirVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
<Stack px={"xs"} align="center">
|
||||
<Text fw={"bold"} lineClamp={1} align="center">
|
||||
{data?.title}
|
||||
</Text>
|
||||
<Badge
|
||||
// size="md"
|
||||
styles={{
|
||||
root: {
|
||||
backgroundColor: AccentColor.blue,
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
color: "white",
|
||||
width: "80%",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Group>
|
||||
<Text>
|
||||
{data?.awalVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
<Text>-</Text>
|
||||
<Text>
|
||||
{data?.akhirVote.toLocaleDateString(["id-ID"], {
|
||||
dateStyle: "medium",
|
||||
})}
|
||||
</Text>
|
||||
</Group>
|
||||
</Badge>
|
||||
</Stack>
|
||||
{visible && <ComponentGlobal_CardLoadingOverlay />}
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
@@ -24,17 +27,13 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Vote_funCreate } from "../fun/create/create_vote";
|
||||
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
|
||||
import { gs_vote_hotMenu } from "../global_state";
|
||||
import { MODEL_VOTING } from "../model/interface";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
|
||||
export default function Vote_Create() {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_vote_hotMenu);
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_vote_status);
|
||||
|
||||
const [data, setData] = useState({
|
||||
title: "",
|
||||
@@ -209,14 +208,7 @@ export default function Vote_Create() {
|
||||
mt={"lg"}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onSave(
|
||||
router,
|
||||
setHotMenu,
|
||||
setTabsStatus,
|
||||
data as any,
|
||||
listVote,
|
||||
setIsLoading
|
||||
);
|
||||
onSave(router, setHotMenu, data as any, listVote, setIsLoading);
|
||||
}}
|
||||
c={"black"}
|
||||
bg={MainColor.yellow}
|
||||
@@ -235,7 +227,6 @@ export default function Vote_Create() {
|
||||
async function onSave(
|
||||
router: AppRouterInstance,
|
||||
setHotMenu: any,
|
||||
setTabsStatus: any,
|
||||
data: MODEL_VOTING,
|
||||
listVote: any[],
|
||||
setIsLoading: any
|
||||
@@ -278,10 +269,9 @@ async function onSave(
|
||||
count: 1,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
setHotMenu(2);
|
||||
setTabsStatus("Review");
|
||||
router.replace(RouterVote.status);
|
||||
router.replace(RouterVote.status({ id: "2" }));
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setIsLoading(true);
|
||||
}
|
||||
|
||||
@@ -1,42 +1,39 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
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 { Button, SimpleGrid, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
||||
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 mqtt_client from "@/util/mqtt_client";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
|
||||
export default function Vote_DetailDraft({
|
||||
dataVote,
|
||||
}: {
|
||||
dataVote: MODEL_VOTING;
|
||||
}) {
|
||||
const [data, setData] = useState(dataVote);
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xl"}>
|
||||
{dataVote?.catatan ? (
|
||||
<ComponentGlobal_BoxInformation
|
||||
isReport
|
||||
informasi={dataVote?.catatan}
|
||||
/>
|
||||
<ComponentGlobal_BoxInformation isReport informasi={data?.catatan} />
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
<ComponentVote_DetailDataSebelumPublish data={dataVote} />
|
||||
<ButtonAction voteId={dataVote.id} awalVote={dataVote.awalVote} />
|
||||
<ComponentVote_DetailDataSebelumPublish data={data} />
|
||||
<ButtonAction voteId={data.id} awalVote={data.awalVote} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
@@ -50,7 +47,6 @@ function ButtonAction({
|
||||
awalVote: Date;
|
||||
}) {
|
||||
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);
|
||||
@@ -84,10 +80,10 @@ function ButtonAction({
|
||||
count: 1,
|
||||
})
|
||||
);
|
||||
setTabsStatus("Review");
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Ajukan Review", 2000);
|
||||
setIsLoading(true);
|
||||
router.back();
|
||||
router.replace(RouterVote.status({ id: "2" }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
@@ -97,9 +93,9 @@ function ButtonAction({
|
||||
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: "3" }));
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
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 notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
||||
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 UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
|
||||
export default function Vote_DetailReview({
|
||||
dataVote,
|
||||
@@ -32,7 +31,6 @@ export default function Vote_DetailReview({
|
||||
function ButtonAction({ voteId }: { voteId: string }) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_vote_status);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
async function onUpdate() {
|
||||
@@ -58,9 +56,9 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
||||
count: 1,
|
||||
})
|
||||
);
|
||||
setTabsStatus("Draft");
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Batalkan Review", 2000);
|
||||
router.back();
|
||||
router.replace(RouterVote.status({ id: "3" }));
|
||||
setIsLoading(true);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,21 +4,33 @@ import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
/**
|
||||
* @param voteId
|
||||
* @returns isActive berubah menjadi false
|
||||
* @param votingId
|
||||
*/
|
||||
export async function Vote_funDeleteById(voteId: string) {
|
||||
const del = await prisma.voting.update({
|
||||
export async function Vote_funDeleteById(votingId: string) {
|
||||
const del = await prisma.voting.delete({
|
||||
where: {
|
||||
id: voteId,
|
||||
id: votingId,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
select: {
|
||||
Voting_DaftarNamaVote: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!del) return { status: 400, message: "Gagal Hapus Data" };
|
||||
revalidatePath("/dev/vote/main/status");
|
||||
|
||||
for (let i of del.Voting_DaftarNamaVote) {
|
||||
const hapusDaftarPilihan = await prisma.voting_DaftarNamaVote.delete({
|
||||
where: {
|
||||
id: i.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!hapusDaftarPilihan)
|
||||
return { status: 400, message: "Gagal Hapus Daftar Pilihan" };
|
||||
}
|
||||
|
||||
revalidatePath("/dev/vote/main/status/3");
|
||||
revalidatePath("/dev/vote/main/status/4");
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Hapus Berhasil",
|
||||
|
||||
@@ -53,7 +53,7 @@ export async function Vote_funEditById(
|
||||
if (!namaPilihan) return { status: 400, message: "Gagal Membuat List" };
|
||||
}
|
||||
|
||||
revalidatePath("/dev/vote/detail/draft");
|
||||
revalidatePath(`/dev/vote/detail/draft`);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Update",
|
||||
|
||||
9
src/app_modules/vote/fun/get/get_list_status_voting.ts
Normal file
9
src/app_modules/vote/fun/get/get_list_status_voting.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function voting_getMasterStatus() {
|
||||
const data = await prisma.voting_Status.findMany({});
|
||||
|
||||
return data;
|
||||
}
|
||||
59
src/app_modules/vote/fun/get/status/get_all_by_status_id.ts
Normal file
59
src/app_modules/vote/fun/get/status/get_all_by_status_id.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_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.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
} else {
|
||||
const data = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import { voting_funUpdateIsArsipById } from "./edit/fun_update_is_arsip_by_id";
|
||||
import { voting_getMasterStatus } from "./get/get_list_status_voting";
|
||||
import { vote_funGetAllByStatusId } from "./get/status/get_all_by_status_id";
|
||||
|
||||
export { voting_funUpdateIsArsipById };
|
||||
export { vote_funGetAllByStatusId };
|
||||
export { voting_getMasterStatus };
|
||||
|
||||
@@ -37,7 +37,7 @@ export default function LayoutVote_Main({
|
||||
{
|
||||
id: 2,
|
||||
name: "Status",
|
||||
path: RouterVote.status,
|
||||
path: RouterVote.status({ id: "1" }),
|
||||
icon: <IconReservedLine />,
|
||||
},
|
||||
{
|
||||
@@ -49,7 +49,7 @@ export default function LayoutVote_Main({
|
||||
{
|
||||
id: 4,
|
||||
name: "Riwayat",
|
||||
path: RouterVote.riwayat,
|
||||
path: RouterVote.riwayat({ id: "1" }),
|
||||
icon: <IconHistory />,
|
||||
},
|
||||
];
|
||||
@@ -91,7 +91,6 @@ export default function LayoutVote_Main({
|
||||
</SimpleGrid>
|
||||
}
|
||||
>
|
||||
|
||||
{children}
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
|
||||
@@ -7,40 +7,53 @@ import Vote_RiwayatSaya from "./saya";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_vote_riwayat } from "../../global_state";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
|
||||
export default function Vote_Riwayat({
|
||||
riwayatId,
|
||||
listRiwayat,
|
||||
listRiwayatSaya,
|
||||
}: {
|
||||
listRiwayat: MODEL_VOTING[];
|
||||
listRiwayatSaya: MODEL_VOTING[];
|
||||
riwayatId: string;
|
||||
listRiwayat?: MODEL_VOTING[];
|
||||
listRiwayatSaya?: MODEL_VOTING[];
|
||||
}) {
|
||||
const [tabsRiwayat, setTabsRiwayat] = useAtom(gs_vote_riwayat);
|
||||
const router = useRouter();
|
||||
const [changeStatus, setChangeStatus] = useState(riwayatId);
|
||||
|
||||
const listTabs = [
|
||||
{
|
||||
id: 1,
|
||||
path: <Vote_SemuaRiwayat listRiwayat={listRiwayat} />,
|
||||
id: "1",
|
||||
value: "Semua",
|
||||
label: "Semua Riwayat",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
path: <Vote_RiwayatSaya listRiwayatSaya={listRiwayatSaya} />,
|
||||
id: "2",
|
||||
value: "Saya",
|
||||
label: "Riwayat Saya",
|
||||
},
|
||||
];
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.push(RouterVote.riwayat({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tabs
|
||||
mt={1}
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
defaultValue={"Semua"}
|
||||
value={tabsRiwayat}
|
||||
onTabChange={setTabsRiwayat}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
@@ -58,15 +71,15 @@ export default function Vote_Riwayat({
|
||||
{listTabs.map((e, i) => (
|
||||
<Tabs.Tab
|
||||
key={i}
|
||||
value={e.value}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
tabsRiwayat === e.value ? MainColor.yellow : "white",
|
||||
changeStatus === e.id ? MainColor.yellow : "white",
|
||||
border:
|
||||
tabsRiwayat === e.value
|
||||
changeStatus === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
@@ -75,11 +88,14 @@ export default function Vote_Riwayat({
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Panel key={e.id} value={e.value}>
|
||||
{e.path}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
|
||||
{riwayatId === "1" && (
|
||||
<Vote_SemuaRiwayat listRiwayat={listRiwayat as any} />
|
||||
)}
|
||||
|
||||
{riwayatId === "2" && (
|
||||
<Vote_RiwayatSaya listRiwayatSaya={listRiwayatSaya as any} />
|
||||
)}
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function Vote_RiwayatSaya({
|
||||
// --- Main component --- //
|
||||
<Box>
|
||||
<ScrollOnly
|
||||
height="75vh"
|
||||
height="76vh"
|
||||
renderLoading={() => (
|
||||
<Center mt={"lg"}>
|
||||
<Loader color={"yellow"} />
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function Vote_SemuaRiwayat({
|
||||
// --- Main component --- //
|
||||
<Box>
|
||||
<ScrollOnly
|
||||
height="75vh"
|
||||
height="76vh"
|
||||
renderLoading={() => (
|
||||
<Center mt={"lg"}>
|
||||
<Loader color={"yellow"} />
|
||||
|
||||
@@ -1,51 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { Stack, Tabs } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_vote_status } from "../../global_state";
|
||||
import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
|
||||
import { Box, Stack, Tabs } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import Vote_StatusDraft from "./draft";
|
||||
import Vote_StatusPublish from "./publish";
|
||||
import Vote_StatusReject from "./reject";
|
||||
import Vote_StatusReview from "./review";
|
||||
|
||||
export default function Vote_Status({
|
||||
listPublish,
|
||||
listReview,
|
||||
listDraft,
|
||||
listReject,
|
||||
statusId,
|
||||
dataVoting,
|
||||
listStatus,
|
||||
}: {
|
||||
listPublish: any[];
|
||||
listReview: any[];
|
||||
listDraft: any[];
|
||||
listReject: any[];
|
||||
statusId: string;
|
||||
dataVoting: MODEL_VOTING[];
|
||||
listStatus: MODEL_NEW_DEFAULT_MASTER[];
|
||||
}) {
|
||||
const [tabsStatus, setTabsStatus] = useAtom(gs_vote_status);
|
||||
const listTabs = [
|
||||
{
|
||||
id: 1,
|
||||
path: <Vote_StatusPublish listPublish={listPublish} />,
|
||||
value: "Publish",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
path: <Vote_StatusReview listReview={listReview} />,
|
||||
value: "Review",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
path: <Vote_StatusDraft listDraft={listDraft} />,
|
||||
value: "Draft",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
path: <Vote_StatusReject listReject={listReject} />,
|
||||
value: "Reject",
|
||||
},
|
||||
];
|
||||
|
||||
const router = useRouter();
|
||||
const [changeStatus, setChangeStatus] = useState(statusId);
|
||||
|
||||
async function onChangeStatus({ statusId }: { statusId: string }) {
|
||||
router.replace(RouterVote.status({ id: statusId }));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -53,9 +38,11 @@ export default function Vote_Status({
|
||||
mt={1}
|
||||
variant="pills"
|
||||
radius={"xl"}
|
||||
defaultValue={"Publish"}
|
||||
value={tabsStatus}
|
||||
onTabChange={setTabsStatus}
|
||||
value={changeStatus}
|
||||
onTabChange={(val: any) => {
|
||||
setChangeStatus(val);
|
||||
onChangeStatus({ statusId: val });
|
||||
}}
|
||||
styles={{
|
||||
tabsList: {
|
||||
backgroundColor: MainColor.darkblue,
|
||||
@@ -70,28 +57,36 @@ export default function Vote_Status({
|
||||
>
|
||||
<Stack>
|
||||
<Tabs.List grow>
|
||||
{listTabs.map((e) => (
|
||||
{listStatus.map((e) => (
|
||||
<Tabs.Tab
|
||||
w={"20%"}
|
||||
key={e.id}
|
||||
value={e.value}
|
||||
value={e.id}
|
||||
fw={"bold"}
|
||||
c={"black"}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
backgroundColor:
|
||||
tabsStatus === e.value ? MainColor.yellow : "white",
|
||||
changeStatus === e.id ? MainColor.yellow : "white",
|
||||
border:
|
||||
changeStatus === e.id
|
||||
? `1px solid ${AccentColor.yellow}`
|
||||
: `1px solid white`,
|
||||
}}
|
||||
>
|
||||
{e.value}
|
||||
{e.name}
|
||||
</Tabs.Tab>
|
||||
))}
|
||||
</Tabs.List>
|
||||
{listTabs.map((e) => (
|
||||
<Tabs.Panel key={e.id} value={e.value}>
|
||||
{e.path}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
|
||||
<Box>
|
||||
{statusId === "1" && (
|
||||
<Vote_StatusPublish listPublish={dataVoting} />
|
||||
)}
|
||||
{statusId === "2" && <Vote_StatusReview listReview={dataVoting} />}
|
||||
{statusId === "3" && <Vote_StatusDraft listDraft={dataVoting} />}
|
||||
{statusId === "4" && <Vote_StatusReject listReject={dataVoting} />}
|
||||
</Box>
|
||||
</Stack>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import ComponentVote_CardViewStatus from "../../component/card_view_status";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import { Box, Center, Loader, Stack, Text } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import ComponentVote_IsEmptyData from "../../component/is_empty_data";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import job_getAllStatusPublish from "@/app_modules/job/fun/get/status/get_list_publish";
|
||||
import { Box, Center, Loader } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import ComponentVote_CardViewPublish from "../../component/card_view_publish";
|
||||
import ComponentVote_CardViewStatus from "../../component/card_view_status";
|
||||
import { vote_getAllReview } from "../../fun/get/status/get_all_review";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
|
||||
export default function Vote_StatusReview({
|
||||
listReview,
|
||||
|
||||
Reference in New Issue
Block a user