Fix: Investasi
Deskripsi: - Upload gambar investasi ke storage wibu - Upload bukti transfer ke storage wibu # No Issue
This commit is contained in:
67
src/app_modules/investasi/_fun/edit/fun_edit_document.tsx
Normal file
67
src/app_modules/investasi/_fun/edit/fun_edit_document.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { MODEL_INVESTASI_DOKUMEN } from "../../_lib/interface";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function investasi_funUpdateDocument({
|
||||
data,
|
||||
fileId,
|
||||
}: {
|
||||
data: MODEL_INVESTASI_DOKUMEN;
|
||||
fileId?: string;
|
||||
}) {
|
||||
try {
|
||||
fileId !== undefined
|
||||
? await prisma.dokumenInvestasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: data.title,
|
||||
fileId: fileId,
|
||||
},
|
||||
})
|
||||
: await prisma.dokumenInvestasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: data.title,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: data.investasiId }));
|
||||
return { status: 200, message: "Berhasil Update" };
|
||||
}
|
||||
|
||||
// if (fileId !== undefined) {
|
||||
// const updt = await prisma.dokumenInvestasi.update({
|
||||
// where: {
|
||||
// id: data.id,
|
||||
// },
|
||||
// data: {
|
||||
// title: data.title,
|
||||
// fileId: fileId,
|
||||
// },
|
||||
// });
|
||||
// } else {
|
||||
// const updt = await prisma.dokumenInvestasi.update({
|
||||
// where: {
|
||||
// id: data.id,
|
||||
// },
|
||||
// data: {
|
||||
// title: data.title,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
// revalidatePath(NEW_RouterInvestasi.rekap_dokumen({ id: data.investasiId }));
|
||||
// return {
|
||||
// status: 200,
|
||||
// message: "Berhasil Update",
|
||||
// };
|
||||
}
|
||||
67
src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx
Normal file
67
src/app_modules/investasi/_fun/edit/fun_edit_investasi.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { MODEL_INVESTASI } from "../../_lib/interface";
|
||||
import _ from "lodash";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export async function investasi_funUpdateInvestasi({
|
||||
data,
|
||||
imageId,
|
||||
totalLembar,
|
||||
}: {
|
||||
data: MODEL_INVESTASI;
|
||||
imageId?: string;
|
||||
totalLembar: string;
|
||||
}) {
|
||||
// console.log(data);
|
||||
// console.log(imageId);
|
||||
// console.log(totalLembar);
|
||||
|
||||
if (imageId !== undefined) {
|
||||
const updtWithImage = await prisma.investasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: totalLembar,
|
||||
sisaLembar: totalLembar,
|
||||
roi: data.roi,
|
||||
masterPembagianDevidenId: data.masterPembagianDevidenId,
|
||||
masterPeriodeDevidenId: data.masterPeriodeDevidenId,
|
||||
masterPencarianInvestorId: data.masterPencarianInvestorId,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updtWithImage) return { status: 400, message: "Gagal update data" };
|
||||
revalidatePath(NEW_RouterInvestasi.detail_draft);
|
||||
return { status: 200, message: "Berhasil update" };
|
||||
} else {
|
||||
const updtNoImage = await prisma.investasi.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
},
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: totalLembar,
|
||||
sisaLembar: totalLembar,
|
||||
roi: data.roi,
|
||||
masterPembagianDevidenId: data.masterPembagianDevidenId,
|
||||
masterPeriodeDevidenId: data.masterPeriodeDevidenId,
|
||||
masterPencarianInvestorId: data.masterPencarianInvestorId,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updtNoImage) return { status: 400, message: "Gagal update data" };
|
||||
revalidatePath(NEW_RouterInvestasi.detail_draft);
|
||||
return { status: 200, message: "Berhasil update" };
|
||||
}
|
||||
}
|
||||
29
src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx
Normal file
29
src/app_modules/investasi/_fun/edit/fun_edit_prospektus.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function investasi_funUpdateProspektus({
|
||||
investasiId,
|
||||
fileId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
fileId: string;
|
||||
}) {
|
||||
const updte = await prisma.investasi.update({
|
||||
where: {
|
||||
id: investasiId,
|
||||
},
|
||||
data: {
|
||||
prospektusFileId: fileId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updte) return { status: 400, message: "Gagal update prospektus" };
|
||||
revalidatePath(NEW_RouterInvestasi.detail_draft);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil update prospektus",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user