"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} ) : ( . )}
Box style={{ display: "flex", justifyContent: "center", }} > {/* */}
{/* */} ); } export default Event_TambahSponsor;