Donasi Info Admni

# feat
- info admin
- hapus admin
## Issue: Loading data belum untuk versi alfa
This commit is contained in:
2024-01-15 11:29:39 +08:00
parent 4af3f74a97
commit 01da30bdb5
128 changed files with 2316 additions and 507 deletions

View File

@@ -0,0 +1,47 @@
"use server";
import prisma from "@/app/lib/prisma";
import _ from "lodash";
import { v4 } from "uuid";
import fs from "fs";
export async function Donasi_funUploadBuktiTransferById(
invoiceId: string,
file: FormData
) {
// console.log(file);
const gambar: any = file.get("file");
const fileName = gambar.name;
const fileExtension = _.lowerCase(gambar.name.split(".").pop());
const fileRandomName = v4(fileName) + "." + fileExtension;
const upload = await prisma.images.create({
data: {
url: fileRandomName,
label: "DONASI_INVOICE"
},
select: {
id: true,
url: true,
},
});
if (!upload) return { status: 400, message: "Gagal upload gambar" };
const uploadFolder = Buffer.from(await gambar.arrayBuffer());
fs.writeFileSync(`./public/donasi/invoice/${upload.url}`, uploadFolder);
const updateFile = await prisma.donasi_Invoice.update({
where: {
id: invoiceId,
},
data: {
imagesId: upload.id,
},
});
if (!updateFile) return { status: 400, message: "Gagal update gambar" };
return {
status: 200,
message: "Berhasil upload",
};
}

View File

@@ -0,0 +1,21 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function Donasi_funUpdateNotifById(notifId: string) {
const updateNotif = await prisma.donasi_Notif.update({
where: {
id: notifId,
},
data: {
isRead: true,
},
});
if (!updateNotif) return { status: 400, message: "Update notif gagal" };
revalidatePath("/dev/donasi/notif_page");
return {
status: 200,
message: "Berhasil update notif",
};
}

View File

@@ -0,0 +1,23 @@
"use server";
import prisma from "@/app/lib/prisma";
import { MODEL_DONASI } from "../../model/interface";
export async function Donasi_funUpdateRekening(data: MODEL_DONASI) {
// console.log(data)
const res = await prisma.donasi.update({
where: {
id: data.id,
},
data: {
namaBank: data.namaBank,
rekening: data.rekening,
},
});
if (!res) return { status: 400, message: "Gagal update rekening" };
return {
status: 200,
message: "Berhasil update",
};
}