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,26 +15,6 @@ export default async function funEditInvestasi(
|
|||||||
const file = formData.get("file");
|
const file = formData.get("file");
|
||||||
|
|
||||||
if (file !== "null") {
|
if (file !== "null") {
|
||||||
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 updateImage = await prisma.images.update({
|
|
||||||
where: {
|
|
||||||
id: data.imagesId,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
url: fRandomName,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!updateImage) return { status: 400, message: "Gagal upload gambar" };
|
|
||||||
const upFolder = Buffer.from(await file.arrayBuffer());
|
|
||||||
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
const editInves = await prisma.investasi.update({
|
const editInves = await prisma.investasi.update({
|
||||||
where: {
|
where: {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
@@ -58,7 +38,27 @@ export default async function funEditInvestasi(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
revalidatePath(RouterInvestasi.edit);
|
const file: any = formData.get("file");
|
||||||
|
const fName = file.name;
|
||||||
|
const fExt =
|
||||||
|
file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
||||||
|
const fRandomName = editInves.id + "." + fExt;
|
||||||
|
|
||||||
|
const updateImage = await prisma.images.update({
|
||||||
|
where: {
|
||||||
|
id: data.imagesId,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
url: fRandomName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateImage) return { status: 400, message: "Gagal upload gambar" };
|
||||||
|
const upFolder = Buffer.from(await file.arrayBuffer());
|
||||||
|
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// revalidatePath(RouterInvestasi.detail_draft);
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Disimpan",
|
message: "Berhasil Disimpan",
|
||||||
|
|||||||
Reference in New Issue
Block a user