From 7651f786f951cb56f83086f9d0f1d5ed83dc3a27 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 27 Feb 2025 16:58:17 +0800 Subject: [PATCH 1/3] fix event button and list peserta --- .../api/admin/event/status/[name]/route.ts | 126 ++-------- src/app/dev/event/detail/draft/[id]/page.tsx | 7 +- .../dev/event/detail/kontribusi/[id]/page.tsx | 13 +- .../dev/event/detail/peserta/[id]/page.tsx | 6 - .../dev/event/detail/publish/[id]/page.tsx | 18 +- .../component/comp_avatar_and_username.tsx | 26 +- .../detail/comp_avatar_and_username_event.tsx | 31 +-- .../event/component/detail/detail_data.tsx | 213 ++++++++++------ .../event/component/detail/detail_main.tsx | 8 +- .../event/component/detail/list_peserta.tsx | 60 ++--- .../skeleton/comp_skeleton_detail.tsx | 4 +- .../skeleton/comp_skeleton_detail_data.tsx | 4 +- src/app_modules/event/detail/draft/index.tsx | 233 ++++++++++-------- .../event/detail/kontribusi/index.tsx | 14 +- .../event/detail/peserta/index.tsx | 112 ++++----- .../event/detail/peserta/layout.tsx | 2 +- .../event/detail/publish/index.tsx | 41 ++- src/app_modules/event/detail/reject/index.tsx | 154 +++++++----- src/app_modules/event/detail/review/index.tsx | 57 ++++- 19 files changed, 568 insertions(+), 561 deletions(-) diff --git a/src/app/api/admin/event/status/[name]/route.ts b/src/app/api/admin/event/status/[name]/route.ts index 4b7e7227..f4fb0e52 100644 --- a/src/app/api/admin/event/status/[name]/route.ts +++ b/src/app/api/admin/event/status/[name]/route.ts @@ -8,8 +8,6 @@ export async function GET( request: Request, { params }: { params: { name: string } } ) { - - const { name } = params; const { searchParams } = new URL(request.url); const search = searchParams.get("search"); @@ -21,35 +19,7 @@ export async function GET( let fixData; const fixStatus = _.startCase(name); - if (!page && !search) { - fixData = await prisma.event.findMany({ - orderBy: { - updatedAt: "desc", - }, - where: { - active: true, - isArsip: false, - EventMaster_Status: { - name: fixStatus, - }, - }, - include: { - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - name: true, - }, - }, - }, - }, - EventMaster_Status: true, - EventMaster_TipeAcara: true, - }, - }); - } else if (!page && search) { + if (!page) { fixData = await prisma.event.findMany({ orderBy: { updatedAt: "desc", @@ -61,7 +31,7 @@ export async function GET( name: fixStatus, }, title: { - contains: search, + contains: search ? search : "", mode: "insensitive", }, }, @@ -81,7 +51,7 @@ export async function GET( EventMaster_TipeAcara: true, }, }); - } else if (page && !search) { + } else { if (fixStatus === "Publish") { const getAllData = await prisma.event.findMany({ where: { @@ -111,77 +81,7 @@ export async function GET( take: takeData, skip: skipData, orderBy: { - updatedAt: "desc", - }, - where: { - active: true, - isArsip: false, - EventMaster_Status: { - name: fixStatus, - }, - }, - include: { - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - name: true, - }, - }, - }, - }, - EventMaster_Status: true, - EventMaster_TipeAcara: true, - }, - }); - - const nCount = await prisma.event.count({ - where: { - EventMaster_Status: { - name: fixStatus, - }, - active: true, - isArsip: false, - }, - }); - - fixData = { - data: data, - nPage: _.ceil(nCount / takeData), - }; - } else if (page && search) { - if (fixStatus === "Publish") { - const getAllData = await prisma.event.findMany({ - where: { - active: true, - EventMaster_Status: { - name: fixStatus, - }, - isArsip: false, - }, - }); - - for (let i of getAllData) { - if (moment(i.tanggalSelesai).diff(moment(), "minutes") < 0) { - await prisma.event.update({ - where: { - id: i.id, - }, - data: { - isArsip: true, - }, - }); - } - } - } - - const data = await prisma.event.findMany({ - take: takeData, - skip: skipData, - orderBy: { - updatedAt: "desc", + tanggal: "asc", }, where: { active: true, @@ -190,7 +90,7 @@ export async function GET( name: fixStatus, }, title: { - contains: search, + contains: search ? search : "", mode: "insensitive", }, }, @@ -215,8 +115,11 @@ export async function GET( where: { active: true, isArsip: false, + EventMaster_Status: { + name: fixStatus, + }, title: { - contains: search, + contains: search ? search : "", mode: "insensitive", }, }, @@ -228,11 +131,12 @@ export async function GET( }; } - return NextResponse.json({ - success: true, - message: `Success get data table event ${name}`, - data: fixData, - }, + return NextResponse.json( + { + success: true, + message: `Success get data table event ${name}`, + data: fixData, + }, { status: 200 } ); } catch (error) { diff --git a/src/app/dev/event/detail/draft/[id]/page.tsx b/src/app/dev/event/detail/draft/[id]/page.tsx index 87f94b9e..5a67a485 100644 --- a/src/app/dev/event/detail/draft/[id]/page.tsx +++ b/src/app/dev/event/detail/draft/[id]/page.tsx @@ -1,10 +1,7 @@ import { Event_DetailDraft } 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 } }) { - const eventId = params.id; - const dataEvent = await event_getOneById(eventId); +export default async function Page() { return ( - + ); } diff --git a/src/app/dev/event/detail/kontribusi/[id]/page.tsx b/src/app/dev/event/detail/kontribusi/[id]/page.tsx index 9a3f6028..80fd281b 100644 --- a/src/app/dev/event/detail/kontribusi/[id]/page.tsx +++ b/src/app/dev/event/detail/kontribusi/[id]/page.tsx @@ -1,18 +1,9 @@ import { Event_DetailKontribusi } from "@/app_modules/event"; -import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id"; -import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id"; -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); - // const listKontributor = await Event_getListPesertaById(eventId); - const totalPeserta = await Event_countTotalPesertaById(eventId) +export default async function Page() { return ( <> - + ); } diff --git a/src/app/dev/event/detail/peserta/[id]/page.tsx b/src/app/dev/event/detail/peserta/[id]/page.tsx index c9fe9657..fec42f21 100644 --- a/src/app/dev/event/detail/peserta/[id]/page.tsx +++ b/src/app/dev/event/detail/peserta/[id]/page.tsx @@ -1,12 +1,6 @@ import Event_DaftarPeserta from '@/app_modules/event/detail/peserta'; -import { Event_countTotalPesertaById } from '@/app_modules/event/fun/count/count_total_peserta_by_id'; -import { event_getOneById } from '@/app_modules/event/fun/get/get_one_by_id'; -import React from 'react'; export default async function Page() { - // const dataEvent = await event_getOneById(eventId); - // const totalPeserta = await Event_countTotalPesertaById(eventId); - return ( ) diff --git a/src/app/dev/event/detail/publish/[id]/page.tsx b/src/app/dev/event/detail/publish/[id]/page.tsx index 1123ede9..e17f8fe4 100644 --- a/src/app/dev/event/detail/publish/[id]/page.tsx +++ b/src/app/dev/event/detail/publish/[id]/page.tsx @@ -1,19 +1,5 @@ import { Event_DetailPublish } from "@/app_modules/event"; -import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id"; -import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id"; -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); - const totalPeserta = await Event_countTotalPesertaById(eventId); - - - return ( - - ); +export default async function Page() { + return ; } diff --git a/src/app_modules/_global/component/comp_avatar_and_username.tsx b/src/app_modules/_global/component/comp_avatar_and_username.tsx index 9fc1c0c4..5f0b7f1d 100644 --- a/src/app_modules/_global/component/comp_avatar_and_username.tsx +++ b/src/app_modules/_global/component/comp_avatar_and_username.tsx @@ -1,15 +1,15 @@ "use client"; +import { apiGetOneProfileById } from "@/app_modules/katalog/profile/lib/api_fetch_profile"; +import { RouterProfile } from "@/lib/router_hipmi/router_katalog"; import { ActionIcon, Avatar, Grid, Stack, Text } from "@mantine/core"; import { Prisma } from "@prisma/client"; import { useRouter } from "next/navigation"; import React, { useState } from "react"; +import { MainColor } from "../color"; +import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global"; import { ComponentGlobal_LoaderAvatar } from "./comp_load_avatar"; import ComponentGlobal_Loader from "./loader"; -import { funGlobal_CheckProfile } from "../fun/get"; -import { RouterProfile } from "@/lib/router_hipmi/router_katalog"; -import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global"; -import { MainColor } from "../color"; type IFontSize = "xs" | "sm" | "md" | "lg" | "xl"; export function ComponentGlobal_AvatarAndUsername({ @@ -27,13 +27,17 @@ export function ComponentGlobal_AvatarAndUsername({ const [visible, setVisible] = useState(false); async function onCheckProfile() { - const res = await funGlobal_CheckProfile({ profileId: profile.id as any }); + try { + const res = await apiGetOneProfileById({ id: profile.id as any }); - if (res !== null) { - setVisible(true); - router.push(RouterProfile.katalog({ id: profile.id as any })); - } else { - ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); + if (res && res.success) { + setVisible(true); + router.push(RouterProfile.katalog({ id: profile.id as any })); + } else { + ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); + } + } catch (error) { + console.log(error); } } @@ -47,7 +51,7 @@ export function ComponentGlobal_AvatarAndUsername({ onClick={() => onCheckProfile()} > {visible ? ( - + ) : ( diff --git a/src/app_modules/event/component/detail/comp_avatar_and_username_event.tsx b/src/app_modules/event/component/detail/comp_avatar_and_username_event.tsx index 29f09852..163cb590 100644 --- a/src/app_modules/event/component/detail/comp_avatar_and_username_event.tsx +++ b/src/app_modules/event/component/detail/comp_avatar_and_username_event.tsx @@ -1,25 +1,10 @@ -import { RouterProfile } from "@/lib/router_hipmi/router_katalog"; import { ComponentGlobal_AvatarAndUsername, ComponentGlobal_CardStyles, - ComponentGlobal_LoaderAvatar, } from "@/app_modules/_global/component"; -import ComponentGlobal_Loader from "@/app_modules/_global/component/loader"; -import { funGlobal_CheckProfile } from "@/app_modules/_global/fun/get"; -import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; -import { - Grid, - ActionIcon, - Avatar, - Stack, - Group, - Badge, - Text, -} from "@mantine/core"; +import { Badge, Group, Stack, Text } from "@mantine/core"; import { Prisma } from "@prisma/client"; import moment from "moment"; -import { useRouter } from "next/navigation"; -import { useState } from "react"; type IFontSize = "xs" | "sm" | "md" | "lg" | "xl"; @@ -40,20 +25,6 @@ function ComponentEvent_AvatarAndUsername({ tanggalSelesai?: Date; isPresent?: boolean; }) { - const router = useRouter(); - const [visible, setVisible] = useState(false); - - async function onCheckProfile() { - const res = await funGlobal_CheckProfile({ profileId: profile.id as any }); - - if (res !== null) { - setVisible(true); - router.push(RouterProfile.katalog({ id: profile.id as any })); - } else { - ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); - } - } - const tglMulai = moment(tanggalMulai).diff(moment(), "minutes") < 0; return ( diff --git a/src/app_modules/event/component/detail/detail_data.tsx b/src/app_modules/event/component/detail/detail_data.tsx index cbc1c49a..1878fb42 100644 --- a/src/app_modules/event/component/detail/detail_data.tsx +++ b/src/app_modules/event/component/detail/detail_data.tsx @@ -1,91 +1,150 @@ "use client"; -import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component"; -import { Grid, Stack, Text, Title } from "@mantine/core"; -import { MODEL_EVENT } from "../../_lib/interface"; import { MainColor } from "@/app_modules/_global/color"; -import { Event_ComponentSkeletonDetailData } from "../skeleton/comp_skeleton_detail_data"; +import { + ComponentGlobal_BoxInformation, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import { Grid, SimpleGrid, Stack, Text, Title } from "@mantine/core"; +import { MODEL_EVENT } from "../../_lib/interface"; +import { Event_ComponentSkeletonDetail } from "../skeleton/comp_skeleton_detail"; +import Event_ComponentBoxDaftarPeserta from "./comp_box_daftar_peserta"; +import Event_ComponentBoxDaftarSponsor from "./comp_box_sponsor"; export default function ComponentEvent_DetailData({ - data, + isDaftarPeserta, + isReport, + data }: { - data: MODEL_EVENT; + isDaftarPeserta?: boolean; + isReport?: boolean; + data: MODEL_EVENT | null }) { + return ( <> - - - - {data ? data?.title : null} - - - - Lokasi - - : - - {data ? data?.lokasi : null} - - - - - Tipe Acara - - : - - {data ? data.EventMaster_TipeAcara?.name : null} - - - - Tanggal & Waktu - - - Mulai - - : - - - {" "} - {new Intl.DateTimeFormat("id-ID", { - dateStyle: "full", - }).format(data?.tanggal)} - ,{" "} - - {new Intl.DateTimeFormat("id-ID", { - timeStyle: "short", - }).format(data?.tanggal)} - - - - - - - Selesai - - : - - - {" "} - {new Intl.DateTimeFormat("id-ID", { - dateStyle: "full", - }).format(data?.tanggalSelesai)} - ,{" "} - - {new Intl.DateTimeFormat("id-ID", { - timeStyle: "short", - }).format(data?.tanggalSelesai)} - - - - - + {!data ? ( + + ) : ( + + {isReport && ( + + )} - - Deskripsi - {data ? data?.deskripsi : null} - + + + + + {data ? data?.title : null} + + + + + Lokasi + + + : + + + {data ? data?.lokasi : null} + + + + + + + Tipe Acara + + + : + + + {data ? data.EventMaster_TipeAcara?.name : null} + + + + + + Tanggal & Waktu + + + + + Mulai + + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(new Date(data?.tanggal))} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(new Date(data?.tanggal))} + + + + + + + + Selesai + + + : + + + {" "} + {new Intl.DateTimeFormat("id-ID", { + dateStyle: "full", + }).format(new Date(data?.tanggalSelesai))} + ,{" "} + + {new Intl.DateTimeFormat("id-ID", { + timeStyle: "short", + }).format(new Date(data?.tanggalSelesai))} + + + + + + + + + Deskripsi + + + {data ? data?.deskripsi : null} + + + + + {isDaftarPeserta && ( + + + + + )} + + - + )} ); } diff --git a/src/app_modules/event/component/detail/detail_main.tsx b/src/app_modules/event/component/detail/detail_main.tsx index 34244920..77dde7a1 100644 --- a/src/app_modules/event/component/detail/detail_main.tsx +++ b/src/app_modules/event/component/detail/detail_main.tsx @@ -6,13 +6,7 @@ import { ComponentGlobal_CardStyles, } from "@/app_modules/_global/component"; import { clientLogger } from "@/util/clientLogger"; -import { - Grid, - SimpleGrid, - Stack, - Text, - Title -} from "@mantine/core"; +import { Grid, SimpleGrid, Stack, Text, Title } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import moment from "moment"; import "moment/locale/id"; diff --git a/src/app_modules/event/component/detail/list_peserta.tsx b/src/app_modules/event/component/detail/list_peserta.tsx index adc96615..98625383 100644 --- a/src/app_modules/event/component/detail/list_peserta.tsx +++ b/src/app_modules/event/component/detail/list_peserta.tsx @@ -8,33 +8,31 @@ import { Grid, Group, Loader, - Skeleton, Stack, Text, - Title, + Title } from "@mantine/core"; import _ from "lodash"; -import { - ComponentGlobal_AvatarAndUsername, - ComponentGlobal_CardStyles, - ComponentGlobal_LoaderAvatar, -} from "@/app_modules/_global/component"; -import { useRouter } from "next/navigation"; -import { MODEL_EVENT_PESERTA } from "../../_lib/interface"; -import { Prisma } from "@prisma/client"; -import { RouterProfile } from "@/lib/router_hipmi/router_katalog"; -import ComponentGlobal_Loader from "@/app_modules/_global/component/loader"; -import { funGlobal_CheckProfile } from "@/app_modules/_global/fun/get"; -import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; -import { useState } from "react"; -import moment from "moment"; -import { useShallowEffect } from "@mantine/hooks"; -import { API_RouteEvent } from "@/lib/api_user_router/route_api_event"; -import Event_ComponentSkeletonListPeserta from "../skeleton/comp_skeleton_list_peserta"; -import { ScrollOnly } from "next-scroll-loader"; -import { event_newGetListPesertaById } from "../../fun"; import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_CardStyles, + ComponentGlobal_LoaderAvatar +} from "@/app_modules/_global/component"; +import ComponentGlobal_Loader from "@/app_modules/_global/component/loader"; +import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; +import { apiGetOneProfileById } from "@/app_modules/katalog/profile/lib/api_fetch_profile"; +import { API_RouteEvent } from "@/lib/api_user_router/route_api_event"; +import { RouterProfile } from "@/lib/router_hipmi/router_katalog"; +import { useShallowEffect } from "@mantine/hooks"; +import { Prisma } from "@prisma/client"; +import moment from "moment"; +import { ScrollOnly } from "next-scroll-loader"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { MODEL_EVENT_PESERTA } from "../../_lib/interface"; +import { event_newGetListPesertaById } from "../../fun"; +import Event_ComponentSkeletonListPeserta from "../skeleton/comp_skeleton_list_peserta"; export default function ComponentEvent_ListPeserta({ total, @@ -75,7 +73,9 @@ export default function ComponentEvent_ListPeserta({
- Daftar Peserta ({total}) + + Daftar Peserta ({total}) +
{_.isEmpty(data) ? ( @@ -163,13 +163,17 @@ function ComponentEvent_AvatarAndUsername({ const [visible, setVisible] = useState(false); async function onCheckProfile() { - const res = await funGlobal_CheckProfile({ profileId: profile.id as any }); + try { + const res = await apiGetOneProfileById({ id: profile.id as any }); - if (res !== null) { - setVisible(true); - router.push(RouterProfile.katalog({ id: profile.id as any })); - } else { - ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); + if (res && res.success) { + setVisible(true); + router.push(RouterProfile.katalog({ id: profile.id as any })); + } else { + ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); + } + } catch (error) { + console.log("Error >>r", error); } } diff --git a/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx b/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx index 28ee1c46..e4fcd758 100644 --- a/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx +++ b/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx @@ -30,7 +30,7 @@ export function Event_ComponentSkeletonDetail() {
- - + */}
diff --git a/src/app_modules/event/component/skeleton/comp_skeleton_detail_data.tsx b/src/app_modules/event/component/skeleton/comp_skeleton_detail_data.tsx index 7d8cc8aa..67b13b1d 100644 --- a/src/app_modules/event/component/skeleton/comp_skeleton_detail_data.tsx +++ b/src/app_modules/event/component/skeleton/comp_skeleton_detail_data.tsx @@ -24,10 +24,10 @@ export function Event_ComponentSkeletonDetailData() { ))} - + {/* - + */} diff --git a/src/app_modules/event/detail/draft/index.tsx b/src/app_modules/event/detail/draft/index.tsx index ba9ea514..132b6d2f 100644 --- a/src/app_modules/event/detail/draft/index.tsx +++ b/src/app_modules/event/detail/draft/index.tsx @@ -1,157 +1,166 @@ "use client"; -import { IRealtimeData } from "@/lib/global_state"; -import { RouterEvent } from "@/lib/router_hipmi/router_event"; -import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; +import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; +import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; +import { IRealtimeData } from "@/lib/global_state"; +import { RouterEvent } from "@/lib/router_hipmi/router_event"; +import { clientLogger } from "@/util/clientLogger"; import { Button, Group, Stack } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; import moment from "moment"; -import { useRouter } from "next/navigation"; +import { useParams, useRouter } from "next/navigation"; import { useState } from "react"; import { WibuRealtime } from "wibu-pkg"; -import { Event_ComponentSkeletonDetailData } from "../../component"; +import { apiGetEventDetailById } from "../../_lib/api_event"; +import { MODEL_EVENT } from "../../_lib/interface"; import ComponentEvent_DetailData from "../../component/detail/detail_data"; import { Event_funDeleteById } from "../../fun/delete/fun_delete"; import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id"; -import { MODEL_EVENT } from "../../_lib/interface"; -import { AccentColor, MainColor } from "@/app_modules/_global/color"; -import { clientLogger } from "@/util/clientLogger"; -export default function Event_DetailDraft({ - dataEvent, - eventId, -}: { - dataEvent: MODEL_EVENT; - eventId: string; -}) { - const [data, setData] = useState(dataEvent); +export default function Event_DetailDraft() { + const params = useParams<{ id: string }>(); + const eventId = params.id as string; + const [data, setData] = useState(null); - if (!data) { - return ( - <> - - - ); - } + useShallowEffect(() => { + onLoadData(); + }, []); + + async function onLoadData() { + try { + const respone = await apiGetEventDetailById({ + id: eventId, + }); + + if (respone) { + setData(respone.data); + } + } catch (error) { + clientLogger.error("Error get data detail event", error); + } + } return ( <> - {/*
{JSON.stringify(dataEvent.tanggal)}
*/} - {data?.catatan ? ( - - ) : ( - "" - )} - - + + ); } -function ButtonAction({ - eventId, - tanggalSelesai, -}: { - eventId: string; - tanggalSelesai?: any; -}) { +function ButtonAction({ eventId, endDate }: { eventId: string; endDate: any }) { const router = useRouter(); const [isLoadingDelete, setLoadingDelete] = useState(false); const [isLoadingAjukan, setLoadingAjukan] = useState(false); const [openModal1, setOpenModal1] = useState(false); const [openModal2, setOpenModal2] = useState(false); + async function onDelete() { - const res = await Event_funDeleteById(eventId); try { - setLoadingDelete(true); - if (res.status === 200) { - router.back(); - ComponentGlobal_NotifikasiBerhasil(res.message, 2000); - } else { + const res = await Event_funDeleteById(eventId); + try { + setLoadingDelete(true); + if (res.status === 200) { + router.back(); + ComponentGlobal_NotifikasiBerhasil(res.message, 2000); + } else { + setLoadingDelete(false); + ComponentGlobal_NotifikasiGagal(res.message); + } + } catch (error) { setLoadingDelete(false); - ComponentGlobal_NotifikasiGagal(res.message); + clientLogger.error("Error delete event", error); } } catch (error) { + console.log("Error delete event", error); setLoadingDelete(false); - clientLogger.error("Error delete event", error); } } async function onAjukan() { - if ( - moment(tanggalSelesai.toISOString().toString()).diff( - moment(), - "minutes" - ) < 0 - ) + if (moment(endDate.toISOString().toString()).diff(moment(), "minutes") < 0) return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat"); - const res = await Event_funEditStatusById("2", eventId); - if (res.status === 200) { - const dataNotifikasi: IRealtimeData = { - appId: res.data?.id as any, - status: res.data?.EventMaster_Status?.name as any, - userId: res.data?.authorId as any, - pesan: res.data?.title as any, - kategoriApp: "EVENT", - title: "Mengajukan review", - }; - - const notif = await notifikasiToAdmin_funCreate({ - data: dataNotifikasi as any, - }); - - if (notif.status === 201) { - WibuRealtime.setData({ - type: "notification", - pushNotificationTo: "ADMIN", - }); - - WibuRealtime.setData({ - type: "trigger", - pushNotificationTo: "ADMIN", - dataMessage: dataNotifikasi, - }); - } - ComponentGlobal_NotifikasiBerhasil(res.message, 2000); + try { setLoadingAjukan(true); - router.replace(RouterEvent.status({ id: "2" })); - } else { - ComponentGlobal_NotifikasiGagal(res.message); + const res = await Event_funEditStatusById("2", eventId); + if (res.status === 200) { + const dataNotifikasi: IRealtimeData = { + appId: res.data?.id as any, + status: res.data?.EventMaster_Status?.name as any, + userId: res.data?.authorId as any, + pesan: res.data?.title as any, + kategoriApp: "EVENT", + title: "Mengajukan review", + }; + + const notif = await notifikasiToAdmin_funCreate({ + data: dataNotifikasi as any, + }); + + if (notif.status === 201) { + WibuRealtime.setData({ + type: "notification", + pushNotificationTo: "ADMIN", + }); + + WibuRealtime.setData({ + type: "trigger", + pushNotificationTo: "ADMIN", + dataMessage: dataNotifikasi, + }); + } + ComponentGlobal_NotifikasiBerhasil(res.message, 2000); + router.replace(RouterEvent.status({ id: "2" })); + } else { + setLoadingAjukan(false); + ComponentGlobal_NotifikasiGagal(res.message); + } + } catch (error) { + setLoadingAjukan(false); + clientLogger.error("Error ajukan event", error); } } return ( <> - - - - + {!endDate ? ( + + + + + ) : ( + + + + + )} {/* MODAL AJUKAN */} setOpenModal1(false)} buttonKiri={ - } @@ -185,7 +199,12 @@ function ButtonAction({ opened={openModal2} close={() => setOpenModal2(false)} buttonKiri={ - } diff --git a/src/app_modules/event/detail/kontribusi/index.tsx b/src/app_modules/event/detail/kontribusi/index.tsx index 1af8c761..015c1182 100644 --- a/src/app_modules/event/detail/kontribusi/index.tsx +++ b/src/app_modules/event/detail/kontribusi/index.tsx @@ -2,21 +2,13 @@ import { Stack } from "@mantine/core"; import ComponentEvent_DetailMainData from "../../component/detail/detail_main"; -import ComponentEvent_ListPeserta from "../../component/detail/list_peserta"; -import { useParams } from "next/navigation"; -export default function Event_DetailKontribusi({ - totalPeserta, -}: { - totalPeserta: number; -}) { - const params = useParams<{id: string}>() - const eventId = params.id +export default function Event_DetailKontribusi() { return ( <> - - + + {/* */} ); diff --git a/src/app_modules/event/detail/peserta/index.tsx b/src/app_modules/event/detail/peserta/index.tsx index c79e35bc..b0ade72d 100644 --- a/src/app_modules/event/detail/peserta/index.tsx +++ b/src/app_modules/event/detail/peserta/index.tsx @@ -1,24 +1,18 @@ "use client"; -import { Stack, Loader, Center } from "@mantine/core"; -import ComponentEvent_ListPeserta from "../../component/detail/list_peserta"; -import { MODEL_EVENT_PESERTA } from "../../_lib/interface"; -import { useParams } from "next/navigation"; -import ComponentEvent_ListPesertaNew from "../../component/detail/list_peserta_new"; -import { useShallowEffect } from "@mantine/hooks"; -import { apiGetEventPesertaById } from "../../_lib/api_event"; -import { useState } from "react"; -import { clientLogger } from "@/util/clientLogger"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; +import { clientLogger } from "@/util/clientLogger"; +import { Center, Loader, Stack } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; import { ScrollOnly } from "next-scroll-loader"; +import { useParams } from "next/navigation"; +import { useState } from "react"; +import { apiGetEventPesertaById } from "../../_lib/api_event"; +import { MODEL_EVENT_PESERTA } from "../../_lib/interface"; import ComponentEvent_AvatarAndUsername from "../../component/detail/comp_avatar_and_username_event"; -import { ComponentGlobal_AvatarAndUsername } from "@/app_modules/_global/component"; +import _ from "lodash"; +import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; -// function Event_DaftarPeserta({ totalPeserta, eventId, isNewPeserta }: { -// totalPeserta?: number; -// eventId?: string; -// isNewPeserta?: boolean | null; -// }) { function Event_DaftarPeserta() { const params = useParams<{ id: string }>(); @@ -44,6 +38,25 @@ function Event_DaftarPeserta() { } } + const handleMoreData = async () => { + try { + const nextPage = activePage + 1; + + const response = await apiGetEventPesertaById({ + id: params.id, + page: `${nextPage}`, + }); + + if (response) { + setActivePage(nextPage); + + return response.data; + } + } catch (error) { + clientLogger.error("Error fetching more data:", error); + } + }; + if (!data) { return ( <> @@ -57,47 +70,34 @@ function Event_DaftarPeserta() { return ( <> - - ( -
- -
- )} - data={data} - setData={setData as any} - moreData={async () => { - try { - const respone = await apiGetEventPesertaById({ - id: params.id, - page: `${activePage + 1}`, - }); - - if (respone) { - setActivePage((val) => val + 1); - - return respone.data; - } - } catch (error) { - clientLogger.error("Error get data peserta:", error); - } - }} - > - {(item) => ( - - )} -
- - {/* */} -
+ {_.isEmpty(data) ? ( + + ) : ( + + ( +
+ +
+ )} + data={data} + setData={setData as any} + moreData={handleMoreData} + > + {(item) => ( + + )} +
+
+ )} ); } diff --git a/src/app_modules/event/detail/peserta/layout.tsx b/src/app_modules/event/detail/peserta/layout.tsx index 47898ed0..903a55d2 100644 --- a/src/app_modules/event/detail/peserta/layout.tsx +++ b/src/app_modules/event/detail/peserta/layout.tsx @@ -4,7 +4,7 @@ import React from 'react'; function LayoutEvent_Peserta({children}: {children: React.ReactNode}) { return ( <> - }> + }> {children} diff --git a/src/app_modules/event/detail/publish/index.tsx b/src/app_modules/event/detail/publish/index.tsx index 50856e35..65171179 100644 --- a/src/app_modules/event/detail/publish/index.tsx +++ b/src/app_modules/event/detail/publish/index.tsx @@ -1,22 +1,39 @@ "use client"; +import { useParams } from "next/navigation"; import ComponentEvent_DetailData from "../../component/detail/detail_data"; -import ComponentEvent_ListPeserta from "../../component/detail/list_peserta"; +import { useState } from "react"; +import { clientLogger } from "@/util/clientLogger"; +import { useShallowEffect } from "@mantine/hooks"; +import { apiGetEventDetailById } from "../../_lib/api_event"; import { MODEL_EVENT } from "../../_lib/interface"; -export default function Event_DetailPublish({ - dataEvent, - totalPeserta, - eventId, -}: { - dataEvent: MODEL_EVENT; - totalPeserta: number; - eventId: string; -}) { +export default function Event_DetailPublish() { + const params = useParams<{ id: string }>(); + const eventId = params.id as string; + const [data, setData] = useState(null); + + useShallowEffect(() => { + onLoadData(); + }, []); + + async function onLoadData() { + try { + const respone = await apiGetEventDetailById({ + id: eventId, + }); + + if (respone) { + setData(respone.data); + } + } catch (error) { + clientLogger.error("Error get data detail event", error); + } + } + return ( <> - - + ); } diff --git a/src/app_modules/event/detail/reject/index.tsx b/src/app_modules/event/detail/reject/index.tsx index 05779eb1..6e3c8e89 100644 --- a/src/app_modules/event/detail/reject/index.tsx +++ b/src/app_modules/event/detail/reject/index.tsx @@ -1,51 +1,72 @@ "use client"; -import { RouterEvent } from "@/lib/router_hipmi/router_event"; -import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; +import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; -import { Button, SimpleGrid, Stack } from "@mantine/core"; +import { RouterEvent } from "@/lib/router_hipmi/router_event"; +import { clientLogger } from "@/util/clientLogger"; +import { Button, Group, SimpleGrid, Stack } from "@mantine/core"; import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime"; -import { useRouter } from "next/navigation"; +import { useParams, useRouter } from "next/navigation"; import { useState } from "react"; import ComponentEvent_DetailData from "../../component/detail/detail_data"; import { Event_funDeleteById } from "../../fun/delete/fun_delete"; import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id"; +import { useShallowEffect } from "@mantine/hooks"; +import { apiGetEventDetailById } from "../../_lib/api_event"; import { MODEL_EVENT } from "../../_lib/interface"; -import { AccentColor, MainColor } from "@/app_modules/_global/color"; -import { clientLogger } from "@/util/clientLogger"; +import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; + +export default function Event_DetailReject() { + const params = useParams<{ id: string }>(); + const eventId = params.id as string; + const [data, setData] = useState(null); + + useShallowEffect(() => { + onLoadData(); + }, []); + + async function onLoadData() { + try { + const respone = await apiGetEventDetailById({ + id: eventId, + }); + + if (respone) { + setData(respone.data); + } + } catch (error) { + clientLogger.error("Error get data detail event", error); + } + } + -export default function Event_DetailReject({ - dataEvent, -}: { - dataEvent: MODEL_EVENT; -}) { - const [data, setData] = useState(dataEvent); - return ( <> - - - + + ); } - -function ButtonAction({ eventId, }: { eventId: string }) { +function ButtonAction({ eventId, data }: { eventId: string , data: MODEL_EVENT | null}) { const router = useRouter(); const [openModal1, setOpenModal1] = useState(false); const [openModal2, setOpenModal2] = useState(false); const [isLoading, setLoading] = useState(false); const [isLoading2, setLoading2] = useState(false); - async function onUpdate(router: AppRouterInstance, eventId: string, setLoading: any) { - await Event_funEditStatusById("3", eventId).then((res) => { - try { - setLoading(true); + async function onUpdate( + router: AppRouterInstance, + eventId: string, + setLoading: any + ) { + try { + setLoading(true); + await Event_funEditStatusById("3", eventId).then((res) => { if (res.status === 200) { ComponentGlobal_NotifikasiBerhasil(res.message); router.push(RouterEvent.status({ id: "3" })); @@ -53,18 +74,21 @@ function ButtonAction({ eventId, }: { eventId: string }) { setLoading(false); ComponentGlobal_NotifikasiGagal(res.message); } - } catch (error) { - setLoading(false); - clientLogger.error("Error update event", error); - } - - }); + }); + } catch (error) { + setLoading(false); + clientLogger.error("Error update event", error); + } } - - async function onDelete(router: AppRouterInstance, eventId: string, setLoading2: any) { - const res = await Event_funDeleteById(eventId); + + async function onDelete( + router: AppRouterInstance, + eventId: string, + setLoading2: any + ) { try { setLoading2(true); + const res = await Event_funDeleteById(eventId); if (res.status === 200) { ComponentGlobal_NotifikasiBerhasil(res.message, 2000); router.back(); @@ -77,31 +101,38 @@ function ButtonAction({ eventId, }: { eventId: string }) { clientLogger.error("Error delete event", error); } } - + return ( <> - - - - + {!data ? ( + + + + + ) : ( + + + + + )} {/* MODAL EDIT */} setOpenModal1(false)} buttonKiri={ - } @@ -135,7 +171,12 @@ function ButtonAction({ eventId, }: { eventId: string }) { opened={openModal2} close={() => setOpenModal2(false)} buttonKiri={ - } @@ -157,4 +198,3 @@ function ButtonAction({ eventId, }: { eventId: string }) { ); } - diff --git a/src/app_modules/event/detail/review/index.tsx b/src/app_modules/event/detail/review/index.tsx index 6d7221ee..95aeee31 100644 --- a/src/app_modules/event/detail/review/index.tsx +++ b/src/app_modules/event/detail/review/index.tsx @@ -8,7 +8,7 @@ import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/cre import mqtt_client from "@/util/mqtt_client"; import { Button, Stack } from "@mantine/core"; import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime"; -import { useRouter } from "next/navigation"; +import { useParams, useRouter } from "next/navigation"; import { useState } from "react"; import ComponentEvent_DetailData from "../../component/detail/detail_data"; import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id"; @@ -18,17 +18,42 @@ import { WibuRealtime } from "wibu-pkg"; import { event_checkStatus } from "../../fun/get/fun_check_status_by_id"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; +import { clientLogger } from "@/util/clientLogger"; +import { useShallowEffect } from "@mantine/hooks"; +import { apiGetEventDetailById } from "../../_lib/api_event"; +import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; -export default function Event_DetailReview({ - dataEvent, -}: { - dataEvent: MODEL_EVENT; -}) { +export default function Event_DetailReview() { + const params = useParams<{ id: string }>(); + const eventId = params.id as string; + const [data, setData] = useState(null); + + useShallowEffect(() => { + onLoadData(); + }, []); + + async function onLoadData() { + try { + const respone = await apiGetEventDetailById({ + id: eventId, + }); + + if (respone) { + setData(respone.data); + } + } catch (error) { + clientLogger.error("Error get data detail event", error); + } + } return ( <> - - + + {!data ? ( + + ) : ( + + )} ); @@ -40,7 +65,12 @@ function ButtonAction({ eventId }: { eventId: string }) { const [openModal, setOpenModal] = useState(false); return ( <> - @@ -49,13 +79,18 @@ function ButtonAction({ eventId }: { eventId: string }) { opened={openModal} close={() => setOpenModal(false)} buttonKiri={ - } buttonKanan={