Fix: Upload image
- Upload image berita ke server wibu - Tampilan detail image di ambil dari server wibu ## No issue
This commit is contained in:
45
src/app_modules/investasi/_fun/create/fun_create_berita.tsx
Normal file
45
src/app_modules/investasi/_fun/create/fun_create_berita.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
import { Model_Berita_Investasi } from "../../_lib/interface";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
|
||||
export async function investasi_funCreateBerita({
|
||||
data,
|
||||
fileId,
|
||||
}: {
|
||||
data: Model_Berita_Investasi | any;
|
||||
fileId?: string;
|
||||
}) {
|
||||
if (fileId != undefined) {
|
||||
const createWithFile = await prisma.beritaInvestasi.create({
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
investasiId: data.investasiId,
|
||||
imageId: fileId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createWithFile)
|
||||
return { status: 400, message: "Gagal menambah berita" };
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: data.investasiId }));
|
||||
return { status: 201, message: "Berhasil menambah berita" };
|
||||
} else {
|
||||
const createNoFile = await prisma.beritaInvestasi.create({
|
||||
data: {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
investasiId: data.investasiId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createNoFile) return { status: 400, message: "Gagal menambah berita" };
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: data.investasiId }));
|
||||
return { status: 201, message: "Berhasil menambah berita " };
|
||||
}
|
||||
}
|
||||
23
src/app_modules/investasi/_fun/delete/fun_delete_berita.tsx
Normal file
23
src/app_modules/investasi/_fun/delete/fun_delete_berita.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"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_funDeleteBerita({
|
||||
beritaId,
|
||||
}: {
|
||||
beritaId: string;
|
||||
}) {
|
||||
const del = await prisma.beritaInvestasi.delete({
|
||||
where: {
|
||||
id: beritaId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!del) return { status: 400, message: "Gagal hapus data" };
|
||||
revalidatePath(
|
||||
NEW_RouterInvestasi.rekap_berita({ id: del.investasiId as any })
|
||||
);
|
||||
return { status: 200, message: "Berhasil hapus data" };
|
||||
}
|
||||
24
src/app_modules/investasi/_fun/get/fun_get_berita_by_id.tsx
Normal file
24
src/app_modules/investasi/_fun/get/fun_get_berita_by_id.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
"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_funGetBeritaById({
|
||||
investasiId,
|
||||
}: {
|
||||
investasiId: string;
|
||||
}) {
|
||||
const data = prisma.beritaInvestasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
investasiId: investasiId,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(NEW_RouterInvestasi.rekap_berita({ id: investasiId }));
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function investasi_funGetOneBeritaById({
|
||||
beritaId,
|
||||
}: {
|
||||
beritaId: any;
|
||||
}) {
|
||||
const data = await prisma.beritaInvestasi.findFirst({
|
||||
where: {
|
||||
id: beritaId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ export async function investasi_funGetOneInvestasiById({
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Investasi_Invoice: true,
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
DokumenInvestasi: true,
|
||||
@@ -24,7 +25,6 @@ export async function investasi_funGetOneInvestasiById({
|
||||
MasterPencarianInvestor: true,
|
||||
MasterPeriodeDeviden: true,
|
||||
MasterProgresInvestasi: true,
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -14,10 +14,15 @@ import { investasi_funCreateDocument } from "./create/fun_create_document";
|
||||
import { investasi_funGetOneDocumentById } from "./get/fun_get_one_document_by_id";
|
||||
import { investasi_funUpdateDocument } from "./edit/fun_edit_document";
|
||||
import { investasi_funDeleteDokumenById } from "./delete/fun_delete_dokumen";
|
||||
import { investasi_funCreateBerita } from "./create/fun_create_berita";
|
||||
import { investasi_funGetBeritaById } from "./get/fun_get_berita_by_id";
|
||||
import { investasi_funGetOneBeritaById } from "./get/fun_get_one_berita_by_id";
|
||||
import { investasi_funDeleteBerita } from "./delete/fun_delete_berita";
|
||||
|
||||
// Create
|
||||
export { investasi_funCreateNewInvestasi };
|
||||
export { investasi_funCreateDocument };
|
||||
export { investasi_funCreateBerita };
|
||||
|
||||
// Get
|
||||
export { investasi_funGetOneInvestasiById };
|
||||
@@ -29,6 +34,8 @@ export { investasi_funGetAllInvestasiNonPublishByUserId };
|
||||
export { investasi_funGetPortofolioByStatusId };
|
||||
export { investasi_funGetAllDocumentById };
|
||||
export { investasi_funGetOneDocumentById };
|
||||
export { investasi_funGetBeritaById };
|
||||
export { investasi_funGetOneBeritaById };
|
||||
|
||||
// Update
|
||||
export { investasi_funUpdateInvestasi };
|
||||
@@ -40,3 +47,4 @@ export { investasi_funUploadBuktiTransferById };
|
||||
|
||||
// Delete
|
||||
export { investasi_funDeleteDokumenById };
|
||||
export { investasi_funDeleteBerita };
|
||||
|
||||
Reference in New Issue
Block a user