fix event & voting
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import { Event_DetailReject } from "@/app_modules/event";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
let eventId = params.id
|
||||
const dataEvent = await event_getOneById(eventId)
|
||||
|
||||
return <Event_DetailReject dataEvent={dataEvent as any}/>;
|
||||
export default async function Page() {
|
||||
return <Event_DetailReject/>;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Event_DetailReview } from "@/app_modules/event";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
let eventId = params.id
|
||||
const dataEvent = await event_getOneById(eventId)
|
||||
|
||||
return <Event_DetailReview dataEvent={dataEvent as any}/>;
|
||||
export default async function Page() {
|
||||
return <Event_DetailReview />;
|
||||
}
|
||||
|
||||
@@ -3,25 +3,23 @@ import {
|
||||
ComponentGlobal_CardStyles,
|
||||
} from "@/app_modules/_global/component";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Center,
|
||||
Group,
|
||||
Stack,
|
||||
Text,
|
||||
Loader,
|
||||
Paper,
|
||||
Box,
|
||||
Text
|
||||
} from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import { MODEL_VOTE_KONTRIBUTOR } from "../model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { apiGetKontributorById } from "../_lib/api_voting";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetKontributorById } from "../_lib/api_voting";
|
||||
import { Voting_ComponentSkeletonDaftarKontributor } from "../component/skeleton_view";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { MODEL_VOTE_KONTRIBUTOR } from "../model/interface";
|
||||
|
||||
export function Voting_ViewDetailKontributorVoting() {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -47,6 +45,23 @@ export function Voting_ViewDetailKontributorVoting() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleMoreData = async () => {
|
||||
try {
|
||||
const nextPage = activePage + 1;
|
||||
const respone = await apiGetKontributorById({
|
||||
id: params.id,
|
||||
page: `${nextPage}`,
|
||||
});
|
||||
|
||||
if (respone) {
|
||||
setActivePage(nextPage);
|
||||
return respone.data;
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data kontributor", error);
|
||||
}
|
||||
};
|
||||
|
||||
if (_.isNull(data)) {
|
||||
return <Voting_ComponentSkeletonDaftarKontributor />;
|
||||
}
|
||||
@@ -66,16 +81,7 @@ export function Voting_ViewDetailKontributorVoting() {
|
||||
)}
|
||||
data={data}
|
||||
setData={setData as any}
|
||||
moreData={async () => {
|
||||
const respone = await apiGetKontributorById({
|
||||
id: params.id,
|
||||
page: `${activePage + 1}`,
|
||||
});
|
||||
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
return respone.data;
|
||||
}}
|
||||
moreData={handleMoreData}
|
||||
>
|
||||
{(item) => (
|
||||
<ComponentGlobal_CardStyles>
|
||||
@@ -102,25 +108,6 @@ export function Voting_ViewDetailKontributorVoting() {
|
||||
</ComponentGlobal_CardStyles>
|
||||
)}
|
||||
</ScrollOnly>
|
||||
|
||||
{/* {data?.map((e, i) => (
|
||||
<ComponentGlobal_AvatarAndUsername
|
||||
key={e.id}
|
||||
profile={e.Author.Profile as any}
|
||||
component={
|
||||
<Group position="right">
|
||||
<Badge w={130}>
|
||||
<Text
|
||||
lineClamp={1}
|
||||
fz={e.Voting_DaftarNamaVote.value.length > 10 ? 8 : 10}
|
||||
>
|
||||
{e.Voting_DaftarNamaVote.value}
|
||||
</Text>
|
||||
</Badge>
|
||||
</Group>
|
||||
}
|
||||
/>
|
||||
))} */}
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
@@ -14,6 +13,7 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_glo
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||
import { IRealtimeData } from "@/lib/global_state";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Badge,
|
||||
@@ -41,6 +41,7 @@ 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";
|
||||
|
||||
export default function Vote_MainDetail({
|
||||
userLoginId,
|
||||
@@ -56,6 +57,8 @@ export default function Vote_MainDetail({
|
||||
null
|
||||
);
|
||||
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [isKontributor, setIsKontributor] = useState<boolean | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
@@ -128,6 +131,7 @@ export default function Vote_MainDetail({
|
||||
|
||||
async function onVote() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await Vote_funCreateHasil({
|
||||
pilihanVotingId: pilihanVotingId,
|
||||
votingId: params.id,
|
||||
@@ -183,10 +187,12 @@ export default function Vote_MainDetail({
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error vote", error);
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal("Gagal melakukan voting");
|
||||
}
|
||||
}
|
||||
@@ -247,6 +253,7 @@ export default function Vote_MainDetail({
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
{isKontributor ? (
|
||||
<Stack
|
||||
align="center"
|
||||
@@ -258,7 +265,11 @@ export default function Vote_MainDetail({
|
||||
<Text mb={"sm"} fw={"bold"} fz={"xs"}>
|
||||
Pilihan anda:
|
||||
</Text>
|
||||
<Badge size="lg">{pilihanKontributor}</Badge>
|
||||
{pilihanKontributor ? (
|
||||
<Badge size="lg">{pilihanKontributor}</Badge>
|
||||
) : (
|
||||
<CustomSkeleton height={30} width={70} radius="xl" />
|
||||
)}
|
||||
</Stack>
|
||||
) : (
|
||||
<Stack
|
||||
@@ -308,6 +319,8 @@ export default function Vote_MainDetail({
|
||||
|
||||
<Center>
|
||||
<Button
|
||||
loading={isLoading}
|
||||
loaderPosition="center"
|
||||
style={{
|
||||
transition: "all 0.3s ease-in-out",
|
||||
}}
|
||||
@@ -330,4 +343,4 @@ export default function Vote_MainDetail({
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user