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