## feat
- Voting user
- Halaman kontribusi
- Halaman riwayat
### No issuue
This commit is contained in:
2024-02-16 17:20:06 +08:00
parent 0dd8e287f4
commit e629157960
135 changed files with 3160 additions and 1501 deletions

View File

@@ -3,6 +3,8 @@
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Stack,
Center,
@@ -20,24 +22,29 @@ import {
Text,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan, IconEyeCheck } from "@tabler/icons-react";
import { IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function AdminVote_Riwayat() {
export default function AdminVote_Riwayat({
dataVote,
}: {
dataVote: MODEL_VOTING[];
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Riwayat" />
<TableStatus listPublish={[]} />
<TableStatus listPublish={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listPublish }: { listPublish: any[] }) {
function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listPublish);
@@ -47,45 +54,50 @@ function TableStatus({ listPublish }: { listPublish: any[] }) {
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Button
radius={"xl"}
color="green"
leftIcon={<IconEyeCheck />}
onClick={() => ComponentGlobal_NotifikasiPeringatan("On Process")}
>
Hasil Voting
</Button>
</Center>
</td>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
<Spoiler
hideLabel="sembunyikan"
maw={400}
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
</Spoiler>
</Center>
</td>
<td>
<Center>Mulai vote</Center>
</td>
<td>
<Center>Selesai vote</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
</Box>
))}
</Stack>
</th>
<td>
<Center>
<Button
loading={
e.id === eventId ? (loading === true ? true : false) : false
}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
onClick={async () => {
setEventId(e.id);
setLoading(true);
await new Promise((v) => setTimeout(v, 500));
await AdminEvent_getListPesertaById(e.id).then((res: any) => {
setPeserta(res);
setLoading(false);
});
open();
}}
>
Hasil Voting
</Button>
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
</tr>
@@ -142,22 +154,24 @@ function TableStatus({ listPublish }: { listPublish: any[] }) {
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Pilihan</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>

View File

@@ -3,10 +3,12 @@
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
import {
MODEL_EVENT,
MODEL_EVENT_PESERTA,
} from "@/app_modules/event/model/interface";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Avatar,
Box,
@@ -24,23 +26,27 @@ import {
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconEyeShare } from "@tabler/icons-react";
import { IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function AdminVote_TablePublish() {
export default function AdminVote_TablePublish({
dataVote,
}: {
dataVote: any;
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Publish" />
<TableStatus listPublish={[]} />
<TableStatus listPublish={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listPublish }: { listPublish: any[] }) {
function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listPublish);
@@ -50,45 +56,50 @@ function TableStatus({ listPublish }: { listPublish: any[] }) {
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Button
radius={"xl"}
color="green"
leftIcon={<IconEyeCheck />}
onClick={() => ComponentGlobal_NotifikasiPeringatan("On Process")}
>
Lihat Hasil
</Button>
</Center>
</td>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
<Spoiler
hideLabel="sembunyikan"
maw={400}
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
</Spoiler>
</Center>
</td>
<td>
<Center>Mulai vote</Center>
</td>
<td>
<Center>Selesai vote</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
</Box>
))}
</Stack>
</th>
<td>
<Center>
<Button
loading={
e.id === eventId ? (loading === true ? true : false) : false
}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
onClick={async () => {
setEventId(e.id);
setLoading(true);
await new Promise((v) => setTimeout(v, 500));
await AdminEvent_getListPesertaById(e.id).then((res: any) => {
setPeserta(res);
setLoading(false);
});
open();
}}
>
Hasil Voting
</Button>
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
</tr>
@@ -145,22 +156,24 @@ function TableStatus({ listPublish }: { listPublish: any[] }) {
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Pilihan</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>

View File

@@ -0,0 +1,242 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Avatar,
Box,
Button,
Center,
Divider,
Grid,
Group,
Modal,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Textarea,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan, IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { AdminVote_funEditCatatanRejectById } from "../../fun/edit/fun_edit_catatan_reject_by_id";
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
export default function AdminVote_TableReject({
dataVote,
}: {
dataVote: MODEL_VOTING[];
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Reject" />
<TableStatus listData={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Button
color={"red"}
leftIcon={<IconBan />}
radius={"xl"}
onClick={() => {
open();
setVotingId(e.id);
setCatatan(e.catatan);
}}
>
<Stack spacing={0}>
<Text fz={10}>Tambah</Text>
<Text fz={10}>Catatan</Text>
</Stack>
</Button>
</Center>
</td>
<td>
<Center>
<Spoiler
hideLabel="sembunyikan"
maw={400}
maxHeight={50}
showLabel="tampilkan"
>
{e.catatan}
</Spoiler>
</Center>
</td>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler
hideLabel="sembunyikan"
maw={400}
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
</Spoiler>
</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
</Box>
))}
</Stack>
</th>
<td>
<Center>
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
</tr>
));
return (
<>
<Modal
opened={opened}
onClose={close}
centered
withCloseButton={false}
size={"lg"}
>
<Stack>
<Textarea
minRows={2}
maxRows={5}
maxLength={300}
autosize
label="Masukan Alasan Penolakan"
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
value={catatan}
onChange={(val) => {
setCatatan(val.target.value);
}}
/>
<Group position="right">
<Button
radius={"xl"}
onClick={() => {
onReject(votingId, catatan, close, setData);
console.log(catatan);
}}
>
Simpan
</Button>
</Group>
</Stack>
</Modal>
<Box>
<Box bg={"red.1"} p={"xs"}>
<Title order={6} c={"red"}>
REJECT
</Title>
</Box>
<ScrollArea w={"100%"}>
<Box w={2000}>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Catatan</Center>
</th>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Pilihan</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
</Box>
</ScrollArea>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}
async function onReject(
votingId: string,
catatan: string,
close: any,
setData: any
) {
await AdminVote_funEditCatatanRejectById(votingId, catatan).then(
async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("4").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
close();
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
}
);
}

View File

@@ -0,0 +1,253 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Avatar,
Box,
Button,
Center,
Divider,
Grid,
Group,
Modal,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Textarea,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan } from "@tabler/icons-react";
import { IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
import toast from "react-simple-toasts";
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
export default function AdminVote_TableReview({
listVote,
}: {
listVote: MODEL_VOTING[];
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Review" />
<TableStatus listData={listVote} />
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler
hideLabel="sembunyikan"
maw={400}
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
</Spoiler>
</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
</Box>
))}
</Stack>
</th>
<td>
<Center>
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Stack align="center">
<Button
w={120}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
onClick={() => onPublish(e.id, setData)}
>
Publish
</Button>
<Button
w={120}
color={"red"}
leftIcon={<IconBan />}
radius={"xl"}
onClick={() => {
open();
setVotingId(e.id);
}}
>
Reject
</Button>
</Stack>
</td>
</tr>
));
return (
<>
<Modal
opened={opened}
onClose={close}
centered
withCloseButton={false}
size={"lg"}
>
<Stack>
<Textarea
minRows={2}
maxRows={5}
maxLength={300}
autosize
label="Masukan Alasan Penolakan"
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
onChange={(val) => {
setCatatan(val.target.value);
}}
/>
<Group position="right">
<Button
radius={"xl"}
onClick={() => {
onReject(votingId, setData, catatan, close);
// console.log("hehe")
}}
>
Simpan
</Button>
</Group>
</Stack>
</Modal>
<Box>
<Box bg={"orange.1"} p={"xs"}>
<Title order={6} c={"orange"}>
REVIEW
</Title>
</Box>
<ScrollArea w={"100%"}>
<Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Pilihan</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
</Box>
</ScrollArea>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}
async function onPublish(voteId: string, setData: any) {
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
async function onReject(
voteId: string,
setData: any,
catatan: string,
close: any
) {
const data = {
id: voteId,
catatan: catatan,
};
await AdminEvent_funEditCatatanById(data as any).then(async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
close();
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}

View File

@@ -0,0 +1,68 @@
"use server";
import prisma from "@/app/lib/prisma";
/**
*
* @param statusId 0: Riwayat , 1: Publish, 2:Review, 4:Reject
* @type string
* @returns jumlah dari voting per status
*/
export default async function AdminVote_funCountByStatusId(statusId: string) {
if (statusId === "0") {
const count = await prisma.voting.count({
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
lte: new Date(),
},
},
});
return count;
}
if (statusId === "1") {
const count = await prisma.voting.count({
where: {
voting_StatusId: "1",
akhirVote: {
gte: new Date(),
},
},
});
return count;
}
if (statusId === "2") {
const count = await prisma.voting.count({
where: {
voting_StatusId: "2",
// akhirVote: {
// gte: new Date(),
// },
},
});
return count;
}
if (statusId === "4") {
const count = await prisma.voting.count({
where: {
voting_StatusId: "4",
isActive: true,
// akhirVote: {
// gte: new Date(),
// },
},
});
return count;
}
if (statusId === undefined || statusId === null) {
return {
status: 400,
message: "Parameter tidak sesuai",
};
}
}

View File

@@ -0,0 +1,22 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function AdminVote_funEditCatatanRejectById(
voteId: string,
catatan: string
) {
const updt = await prisma.voting.update({
where: {
id: voteId,
},
data: {
catatan: catatan,
},
});
if (!updt) return { status: 400, message: "Gagal Update Catatan" };
revalidatePath("/dev/admin/vote/child/table_reject");
return { status: 200, message: "Berhasil Update Catatan" };
}

View File

@@ -0,0 +1,23 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function AdminVote_funEditStatusPublishById(voteId: string) {
const updt = await prisma.voting.update({
where: {
id: voteId,
},
data: {
voting_StatusId: "1",
},
});
if (!updt) return { status: 400, message: "Update Gagal" };
revalidatePath("/dev/admin/vote/main");
return {
status: 200,
message: "Berhasil Update Status",
};
}

View File

@@ -0,0 +1,26 @@
"use server";
import prisma from "@/app/lib/prisma";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import { revalidatePath } from "next/cache";
export async function AdminEvent_funEditCatatanById(
data: MODEL_VOTING,
) {
const updt = await prisma.voting.update({
where: {
id: data.id,
},
data: {
voting_StatusId: "4",
catatan: data.catatan,
},
});
if (!updt) return { status: 400, message: "Update Gagal" };
revalidatePath("/dev/admin/event/main");
return {
status: 200,
message: "Berhasil Update Status",
};
}

View File

@@ -0,0 +1,117 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function AdminVote_getListTableByStatusId(statusId: string) {
if (statusId === "0") {
const getData = await prisma.voting.findMany({
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
lte: new Date(),
},
},
select: {
id: true,
title: true,
isActive: true,
createdAt: true,
updatedAt: true,
deskripsi: true,
awalVote: true,
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
});
return getData;
}
if (statusId === "1") {
const getData = await prisma.voting.findMany({
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
gte: new Date(),
},
},
select: {
id: true,
title: true,
isActive: true,
createdAt: true,
updatedAt: true,
deskripsi: true,
awalVote: true,
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
});
return getData;
}
if (statusId === "2") {
const getData = await prisma.voting.findMany({
where: {
voting_StatusId: "2",
isActive: true,
},
select: {
id: true,
title: true,
isActive: true,
createdAt: true,
updatedAt: true,
deskripsi: true,
awalVote: true,
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
});
return getData;
}
if (statusId === "4") {
const getData = await prisma.voting.findMany({
where: {
voting_StatusId: "4",
isActive: true,
},
select: {
id: true,
title: true,
isActive: true,
createdAt: true,
updatedAt: true,
deskripsi: true,
awalVote: true,
akhirVote: true,
catatan: true,
authorId: true,
Author: true,
voting_StatusId: true,
Voting_DaftarNamaVote: true,
},
});
return getData;
}
}

View File

@@ -9,14 +9,12 @@ export default function AdminVote_Main({
countReview,
countDraft,
countReject,
countTipeAcara,
countRiwayat,
}: {
countPublish?: number;
countReview?: number;
countDraft?: number;
countReject?: number;
countTipeAcara?: number;
countRiwayat?: number;
}) {
const router = useRouter();
@@ -36,17 +34,17 @@ export default function AdminVote_Main({
},
{
id: 3,
name: "Draft",
jumlah: countDraft,
path: "",
color: "yellow",
},
{
id: 4,
name: "Reject",
jumlah: countReject,
color: "red",
},
{
id: 4,
name: "Riwayat",
jumlah: countDraft,
path: "",
color: "gray",
},
];
return (

View File

@@ -1,176 +0,0 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import {
Avatar,
Box,
Button,
Center,
Divider,
Grid,
Group,
Modal,
Paper,
Spoiler,
Stack,
Table,
Text,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function AdminVote_TableReject() {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Reject" />
<TableStatus listData={[]} />
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: any[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [peserta, setPeserta] = useState<any[]>();
const [eventId, setEventId] = useState("");
const [loading, setLoading] = useState(false);
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
{e.deskripsi}
</Spoiler>
</Center>
</td>
<td>
<Center>Mulai vote</Center>
</td>
<td>
<Center>Selesai vote</Center>
</td>
<td>
<Center>
<Button
loading={
e.id === eventId ? (loading === true ? true : false) : false
}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
onClick={async () => {
setEventId(e.id);
setLoading(true);
await new Promise((v) => setTimeout(v, 500));
await AdminEvent_getListPesertaById(e.id).then((res: any) => {
setPeserta(res);
setLoading(false);
});
open();
}}
>
Hasil Voting
</Button>
</Center>
</td>
</tr>
));
return (
<>
<Modal opened={opened} onClose={close}>
<Paper>
<Stack>
<Center>
<Title order={3}>Daftar Peserta</Title>
</Center>
<Stack>
{peserta?.map((e) => (
<Stack key={e.id} spacing={"xs"}>
<Grid>
<Grid.Col span={"content"}>
<Avatar
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
src={
RouterProfile.api_foto_profile +
e.User.Profile.imagesId
}
/>
</Grid.Col>
<Grid.Col span={"auto"}>
<Group align="center" h={"100%"}>
<Text>{e.User.Profile.name}</Text>
</Group>
</Grid.Col>
</Grid>
<Divider />
</Stack>
))}
</Stack>
</Stack>
</Paper>
</Modal>
<Box>
<Box bg={"red.1"} p={"xs"}>
<Title order={6} c={"red"}>
REJECT
</Title>
</Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}

View File

@@ -1,164 +0,0 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { Avatar, Box, Button, Center, Divider, Grid, Group, Modal, Paper, Spoiler, Stack, Table, Text, Title } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan } from "@tabler/icons-react";
import { IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
export default function AdminVote_TableReview() {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Review" />
<TableStatus listData={[]}/>
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: any[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [peserta, setPeserta] = useState<any[]>();
const [eventId, setEventId] = useState("");
const [loading, setLoading] = useState(false);
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>{e.title}</Center>
</td>
<td>
<Center>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
{e.deskripsi}
</Spoiler>
</Center>
</td>
<td>
<Center>Mulai vote</Center>
</td>
<td>
<Center>Selesai vote</Center>
</td>
<td>
<Stack align="center">
<Button
w={150}
color={"green"}
leftIcon={<IconEyeShare />}
radius={"xl"}
// onClick={() => onPublish(e.id, setData)}
>
Publish
</Button>
<Button
w={150}
color={"red"}
leftIcon={<IconBan />}
radius={"xl"}
// onClick={() => {
// open();
// setEventId(e.id);
// }}
>
Reject
</Button>
</Stack>
</td>
</tr>
));
return (
<>
<Modal opened={opened} onClose={close}>
<Paper>
<Stack>
<Center>
<Title order={3}>Daftar Peserta</Title>
</Center>
<Stack>
{peserta?.map((e) => (
<Stack key={e.id} spacing={"xs"}>
<Grid>
<Grid.Col span={"content"}>
<Avatar
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
src={
RouterProfile.api_foto_profile +
e.User.Profile.imagesId
}
/>
</Grid.Col>
<Grid.Col span={"auto"}>
<Group align="center" h={"100%"}>
<Text>{e.User.Profile.name}</Text>
</Group>
</Grid.Col>
</Grid>
<Divider />
</Stack>
))}
</Stack>
</Stack>
</Paper>
</Modal>
<Box>
<Box bg={"orange.1"} p={"xs"}>
<Title order={6} c={"orange"}>
REVIEW
</Title>
</Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Mulai Vote</Center>
</th>
<th>
<Center>Selesai Vote</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}