fix voting
deskripsi: - ubah metode pemanggilan data dari SSR menjadi metode API , pada page: detail all No Issue
This commit is contained in:
@@ -1,28 +1,14 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { LayoutVote_DetailKontribusi } from "@/app_modules/vote";
|
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";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
params,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { id: string };
|
|
||||||
}) {
|
}) {
|
||||||
const votingId = params.id;
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
const dataVoting = await voting_funGetOneVotingbyId(votingId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutVote_DetailKontribusi
|
<LayoutVote_DetailKontribusi>{children}</LayoutVote_DetailKontribusi>
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</LayoutVote_DetailKontribusi>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,14 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { LayoutVote_MainDetail } from "@/app_modules/vote";
|
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";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
params,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { id: string };
|
|
||||||
}) {
|
}) {
|
||||||
const votingId = params.id;
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
const dataVoting = await voting_funGetOneVotingbyId(votingId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutVote_MainDetail
|
<LayoutVote_MainDetail>{children}</LayoutVote_MainDetail>
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</LayoutVote_MainDetail>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { Vote_MainDetail } from "@/app_modules/vote";
|
import { Vote_MainDetail } from "@/app_modules/vote";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Vote_MainDetail
|
<Vote_MainDetail />
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,14 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { LayoutVote_DetailPublish } from "@/app_modules/vote";
|
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";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
params,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { id: string };
|
|
||||||
}) {
|
}) {
|
||||||
const votingId = params.id;
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
const dataVoting = await voting_funGetOneVotingbyId(votingId);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutVote_DetailPublish
|
<LayoutVote_DetailPublish>{children}</LayoutVote_DetailPublish>
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</LayoutVote_DetailPublish>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { Vote_DetailPublish } from "@/app_modules/vote";
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Vote_DetailPublish dataVote={dataVote as any} />
|
<Vote_DetailPublish />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
import { Vote_DetailRiwayatSaya } from "@/app_modules/vote";
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Vote_DetailRiwayatSaya
|
<Vote_DetailRiwayatSaya />
|
||||||
dataVote={dataVote as any}
|
|
||||||
listKontributor={listKontributor}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,14 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { LayoutVote_DetailSemuaRiwayat } from "@/app_modules/vote";
|
import { LayoutVote_DetailSemuaRiwayat } from "@/app_modules/vote";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
params,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { id: string };
|
|
||||||
}) {
|
}) {
|
||||||
const votingId = params.id;
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutVote_DetailSemuaRiwayat
|
<LayoutVote_DetailSemuaRiwayat>{children}</LayoutVote_DetailSemuaRiwayat>
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId as string}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</LayoutVote_DetailSemuaRiwayat>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { RouterVote } from "@/lib/router_hipmi/router_vote";
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
|
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_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
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 {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Button,
|
Button,
|
||||||
@@ -14,55 +17,84 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
IconArchive,
|
IconArchive,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
IconUsersGroup,
|
IconUsersGroup,
|
||||||
IconX,
|
IconX,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { apiGetOneVotingById } from "../../_lib/api_voting";
|
||||||
import { voting_funUpdateIsArsipById } from "../../fun";
|
import { voting_funUpdateIsArsipById } from "../../fun";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
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({
|
export function Voting_ComponentLayoutHeaderDetailPublish({
|
||||||
votingId,
|
|
||||||
title,
|
title,
|
||||||
userLoginId,
|
|
||||||
dataVoting,
|
|
||||||
}: {
|
}: {
|
||||||
votingId: string;
|
|
||||||
title: string;
|
title: string;
|
||||||
userLoginId: string;
|
|
||||||
dataVoting: any;
|
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState<MODEL_VOTING>(dataVoting);
|
const router = useRouter();
|
||||||
|
const { id } = useParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
async function onUpdateStatusArsip({ isArsip }: { isArsip: boolean }) {
|
const [data, setData] = useState<MODEL_VOTING | null | any>();
|
||||||
setIsLoading(true);
|
const [userLoginId, setUserLoginId] = useState<string | null>(null);
|
||||||
const res = await voting_funUpdateIsArsipById({
|
|
||||||
votingId,
|
useShallowEffect(() => {
|
||||||
isArsip: isArsip,
|
handleGetUserId();
|
||||||
});
|
onLoadData();
|
||||||
if (res.status === 200) {
|
}, []);
|
||||||
try {
|
|
||||||
const loadData = await voting_funGetOneVotingbyId(votingId);
|
async function handleGetUserId() {
|
||||||
setData(loadData as any);
|
try {
|
||||||
} catch (error) {
|
const respone = await apiNewGetUserIdByToken();
|
||||||
console.log(error);
|
|
||||||
} finally {
|
if (respone) {
|
||||||
setOpenModal(false);
|
setUserLoginId(respone.userId);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
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);
|
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({
|
|||||||
<Component_Header
|
<Component_Header
|
||||||
title={title}
|
title={title}
|
||||||
customButtonRight={
|
customButtonRight={
|
||||||
<ActionIcon
|
userLoginId ? (
|
||||||
variant="transparent"
|
<ActionIcon
|
||||||
onClick={() => {
|
variant="transparent"
|
||||||
setOpenDrawer(true);
|
onClick={() => {
|
||||||
}}
|
setOpenDrawer(true);
|
||||||
>
|
}}
|
||||||
<IconDotsVertical color="white" />
|
>
|
||||||
</ActionIcon>
|
<IconDotsVertical color="white" />
|
||||||
|
</ActionIcon>
|
||||||
|
) : (
|
||||||
|
<CustomSkeleton circle height={24} width={24} />
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -123,14 +159,14 @@ export function Voting_ComponentLayoutHeaderDetailPublish({
|
|||||||
{/* Check Author */}
|
{/* Check Author */}
|
||||||
{data?.authorId === userLoginId ? (
|
{data?.authorId === userLoginId ? (
|
||||||
<BoxIsAuthor
|
<BoxIsAuthor
|
||||||
votingId={votingId}
|
votingId={id as string}
|
||||||
onSetDrawer={(val: any) => {
|
onSetDrawer={(val: any) => {
|
||||||
setOpenDrawer(val.drawer);
|
setOpenDrawer(val.drawer);
|
||||||
setOpenModal(val.modal);
|
setOpenModal(val.modal);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<BoxNotAuthor votingId={votingId} />
|
<BoxNotAuthor votingId={id as string} />
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
@@ -9,38 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
|
|||||||
|
|
||||||
export default function LayoutVote_DetailKontribusi({
|
export default function LayoutVote_DetailKontribusi({
|
||||||
children,
|
children,
|
||||||
votingId,
|
|
||||||
userLoginId,
|
|
||||||
dataVoting,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
votingId: string;
|
|
||||||
userLoginId: string;
|
|
||||||
dataVoting: any;
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
title="Detail Kontribusi"
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
votingId={votingId}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Kontributor" />
|
||||||
dataVoting={dataVoting}
|
|
||||||
title="Detail Kontributor"
|
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
|
||||||
</UI_NewHeader>
|
</UI_NewHeader>
|
||||||
<UI_NewChildren>{children}</UI_NewChildren>
|
<UI_NewChildren>{children}</UI_NewChildren>
|
||||||
</UI_NewLayoutTamplate>
|
</UI_NewLayoutTamplate>
|
||||||
|
|||||||
@@ -9,9 +9,11 @@ import {
|
|||||||
ComponentGlobal_CardStyles,
|
ComponentGlobal_CardStyles,
|
||||||
} from "@/app_modules/_global/component";
|
} from "@/app_modules/_global/component";
|
||||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
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_NotifikasiGagal } from "@/app_modules/_global/notif_global";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
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 notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||||
import { IRealtimeData } from "@/lib/global_state";
|
import { IRealtimeData } from "@/lib/global_state";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
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 { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
|
||||||
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
|
||||||
import { Comp_SetInnerHTML } from "@/app_modules/_global/component/new/comp_set_inner_html";
|
|
||||||
|
|
||||||
export default function Vote_MainDetail({
|
export default function Vote_MainDetail() {
|
||||||
userLoginId,
|
|
||||||
}: {
|
|
||||||
userLoginId: string;
|
|
||||||
}) {
|
|
||||||
const params = useParams<{ id: string }>();
|
const params = useParams<{ id: string }>();
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const [data, setData] = useState<MODEL_VOTING | null>(null);
|
const [data, setData] = useState<MODEL_VOTING | null>(null);
|
||||||
@@ -59,12 +56,13 @@ export default function Vote_MainDetail({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
const [isKontributor, setIsKontributor] = useState<boolean | null>(null);
|
const [isKontributor, setIsKontributor] = useState<boolean | null>(null);
|
||||||
|
const [userLoginId, setUserLoginId] = useState<string | null>(null);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoadData();
|
onLoadData();
|
||||||
onLoadHasil();
|
onLoadHasil();
|
||||||
|
handleGetUserId();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function onLoadData() {
|
async function onLoadData() {
|
||||||
@@ -100,6 +98,18 @@ export default function Vote_MainDetail({
|
|||||||
onLoadPilihan();
|
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() {
|
async function onCheckKontribusi() {
|
||||||
try {
|
try {
|
||||||
const respone = await apiCheckKontributorToOneVoting({
|
const respone = await apiCheckKontributorToOneVoting({
|
||||||
|
|||||||
@@ -9,37 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
|
|||||||
|
|
||||||
export default function LayoutVote_MainDetail({
|
export default function LayoutVote_MainDetail({
|
||||||
children,
|
children,
|
||||||
votingId,
|
|
||||||
userLoginId,
|
|
||||||
dataVoting,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
votingId: string;
|
|
||||||
userLoginId: string;
|
|
||||||
dataVoting: any;
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
|
||||||
title="Detail Voting"
|
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Voting" />
|
||||||
dataVoting={dataVoting}
|
|
||||||
title="Detail Voting"
|
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
|
||||||
</UI_NewHeader>
|
</UI_NewHeader>
|
||||||
<UI_NewChildren>{children}</UI_NewChildren>
|
<UI_NewChildren>{children}</UI_NewChildren>
|
||||||
</UI_NewLayoutTamplate>
|
</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_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
|
||||||
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
|
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack py={"md"}>
|
<Stack py={"md"}>
|
||||||
<Center >
|
<Center>
|
||||||
<Badge color={dataVote?.isArsip ? "gray" : "green"}>
|
<Badge color={data?.isArsip ? "gray" : "green"}>
|
||||||
{dataVote?.isArsip ? "Arsip" : "Publish"}
|
{data?.isArsip ? "Arsip" : "Publish"}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Center>
|
</Center>
|
||||||
<ComponentVote_DetailDataSetelahPublish data={dataVote} />
|
<ComponentVote_DetailDataSetelahPublish data={data as any} />
|
||||||
<ComponentVote_HasilVoting data={dataVote.Voting_DaftarNamaVote} />
|
<ComponentVote_HasilVoting data={data?.Voting_DaftarNamaVote} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,38 +9,14 @@ import { Voting_ComponentLayoutHeaderDetailPublish } from "../../component";
|
|||||||
|
|
||||||
export default function LayoutVote_DetailPublish({
|
export default function LayoutVote_DetailPublish({
|
||||||
children,
|
children,
|
||||||
votingId,
|
|
||||||
userLoginId,
|
|
||||||
dataVoting,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
votingId: string;
|
|
||||||
userLoginId: string;
|
|
||||||
dataVoting: any;
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <UIGlobal_LayoutTamplate
|
|
||||||
header={
|
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
|
||||||
dataVoting={dataVoting}
|
|
||||||
title="Detail Publish"
|
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</UIGlobal_LayoutTamplate> */}
|
|
||||||
|
|
||||||
<UI_NewLayoutTamplate>
|
<UI_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
<Voting_ComponentLayoutHeaderDetailPublish
|
<Voting_ComponentLayoutHeaderDetailPublish title="Detail Publish" />
|
||||||
dataVoting={dataVoting}
|
|
||||||
title="Detail Publish"
|
|
||||||
votingId={votingId}
|
|
||||||
userLoginId={userLoginId}
|
|
||||||
/>
|
|
||||||
</UI_NewHeader>
|
</UI_NewHeader>
|
||||||
<UI_NewChildren>{children}</UI_NewChildren>
|
<UI_NewChildren>{children}</UI_NewChildren>
|
||||||
</UI_NewLayoutTamplate>
|
</UI_NewLayoutTamplate>
|
||||||
|
|||||||
@@ -16,13 +16,7 @@ import {
|
|||||||
} from "../../_lib/api_voting";
|
} from "../../_lib/api_voting";
|
||||||
import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
|
import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
|
||||||
|
|
||||||
export default function Vote_DetailRiwayatSaya({
|
export default function Vote_DetailRiwayatSaya() {
|
||||||
dataVote,
|
|
||||||
listKontributor,
|
|
||||||
}: {
|
|
||||||
dataVote: MODEL_VOTING;
|
|
||||||
listKontributor: any[];
|
|
||||||
}) {
|
|
||||||
const params = useParams<{ id: string }>();
|
const params = useParams<{ id: string }>();
|
||||||
const [data, setData] = useState<MODEL_VOTING | null>(null);
|
const [data, setData] = useState<MODEL_VOTING | null>(null);
|
||||||
const [hasil, setHasil] = useState<any[] | 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 React, { useState } from "react";
|
||||||
import { Component_Header } from "@/app_modules/_global/component/new/component_header";
|
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 UI_NewLayoutTamplate, { UI_NewHeader, UI_NewChildren } from "@/app_modules/_global/ui/V2_layout_tamplate";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
|
||||||
export default function LayoutVote_DetailSemuaRiwayat({
|
export default function LayoutVote_DetailSemuaRiwayat({
|
||||||
children,
|
children,
|
||||||
votingId,
|
|
||||||
userLoginId,
|
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
votingId: string;
|
|
||||||
userLoginId: string;
|
|
||||||
}) {
|
}) {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const votingId = params.id;
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
|
||||||
return (
|
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_NewLayoutTamplate>
|
||||||
<UI_NewHeader>
|
<UI_NewHeader>
|
||||||
|
|||||||
Reference in New Issue
Block a user