fix voting
deskripsi: - ubah metode pemanggilan data dari SSR menjadi metode API , pada page: detail all No Issue
This commit is contained in:
@@ -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 (
|
||||
<>
|
||||
{/* <UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
dataVoting={dataVoting}
|
||||
title="Detail Kontribusi"
|
||||
userLoginId={userLoginId}
|
||||
votingId={votingId}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</UIGlobal_LayoutTamplate> */}
|
||||
|
||||
<UI_NewLayoutTamplate>
|
||||
<UI_NewHeader>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
dataVoting={dataVoting}
|
||||
title="Detail Kontributor"
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Kontributor" />
|
||||
</UI_NewHeader>
|
||||
<UI_NewChildren>{children}</UI_NewChildren>
|
||||
</UI_NewLayoutTamplate>
|
||||
|
||||
@@ -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<MODEL_VOTING | null>(null);
|
||||
@@ -59,12 +56,13 @@ export default function Vote_MainDetail({
|
||||
);
|
||||
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [isKontributor, setIsKontributor] = useState<boolean | null>(null);
|
||||
const [userLoginId, setUserLoginId] = useState<string | null>(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({
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
{/* <UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
title="Detail Voting"
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
dataVoting={dataVoting}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</UIGlobal_LayoutTamplate> */}
|
||||
<UI_NewLayoutTamplate>
|
||||
<UI_NewHeader>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
dataVoting={dataVoting}
|
||||
title="Detail Voting"
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Voting" />
|
||||
</UI_NewHeader>
|
||||
<UI_NewChildren>{children}</UI_NewChildren>
|
||||
</UI_NewLayoutTamplate>
|
||||
|
||||
@@ -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<MODEL_VOTING | null>();
|
||||
|
||||
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 <CustomSkeleton height={400} />;
|
||||
|
||||
export default function Vote_DetailPublish({
|
||||
dataVote,
|
||||
}: {
|
||||
dataVote: MODEL_VOTING;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack py={"md"}>
|
||||
<Center >
|
||||
<Badge color={dataVote?.isArsip ? "gray" : "green"}>
|
||||
{dataVote?.isArsip ? "Arsip" : "Publish"}
|
||||
<Center>
|
||||
<Badge color={data?.isArsip ? "gray" : "green"}>
|
||||
{data?.isArsip ? "Arsip" : "Publish"}
|
||||
</Badge>
|
||||
</Center>
|
||||
<ComponentVote_DetailDataSetelahPublish data={dataVote} />
|
||||
<ComponentVote_HasilVoting data={dataVote.Voting_DaftarNamaVote} />
|
||||
<ComponentVote_DetailDataSetelahPublish data={data as any} />
|
||||
<ComponentVote_HasilVoting data={data?.Voting_DaftarNamaVote} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
{/* <UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
dataVoting={dataVoting}
|
||||
title="Detail Publish"
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</UIGlobal_LayoutTamplate> */}
|
||||
|
||||
<UI_NewLayoutTamplate>
|
||||
<UI_NewHeader>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish
|
||||
dataVoting={dataVoting}
|
||||
title="Detail Publish"
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Publish" />
|
||||
</UI_NewHeader>
|
||||
<UI_NewChildren>{children}</UI_NewChildren>
|
||||
</UI_NewLayoutTamplate>
|
||||
|
||||
@@ -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<MODEL_VOTING | null>(null);
|
||||
const [hasil, setHasil] = useState<any[] | null>(null);
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
{/* <UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="Detail Riwayat"
|
||||
customButtonRight={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenDrawer(true);
|
||||
}}
|
||||
>
|
||||
<IconDotsVertical color="white" />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</UIGlobal_LayoutTamplate> */}
|
||||
|
||||
<UI_NewLayoutTamplate>
|
||||
<UI_NewHeader>
|
||||
|
||||
Reference in New Issue
Block a user