import { AlertDefaultSystem, BadgeCustom, BoxWithHeaderSection, ButtonCustom, Spacing, StackCustom, TextCustom } from "@/components"; import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom"; import { apiVotingVote } from "@/service/api-client/api-voting"; import { today } from "@/utils/dateTimeView"; import { router } from "expo-router"; import { useState } from "react"; import { View } from "react-native"; import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection"; export function Voting_BoxDetailPublishSection({ headerAvatar, data, userId, isContribution, nameChoice, }: { headerAvatar?: React.ReactNode; data?: any; userId: string; isContribution?: boolean; nameChoice?: string; }) { const [value, setValue] = useState(""); const handlerSubmitVote = async () => { const newData = { chooseId: value, userId: userId, }; try { const response = await apiVotingVote({ id: data?.id, data: newData, }); if (response.success) { router.push(`/voting/${data?.id}/list-of-contributor`); } } catch (error) { console.log("[ERROR]", error); } }; return ( <> {headerAvatar && ( <> {headerAvatar} )} {isContribution ? ( Pilihan Anda : {nameChoice || "-"} ) : ( <> Pilihan : {data?.Voting_DaftarNamaVote?.map((item: any, i: number) => ( ))} { AlertDefaultSystem({ title: "Anda melaukan voting", message: "Yakin dengan pilihan anda ini ?", textLeft: "Batal", textRight: "Ya", onPressRight: () => handlerSubmitVote(), }); }} > Vote )} ); }