Merge pull request #251 from bipproduction/bagas/21-jan-25
Bagas/21 jan 25
This commit is contained in:
@@ -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.
|
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.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)
|
## [1.2.39](https://github.com/bipproduction/hipmi/compare/v1.2.38...v1.2.39) (2025-01-12)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.2.40",
|
"version": "1.2.41",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ model User {
|
|||||||
User_Notifikasi Notifikasi[] @relation("UserNotifikasi")
|
User_Notifikasi Notifikasi[] @relation("UserNotifikasi")
|
||||||
BusinessMaps BusinessMaps[]
|
BusinessMaps BusinessMaps[]
|
||||||
Investasi_Invoice Investasi_Invoice[]
|
Investasi_Invoice Investasi_Invoice[]
|
||||||
|
|
||||||
|
EventSponsor EventSponsor[]
|
||||||
|
EventTransaksi EventTransaksi[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model MasterUserRole {
|
model MasterUserRole {
|
||||||
@@ -166,6 +169,7 @@ model MasterBank {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
Investasi_Invoice Investasi_Invoice[]
|
Investasi_Invoice Investasi_Invoice[]
|
||||||
|
EventTransaksi EventTransaksi[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model MasterStatus {
|
model MasterStatus {
|
||||||
@@ -593,6 +597,8 @@ model Event {
|
|||||||
Event_Peserta Event_Peserta[]
|
Event_Peserta Event_Peserta[]
|
||||||
EventMaster_TipeAcara EventMaster_TipeAcara? @relation(fields: [eventMaster_TipeAcaraId], references: [id])
|
EventMaster_TipeAcara EventMaster_TipeAcara? @relation(fields: [eventMaster_TipeAcaraId], references: [id])
|
||||||
eventMaster_TipeAcaraId Int?
|
eventMaster_TipeAcaraId Int?
|
||||||
|
EventSponsor EventSponsor[]
|
||||||
|
EventTransaksi EventTransaksi[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model EventMaster_TipeAcara {
|
model EventMaster_TipeAcara {
|
||||||
@@ -952,3 +958,45 @@ model MasterKategoriApp {
|
|||||||
name String
|
name String
|
||||||
value 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
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,3 +48,5 @@ export async function GET(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,12 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log("server", fixData)
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success get data",
|
message: "Success get data",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
backendLogger.error("Error get list data:", error);
|
backendLogger.error("Error get list data:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
52
src/app/api/event/sponsor/[id]/route.ts
Normal file
52
src/app/api/event/sponsor/[id]/route.ts
Normal file
@@ -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 }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -21,6 +21,10 @@ const DIRECTORY_ID = {
|
|||||||
|
|
||||||
// Job
|
// Job
|
||||||
job_image: "cm0ypp6zl0003kp7jf59zuvjy",
|
job_image: "cm0ypp6zl0003kp7jf59zuvjy",
|
||||||
|
|
||||||
|
// Event
|
||||||
|
event_sponsor: "cm65zlbyf001udvmggnd6i0oh",
|
||||||
|
event_bukti_transfer: "cm65zlehy001wdvmgnobur2zh",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DIRECTORY_ID;
|
export default DIRECTORY_ID;
|
||||||
|
|||||||
@@ -34,18 +34,13 @@ export const RouterEvent = {
|
|||||||
detail_riwayat: "/dev/event/detail/riwayat/",
|
detail_riwayat: "/dev/event/detail/riwayat/",
|
||||||
|
|
||||||
//peserta
|
//peserta
|
||||||
daftar_peserta: ({ id }: { id: string }) =>
|
daftar_peserta: ({ id }: { id: string }) => `/dev/event/detail/peserta/${id}`,
|
||||||
`/dev/event/detail/peserta/${id}`,
|
|
||||||
|
|
||||||
//sponsor
|
//sponsor
|
||||||
daftar_sponsor: ({ id }: { id: string }) =>
|
daftar_sponsor: ({ id }: { id: string }) => `/dev/event/detail/sponsor/${id}`,
|
||||||
`/dev/event/detail/sponsor/${id}`,
|
|
||||||
edit_sponsor: "/dev/event/detail/sponsor/edit_sponsor/",
|
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 }) =>
|
detail_sponsor: ({ id }: { id: string }) =>
|
||||||
`/dev/event/detail/detail_sponsor/${id}`,
|
`/dev/event/detail/detail_sponsor/${id}`,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,3 +60,29 @@ export const apiGetEventPesertaById = async ({
|
|||||||
|
|
||||||
return await response.json().catch(() => null);
|
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);
|
||||||
|
};
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<>
|
||||||
|
<ComponentGlobal_CardStyles marginBottom={"15px"}>
|
||||||
|
<ComponentGlobal_AvatarAndUsername
|
||||||
|
profile={profile}
|
||||||
|
component={
|
||||||
|
tglMulai && (
|
||||||
|
<Group position="right">
|
||||||
|
<Stack justify="center" h={30}>
|
||||||
|
<Text fw={"bold"} fz={fontSize ? fontSize : "md"}>
|
||||||
|
{isPresent ? (
|
||||||
|
<Badge color="green">Hadir</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge>-</Badge>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Group>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ComponentEvent_AvatarAndUsername;
|
||||||
@@ -39,7 +39,6 @@ export default function Event_DetailMain({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (respone) {
|
if (respone) {
|
||||||
console.log(respone.data)
|
|
||||||
setIsJoinSuccess(respone.data);
|
setIsJoinSuccess(respone.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Stack } from "@mantine/core";
|
import { Stack, Loader, Center } from "@mantine/core";
|
||||||
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
||||||
import { MODEL_EVENT_PESERTA } from "../../model/interface";
|
import { MODEL_EVENT_PESERTA } from "../../model/interface";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
@@ -9,6 +9,10 @@ import { useShallowEffect } from "@mantine/hooks";
|
|||||||
import { apiGetEventPesertaById } from "../../_lib/api_event";
|
import { apiGetEventPesertaById } from "../../_lib/api_event";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
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 }: {
|
// function Event_DaftarPeserta({ totalPeserta, eventId, isNewPeserta }: {
|
||||||
// totalPeserta?: number;
|
// totalPeserta?: number;
|
||||||
@@ -33,7 +37,6 @@ function Event_DaftarPeserta() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (respone) {
|
if (respone) {
|
||||||
console.log(respone.data);
|
|
||||||
setData(respone.data);
|
setData(respone.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -41,10 +44,58 @@ function Event_DaftarPeserta() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack>
|
||||||
|
<CustomSkeleton height={70} width={"100%"} />
|
||||||
|
<CustomSkeleton height={70} width={"100%"} />
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentEvent_ListPesertaNew />
|
<ScrollOnly
|
||||||
|
height="90vh"
|
||||||
|
renderLoading={() => (
|
||||||
|
<Center mt={"lg"}>
|
||||||
|
<Loader color={"yellow"} />
|
||||||
|
</Center>
|
||||||
|
)}
|
||||||
|
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) => (
|
||||||
|
<ComponentEvent_AvatarAndUsername
|
||||||
|
profile={item?.User?.Profile as any}
|
||||||
|
sizeAvatar={30}
|
||||||
|
fontSize={"sm"}
|
||||||
|
tanggalMulai={item?.Event?.tanggal}
|
||||||
|
tanggalSelesai={item?.Event?.tanggalSelesai}
|
||||||
|
isPresent={item?.isPresent}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ScrollOnly>
|
||||||
|
|
||||||
{/* <ComponentEvent_ListPeserta eventId={params.id} total={totalPeserta as any} isNewPeserta={isNewPeserta} /> */}
|
{/* <ComponentEvent_ListPeserta eventId={params.id} total={totalPeserta as any} isNewPeserta={isNewPeserta} /> */}
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,27 +1,37 @@
|
|||||||
'use client';
|
"use client";
|
||||||
import { RouterEvent } from '@/app/lib/router_hipmi/router_event';
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
import { UIGlobal_Drawer, UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from '@/app_modules/_global/ui';
|
import {
|
||||||
import { ActionIcon } from '@mantine/core';
|
UIGlobal_Drawer,
|
||||||
import { IconDotsVertical } from '@tabler/icons-react';
|
UIGlobal_LayoutHeaderTamplate,
|
||||||
import React, { useState } from 'react';
|
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";
|
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);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<UIGlobal_LayoutHeaderTamplate
|
header={
|
||||||
title="Daftar Sponsor"
|
<UIGlobal_LayoutHeaderTamplate
|
||||||
customButtonRight={
|
title="Daftar Sponsor"
|
||||||
<ActionIcon
|
customButtonRight={
|
||||||
variant='transparent'
|
<ActionIcon
|
||||||
onClick={() => setOpenDrawer(true)}
|
variant="transparent"
|
||||||
>
|
onClick={() => setOpenDrawer(true)}
|
||||||
<IconDotsVertical color="white" />
|
>
|
||||||
</ActionIcon>
|
<IconDotsVertical color="white" />
|
||||||
}
|
</ActionIcon>
|
||||||
/>}>
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
<UIGlobal_Drawer
|
<UIGlobal_Drawer
|
||||||
@@ -30,12 +40,11 @@ function LayoutEvent_Sponsor({ children}: { children: React.ReactNode;}) {
|
|||||||
component={[
|
component={[
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Tambah Sponsor',
|
name: "Tambah Sponsor",
|
||||||
icon: <TfiCup/>,
|
icon: <TfiCup />,
|
||||||
path: RouterEvent.tambah_sponsor,
|
path: RouterEvent.tambah_sponsor({ id: params.id }),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { AccentColor, MainColor } from '@/app_modules/_global/color';
|
import { AccentColor, MainColor } from '@/app_modules/_global/color';
|
||||||
import { MODEL_MASTER_BANK } from '@/app_modules/investasi/_lib/interface';
|
import { MODEL_MASTER_BANK } from '@/app_modules/investasi/_lib/interface';
|
||||||
import { Button, Paper, Radio, Stack, Title } from '@mantine/core';
|
import { Button, Paper, Radio, Stack, Title } from '@mantine/core';
|
||||||
@@ -19,7 +20,7 @@ const bank = [
|
|||||||
namaBank: "BNI",
|
namaBank: "BNI",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 4,
|
||||||
namaBank: "BSI",
|
namaBank: "BSI",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,11 +1,201 @@
|
|||||||
import Event_CreateSponsor from '@/app_modules/event/component/detail/create_sponsor';
|
"use client";
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
|
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() {
|
function Event_TambahSponsor() {
|
||||||
|
const params = useParams<{ id: string }>();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [file, setFile] = useState<File | null>(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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Event_CreateSponsor/>
|
<Stack spacing={"md"} px={"xs"}>
|
||||||
|
<Box mb={"sm"}>
|
||||||
|
<ComponentGlobal_BoxInformation informasi="Upload file berformat pdf atau file gambar untuk logo sponsor anda." />
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
styles={{
|
||||||
|
label: {
|
||||||
|
color: MainColor.white,
|
||||||
|
},
|
||||||
|
required: {
|
||||||
|
color: MainColor.red,
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
backgroundColor: MainColor.white,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
withAsterisk
|
||||||
|
label="Nama Sponsor"
|
||||||
|
placeholder="Masukan nama sponsor"
|
||||||
|
onChange={(e) => setName(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* <ComponentGlobal_BoxUploadImage>
|
||||||
|
{isLoadingImg ? (
|
||||||
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
|
<Loader size={150} color="yellow" />
|
||||||
|
</Stack>
|
||||||
|
) : img ? (
|
||||||
|
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||||
|
<Image
|
||||||
|
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||||
|
alt="Foto"
|
||||||
|
height={250}
|
||||||
|
src={URL.createObjectURL(img)}
|
||||||
|
/>
|
||||||
|
</AspectRatio>
|
||||||
|
) : (
|
||||||
|
<Stack justify="center" align="center" h={"100%"}>
|
||||||
|
<IconPhoto size={150} color="gray" />
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</ComponentGlobal_BoxUploadImage> */}
|
||||||
|
|
||||||
|
<Stack spacing={0}>
|
||||||
|
<ComponentGlobal_CardStyles marginBottom={0}>
|
||||||
|
<Center>
|
||||||
|
{file ? (
|
||||||
|
<Text>{file.name}</Text>
|
||||||
|
) : (
|
||||||
|
<Group>
|
||||||
|
<IconFileTypePdf size={50} /> . <IconPhoto size={50} />
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
</Center>
|
||||||
|
</ComponentGlobal_CardStyles>
|
||||||
|
|
||||||
|
<Center>
|
||||||
|
<ComponentGlobal_ButtonUploadFileImage
|
||||||
|
onSetFile={setFile}
|
||||||
|
accept="image/jpeg,image/png,application/pdf"
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
transition: "all 0.3s ease",
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 20,
|
||||||
|
width: "90%",
|
||||||
|
}}
|
||||||
|
disabled={file == null || name == ""}
|
||||||
|
loading={isLoading ? true : false}
|
||||||
|
loaderPosition="center"
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
// onCreated();
|
||||||
|
}}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* <Stack mt={30}>
|
||||||
|
<Button
|
||||||
|
mt={90}
|
||||||
|
mb={20}
|
||||||
|
radius={"xl"}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
onClick={() =>
|
||||||
|
router.replace("/dev/event/detail/sponsor/nominal_sponsor")
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Stack> */}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{/* <Event_CreateSponsor /> */}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user