title: auto
des: auto note:auto
This commit is contained in:
@@ -25,6 +25,7 @@ export const RouterInvestasi = {
|
||||
edit_berita: "/dev/investasi/edit_berita/",
|
||||
|
||||
// detail //
|
||||
detail_portofolio: "",
|
||||
detail_saham_terbeli: "/dev/investasi/detail_saham_terbeli/",
|
||||
detail_prospektus: "/dev/investasi/detail_prospektus/",
|
||||
detail_dokumen: "/dev/investasi/detail_dokumen/",
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_Investasi } from "../model/model_investasi";
|
||||
import _ from "lodash";
|
||||
import { v4 } from "uuid";
|
||||
// import { v4 } from "uuid";
|
||||
import fs from "fs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
// import { revalidatePath } from "next/cache";
|
||||
// import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export default async function funEditInvestasi(
|
||||
formData: FormData,
|
||||
@@ -15,11 +15,34 @@ export default async function funEditInvestasi(
|
||||
const file = formData.get("file");
|
||||
|
||||
if (file !== "null") {
|
||||
const editInves = await prisma.investasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: data.title,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: data.totalLembar,
|
||||
roi: data.roi,
|
||||
masterPencarianInvestorId: data.MasterPencarianInvestor.id,
|
||||
masterPembagianDevidenId: data.MasterPembagianDeviden.id,
|
||||
masterPeriodeDevidenId: data.MasterPeriodeDeviden.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!editInves) {
|
||||
return {
|
||||
status: 400,
|
||||
message: "Gagal update",
|
||||
};
|
||||
}
|
||||
|
||||
const file: any = formData.get("file");
|
||||
const fName = file.name;
|
||||
const fExt =
|
||||
file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
||||
const fRandomName = v4(fName) + "." + fExt;
|
||||
const fRandomName = editInves.id + "." + fExt;
|
||||
|
||||
const updateImage = await prisma.images.update({
|
||||
where: {
|
||||
@@ -35,30 +58,7 @@ export default async function funEditInvestasi(
|
||||
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
||||
}
|
||||
|
||||
const editInves = await prisma.investasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: data.title,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: data.totalLembar,
|
||||
roi: data.roi,
|
||||
masterPencarianInvestorId: data.MasterPencarianInvestor.id,
|
||||
masterPembagianDevidenId: data.MasterPembagianDeviden.id,
|
||||
masterPeriodeDevidenId: data.MasterPeriodeDeviden.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!editInves) {
|
||||
return {
|
||||
status: 400,
|
||||
message: "Gagal update",
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(RouterInvestasi.edit);
|
||||
// revalidatePath(RouterInvestasi.detail_draft);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Disimpan",
|
||||
|
||||
Reference in New Issue
Block a user