();
+ 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[] }) {
}
- 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
@@ -105,38 +117,16 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
return (
<>
-
-
-
-
- Daftar Peserta
-
-
- {peserta?.map((e) => (
-
-
-
-
-
-
-
- {e.User.Profile.name}
-
-
-
-
-
- ))}
-
-
-
+
+
@@ -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();
+}
diff --git a/src/app_modules/admin/vote/child/table_publish/index.tsx b/src/app_modules/admin/vote/child/table_publish/index.tsx
index 0c9236ec..821e074a 100644
--- a/src/app_modules/admin/vote/child/table_publish/index.tsx
+++ b/src/app_modules/admin/vote/child/table_publish/index.tsx
@@ -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();
- const [eventId, setEventId] = useState("");
+ const [hasil, setHasil] = useState();
+ const [kontributor, setKontributor] = useState();
+ 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[] }) {
}
- 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
@@ -107,38 +125,13 @@ function TableStatus({ listPublish }: { listPublish: MODEL_VOTING[] }) {
return (
<>
-
-
-
-
- Daftar Peserta
-
-
- {peserta?.map((e) => (
-
-
-
-
-
-
-
- {e.User.Profile.name}
-
-
-
-
-
- ))}
-
-
-
+
+
@@ -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();
+}
diff --git a/src/app_modules/admin/vote/child/table_review/index.tsx b/src/app_modules/admin/vote/child/table_review/index.tsx
index 35dbce85..58c146e7 100644
--- a/src/app_modules/admin/vote/child/table_review/index.tsx
+++ b/src/app_modules/admin/vote/child/table_review/index.tsx
@@ -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={}
radius={"xl"}
- onClick={() => onPublish(e.id, setData)}
+ onClick={() => onPublish(e.id, setData, e.awalVote)}
>
Publish
@@ -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) => {
diff --git a/src/app_modules/admin/vote/component/detail_hasil.tsx b/src/app_modules/admin/vote/component/detail_hasil.tsx
new file mode 100644
index 00000000..9c127873
--- /dev/null
+++ b/src/app_modules/admin/vote/component/detail_hasil.tsx
@@ -0,0 +1,119 @@
+"use client"
+
+import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
+import { MODEL_VOTE_KONTRIBUTOR, MODEL_VOTING_DAFTAR_NAMA_VOTE } from "@/app_modules/vote/model/interface";
+import { Paper, Stack, Center, Title, Grid, Card, Avatar, Badge, Divider, Text } from "@mantine/core";
+import _ from "lodash";
+import router from "next/router";
+
+export default function ComponentAdminVote_DetailHasil({
+ hasil,
+ kontributor,
+}: {
+ hasil?: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
+ kontributor?: MODEL_VOTE_KONTRIBUTOR[]
+}) {
+ return (
+ <>
+
+
+
+ Hasil
+
+
+
+ {hasil?.map((e: MODEL_VOTING_DAFTAR_NAMA_VOTE, i) => (
+
+
+
+ {e.jumlah}
+
+
+ {e.value}
+
+
+
+ ))}
+
+
+
+
+
+
+ Daftar Kontributor
+
+
+ {_.isEmpty(kontributor) ? (
+
+
+ - Tidak ada voting -
+
+
+ ) : (
+
+ {kontributor?.map((e, i) => (
+
+
+
+ router.push(
+ RouterProfile.katalog + e.Author.Profile.id
+ )
+ }
+ >
+
+
+
+
+
+ {e ? e.Author.Profile.name : "Nama author"}
+
+
+
+
+
+
+ 10
+ ? 8
+ : 10
+ }
+ >
+ {e.Voting_DaftarNamaVote.value}
+
+
+
+
+
+
+
+ ))}
+
+ )}
+
+
+
+
+ {/* {JSON.stringify(kontributor, null, 2)} */}
+
+
+ >
+ );
+}
\ No newline at end of file
diff --git a/src/app_modules/admin/vote/fun/get/get_hasil_by_id.ts b/src/app_modules/admin/vote/fun/get/get_hasil_by_id.ts
new file mode 100644
index 00000000..c804e3fc
--- /dev/null
+++ b/src/app_modules/admin/vote/fun/get/get_hasil_by_id.ts
@@ -0,0 +1,14 @@
+"use server";
+
+import prisma from "@/app/lib/prisma";
+
+export async function AdminVote_getHasilById(voteId: string) {
+ const data = await prisma.voting_DaftarNamaVote.findMany({
+ where: {
+ votingId: voteId,
+ },
+ });
+
+ return data;
+
+}
diff --git a/src/app_modules/admin/vote/fun/get/get_list_kontributor_by_id.ts b/src/app_modules/admin/vote/fun/get/get_list_kontributor_by_id.ts
new file mode 100644
index 00000000..1ecd2731
--- /dev/null
+++ b/src/app_modules/admin/vote/fun/get/get_list_kontributor_by_id.ts
@@ -0,0 +1,21 @@
+"use server";
+
+import prisma from "@/app/lib/prisma";
+
+export async function AdminVote_getListKontributorById(voteId: string) {
+ const data = await prisma.voting_Kontributor.findMany({
+ where: {
+ votingId: voteId,
+ },
+ select: {
+ Voting_DaftarNamaVote: true,
+ Author: {
+ select: {
+ Profile: true,
+ },
+ },
+ },
+ });
+
+ return data;
+}
diff --git a/src/app_modules/component_global/maintenance_information.tsx b/src/app_modules/component_global/maintenance_information.tsx
new file mode 100644
index 00000000..6f549f02
--- /dev/null
+++ b/src/app_modules/component_global/maintenance_information.tsx
@@ -0,0 +1,24 @@
+"use client";
+
+import { Box, Group, Text } from "@mantine/core";
+import Marquee from "react-fast-marquee";
+
+export default function ComponentGlobal_MaintenanceInformation() {
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/src/app_modules/component_global/notif_global/notifikasi_peringatan.tsx b/src/app_modules/component_global/notif_global/notifikasi_peringatan.tsx
index a0ecfb15..5c012279 100644
--- a/src/app_modules/component_global/notif_global/notifikasi_peringatan.tsx
+++ b/src/app_modules/component_global/notif_global/notifikasi_peringatan.tsx
@@ -8,7 +8,10 @@ import { IconAlertTriangle } from "@tabler/icons-react";
* @type string
* @returns notifikasi peringatan
*/
-export async function ComponentGlobal_NotifikasiPeringatan(text: string) {
+export async function ComponentGlobal_NotifikasiPeringatan(
+ text: string,
+ durasi?: number
+) {
return notifications.show({
message: (
@@ -17,8 +20,13 @@ export async function ComponentGlobal_NotifikasiPeringatan(text: string) {
),
color: "yellow.3",
radius: "md",
- autoClose: 1000,
- icon: ,
+ autoClose: durasi ? durasi : 1000,
+
+ icon: (
+
+
+
+ ),
withCloseButton: false,
styles: (theme) => ({
diff --git a/src/app_modules/home/view.tsx b/src/app_modules/home/view.tsx
index d2142f49..e1e6d88c 100644
--- a/src/app_modules/home/view.tsx
+++ b/src/app_modules/home/view.tsx
@@ -32,11 +32,10 @@ import { MODEL_PROFILE_OLD } from "./model/user_profile";
import AppNotif from "../notif";
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
+import { MODEL_USER } from "./model/interface";
+import { ComponentGlobal_NotifikasiPeringatan } from "../component_global/notif_global/notifikasi_peringatan";
-// export const dynamic = "force-dynamic"
-// export const revalidate = 0
-
-export default function HomeView() {
+export default function HomeView({ dataUser }: { dataUser: MODEL_USER }) {
const router = useRouter();
// const [stateUser, setStateUser] = useState(user);
@@ -117,10 +116,18 @@ export default function HomeView() {
h={100}
withBorder
onClick={() => {
- if (e.link === "") {
- toast("Cooming Soon !!");
+ if (dataUser.Profile === null) {
+ return ComponentGlobal_NotifikasiPeringatan(
+ "Lengkapi Data Profile"
+ );
} else {
- return router.push(e.link);
+ if (e.link === "") {
+ return ComponentGlobal_NotifikasiPeringatan(
+ "Cooming Soon !!"
+ );
+ } else {
+ return router.push(e.link);
+ }
}
}}
>
diff --git a/src/app_modules/katalog/main/view.tsx b/src/app_modules/katalog/main/view.tsx
index fd07a886..b2155b1c 100644
--- a/src/app_modules/katalog/main/view.tsx
+++ b/src/app_modules/katalog/main/view.tsx
@@ -42,7 +42,7 @@ export default function KatalogView({
userLoginId={userLoginId}
/>
- {profile.User.id === userLoginId ? : ""}
+ {profile?.User.id === userLoginId ? : ""}
>
diff --git a/src/app_modules/user_search/main/index.tsx b/src/app_modules/user_search/main/index.tsx
index 62f2471a..3f8137c8 100644
--- a/src/app_modules/user_search/main/index.tsx
+++ b/src/app_modules/user_search/main/index.tsx
@@ -13,72 +13,94 @@ import {
Stack,
Text,
TextInput,
+ Title,
} from "@mantine/core";
import { IconChevronRight, IconSearch } from "@tabler/icons-react";
import { useState } from "react";
import { UserSearch_searchByName } from "../fun/search/fun_search_by_name";
import { useRouter } from "next/navigation";
+import ComponentGlobal_MaintenanceInformation from "@/app_modules/component_global/maintenance_information";
export default function UserSearch_MainView({
listUser,
}: {
listUser: MODEL_USER[];
}) {
- const router = useRouter()
+ const router = useRouter();
const [user, setUser] = useState(listUser);
async function onSearch(name: string) {
await UserSearch_searchByName(name).then((res) => setUser(res as any));
}
- return<>>
// return (
// <>
- //
- // {/* {JSON.stringify(user, null,2)}r */}
- //
- // }
- // placeholder="Masukan nama pegguna"
- // onChange={(val) => onSearch(val.target.value)}
- // />
- // {user.map((e) => (
- //
- //
- //
- // {/* */}
- //
- //
- //
- //
- // {e.Profile.name}
- //
- //
- // +{e.nomor}
- //
- //
- //
- //
- //
- // router.push(RouterProfile.katalog + `${e.Profile.id}`)}
- // >
- //
- //
- //
- //
- //
- //
- //
- // ))}
- //
- //
+ //
+ //
+ //
// >
// );
+ return (
+ <>
+
+ {/* {JSON.stringify(user, null,2)}r */}
+
+ }
+ placeholder="Masukan nama pegguna"
+ onChange={(val) => onSearch(val.target.value)}
+ />
+ {!user ? (
+ ""
+ ) : (
+
+ {user?.map((e) => (
+
+
+
+
+
+
+
+
+
+
+ {e.Profile.name}
+
+
+ +{e.nomor}
+
+
+
+
+
+
+ router.push(
+ RouterProfile.katalog + `${e.Profile.id}`
+ )
+ }
+ >
+
+
+
+
+
+
+
+ ))}
+
+ )}
+
+
+ >
+ );
}
diff --git a/yarn.lock b/yarn.lock
index b2657f61..ba877b09 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3078,6 +3078,11 @@ react-easy-swipe@^0.0.21:
dependencies:
prop-types "^15.5.8"
+react-fast-marquee@^1.6.4:
+ version "1.6.4"
+ resolved "https://registry.yarnpkg.com/react-fast-marquee/-/react-fast-marquee-1.6.4.tgz#ac0bed0faee63e4d97e9b8cd03f3bea9f242fab3"
+ integrity sha512-LAgvhRmHdqaUQ8R5jCUwzEGFUIjnCCt3T3W8X7j7wF6DWe0SATlpP0JX1V0pp2qX3DYUezmn1Iz5AtRFdL2EWQ==
+
react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
| |