title: auto
des: auto note:auto
This commit is contained in:
BIN
public/investasi/985fb948-bd46-4a10-8954-269956432c85.png
Normal file
BIN
public/investasi/985fb948-bd46-4a10-8954-269956432c85.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 263 KiB |
BIN
public/investasi/f6b1439c-220d-49c0-aedc-a0f0fc85ab37.jpeg
Normal file
BIN
public/investasi/f6b1439c-220d-49c0-aedc-a0f0fc85ab37.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 110 KiB |
@@ -35,13 +35,11 @@ import { useDisclosure, useWindowScroll } from "@mantine/hooks";
|
|||||||
import { test_server } from "./_makuro/test_server";
|
import { test_server } from "./_makuro/test_server";
|
||||||
|
|
||||||
export default function EditIntroInvestasi({
|
export default function EditIntroInvestasi({
|
||||||
|
|
||||||
dataInvestasi,
|
dataInvestasi,
|
||||||
listPencarian,
|
listPencarian,
|
||||||
listPeriode,
|
listPeriode,
|
||||||
listPembagian,
|
listPembagian,
|
||||||
}: {
|
}: {
|
||||||
|
|
||||||
dataInvestasi: MODEL_Investasi;
|
dataInvestasi: MODEL_Investasi;
|
||||||
listPencarian: MODEL_DEFAULT_MASTER[];
|
listPencarian: MODEL_DEFAULT_MASTER[];
|
||||||
listPeriode: MODEL_DEFAULT_MASTER[];
|
listPeriode: MODEL_DEFAULT_MASTER[];
|
||||||
@@ -70,13 +68,11 @@ export default function EditIntroInvestasi({
|
|||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append("file", fl as any);
|
fd.append("file", fl as any);
|
||||||
|
|
||||||
|
await funEditInvestasi(fd, body).then(async (res) => {
|
||||||
|
res.status === 200
|
||||||
// await funEditInvestasi(fd, body).then(async (res) => {
|
? (toast(res.message), router.back())
|
||||||
// res.status === 200
|
: toast(res.message);
|
||||||
// ? (toast(res.message), router.back())
|
});
|
||||||
// : toast(res.message);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -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,50 +15,50 @@ 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({
|
const file: any = formData.get("file");
|
||||||
// where: {
|
const fName = file.name;
|
||||||
// id: data.id,
|
const fExt =
|
||||||
// },
|
file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
||||||
// data: {
|
const fRandomName = v4(fName) + "." + fExt;
|
||||||
// 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) {
|
const updateImage = await prisma.images.update({
|
||||||
// return {
|
where: {
|
||||||
// status: 400,
|
id: data.imagesId,
|
||||||
// message: "Gagal update",
|
},
|
||||||
// };
|
data: {
|
||||||
// }
|
url: fRandomName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// const file: any = formData.get("file");
|
if (!updateImage) return { status: 400, message: "Gagal upload gambar" };
|
||||||
// const fName = file.name;
|
const upFolder = Buffer.from(await file.arrayBuffer());
|
||||||
// const fExt =
|
fs.writeFileSync(`./public/investasi/${updateImage.url}`, upFolder);
|
||||||
// file && file.name ? _.lowerCase(file.name.split(".").pop()) : "";
|
|
||||||
// const fRandomName = "file_" + _.random(100000000, 999999999999) + "." + 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);
|
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.detail_draft);
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil Disimpan",
|
message: "Berhasil Disimpan",
|
||||||
|
|||||||
Reference in New Issue
Block a user