diff --git a/src/app/dev/(user)/vote/detail/kontribusi/[id]/layout.tsx b/src/app/dev/(user)/vote/detail/kontribusi/[id]/layout.tsx
index 99ce0157..ca76dac8 100644
--- a/src/app/dev/(user)/vote/detail/kontribusi/[id]/layout.tsx
+++ b/src/app/dev/(user)/vote/detail/kontribusi/[id]/layout.tsx
@@ -1,28 +1,14 @@
-import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { LayoutVote_DetailKontribusi } from "@/app_modules/vote";
-import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
import React from "react";
export default async function Layout({
children,
- params,
}: {
children: React.ReactNode;
- params: { id: string };
}) {
- const votingId = params.id;
- const userLoginId = await funGetUserIdByToken();
- const dataVoting = await voting_funGetOneVotingbyId(votingId);
-
return (
<>
-
- {children}
-
+ {children}
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/main/[id]/layout.tsx b/src/app/dev/(user)/vote/detail/main/[id]/layout.tsx
index 52e73baa..6e978bef 100644
--- a/src/app/dev/(user)/vote/detail/main/[id]/layout.tsx
+++ b/src/app/dev/(user)/vote/detail/main/[id]/layout.tsx
@@ -1,28 +1,14 @@
-import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { LayoutVote_MainDetail } from "@/app_modules/vote";
-import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
import React from "react";
export default async function Layout({
children,
- params,
}: {
children: React.ReactNode;
- params: { id: string };
}) {
- const votingId = params.id;
- const userLoginId = await funGetUserIdByToken();
- const dataVoting = await voting_funGetOneVotingbyId(votingId);
-
return (
<>
-
- {children}
-
+ {children}
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/main/[id]/page.tsx b/src/app/dev/(user)/vote/detail/main/[id]/page.tsx
index b26b402a..6f1307de 100644
--- a/src/app/dev/(user)/vote/detail/main/[id]/page.tsx
+++ b/src/app/dev/(user)/vote/detail/main/[id]/page.tsx
@@ -1,13 +1,9 @@
-import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Vote_MainDetail } from "@/app_modules/vote";
-export default async function Page({ params }: { params: { id: string } }) {
- const userLoginId = await funGetUserIdByToken();
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/publish/[id]/layout.tsx b/src/app/dev/(user)/vote/detail/publish/[id]/layout.tsx
index e2359ded..52d87354 100644
--- a/src/app/dev/(user)/vote/detail/publish/[id]/layout.tsx
+++ b/src/app/dev/(user)/vote/detail/publish/[id]/layout.tsx
@@ -1,29 +1,14 @@
-import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { LayoutVote_DetailPublish } from "@/app_modules/vote";
-import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
import React from "react";
export default async function Layout({
children,
- params,
}: {
children: React.ReactNode;
- params: { id: string };
}) {
- const votingId = params.id;
- const userLoginId = await funGetUserIdByToken();
-
- const dataVoting = await voting_funGetOneVotingbyId(votingId);
-
return (
<>
-
- {children}
-
+ {children}
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/publish/[id]/page.tsx b/src/app/dev/(user)/vote/detail/publish/[id]/page.tsx
index df0477dc..36b9389e 100644
--- a/src/app/dev/(user)/vote/detail/publish/[id]/page.tsx
+++ b/src/app/dev/(user)/vote/detail/publish/[id]/page.tsx
@@ -1,14 +1,9 @@
import { Vote_DetailPublish } from "@/app_modules/vote";
-import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id";
-import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
-
-export default async function Page({ params }: { params: { id: string } }) {
- let voteId = params.id;
- const dataVote = await voting_funGetOneVotingbyId(voteId);
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/riwayat_saya/[id]/page.tsx b/src/app/dev/(user)/vote/detail/riwayat_saya/[id]/page.tsx
index f4542ad0..56807551 100644
--- a/src/app/dev/(user)/vote/detail/riwayat_saya/[id]/page.tsx
+++ b/src/app/dev/(user)/vote/detail/riwayat_saya/[id]/page.tsx
@@ -1,19 +1,9 @@
import { Vote_DetailRiwayatSaya } from "@/app_modules/vote";
-import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id";
-import { Vote_getOnePublishbyId } from "@/app_modules/vote/fun/get/get_one_publish_by_id";
-
-export default async function Page({params}: {params: {id: string}}) {
- let voteId = params.id;
- const dataVote = await Vote_getOnePublishbyId(voteId);
- const listKontributor = await Vote_getListKontributorById(voteId);
-
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/(user)/vote/detail/semua_riwayat/[id]/layout.tsx b/src/app/dev/(user)/vote/detail/semua_riwayat/[id]/layout.tsx
index 29d02c51..4723aa9d 100644
--- a/src/app/dev/(user)/vote/detail/semua_riwayat/[id]/layout.tsx
+++ b/src/app/dev/(user)/vote/detail/semua_riwayat/[id]/layout.tsx
@@ -1,25 +1,14 @@
-import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { LayoutVote_DetailSemuaRiwayat } from "@/app_modules/vote";
import React from "react";
export default async function Layout({
children,
- params,
}: {
children: React.ReactNode;
- params: { id: string };
}) {
- const votingId = params.id;
- const userLoginId = await funGetUserIdByToken();
-
return (
<>
-
- {children}
-
+ {children}
>
);
}
diff --git a/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx b/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
index bf3de1b8..40df7e65 100644
--- a/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
+++ b/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
@@ -1,10 +1,13 @@
-import { RouterVote } from "@/lib/router_hipmi/router_vote";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
+import { Component_Header } from "@/app_modules/_global/component/new/component_header";
+import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
-import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { RouterVote } from "@/lib/router_hipmi/router_vote";
import {
ActionIcon,
Button,
@@ -14,55 +17,84 @@ import {
Stack,
Text,
} from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
import {
IconArchive,
IconDotsVertical,
IconUsersGroup,
IconX,
} from "@tabler/icons-react";
-import { useRouter } from "next/navigation";
+import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
+import { apiGetOneVotingById } from "../../_lib/api_voting";
import { voting_funUpdateIsArsipById } from "../../fun";
import { MODEL_VOTING } from "../../model/interface";
-import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
-import { Component_Header } from "@/app_modules/_global/component/new/component_header";
export function Voting_ComponentLayoutHeaderDetailPublish({
- votingId,
title,
- userLoginId,
- dataVoting,
}: {
- votingId: string;
title: string;
- userLoginId: string;
- dataVoting: any;
}) {
- const [data, setData] = useState(dataVoting);
+ const router = useRouter();
+ const { id } = useParams();
const [openDrawer, setOpenDrawer] = useState(false);
const [openModal, setOpenModal] = useState(false);
const [isLoading, setIsLoading] = useState(false);
- async function onUpdateStatusArsip({ isArsip }: { isArsip: boolean }) {
- setIsLoading(true);
- const res = await voting_funUpdateIsArsipById({
- votingId,
- isArsip: isArsip,
- });
- if (res.status === 200) {
- try {
- const loadData = await voting_funGetOneVotingbyId(votingId);
- setData(loadData as any);
- } catch (error) {
- console.log(error);
- } finally {
- setOpenModal(false);
- ComponentGlobal_NotifikasiBerhasil(res.message);
- setIsLoading(false);
+ const [data, setData] = useState();
+ const [userLoginId, setUserLoginId] = useState(null);
+
+ useShallowEffect(() => {
+ handleGetUserId();
+ onLoadData();
+ }, []);
+
+ async function handleGetUserId() {
+ try {
+ const respone = await apiNewGetUserIdByToken();
+
+ if (respone) {
+ setUserLoginId(respone.userId);
}
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ } catch (error) {
+ console.error("Error get data detail", error);
+ }
+ }
+
+ async function onLoadData() {
+ try {
+ const response = await apiGetOneVotingById({ id: id as string });
+ if (response) {
+ setData(response.data);
+ } else {
+ setData(null);
+ }
+ } catch (error) {
+ console.log(error);
+ }
+ }
+
+ async function onUpdateStatusArsip({ isArsip }: { isArsip: boolean }) {
+ try {
+ setIsLoading(true);
+ const res = await voting_funUpdateIsArsipById({
+ votingId: id as string,
+ isArsip: isArsip,
+ });
+
+ if (res.status !== 200) {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiPeringatan(res.message);
+ return;
+ }
+
setIsLoading(false);
+ ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
+ router.back();
+ } catch (error) {
+ console.log(error);
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal("Gagal Update");
}
}
@@ -71,14 +103,18 @@ export function Voting_ComponentLayoutHeaderDetailPublish({
{
- setOpenDrawer(true);
- }}
- >
-
-
+ userLoginId ? (
+ {
+ setOpenDrawer(true);
+ }}
+ >
+
+
+ ) : (
+
+ )
}
/>
@@ -123,14 +159,14 @@ export function Voting_ComponentLayoutHeaderDetailPublish({
{/* Check Author */}
{data?.authorId === userLoginId ? (
{
setOpenDrawer(val.drawer);
setOpenModal(val.modal);
}}
/>
) : (
-
+
)}
diff --git a/src/app_modules/vote/detail/kontribusi/layout.tsx b/src/app_modules/vote/detail/kontribusi/layout.tsx
index cdfc5717..735e153d 100644
--- a/src/app_modules/vote/detail/kontribusi/layout.tsx
+++ b/src/app_modules/vote/detail/kontribusi/layout.tsx
@@ -9,38 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
export default function LayoutVote_DetailKontribusi({
children,
- votingId,
- userLoginId,
- dataVoting,
}: {
children: React.ReactNode;
- votingId: string;
- userLoginId: string;
- dataVoting: any;
}) {
return (
<>
- {/*
- }
- >
- {children}
- */}
-
-
+
{children}
diff --git a/src/app_modules/vote/detail/main/index.tsx b/src/app_modules/vote/detail/main/index.tsx
index 5f81ae5b..216d63db 100644
--- a/src/app_modules/vote/detail/main/index.tsx
+++ b/src/app_modules/vote/detail/main/index.tsx
@@ -9,9 +9,11 @@ import {
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
+import { Comp_SetInnerHTML } from "@/app_modules/_global/component/new/comp_set_inner_html";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
import { IRealtimeData } from "@/lib/global_state";
import { clientLogger } from "@/util/clientLogger";
@@ -41,14 +43,9 @@ import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_votin
import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
import { MODEL_VOTING } from "../../model/interface";
-import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
-import { Comp_SetInnerHTML } from "@/app_modules/_global/component/new/comp_set_inner_html";
+import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
-export default function Vote_MainDetail({
- userLoginId,
-}: {
- userLoginId: string;
-}) {
+export default function Vote_MainDetail() {
const params = useParams<{ id: string }>();
const today = new Date();
const [data, setData] = useState(null);
@@ -59,12 +56,13 @@ export default function Vote_MainDetail({
);
const [isLoading, setLoading] = useState(false);
-
const [isKontributor, setIsKontributor] = useState(null);
+ const [userLoginId, setUserLoginId] = useState(null);
useShallowEffect(() => {
onLoadData();
onLoadHasil();
+ handleGetUserId();
}, []);
async function onLoadData() {
@@ -100,6 +98,18 @@ export default function Vote_MainDetail({
onLoadPilihan();
}, []);
+ async function handleGetUserId() {
+ try {
+ const respone = await apiNewGetUserIdByToken();
+
+ if (respone) {
+ setUserLoginId(respone.userId);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data detail", error);
+ }
+ }
+
async function onCheckKontribusi() {
try {
const respone = await apiCheckKontributorToOneVoting({
diff --git a/src/app_modules/vote/detail/main/layout.tsx b/src/app_modules/vote/detail/main/layout.tsx
index eef3557e..86394e4e 100644
--- a/src/app_modules/vote/detail/main/layout.tsx
+++ b/src/app_modules/vote/detail/main/layout.tsx
@@ -9,37 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
export default function LayoutVote_MainDetail({
children,
- votingId,
- userLoginId,
- dataVoting,
}: {
children: React.ReactNode;
- votingId: string;
- userLoginId: string;
- dataVoting: any;
}) {
return (
<>
- {/*
- }
- >
- {children}
- */}
-
+
{children}
diff --git a/src/app_modules/vote/detail/publish/index.tsx b/src/app_modules/vote/detail/publish/index.tsx
index d44049f7..05d0c9d0 100644
--- a/src/app_modules/vote/detail/publish/index.tsx
+++ b/src/app_modules/vote/detail/publish/index.tsx
@@ -4,22 +4,45 @@ import { Badge, Center, Stack } from "@mantine/core";
import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import { MODEL_VOTING } from "../../model/interface";
+import { apiGetOneVotingById } from "../../_lib/api_voting";
+import { useParams } from "next/navigation";
+import { useState } from "react";
+import { useShallowEffect } from "@mantine/hooks";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+
+export default function Vote_DetailPublish() {
+ const { id } = useParams();
+ const [data, setData] = useState();
+
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const response = await apiGetOneVotingById({ id: id as string });
+ if (response) {
+ setData(response.data);
+ } else {
+ setData(null);
+ }
+ } catch (error) {
+ console.log(error);
+ }
+ }
+
+ if (!data) return ;
-export default function Vote_DetailPublish({
- dataVote,
-}: {
- dataVote: MODEL_VOTING;
-}) {
return (
<>
-
-
- {dataVote?.isArsip ? "Arsip" : "Publish"}
+
+
+ {data?.isArsip ? "Arsip" : "Publish"}
-
-
+
+
>
);
diff --git a/src/app_modules/vote/detail/publish/layout.tsx b/src/app_modules/vote/detail/publish/layout.tsx
index 73d4ab6e..c698cd62 100644
--- a/src/app_modules/vote/detail/publish/layout.tsx
+++ b/src/app_modules/vote/detail/publish/layout.tsx
@@ -9,38 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
export default function LayoutVote_DetailPublish({
children,
- votingId,
- userLoginId,
- dataVoting,
}: {
children: React.ReactNode;
- votingId: string;
- userLoginId: string;
- dataVoting: any;
}) {
return (
<>
- {/*
- }
- >
- {children}
- */}
-
-
+
{children}
diff --git a/src/app_modules/vote/detail/riwayat_saya/index.tsx b/src/app_modules/vote/detail/riwayat_saya/index.tsx
index 6f1ab681..0a064fbc 100644
--- a/src/app_modules/vote/detail/riwayat_saya/index.tsx
+++ b/src/app_modules/vote/detail/riwayat_saya/index.tsx
@@ -16,13 +16,7 @@ import {
} from "../../_lib/api_voting";
import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
-export default function Vote_DetailRiwayatSaya({
- dataVote,
- listKontributor,
-}: {
- dataVote: MODEL_VOTING;
- listKontributor: any[];
-}) {
+export default function Vote_DetailRiwayatSaya() {
const params = useParams<{ id: string }>();
const [data, setData] = useState(null);
const [hasil, setHasil] = useState(null);
diff --git a/src/app_modules/vote/detail/semua_riwayat/layout.tsx b/src/app_modules/vote/detail/semua_riwayat/layout.tsx
index 18e28634..50caffb1 100644
--- a/src/app_modules/vote/detail/semua_riwayat/layout.tsx
+++ b/src/app_modules/vote/detail/semua_riwayat/layout.tsx
@@ -11,39 +11,19 @@ import { IconDots } from "@tabler/icons-react";
import React, { useState } from "react";
import { Component_Header } from "@/app_modules/_global/component/new/component_header";
import UI_NewLayoutTamplate, { UI_NewHeader, UI_NewChildren } from "@/app_modules/_global/ui/V2_layout_tamplate";
+import { useParams } from "next/navigation";
export default function LayoutVote_DetailSemuaRiwayat({
children,
- votingId,
- userLoginId,
}: {
children: React.ReactNode;
- votingId: string;
- userLoginId: string;
}) {
+ const params = useParams<{ id: string }>();
+ const votingId = params.id;
const [openDrawer, setOpenDrawer] = useState(false);
return (
<>
- {/* {
- setOpenDrawer(true);
- }}
- >
-
-
- }
- />
- }
- >
- {children}
- */}