Donasi Info Admni
# feat - info admin - hapus admin ## Issue: Loading data belum untuk versi alfa
This commit is contained in:
47
src/app_modules/donasi/fun/update/fun_update_invoice.ts
Normal file
47
src/app_modules/donasi/fun/update/fun_update_invoice.ts
Normal 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",
|
||||
};
|
||||
}
|
||||
@@ -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",
|
||||
};
|
||||
}
|
||||
23
src/app_modules/donasi/fun/update/fun_update_rekening.ts
Normal file
23
src/app_modules/donasi/fun/update/fun_update_rekening.ts
Normal 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",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user