diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f1df440..2e93ff79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.2.41](https://github.com/bipproduction/hipmi/compare/v1.2.40...v1.2.41) (2025-01-21) + ## [1.2.40](https://github.com/bipproduction/hipmi/compare/v1.2.39...v1.2.40) (2025-01-16) ## [1.2.39](https://github.com/bipproduction/hipmi/compare/v1.2.38...v1.2.39) (2025-01-12) diff --git a/package.json b/package.json index 5b97338f..f2723063 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.2.40", + "version": "1.2.41", "private": true, "prisma": { "seed": "bun prisma/seed.ts" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index bda6bd67..fd47634b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -47,6 +47,9 @@ model User { User_Notifikasi Notifikasi[] @relation("UserNotifikasi") BusinessMaps BusinessMaps[] Investasi_Invoice Investasi_Invoice[] + + EventSponsor EventSponsor[] + EventTransaksi EventTransaksi[] } model MasterUserRole { @@ -166,6 +169,7 @@ model MasterBank { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt Investasi_Invoice Investasi_Invoice[] + EventTransaksi EventTransaksi[] } model MasterStatus { @@ -593,6 +597,8 @@ model Event { Event_Peserta Event_Peserta[] EventMaster_TipeAcara EventMaster_TipeAcara? @relation(fields: [eventMaster_TipeAcaraId], references: [id]) eventMaster_TipeAcaraId Int? + EventSponsor EventSponsor[] + EventTransaksi EventTransaksi[] } model EventMaster_TipeAcara { @@ -952,3 +958,45 @@ model MasterKategoriApp { name String value String? } + +// ======================= EVENT ======================= // + +model EventSponsor { + id String @id @default(cuid()) + isActive Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + name String + fileName String + fileExt String? + fileId String + + Author User? @relation(fields: [auhtorId], references: [id]) + auhtorId String? + + Event Event? @relation(fields: [eventId], references: [id]) + eventId String? + + EventTransaksi EventTransaksi? +} + +model EventTransaksi { + id String @id @default(cuid()) + isActive Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + nominal Int + MasterBank MasterBank? @relation(fields: [masterBankId], references: [id]) + masterBankId String? + status String + transferImageId String? + + AuthorId User? @relation(fields: [authorId], references: [id]) + authorId String? + + Event Event? @relation(fields: [eventId], references: [id]) + eventId String? + + EventSponsor EventSponsor? @relation(fields: [eventSponsorId], references: [id]) + eventSponsorId String? @unique +} diff --git a/src/app/api/event/[id]/route.ts b/src/app/api/event/[id]/route.ts index 4ad7728f..516b15d0 100644 --- a/src/app/api/event/[id]/route.ts +++ b/src/app/api/event/[id]/route.ts @@ -48,3 +48,5 @@ export async function GET( ); } } + + diff --git a/src/app/api/event/peserta/[id]/route.ts b/src/app/api/event/peserta/[id]/route.ts index 7e269e30..dcc565d8 100644 --- a/src/app/api/event/peserta/[id]/route.ts +++ b/src/app/api/event/peserta/[id]/route.ts @@ -48,16 +48,12 @@ export async function GET( }, }); - - - console.log("server", fixData) return NextResponse.json({ success: true, message: "Success get data", data: fixData, }); } catch (error) { - backendLogger.error("Error get list data:", error); return NextResponse.json( { diff --git a/src/app/api/event/sponsor/[id]/route.ts b/src/app/api/event/sponsor/[id]/route.ts new file mode 100644 index 00000000..9d6266b6 --- /dev/null +++ b/src/app/api/event/sponsor/[id]/route.ts @@ -0,0 +1,52 @@ +import { prisma } from "@/app/lib"; +import { NextResponse } from "next/server"; + +export async function POST( + request: Request, + context: { params: { id: string } } +) { + const method = request.method; + if (method !== "POST") { + return NextResponse.json( + { success: false, message: "Method not allowed" }, + { status: 405 } + ); + } + + const { id } = context.params; + + const body = await request.json(); + console.log("body", body); + console.log("id", id); + + // const res = await prisma.eventSponsor.create({ + + // }) + + return NextResponse.json({ + success: true, + message: "Success create sponsor", + }); + + // try { + // const { id } = context.params; + + // const body = await request.json(); + // console.log("body",body); + // console.log("id",id); + + // // const res = await prisma.eventSponsor.create({ + + // // }) + + // return NextResponse.json({ + // success: true, + // message: "Success create sponsor", + // }); + // } catch (error) { + // return NextResponse.json( + // { success: false, message: "Failed create sponsor" }, + // { status: 500 } + // ); + // } +} diff --git a/src/app/dev/event/detail/sponsor/tambah_sponsor/layout.tsx b/src/app/dev/event/detail/sponsor/tambah_sponsor/[id]/layout.tsx similarity index 100% rename from src/app/dev/event/detail/sponsor/tambah_sponsor/layout.tsx rename to src/app/dev/event/detail/sponsor/tambah_sponsor/[id]/layout.tsx diff --git a/src/app/dev/event/detail/sponsor/tambah_sponsor/page.tsx b/src/app/dev/event/detail/sponsor/tambah_sponsor/[id]/page.tsx similarity index 100% rename from src/app/dev/event/detail/sponsor/tambah_sponsor/page.tsx rename to src/app/dev/event/detail/sponsor/tambah_sponsor/[id]/page.tsx diff --git a/src/app/lib/id-derectory.ts b/src/app/lib/id-derectory.ts index dc430470..0fed8931 100644 --- a/src/app/lib/id-derectory.ts +++ b/src/app/lib/id-derectory.ts @@ -21,6 +21,10 @@ const DIRECTORY_ID = { // Job job_image: "cm0ypp6zl0003kp7jf59zuvjy", + + // Event + event_sponsor: "cm65zlbyf001udvmggnd6i0oh", + event_bukti_transfer: "cm65zlehy001wdvmgnobur2zh", }; export default DIRECTORY_ID; diff --git a/src/app/lib/router_hipmi/router_event.ts b/src/app/lib/router_hipmi/router_event.ts index 12baa87e..1e04011a 100644 --- a/src/app/lib/router_hipmi/router_event.ts +++ b/src/app/lib/router_hipmi/router_event.ts @@ -7,7 +7,7 @@ export const RouterEvent = { riwayat: ({ id }: { id: string }) => `/dev/event/main/riwayat/${id}`, /** - * + * * @param statusId | 1 - 4 | 1: Publish, 2: Review, 3: Draft, 4: Reject * @type string */ @@ -34,18 +34,13 @@ export const RouterEvent = { detail_riwayat: "/dev/event/detail/riwayat/", //peserta - daftar_peserta: ({ id }: { id: string }) => - `/dev/event/detail/peserta/${id}`, + daftar_peserta: ({ id }: { id: string }) => `/dev/event/detail/peserta/${id}`, //sponsor - daftar_sponsor: ({ id }: { id: string }) => - `/dev/event/detail/sponsor/${id}`, + daftar_sponsor: ({ id }: { id: string }) => `/dev/event/detail/sponsor/${id}`, edit_sponsor: "/dev/event/detail/sponsor/edit_sponsor/", - tambah_sponsor: "/dev/event/detail/sponsor/tambah_sponsor/", + tambah_sponsor: ({ id }: { id: string }) => + `/dev/event/detail/sponsor/tambah_sponsor/${id}`, detail_sponsor: ({ id }: { id: string }) => `/dev/event/detail/detail_sponsor/${id}`, - - - }; - diff --git a/src/app_modules/event/_lib/api_event.ts b/src/app_modules/event/_lib/api_event.ts index 2a6c52a0..2104589a 100644 --- a/src/app_modules/event/_lib/api_event.ts +++ b/src/app_modules/event/_lib/api_event.ts @@ -60,3 +60,29 @@ export const apiGetEventPesertaById = async ({ return await response.json().catch(() => null); }; + +// =============== SPONSOR =============== // + +export const apiGetEventCreateSponsor = async ({ + id, + data, +}: { + id: string; + data: any; +}) => { + const { token } = await fetch("/api/get-cookie").then((res) => res.json()); + if (!token) return await token.json().catch(() => null); + + const response = await fetch(`/api/event/sponsor/${id}`, { + method: "POST", + body: data, + headers: { + "Content-Type": "application/json", + Accept: "application/json", + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + }); + + return await response.json().catch(() => null); +}; 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 new file mode 100644 index 00000000..6feaa7e8 --- /dev/null +++ b/src/app_modules/event/component/detail/comp_avatar_and_username_event.tsx @@ -0,0 +1,85 @@ +import { RouterProfile } from "@/app/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 { Prisma } from "@prisma/client"; +import moment from "moment"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +type IFontSize = "xs" | "sm" | "md" | "lg" | "xl"; + +function ComponentEvent_AvatarAndUsername({ + profile, + component, + sizeAvatar, + fontSize, + tanggalMulai, + tanggalSelesai, + isPresent, +}: { + profile: Prisma.ProfileSelect; + component?: React.ReactNode; + sizeAvatar?: number; + fontSize?: IFontSize | {}; + tanggalMulai?: Date; + 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 ( + <> + + + + + {isPresent ? ( + Hadir + ) : ( + - + )} + + + + ) + } + /> + + + ); +} + +export default ComponentEvent_AvatarAndUsername; diff --git a/src/app_modules/event/detail/main_detail/index.tsx b/src/app_modules/event/detail/main_detail/index.tsx index d0146c6a..9bef481e 100644 --- a/src/app_modules/event/detail/main_detail/index.tsx +++ b/src/app_modules/event/detail/main_detail/index.tsx @@ -39,7 +39,6 @@ export default function Event_DetailMain({ }); if (respone) { - console.log(respone.data) setIsJoinSuccess(respone.data); } } catch (error) { diff --git a/src/app_modules/event/detail/peserta/index.tsx b/src/app_modules/event/detail/peserta/index.tsx index 928f4f18..a14fc534 100644 --- a/src/app_modules/event/detail/peserta/index.tsx +++ b/src/app_modules/event/detail/peserta/index.tsx @@ -1,6 +1,6 @@ "use client"; -import { Stack } from "@mantine/core"; +import { Stack, Loader, Center } from "@mantine/core"; import ComponentEvent_ListPeserta from "../../component/detail/list_peserta"; import { MODEL_EVENT_PESERTA } from "../../model/interface"; import { useParams } from "next/navigation"; @@ -9,6 +9,10 @@ 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 { ScrollOnly } from "next-scroll-loader"; +import ComponentEvent_AvatarAndUsername from "../../component/detail/comp_avatar_and_username_event"; +import { ComponentGlobal_AvatarAndUsername } from "@/app_modules/_global/component"; // function Event_DaftarPeserta({ totalPeserta, eventId, isNewPeserta }: { // totalPeserta?: number; @@ -33,7 +37,6 @@ function Event_DaftarPeserta() { }); if (respone) { - console.log(respone.data); setData(respone.data); } } catch (error) { @@ -41,10 +44,58 @@ function Event_DaftarPeserta() { } } + if (!data) { + return ( + <> + + + + + + ); + } + 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) => ( + + )} +
+ {/* */}
diff --git a/src/app_modules/event/detail/sponsor/layout.tsx b/src/app_modules/event/detail/sponsor/layout.tsx index 76c55f1d..ea61e6e4 100644 --- a/src/app_modules/event/detail/sponsor/layout.tsx +++ b/src/app_modules/event/detail/sponsor/layout.tsx @@ -1,27 +1,37 @@ -'use client'; -import { RouterEvent } from '@/app/lib/router_hipmi/router_event'; -import { UIGlobal_Drawer, UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from '@/app_modules/_global/ui'; -import { ActionIcon } from '@mantine/core'; -import { IconDotsVertical } from '@tabler/icons-react'; -import React, { useState } from 'react'; +"use client"; +import { RouterEvent } from "@/app/lib/router_hipmi/router_event"; +import { + UIGlobal_Drawer, + UIGlobal_LayoutHeaderTamplate, + UIGlobal_LayoutTamplate, +} from "@/app_modules/_global/ui"; +import { ActionIcon } from "@mantine/core"; +import { IconDotsVertical } from "@tabler/icons-react"; +import { useParams } from "next/navigation"; +import React, { useState } from "react"; import { TfiCup } from "react-icons/tfi"; -function LayoutEvent_Sponsor({ children}: { children: React.ReactNode;}) { +function LayoutEvent_Sponsor({ children }: { children: React.ReactNode }) { + const params = useParams<{ id: string }>(); + const [openDrawer, setOpenDrawer] = useState(false); return ( <> setOpenDrawer(true)} - > - - - } - />}> + header={ + setOpenDrawer(true)} + > + + + } + /> + } + > {children} , - path: RouterEvent.tambah_sponsor, + name: "Tambah Sponsor", + icon: , + path: RouterEvent.tambah_sponsor({ id: params.id }), }, ]} - /> ); diff --git a/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx b/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx index a3ba083f..365af7dc 100644 --- a/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx +++ b/src/app_modules/event/detail/sponsor/metode_pembayaran/index.tsx @@ -1,4 +1,5 @@ 'use client'; + import { AccentColor, MainColor } from '@/app_modules/_global/color'; import { MODEL_MASTER_BANK } from '@/app_modules/investasi/_lib/interface'; import { Button, Paper, Radio, Stack, Title } from '@mantine/core'; @@ -19,7 +20,7 @@ const bank = [ namaBank: "BNI", }, { - id: 1, + id: 4, namaBank: "BSI", } ] diff --git a/src/app_modules/event/detail/tambah_sponsor/index.tsx b/src/app_modules/event/detail/tambah_sponsor/index.tsx index ef5fb391..1cb35624 100644 --- a/src/app_modules/event/detail/tambah_sponsor/index.tsx +++ b/src/app_modules/event/detail/tambah_sponsor/index.tsx @@ -1,11 +1,201 @@ -import Event_CreateSponsor from '@/app_modules/event/component/detail/create_sponsor'; -import React from 'react'; +"use client"; +import { MainColor } from "@/app_modules/_global/color"; +import { + ComponentGlobal_BoxInformation, + ComponentGlobal_BoxUploadImage, + ComponentGlobal_ButtonUploadFileImage, + ComponentGlobal_CardStyles, +} from "@/app_modules/_global/component"; +import Event_CreateSponsor from "@/app_modules/event/component/detail/create_sponsor"; +import { + Stack, + Box, + AspectRatio, + Group, + Button, + TextInput, + Title, + Loader, + Image, + Center, + Text, +} from "@mantine/core"; +import { IconPhoto, IconCamera, IconFileTypePdf } from "@tabler/icons-react"; +import { useParams, useRouter } from "next/navigation"; +import React, { useState } from "react"; +import { apiGetEventCreateSponsor } from "../../_lib/api_event"; +import { clientLogger } from "@/util/clientLogger"; +import { funUploadFileToStorage } from "@/app_modules/_global/fun/upload/fun_upload_to_storage"; +import { + ComponentGlobal_NotifikasiBerhasil, + ComponentGlobal_NotifikasiPeringatan, +} from "@/app_modules/_global/notif_global"; +import { DIRECTORY_ID } from "@/app/lib"; function Event_TambahSponsor() { + const params = useParams<{ id: string }>(); + const router = useRouter(); + + const [file, setFile] = useState(null); + const [isLoading, setIsLoading] = useState(false); + + const [name, setName] = useState(""); + + async function onCreated() { + if (!file) { + setIsLoading(false); + return; + } + + try { + setIsLoading(true); + + const uploadFile = await funUploadFileToStorage({ + file: file, + dirId: DIRECTORY_ID.event_sponsor, + }); + + if (!uploadFile.success) { + setIsLoading(false); + ComponentGlobal_NotifikasiPeringatan("Gagal upload file"); + return; + } + + const data = { + name: name, + fileName: file.name, + fileId: uploadFile.data.id, + }; + + const created: any = await apiGetEventCreateSponsor({ + id: params.id, + data: data, + }); + + if (created) { + setIsLoading(false); + ComponentGlobal_NotifikasiBerhasil(created.message); + } + } catch (error) { + setIsLoading(false); + clientLogger.error("Error create sponsor", error); + } + } + return ( <> - + + + + + + setName(e.target.value)} + /> + + {/* + {isLoadingImg ? ( + + + + ) : img ? ( + + Foto + + ) : ( + + + + )} + */} + + + +
+ {file ? ( + {file.name} + ) : ( + + . + + )} +
+
+ +
+ +
+
+ + + + + + {/* + + */} +
+ + {/* */} ); }