Bursa Investasi
# feat: - Tampilan portofolio selesai - Hapus investasi - Function get data publish ### no issue
This commit is contained in:
26
src/app_modules/investasi/fun/fun_delete_investasi.ts
Normal file
26
src/app_modules/investasi/fun/fun_delete_investasi.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function funDeleteInvestasi(id: string) {
|
||||
const res = await prisma.investasi.delete({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!res) return { status: 400, message: "Gagal Hapus Data" };
|
||||
|
||||
|
||||
revalidatePath(RouterInvestasi.portofolio)
|
||||
revalidatePath(RouterAdminInvestasi.main_investasi)
|
||||
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Hapus",
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function funGantiStatusInvestasi(id: string, val: string) {
|
||||
@@ -16,7 +17,7 @@ export default async function funGantiStatusInvestasi(id: string, val: string) {
|
||||
|
||||
if(!data) return {status: 400}
|
||||
|
||||
revalidatePath("/dev/investasi/main/portofolio")
|
||||
revalidatePath(RouterInvestasi.portofolio)
|
||||
revalidatePath(RouterAdminInvestasi.main_investasi)
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function getInvestasiById(id: string) {
|
||||
export default async function getInvestasiByStatusId(
|
||||
id: string,
|
||||
) {
|
||||
const data = await prisma.user.findUnique({
|
||||
where: { id: id },
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
Investasi: {
|
||||
select: {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function getListAllInvestasi() {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
44
src/app_modules/investasi/fun/get_list_all_publish.ts
Normal file
44
src/app_modules/investasi/fun/get_list_all_publish.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function getListAllPublish() {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
MasterStatusInvestasi: {
|
||||
name: {
|
||||
equals: "Publish",
|
||||
},
|
||||
},
|
||||
AND: {
|
||||
active: true
|
||||
}
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
hargaLembar: true,
|
||||
targetDana: true,
|
||||
totalLembar: true,
|
||||
roi: true,
|
||||
active: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
imagesId: true,
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
DokumenInvestasi: true,
|
||||
ProspektusInvestasi: true,
|
||||
MasterPembagianDeviden: true,
|
||||
MasterPencarianInvestor: true,
|
||||
MasterPeriodeDeviden: true,
|
||||
SahamTerbeli: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -16,6 +16,9 @@ export default async function getOneInvestasiById(id: string) {
|
||||
totalLembar: true,
|
||||
roi: true,
|
||||
active: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
catatan: true,
|
||||
imagesId: true,
|
||||
MasterStatusInvestasi: true,
|
||||
BeritaInvestasi: true,
|
||||
|
||||
104
src/app_modules/investasi/fun/get_porto_status_by_id.ts
Normal file
104
src/app_modules/investasi/fun/get_porto_status_by_id.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function getPortoByStatusId(id: string, statusId: number) {
|
||||
// Draft
|
||||
if (statusId === 1) {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: id,
|
||||
MasterStatusInvestasi: {
|
||||
name: "Draft",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
imagesId: true,
|
||||
// hargaLembar: true,
|
||||
// targetDana: true,
|
||||
// totalLembar: true,
|
||||
// roi: true,
|
||||
// active: true,
|
||||
// MasterStatusInvestasi: true,
|
||||
// BeritaInvestasi: true,
|
||||
// DokumenInvestasi: true,
|
||||
// ProspektusInvestasi: true,
|
||||
// MasterPembagianDeviden: true,
|
||||
// MasterPencarianInvestor: true,
|
||||
// MasterPeriodeDeviden: true,
|
||||
// SahamTerbeli: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// Review
|
||||
if (statusId === 2) {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: id,
|
||||
MasterStatusInvestasi: {
|
||||
name: "Review",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
imagesId: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// Publish
|
||||
if (statusId === 3) {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: id,
|
||||
MasterStatusInvestasi: {
|
||||
name: "Publish",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
imagesId: true,
|
||||
updatedAt: true,
|
||||
MasterPencarianInvestor: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// Reject
|
||||
if (statusId === 4) {
|
||||
const data = await prisma.investasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: id,
|
||||
MasterStatusInvestasi: {
|
||||
name: "Reject",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
imagesId: true,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user