@@ -113,7 +113,6 @@ model Images {
|
|||||||
Donasi_Kabar Donasi_Kabar[]
|
Donasi_Kabar Donasi_Kabar[]
|
||||||
Donasi_PencairanDana Donasi_PencairanDana[]
|
Donasi_PencairanDana Donasi_PencairanDana[]
|
||||||
Donasi_Invoice Donasi_Invoice[]
|
Donasi_Invoice Donasi_Invoice[]
|
||||||
Portofolio Portofolio[]
|
|
||||||
Image_Map BusinessMaps[] @relation("ImageMap")
|
Image_Map BusinessMaps[] @relation("ImageMap")
|
||||||
Image_Pin BusinessMaps[] @relation("ImagePin")
|
Image_Pin BusinessMaps[] @relation("ImagePin")
|
||||||
Investasi_Invoice Investasi_Invoice[]
|
Investasi_Invoice Investasi_Invoice[]
|
||||||
@@ -143,11 +142,9 @@ model Portofolio {
|
|||||||
profileId String?
|
profileId String?
|
||||||
MasterBidangBisnis MasterBidangBisnis @relation(fields: [masterBidangBisnisId], references: [id])
|
MasterBidangBisnis MasterBidangBisnis @relation(fields: [masterBidangBisnisId], references: [id])
|
||||||
masterBidangBisnisId String
|
masterBidangBisnisId String
|
||||||
Logo Images? @relation(fields: [logoId], references: [id])
|
|
||||||
logoId String?
|
|
||||||
Portofolio_MediaSosial Portofolio_MediaSosial?
|
Portofolio_MediaSosial Portofolio_MediaSosial?
|
||||||
BusinessMaps BusinessMaps?
|
BusinessMaps BusinessMaps?
|
||||||
imageId String?
|
logoId String?
|
||||||
}
|
}
|
||||||
|
|
||||||
model Portofolio_MediaSosial {
|
model Portofolio_MediaSosial {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN!;
|
|||||||
const WS_APIKEY = process.env.WS_APIKEY!;
|
const WS_APIKEY = process.env.WS_APIKEY!;
|
||||||
|
|
||||||
if (!DATABASE_URL) throw new Error("Require DATABASE_URL");
|
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 (!Client_KEY) throw new Error("Require Client_KEY");
|
||||||
if (!Server_KEY) throw new Error("Require Server_KEY");
|
if (!Server_KEY) throw new Error("Require Server_KEY");
|
||||||
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
||||||
|
|||||||
@@ -11,17 +11,19 @@ import _ from "lodash";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import funCreatePortofolio from "../../fun/fun_create_portofolio";
|
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({
|
export function Portofolio_ComponentButtonSelanjutnya({
|
||||||
profileId,
|
profileId,
|
||||||
dataPorto,
|
dataPortofolio,
|
||||||
file,
|
file,
|
||||||
dataMedsos,
|
dataMedsos,
|
||||||
setIsFile,
|
setIsFile,
|
||||||
}: {
|
}: {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
dataPorto: MODEL_PORTOFOLIO_OLD;
|
dataPortofolio: MODEL_PORTOFOLIO_OLD;
|
||||||
file: FormData;
|
file: File;
|
||||||
dataMedsos: any;
|
dataMedsos: any;
|
||||||
setIsFile: any;
|
setIsFile: any;
|
||||||
}) {
|
}) {
|
||||||
@@ -30,29 +32,30 @@ export function Portofolio_ComponentButtonSelanjutnya({
|
|||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
const porto = {
|
const porto = {
|
||||||
namaBisnis: dataPorto.namaBisnis,
|
namaBisnis: dataPortofolio.namaBisnis,
|
||||||
masterBidangBisnisId: dataPorto.masterBidangBisnisId,
|
masterBidangBisnisId: dataPortofolio.masterBidangBisnisId,
|
||||||
alamatKantor: dataPorto.alamatKantor,
|
alamatKantor: dataPortofolio.alamatKantor,
|
||||||
tlpn: dataPorto.tlpn,
|
tlpn: dataPortofolio.tlpn,
|
||||||
deskripsi: dataPorto.deskripsi,
|
deskripsi: dataPortofolio.deskripsi,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_.values(porto).includes(""))
|
if (_.values(porto).includes(""))
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||||
if (file === null) {
|
|
||||||
setIsFile(true);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gambar = new FormData();
|
const uploadFile = await funGlobal_UploadToStorage({
|
||||||
gambar.append("file", file as any);
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.portofolio_logo,
|
||||||
|
});
|
||||||
|
|
||||||
const res = await funCreatePortofolio(
|
if (!uploadFile.success)
|
||||||
profileId,
|
return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
|
||||||
porto as any,
|
|
||||||
gambar,
|
const res = await funCreatePortofolio({
|
||||||
dataMedsos
|
profileId: profileId,
|
||||||
);
|
data: dataPortofolio as any,
|
||||||
|
medsos: dataMedsos,
|
||||||
|
fileId: uploadFile.data.id,
|
||||||
|
});
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
// ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||||
@@ -64,7 +67,7 @@ export function Portofolio_ComponentButtonSelanjutnya({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
disabled={_.values(dataPorto).includes("") || file === null}
|
disabled={_.values(dataPortofolio).includes("") || file === null}
|
||||||
mt={"md"}
|
mt={"md"}
|
||||||
radius={50}
|
radius={50}
|
||||||
loading={loading ? true : false}
|
loading={loading ? true : false}
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ export default function CreatePortofolio({
|
|||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Portofolio_ComponentButtonSelanjutnya
|
<Portofolio_ComponentButtonSelanjutnya
|
||||||
dataPorto={dataPortofolio as any}
|
dataPortofolio={dataPortofolio as any}
|
||||||
dataMedsos={dataMedsos}
|
dataMedsos={dataMedsos}
|
||||||
file={file}
|
file={file}
|
||||||
profileId={profileId}
|
profileId={profileId}
|
||||||
|
|||||||
@@ -8,32 +8,17 @@ import _ from "lodash";
|
|||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
export default async function funCreatePortofolio(
|
export default async function funCreatePortofolio({
|
||||||
profileId: string,
|
profileId,
|
||||||
data: MODEL_PORTOFOLIO,
|
data,
|
||||||
file: FormData,
|
fileId,
|
||||||
medsos: MODEL_PORTOFOLIO_MEDSOS
|
medsos,
|
||||||
) {
|
}: {
|
||||||
const gambar: any = file.get("file");
|
profileId: string;
|
||||||
const fileName = gambar.name;
|
data: MODEL_PORTOFOLIO;
|
||||||
const fileExtension = _.lowerCase(gambar.name.split(".").pop());
|
fileId: string;
|
||||||
const fRandomName = v4(fileName) + "." + fileExtension;
|
medsos: MODEL_PORTOFOLIO_MEDSOS;
|
||||||
|
}) {
|
||||||
const upload = await prisma.images.create({
|
|
||||||
data: {
|
|
||||||
url: fRandomName,
|
|
||||||
label: "PORTOFOLIO_LOGO",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
url: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!upload) return { status: 400, message: "Gagal upload logo portofolio" };
|
|
||||||
const upload_Folder = Buffer.from(await gambar.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/portofolio/logo/${upload.url}`, upload_Folder);
|
|
||||||
|
|
||||||
const createPortofolio = await prisma.portofolio.create({
|
const createPortofolio = await prisma.portofolio.create({
|
||||||
data: {
|
data: {
|
||||||
profileId: profileId,
|
profileId: profileId,
|
||||||
@@ -43,11 +28,12 @@ export default async function funCreatePortofolio(
|
|||||||
tlpn: data.tlpn,
|
tlpn: data.tlpn,
|
||||||
alamatKantor: data.alamatKantor,
|
alamatKantor: data.alamatKantor,
|
||||||
masterBidangBisnisId: data.masterBidangBisnisId,
|
masterBidangBisnisId: data.masterBidangBisnisId,
|
||||||
logoId: upload.id,
|
logoId: fileId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!createPortofolio) return { status: 400, message: "Gagal membuat portofolio" };
|
if (!createPortofolio)
|
||||||
|
return { status: 400, message: "Gagal membuat portofolio" };
|
||||||
|
|
||||||
const createMedsos = await prisma.portofolio_MediaSosial.create({
|
const createMedsos = await prisma.portofolio_MediaSosial.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN!;
|
|||||||
const WS_APIKEY = process.env.WS_APIKEY!;
|
const WS_APIKEY = process.env.WS_APIKEY!;
|
||||||
|
|
||||||
if (!DATABASE_URL) throw new Error("Require DATABASE_URL");
|
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 (!Client_KEY) throw new Error("Require Client_KEY");
|
||||||
if (!Server_KEY) throw new Error("Require Server_KEY");
|
if (!Server_KEY) throw new Error("Require Server_KEY");
|
||||||
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
||||||
Reference in New Issue
Block a user