title: auto
des: auto note:auto
This commit is contained in:
BIN
public/investasi/599dab5e-b934-4928-98bc-7f8856ab54ac.jpeg
Normal file
BIN
public/investasi/599dab5e-b934-4928-98bc-7f8856ab54ac.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
public/investasi/68b0cbaa-041a-43c6-82a5-6162710968d7.png
Normal file
BIN
public/investasi/68b0cbaa-041a-43c6-82a5-6162710968d7.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 263 KiB |
@@ -25,6 +25,7 @@ export const RouterInvestasi = {
|
|||||||
edit_berita: "/dev/investasi/edit_berita/",
|
edit_berita: "/dev/investasi/edit_berita/",
|
||||||
|
|
||||||
// detail //
|
// detail //
|
||||||
|
detail_portofolio: "",
|
||||||
detail_saham_terbeli: "/dev/investasi/detail_saham_terbeli/",
|
detail_saham_terbeli: "/dev/investasi/detail_saham_terbeli/",
|
||||||
detail_prospektus: "/dev/investasi/detail_prospektus/",
|
detail_prospektus: "/dev/investasi/detail_prospektus/",
|
||||||
detail_dokumen: "/dev/investasi/detail_dokumen/",
|
detail_dokumen: "/dev/investasi/detail_dokumen/",
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import { MODEL_Investasi } from "../model/model_investasi";
|
import { MODEL_Investasi } from "../model/model_investasi";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { v4 } from "uuid";
|
// import { v4 } from "uuid";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { revalidatePath } from "next/cache";
|
// import { revalidatePath } from "next/cache";
|
||||||
import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
// import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||||
|
|
||||||
export default async function funEditInvestasi(
|
export default async function funEditInvestasi(
|
||||||
formData: FormData,
|
formData: FormData,
|
||||||
@@ -15,11 +15,34 @@ export default async function funEditInvestasi(
|
|||||||
const file = formData.get("file");
|
const file = formData.get("file");
|
||||||
|
|
||||||
if (file !== "null") {
|
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 file: any = formData.get("file");
|
||||||
const fName = file.name;
|
const fName = file.name;
|
||||||
const fExt =
|
const fExt =
|
||||||
file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
||||||
const fRandomName = v4(fName) + "." + fExt;
|
const fRandomName = editInves.id + "." + fExt;
|
||||||
|
|
||||||
const updateImage = await prisma.images.update({
|
const updateImage = await prisma.images.update({
|
||||||
where: {
|
where: {
|
||||||
@@ -35,30 +58,7 @@ export default async function funEditInvestasi(
|
|||||||
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
const editInves = await prisma.investasi.update({
|
// revalidatePath(RouterInvestasi.detail_draft);
|
||||||
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);
|
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Disimpan",
|
message: "Berhasil Disimpan",
|
||||||
|
|||||||
Reference in New Issue
Block a user