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/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/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..308affcf 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 ? (
+
+
+
+ ) : (
+
+
+
+ )}
+ */}
+
+
+
+
+ {file ? (
+ {file.name}
+ ) : (
+
+ .
+
+ )}
+
+
+
+
+
+
+
+
+ Box
+ style={{
+ display: "flex",
+ justifyContent: "center",
+ }}
+ >
+
+
+
+ {/*
+
+ */}
+
+
+ {/* */}
>
);
}