From 128da1eb326f9a2e685756dad825ec5c14927e69 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 19 Sep 2024 16:32:20 +0800 Subject: [PATCH] test server --- prisma/schema.prisma | 5 +-- src/app/layout.tsx | 2 +- .../button/comp_button_selanjutnya.tsx | 45 ++++++++++--------- .../katalog/portofolio/create/view.tsx | 2 +- .../portofolio/fun/fun_create_portofolio.ts | 42 ++++++----------- src/bin/{hipmi_env.ts => hipmi_env.back.txt} | 2 +- 6 files changed, 42 insertions(+), 56 deletions(-) rename src/bin/{hipmi_env.ts => hipmi_env.back.txt} (94%) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 74ed0d31..5a37e8b4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -113,7 +113,6 @@ model Images { Donasi_Kabar Donasi_Kabar[] Donasi_PencairanDana Donasi_PencairanDana[] Donasi_Invoice Donasi_Invoice[] - Portofolio Portofolio[] Image_Map BusinessMaps[] @relation("ImageMap") Image_Pin BusinessMaps[] @relation("ImagePin") Investasi_Invoice Investasi_Invoice[] @@ -143,11 +142,9 @@ model Portofolio { profileId String? MasterBidangBisnis MasterBidangBisnis @relation(fields: [masterBidangBisnisId], references: [id]) masterBidangBisnisId String - Logo Images? @relation(fields: [logoId], references: [id]) - logoId String? Portofolio_MediaSosial Portofolio_MediaSosial? BusinessMaps BusinessMaps? - imageId String? + logoId String? } model Portofolio_MediaSosial { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 1c54d780..3da2327d 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -18,7 +18,7 @@ const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN!; const WS_APIKEY = process.env.WS_APIKEY!; if (!DATABASE_URL) throw new Error("Require DATABASE_URL"); -if (!WIBU_PWD) throw new Error("Require PWD"); +if (!WIBU_PWD) throw new Error("Require WIBU_PWD"); if (!Client_KEY) throw new Error("Require Client_KEY"); if (!Server_KEY) throw new Error("Require Server_KEY"); if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN"); diff --git a/src/app_modules/katalog/portofolio/component/button/comp_button_selanjutnya.tsx b/src/app_modules/katalog/portofolio/component/button/comp_button_selanjutnya.tsx index 6b4e307a..561e8437 100644 --- a/src/app_modules/katalog/portofolio/component/button/comp_button_selanjutnya.tsx +++ b/src/app_modules/katalog/portofolio/component/button/comp_button_selanjutnya.tsx @@ -11,17 +11,19 @@ import _ from "lodash"; import { useRouter } from "next/navigation"; import { useState } from "react"; import funCreatePortofolio from "../../fun/fun_create_portofolio"; +import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun"; +import { DIRECTORY_ID } from "@/app/lib"; export function Portofolio_ComponentButtonSelanjutnya({ profileId, - dataPorto, + dataPortofolio, file, dataMedsos, setIsFile, }: { profileId: string; - dataPorto: MODEL_PORTOFOLIO_OLD; - file: FormData; + dataPortofolio: MODEL_PORTOFOLIO_OLD; + file: File; dataMedsos: any; setIsFile: any; }) { @@ -30,29 +32,30 @@ export function Portofolio_ComponentButtonSelanjutnya({ async function onSubmit() { const porto = { - namaBisnis: dataPorto.namaBisnis, - masterBidangBisnisId: dataPorto.masterBidangBisnisId, - alamatKantor: dataPorto.alamatKantor, - tlpn: dataPorto.tlpn, - deskripsi: dataPorto.deskripsi, + namaBisnis: dataPortofolio.namaBisnis, + masterBidangBisnisId: dataPortofolio.masterBidangBisnisId, + alamatKantor: dataPortofolio.alamatKantor, + tlpn: dataPortofolio.tlpn, + deskripsi: dataPortofolio.deskripsi, }; if (_.values(porto).includes("")) return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data"); - if (file === null) { - setIsFile(true); - return null; - } - const gambar = new FormData(); - gambar.append("file", file as any); + const uploadFile = await funGlobal_UploadToStorage({ + file: file, + dirId: DIRECTORY_ID.portofolio_logo, + }); - const res = await funCreatePortofolio( - profileId, - porto as any, - gambar, - dataMedsos - ); + if (!uploadFile.success) + return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar"); + + const res = await funCreatePortofolio({ + profileId: profileId, + data: dataPortofolio as any, + medsos: dataMedsos, + fileId: uploadFile.data.id, + }); if (res.status === 201) { setLoading(true); // ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan"); @@ -64,7 +67,7 @@ export function Portofolio_ComponentButtonSelanjutnya({ return ( <>