# Voting Admin
## feat - Tampilan kontributor ### No issuue
This commit is contained in:
@@ -28,6 +28,9 @@ import _ from "lodash";
|
||||
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";
|
||||
|
||||
export default function AdminVote_Riwayat({
|
||||
dataVote,
|
||||
@@ -48,8 +51,9 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [data, setData] = useState(listPublish);
|
||||
const [peserta, setPeserta] = useState<any[]>();
|
||||
const [eventId, setEventId] = useState("");
|
||||
const [hasil, setHasil] = useState<any[]>();
|
||||
const [kontributor, setKontributor] = useState<any[]>();
|
||||
const [voteId, setVoteId] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const TableRows = data.map((e, i) => (
|
||||
@@ -57,10 +61,18 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loading={
|
||||
e.id === voteId ? (loading === true ? true : false) : false
|
||||
}
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck />}
|
||||
onClick={() => ComponentGlobal_NotifikasiPeringatan("On Process")}
|
||||
onClick={async () => {
|
||||
setVoteId(e.id);
|
||||
setLoading(true);
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
onList(e.id, setHasil, setKontributor, setLoading, open);
|
||||
}}
|
||||
>
|
||||
Hasil Voting
|
||||
</Button>
|
||||
@@ -105,38 +117,16 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
|
||||
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
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
size={"xl"}
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ComponentAdminVote_DetailHasil
|
||||
hasil={hasil}
|
||||
kontributor={kontributor}
|
||||
/>
|
||||
</Modal>
|
||||
<Box>
|
||||
<Box bg={"gray.1"} p={"xs"}>
|
||||
@@ -189,3 +179,23 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onList(
|
||||
voteId: string,
|
||||
setHasil: any,
|
||||
setKontributor: any,
|
||||
setLoading: any,
|
||||
open: any
|
||||
) {
|
||||
await AdminVote_getHasilById(voteId).then((res) => {
|
||||
setHasil(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
await AdminVote_getListKontributorById(voteId).then((res) => {
|
||||
setKontributor(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
open();
|
||||
}
|
||||
|
||||
@@ -8,11 +8,17 @@ import {
|
||||
MODEL_EVENT,
|
||||
MODEL_EVENT_PESERTA,
|
||||
} from "@/app_modules/event/model/interface";
|
||||
import { MODEL_VOTING } from "@/app_modules/vote/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,
|
||||
@@ -30,6 +36,9 @@ import { IconEyeCheck, IconEyeShare } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
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";
|
||||
|
||||
export default function AdminVote_TablePublish({
|
||||
dataVote,
|
||||
@@ -50,8 +59,9 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [data, setData] = useState(listPublish);
|
||||
const [peserta, setPeserta] = useState<any[]>();
|
||||
const [eventId, setEventId] = useState("");
|
||||
const [hasil, setHasil] = useState<any[]>();
|
||||
const [kontributor, setKontributor] = useState<any[]>();
|
||||
const [voteId, setVoteId] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const TableRows = data.map((e, i) => (
|
||||
@@ -59,10 +69,18 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loading={
|
||||
e.id === voteId ? (loading === true ? true : false) : false
|
||||
}
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck />}
|
||||
onClick={() => ComponentGlobal_NotifikasiPeringatan("On Process")}
|
||||
onClick={async () => {
|
||||
setVoteId(e.id);
|
||||
setLoading(true);
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
onList(e.id, setHasil, setKontributor, setLoading, open);
|
||||
}}
|
||||
>
|
||||
Lihat Hasil
|
||||
</Button>
|
||||
@@ -107,38 +125,13 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
|
||||
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
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
size={"xl"}
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ComponentAdminVote_DetailHasil hasil={hasil} kontributor={kontributor}/>
|
||||
</Modal>
|
||||
<Box>
|
||||
<Box bg={"green.1"} p={"xs"}>
|
||||
@@ -191,3 +184,23 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onList(
|
||||
voteId: string,
|
||||
setHasil: any,
|
||||
setKontributor: any,
|
||||
setLoading: any,
|
||||
open: any
|
||||
) {
|
||||
await AdminVote_getHasilById(voteId).then((res) => {
|
||||
setHasil(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
await AdminVote_getListKontributorById(voteId).then((res) => {
|
||||
setKontributor(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
open();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_b
|
||||
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";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
|
||||
export default function AdminVote_TableReview({
|
||||
listVote,
|
||||
@@ -102,7 +103,7 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeShare />}
|
||||
radius={"xl"}
|
||||
onClick={() => onPublish(e.id, setData)}
|
||||
onClick={() => onPublish(e.id, setData, e.awalVote)}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
@@ -216,7 +217,14 @@ function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
async function onPublish(voteId: string, setData: any) {
|
||||
async function onPublish(voteId: string, setData: any, awalVote: Date) {
|
||||
const hariIni = new Date();
|
||||
if (awalVote < hariIni)
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Tanggal Mulai Votig Lewat, Edit Kembali",
|
||||
1500
|
||||
);
|
||||
|
||||
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
|
||||
Reference in New Issue
Block a user