## Deskripsi:
- Optimalisasi admin voting
## No issue
This commit is contained in:
2024-08-28 15:00:43 +08:00
parent 916c5c7d85
commit 8a018462c7
78 changed files with 3567 additions and 2493 deletions

View File

@@ -1,29 +1,25 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Stack,
Center,
Spoiler,
Button,
Modal,
Paper,
Title,
Grid,
Avatar,
Group,
Divider,
Box,
Button,
Center,
Group,
Modal,
Pagination,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
TextInput,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan, IconEyeCheck } from "@tabler/icons-react";
import { IconEyeShare } from "@tabler/icons-react";
import { IconEyeCheck, IconSearch } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
@@ -31,6 +27,8 @@ import { useState } from "react";
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
import { adminVote_funGetListRiwayat } from "../../fun";
import { IconCircleCheckFilled } from "@tabler/icons-react";
export default function AdminVote_Riwayat({
dataVote,
@@ -40,46 +38,73 @@ export default function AdminVote_Riwayat({
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Riwayat" />
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
<TableStatus listPublish={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
function TableStatus({ listPublish }: { listPublish: any }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listPublish);
const [data, setData] = useState<MODEL_VOTING[]>(listPublish.data);
const [hasil, setHasil] = useState<any[]>();
const [kontributor, setKontributor] = useState<any[]>();
const [voteId, setVoteId] = useState("");
const [loading, setLoading] = useState(false);
const [isNPage, setNPage] = useState(listPublish.nPage);
const [isActivePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
async function onSearch(s: string) {
setSearch(s);
const loadData = await adminVote_funGetListRiwayat({
page: 1,
search: s,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onPageClick(p: any) {
setActivePage(p);
const loadData = await adminVote_funGetListRiwayat({
search: isSearch,
page: p,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Button
loading={
e.id === voteId ? (loading === true ? true : false) : false
e?.id === voteId ? (loading === true ? true : false) : false
}
radius={"xl"}
color="green"
leftIcon={<IconEyeCheck />}
leftIcon={<IconCircleCheckFilled />}
onClick={async () => {
setVoteId(e.id);
setVoteId(e?.id);
setLoading(true);
await new Promise((r) => setTimeout(r, 500));
onList(e.id, setHasil, setKontributor, setLoading, open);
onList(e?.id, setHasil, setKontributor, setLoading, open);
}}
>
Hasil Voting
Lihat Hasil
</Button>
</Center>
</td>
<td>
<Center>{e.title}</Center>
<Center>{e?.Author?.username}</Center>
</td>
<td>
<Center>{e?.title}</Center>
</td>
<td>
<Center>
@@ -89,27 +114,27 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
maxHeight={50}
showLabel="tampilkan"
>
{e.deskripsi}
{e?.deskripsi}
</Spoiler>
</Center>
</td>
<th>
<Stack>
{e.Voting_DaftarNamaVote.map((v) => (
<Box key={v.id}>
<Text>- {v.value}</Text>
{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" })}
{e?.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
<td>
<Center>
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
{e?.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
</Center>
</td>
</tr>
@@ -117,6 +142,76 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
return (
<>
<Stack spacing={"xs"} h={"100%"}>
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
<Group
position="apart"
bg={"gray.4"}
p={"xs"}
style={{ borderRadius: "6px" }}
>
<Title order={4}>Riwayat</Title>
<TextInput
icon={<IconSearch size={20} />}
radius={"xl"}
placeholder="Masukan judul"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
</Group>
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}>
<Table
verticalSpacing={"md"}
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Username</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>
</ScrollArea>
<Center mt={"xl"}>
<Pagination
value={isActivePage}
total={isNPage}
onChange={(val) => {
onPageClick(val);
}}
/>
</Center>
</Paper>
</Stack>
<Modal
opened={opened}
onClose={close}
@@ -128,54 +223,6 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
kontributor={kontributor}
/>
</Modal>
<Box>
<Box bg={"gray.1"} p={"xs"}>
<Title order={6} c={"gray"}>
RIWAYAT
</Title>
</Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<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>
</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,44 +1,31 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
MODEL_EVENT,
MODEL_EVENT_PESERTA,
} from "@/app_modules/event/model/interface";
import {
MODEL_VOTE_KONTRIBUTOR,
MODEL_VOTING,
MODEL_VOTING_DAFTAR_NAMA_VOTE,
} from "@/app_modules/vote/model/interface";
import {
Avatar,
Badge,
Box,
Button,
Card,
Center,
Divider,
Grid,
Group,
Modal,
Pagination,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
TextInput,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { IconCircleCheckFilled, IconEyeCheck, IconSearch } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
import { adminVote_funGetListPublish } from "../../fun/get/status/get_list_publish";
export default function AdminVote_TablePublish({
dataVote,
@@ -48,22 +35,46 @@ export default function AdminVote_TablePublish({
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Publish" />
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
<TableStatus listPublish={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
function TableStatus({ listPublish }: { listPublish: any }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listPublish);
const [data, setData] = useState<MODEL_VOTING[]>(listPublish.data);
const [hasil, setHasil] = useState<any[]>();
const [kontributor, setKontributor] = useState<any[]>();
const [voteId, setVoteId] = useState("");
const [loading, setLoading] = useState(false);
const [isNPage, setNPage] = useState(listPublish.nPage);
const [isActivePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
async function onSearch(s: string) {
setSearch(s);
const loadData = await adminVote_funGetListPublish({
page: 1,
search: s,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onPageClick(p: any) {
setActivePage(p);
const loadData = await adminVote_funGetListPublish({
search: isSearch,
page: p,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
@@ -74,7 +85,7 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
}
radius={"xl"}
color="green"
leftIcon={<IconEyeCheck />}
leftIcon={<IconCircleCheckFilled />}
onClick={async () => {
setVoteId(e?.id);
setLoading(true);
@@ -87,7 +98,7 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
</Center>
</td>
<td>
<Center>{e?.Author?.Profile?.name}</Center>
<Center>{e?.Author?.username}</Center>
</td>
<td>
<Center>{e?.title}</Center>
@@ -128,6 +139,76 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
return (
<>
<Stack spacing={"xs"} h={"100%"}>
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
<Group
position="apart"
bg={"green.4"}
p={"xs"}
style={{ borderRadius: "6px" }}
>
<Title order={4}>Publish</Title>
<TextInput
icon={<IconSearch size={20} />}
radius={"xl"}
placeholder="Masukan judul"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
</Group>
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}>
<Table
verticalSpacing={"md"}
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Username</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>
</ScrollArea>
<Center mt={"xl"}>
<Pagination
value={isActivePage}
total={isNPage}
onChange={(val) => {
onPageClick(val);
}}
/>
</Center>
</Paper>
</Stack>
<Modal
opened={opened}
onClose={close}
@@ -139,57 +220,6 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
kontributor={kontributor}
/>
</Modal>
<Box>
<Box bg={"green.1"} p={"xs"}>
<Title order={6} c={"green"}>
PUBLISH
</Title>
</Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Aksi</Center>
</th>
<th>
<Center>Author</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>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}

View File

@@ -1,18 +1,16 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/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,
Pagination,
Paper,
ScrollArea,
Spoiler,
@@ -20,40 +18,80 @@ import {
Table,
Text,
Textarea,
TextInput,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan, IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { IconBan, IconSearch } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { adminVote_funGetListReject } from "../../fun";
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/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
export default function AdminVote_TableReject({
dataVote,
}: {
dataVote: MODEL_VOTING[];
}) {
export default function AdminVote_TableReject({ dataVote }: { dataVote: any }) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Reject" />
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
<TableStatus listData={dataVote} />
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
function TableStatus({ listData }: { listData: any }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const [isNPage, setNPage] = useState(listData.nPage);
const [isActivePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
async function onSearch(s: string) {
setSearch(s);
const loadData = await adminVote_funGetListReject({
page: 1,
search: s,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onPageClick(p: any) {
setActivePage(p);
const loadData = await adminVote_funGetListReject({
search: isSearch,
page: p,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onReject(
votingId: string,
catatan: string,
close: any,
setData: any
) {
const res = await AdminVote_funEditCatatanRejectById(votingId, catatan);
if (res.status === 200) {
const loadData = await adminVote_funGetListReject({
page: 1,
search: isSearch,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
setActivePage(1);
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
close();
} else {
ComponentAdminGlobal_NotifikasiGagal(res.message);
}
}
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
@@ -129,53 +167,32 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
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}
<Stack spacing={"xs"} h={"100%"}>
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
<Group
position="apart"
bg={"red.4"}
p={"xs"}
style={{ borderRadius: "6px" }}
>
<Title order={4}>Reject</Title>
<TextInput
icon={<IconSearch size={20} />}
radius={"xl"}
placeholder="Masukan judul"
onChange={(val) => {
setCatatan(val.target.value);
onSearch(val.currentTarget.value);
}}
/>
<Group position="right">
<Button
radius={"xl"}
onClick={() => {
onReject(votingId, catatan, close, setData);
console.log(catatan);
}}
>
Simpan
</Button>
</Group>
</Stack>
</Modal>
</Group>
<Box>
<Box bg={"red.1"} p={"xs"}>
<Title order={6} c={"red"}>
REJECT
</Title>
</Box>
<ScrollArea w={"100%"}>
<Box w={2000}>
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
@@ -209,39 +226,56 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
</thead>
<tbody>{TableRows}</tbody>
</Table>
</Box>
</ScrollArea>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</ScrollArea>
<Center mt={"xl"}>
<Pagination
value={isActivePage}
total={isNPage}
onChange={(val) => {
onPageClick(val);
}}
/>
</Center>
</Paper>
</Stack>
<Modal
opened={opened}
onClose={close}
centered
withCloseButton={false}
size={"md"}
>
<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={() => close()}>
Batal
</Button>
<Button
radius={"xl"}
onClick={() => {
onReject(votingId, catatan, close, setData);
console.log(catatan);
}}
>
Simpan
</Button>
</Group>
</Stack>
</Modal>
</>
);
}
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

@@ -8,16 +8,19 @@ import {
Center,
Group,
Modal,
Pagination,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Textarea,
TextInput,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan, IconEyeShare } from "@tabler/icons-react";
import { IconBan, IconEyeShare, IconSearch } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
@@ -31,6 +34,8 @@ import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_re
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
import mqtt_client from "@/util/mqtt_client";
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
import { adminVote_funGetListReview } from "../../fun";
import { IconCircleCheckFilled } from "@tabler/icons-react";
export default function AdminVote_TableReview({
listVote,
@@ -40,26 +45,50 @@ export default function AdminVote_TableReview({
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Voting: Table Review" />
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
<TableStatus listData={listVote} />
</Stack>
</>
);
}
function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
function TableStatus({ listData }: { listData: any }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const [isLoadingPublish, setLoadingPublish] = useState(false);
const [isSaveLoading, setSaveLoading] = useState(false);
const [isNPage, setNPage] = useState(listData.nPage);
const [isActivePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
async function onSearch(s: string) {
setSearch(s);
const loadData = await adminVote_funGetListReview({
page: 1,
search: s,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onPageClick(p: any) {
setActivePage(p);
const loadData = await adminVote_funGetListReview({
search: isSearch,
page: p,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>
<Center>{e?.Author?.Profile?.name}</Center>
<Center>{e?.Author?.username}</Center>
</td>
<td>
<Center>{e.title}</Center>
@@ -105,7 +134,7 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
}
w={120}
color={"green"}
leftIcon={<IconEyeShare />}
leftIcon={<IconCircleCheckFilled />}
radius={"xl"}
onClick={() =>
onPublish(
@@ -138,12 +167,83 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
return (
<>
<Stack spacing={"xs"} h={"100%"}>
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
<Group
position="apart"
bg={"orange.4"}
p={"xs"}
style={{ borderRadius: "6px" }}
>
<Title order={4}>Review</Title>
<TextInput
icon={<IconSearch size={20} />}
radius={"xl"}
placeholder="Masukan judul"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
</Group>
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}>
<Table
verticalSpacing={"md"}
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Username</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>
</Table>
</ScrollArea>
<Center mt={"xl"}>
<Pagination
value={isActivePage}
total={isNPage}
onChange={(val) => {
onPageClick(val);
}}
/>
</Center>
</Paper>
</Stack>
<Modal
opened={opened}
onClose={close}
centered
withCloseButton={false}
size={"lg"}
size={"md"}
>
<Stack>
<Textarea
@@ -174,63 +274,6 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
</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>Author</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>
</Table>
</Box>
</ScrollArea>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}

View File

@@ -0,0 +1,65 @@
"use server";
import prisma from "@/app/lib/prisma";
import { ceil } from "lodash";
export async function adminVote_funGetListReject({
page,
search,
}: {
page: number;
search?: string;
}) {
let takeData = 10;
let skipData = page * takeData - takeData;
const data = await prisma.voting.findMany({
skip: skipData,
take: takeData,
orderBy: {
updatedAt: "desc",
},
where: {
voting_StatusId: "4",
isActive: true,
title: {
contains: search,
mode: "insensitive",
},
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
Voting_Kontributor: true,
Voting_DaftarNamaVote: true,
},
});
const nCount = await prisma.voting.count({
where: {
voting_StatusId: "4",
isActive: true,
title: {
contains: search,
mode: "insensitive",
},
},
});
const allData = {
data: data,
nPage: ceil(nCount / takeData),
};
return allData;
}

View File

@@ -0,0 +1,65 @@
"use server";
import prisma from "@/app/lib/prisma";
import { ceil } from "lodash";
export async function adminVote_funGetListReview({
page,
search,
}: {
page: number;
search?: string;
}) {
let takeData = 10;
let skipData = page * takeData - takeData;
const data = await prisma.voting.findMany({
skip: skipData,
take: takeData,
orderBy: {
createdAt: "desc",
},
where: {
voting_StatusId: "2",
isActive: true,
title: {
contains: search,
mode: "insensitive",
},
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
Voting_Kontributor: true,
Voting_DaftarNamaVote: true,
},
});
const nCount = await prisma.voting.count({
where: {
voting_StatusId: "2",
isActive: true,
title: {
contains: search,
mode: "insensitive",
},
},
});
const allData = {
data: data,
nPage: ceil(nCount / takeData),
};
return allData;
}

View File

@@ -0,0 +1,73 @@
"use server"
"use server";
import prisma from "@/app/lib/prisma";
import { ceil } from "lodash";
export async function adminVote_funGetListRiwayat({
page,
search,
}: {
page: number;
search?: string;
}) {
let takeData = 10;
let skipData = page * takeData - takeData;
const data = await prisma.voting.findMany({
skip: skipData,
take: takeData,
orderBy: {
createdAt: "desc",
},
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
lte: new Date(),
},
title: {
contains: search,
mode: "insensitive",
},
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
Voting_Kontributor: true,
Voting_DaftarNamaVote: true,
},
});
const nCount = await prisma.voting.count({
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
lte: new Date(),
},
title: {
contains: search,
mode: "insensitive",
},
},
});
const allData = {
data: data,
nPage: ceil(nCount / takeData),
};
return allData;
}

View File

@@ -0,0 +1,71 @@
"use server";
import prisma from "@/app/lib/prisma";
import { ceil } from "lodash";
export async function adminVote_funGetListPublish({
page,
search,
}: {
page: number;
search?: string;
}) {
let takeData = 10;
let skipData = page * takeData - takeData;
const data = await prisma.voting.findMany({
skip: skipData,
take: takeData,
orderBy: {
createdAt: "desc",
},
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
gte: new Date(),
},
title: {
contains: search,
mode: "insensitive",
},
},
include: {
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
Voting_Kontributor: true,
Voting_DaftarNamaVote: true,
},
});
const nCount = await prisma.voting.count({
where: {
voting_StatusId: "1",
isActive: true,
akhirVote: {
gte: new Date(),
},
title: {
contains: search,
mode: "insensitive",
},
},
});
const allData = {
data: data,
nPage: ceil(nCount / takeData),
};
return allData;
}

View File

@@ -0,0 +1,7 @@
import { adminVote_funGetListReject } from "./get/status/fun_get_list_reject";
import { adminVote_funGetListReview } from "./get/status/fun_get_list_review";
import { adminVote_funGetListRiwayat } from "./get/status/fun_get_riwayat";
export { adminVote_funGetListReview };
export { adminVote_funGetListReject };
export { adminVote_funGetListRiwayat };