From 09c8848a28749f43ed29086ba7a85f9e8eb0e15c Mon Sep 17 00:00:00 2001 From: Ezra Khairan Permana Date: Fri, 13 Oct 2023 21:13:33 +0700 Subject: [PATCH] feat: menambahkan halaman status --- apps/web/src/pages/kandidat/index.tsx | 6 + apps/web/src/pages/kandidat/status.tsx | 226 +++++++++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 apps/web/src/pages/kandidat/status.tsx diff --git a/apps/web/src/pages/kandidat/index.tsx b/apps/web/src/pages/kandidat/index.tsx index 2f6cc88a..2326f90a 100644 --- a/apps/web/src/pages/kandidat/index.tsx +++ b/apps/web/src/pages/kandidat/index.tsx @@ -137,6 +137,12 @@ const Candidate = () => { Tambah Kandidat Baru + + + + diff --git a/apps/web/src/pages/kandidat/status.tsx b/apps/web/src/pages/kandidat/status.tsx new file mode 100644 index 00000000..a3736ad0 --- /dev/null +++ b/apps/web/src/pages/kandidat/status.tsx @@ -0,0 +1,226 @@ +import Head from "next/head"; +import { + Box, + Container, + Flex, + HStack, + Text, + Tooltip, + VStack, + useColorModeValue, +} from "@chakra-ui/react"; + +import { api } from "~/utils/api"; +import Sidebar from "~/components/Sidebar"; + +const Status = () => { + const candidateQuery = api.candidate.adminCandidateList.useQuery(undefined, { + refetchInterval: 2500, + refetchIntervalInBackground: true, + }); + + const counterQuery = api.candidate.getCandidateAndParticipantCount.useQuery( + undefined, + { + refetchInterval: 2500, + refetchIntervalInBackground: true, + }, + ); + + return ( + <> + + Status Pemilihan + + + + + Status Pemilihan + + + + {!candidateQuery.isLoading && + !candidateQuery.isError && + candidateQuery.data.length > 0 && + counterQuery.data ? ( + + + + Akumulasi Kandidat: + {" "} + {counterQuery.data.candidates} Orang + + + + Akumulasi Pemilih: + {" "} + {counterQuery.data.participants} Orang + + + + {counterQuery.data.isMatch ? "COCOK!" : "TIDAK COCOK!"} + + + + ) : null} + + + + + + Akumulasi Kandidat + + + + + {!candidateQuery.isLoading && + !candidateQuery.isError && + candidateQuery.data.length > 0 && + counterQuery.data ? ( + + {counterQuery.data.candidates} Orang + + ) : ( + <> + + N/A + + + Belum di setup. + + )} + + + + + + + + + Akumulasi Pemilih + + + + + {!candidateQuery.isLoading && + !candidateQuery.isError && + candidateQuery.data.length > 0 && + counterQuery.data ? ( + + {counterQuery.data.participants} Orang + + ) : ( + <> + + N/A + + + Belum di setup. + + )} + + + + + + + + + Kecocokan Data + + + + + {!candidateQuery.isLoading && + !candidateQuery.isError && + candidateQuery.data.length > 0 && + counterQuery.data ? ( + + + {counterQuery.data.isMatch ? "COCOK!" : "TIDAK COCOK!"} + + + ) : ( + <> + + N/A + + + Belum di setup. + + )} + + + + + + + ); +}; + +export default Sidebar(Status);