Layouts & Navigation - app/(application)/_layout.tsx - app/(application)/(user)/_layout.tsx - app/(application)/(user)/event/(tabs)/_layout.tsx - app/(application)/(user)/job/(tabs)/_layout.tsx - app/(application)/(user)/voting/(tabs)/_layout.tsx - app/(application)/(user)/portofolio/_layout.tsx - app/(application)/(user)/profile/_layout.tsx - app/(application)/admin/_layout.tsx - app/+not-found.tsx User – File - app/(application)/(file)/[id].tsx User – Collaboration - app/(application)/(user)/collaboration/[id]/index.tsx - app/(application)/(user)/collaboration/[id]/detail-project-main.tsx - app/(application)/(user)/collaboration/[id]/detail-participant.tsx - app/(application)/(user)/collaboration/[id]/[detail]/info.tsx - app/(application)/(user)/collaboration/[id]/[detail]/room-chat.tsx User – Donation - app/(application)/(user)/donation/[id]/index.tsx - app/(application)/(user)/donation/[id]/[status]/detail.tsx - app/(application)/(user)/donation/[id]/(news)/[news]/index.tsx User – Event - app/(application)/(user)/event/[id]/[status]/detail-event.tsx - app/(application)/(user)/event/[id]/confirmation.tsx - app/(application)/(user)/event/[id]/contribution.tsx - app/(application)/(user)/event/[id]/history.tsx - app/(application)/(user)/event/[id]/publish.tsx User – Investment - app/(application)/(user)/investment/[id]/index.tsx - app/(application)/(user)/investment/[id]/[status]/detail.tsx - app/(application)/(user)/investment/[id]/(my-holding)/[id].tsx - app/(application)/(user)/investment/[id]/(news)/[news]/index.tsx User – Job - app/(application)/(user)/job/[id]/[status]/detail.tsx User – Portofolio - app/(application)/(user)/portofolio/[id]/index.tsx User – Profile - app/(application)/(user)/profile/[id]/index.tsx User – Voting - app/(application)/(user)/voting/[id]/index.tsx - app/(application)/(user)/voting/[id]/[status]/detail.tsx - app/(application)/(user)/voting/[id]/contribution.tsx - app/(application)/(user)/voting/[id]/history.tsx Components - components/Button/BackButtonFromNotification.tsx - components/_ShareComponent/AppHeader.tsx Admin Screens - screens/Admin/Notification-Admin/ScreenNotificationAdmin.tsx - screens/Admin/Notification-Admin/ScreenNotificationAdmin2.tsx Screens – Donation - screens/Donation/ScreenListOfNews.tsx - screens/Donation/ScreenRecapOfNews.tsx Screens – Forum - screens/Forum/ViewBeranda.tsx - screens/Forum/ViewBeranda2.tsx - screens/Forum/ViewBeranda3.tsx Screens – Investment - screens/Invesment/Document/ScreenRecapOfDocument.tsx - screens/Invesment/News/ScreenListOfNews.tsx - screens/Invesment/News/ScreenRecapOfNews.tsx Screens – Notification - screens/Notification/ScreenNotification_V1.tsx - screens/Notification/ScreenNotification_V2.tsx iOS - ios/HIPMIBadungConnect.xcodeproj/project.pbxproj Docs - QWEN.md ### Issue: Tabs can't clicked
141 lines
3.8 KiB
TypeScript
141 lines
3.8 KiB
TypeScript
/* eslint-disable react-hooks/exhaustive-deps */
|
|
import {
|
|
AvatarUsernameAndOtherComponent,
|
|
BackButton,
|
|
DotButton,
|
|
DrawerCustom,
|
|
LoaderCustom,
|
|
MenuDrawerDynamicGrid,
|
|
Spacing,
|
|
ViewWrapper,
|
|
} from "@/components";
|
|
import AppHeader from "@/components/_ShareComponent/AppHeader";
|
|
import { IconContribution } from "@/components/_Icon";
|
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
|
import { Voting_BoxDetailHistorySection } from "@/screens/Voting/BoxDetailHistorySection";
|
|
import {
|
|
apiVotingContribution,
|
|
apiVotingGetOne,
|
|
} from "@/service/api-client/api-voting";
|
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export default function VotingDetailHistory() {
|
|
const { id } = useLocalSearchParams();
|
|
const { user } = useAuth();
|
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
|
|
|
const [data, setData] = useState<any>(null);
|
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
|
const [nameChoice, setNameChoice] = useState("");
|
|
|
|
useEffect(() => {
|
|
handlerLoadData();
|
|
}, [id, user?.id]);
|
|
|
|
async function handlerLoadData() {
|
|
try {
|
|
setLoadingGetData(true);
|
|
await onLoadData();
|
|
await onLoadCheckContribution();
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
} finally {
|
|
setLoadingGetData(false);
|
|
}
|
|
}
|
|
|
|
const onLoadData = async () => {
|
|
try {
|
|
const response = await apiVotingGetOne({ id: id as string });
|
|
if (response.success) {
|
|
setData(response.data);
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
};
|
|
|
|
const onLoadCheckContribution = async () => {
|
|
try {
|
|
const response = await apiVotingContribution({
|
|
id: id as string,
|
|
authorId: user?.id as string,
|
|
category: "checked",
|
|
});
|
|
|
|
if (response.success) {
|
|
setNameChoice(response.data.nameChoice);
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
};
|
|
|
|
const handlePressPublish = (item: IMenuDrawerItem) => {
|
|
router.navigate(item.path as any);
|
|
setOpenDrawerPublish(false);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Stack.Screen
|
|
options={{
|
|
header: () => (
|
|
<AppHeader
|
|
title="Riwayat Voting"
|
|
left={<BackButton />}
|
|
right={
|
|
<DotButton onPress={() => setOpenDrawerPublish(true)} />
|
|
}
|
|
/>
|
|
),
|
|
}}
|
|
/>
|
|
<ViewWrapper>
|
|
{loadingGetData ? (
|
|
<LoaderCustom />
|
|
) : (
|
|
<>
|
|
<Voting_BoxDetailHistorySection
|
|
data={data}
|
|
nameChoice={nameChoice}
|
|
headerAvatar={
|
|
<AvatarUsernameAndOtherComponent
|
|
avatar={data?.Author?.Profile?.imageId || ""}
|
|
name={data?.Author?.username || "Username"}
|
|
avatarHref={`/profile/${data?.Author?.Profile?.id}`}
|
|
/>
|
|
}
|
|
/>
|
|
<Voting_BoxDetailHasilVotingSection
|
|
listData={data?.Voting_DaftarNamaVote}
|
|
/>
|
|
<Spacing />
|
|
</>
|
|
)}
|
|
</ViewWrapper>
|
|
|
|
{/* ========= Publish Drawer ========= */}
|
|
<DrawerCustom
|
|
isVisible={openDrawerPublish}
|
|
closeDrawer={() => setOpenDrawerPublish(false)}
|
|
height={"auto"}
|
|
>
|
|
<MenuDrawerDynamicGrid
|
|
data={[
|
|
{
|
|
icon: <IconContribution />,
|
|
label: "Daftar Kontributor",
|
|
path: `/voting/${id}/list-of-contributor`,
|
|
},
|
|
]}
|
|
onPressItem={handlePressPublish as any}
|
|
/>
|
|
</DrawerCustom>
|
|
</>
|
|
);
|
|
}
|