Fix: Donasi
Deskripsi: - Fix notitikasi user to admin - Fix notifikasi admin to user
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function admin_funDonasiCheckStatus({ id }: { id: string }) {
|
||||
const data = await prisma.donasi.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
DonasiMaster_Status: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return { status: 400, message: "Id tidak ditemukan", statusName: "" };
|
||||
return {
|
||||
status: 200,
|
||||
message: "Id ditemukan",
|
||||
statusName: _.lowerCase(data.DonasiMaster_Status?.name),
|
||||
};
|
||||
}
|
||||
@@ -1,50 +1,85 @@
|
||||
import { RouterAdminDonasi } from "@/app/lib/router_admin/router_admin_donasi";
|
||||
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
import { data } from "autoprefixer";
|
||||
import _ from "lodash";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { IAdmin_ActivePage, IAdmin_ActiveChildId } from "./type_of_select_page";
|
||||
import { admin_funDonasiCheckStatus } from "../fun/get/fun_donasi_check_status";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
|
||||
export default async function adminNotifikasi_findRouterDonasi({
|
||||
data,
|
||||
appId,
|
||||
notifikasiId,
|
||||
router,
|
||||
onLoadCountNotif,
|
||||
onLoadDataNotifikasi,
|
||||
onChangeNavbar,
|
||||
onToggleNavbar,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
appId: string;
|
||||
notifikasiId: string;
|
||||
router: AppRouterInstance;
|
||||
onChangeNavbar: (val: any) => void;
|
||||
onToggleNavbar: (val: any) => void;
|
||||
onLoadCountNotif: (val: any) => void;
|
||||
onLoadDataNotifikasi: (val: any) => void;
|
||||
onChangeNavbar: (val: {
|
||||
id: IAdmin_ActivePage;
|
||||
childId: IAdmin_ActiveChildId;
|
||||
}) => void;
|
||||
}) {
|
||||
if (data.status === "Review") {
|
||||
const path = RouterAdminDonasi.table_review;
|
||||
router.push(path);
|
||||
onChangeNavbar({
|
||||
id: 3,
|
||||
childId: 33,
|
||||
const check = await admin_funDonasiCheckStatus({ id: appId });
|
||||
|
||||
if (check.status == 200) {
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: notifikasiId,
|
||||
});
|
||||
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
|
||||
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||
page: 1,
|
||||
});
|
||||
onLoadDataNotifikasi(loadListNotifikasi);
|
||||
|
||||
const path = `/dev/admin/donasi/sub-menu/${check.statusName}`;
|
||||
|
||||
if (check.statusName == "draft") {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Status telah dirubah oleh user"
|
||||
);
|
||||
} else {
|
||||
if (check.statusName == "publish") {
|
||||
onChangeNavbar({
|
||||
id: "Donasi",
|
||||
childId: "Donasi_2",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "review") {
|
||||
onChangeNavbar({
|
||||
id: "Donasi",
|
||||
childId: "Donasi_3",
|
||||
});
|
||||
}
|
||||
|
||||
if (check.statusName == "reject") {
|
||||
onChangeNavbar({
|
||||
id: "Donasi",
|
||||
childId: "Donasi_4",
|
||||
});
|
||||
}
|
||||
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
data.status === "Menunggu" ||
|
||||
data.status === "Berhasil" ||
|
||||
data.status === "Proses" ||
|
||||
data.status === "Gagal"
|
||||
) {
|
||||
const path = RouterAdminDonasi_OLD.detail_publish + data.appId;
|
||||
router.push(path, { scroll: false });
|
||||
onChangeNavbar({
|
||||
id: 3,
|
||||
childId: 32,
|
||||
});
|
||||
}
|
||||
|
||||
// if (data.status === "Draft") {
|
||||
// router.push(routeName + "review");
|
||||
// onChangeNavbar({
|
||||
// id: 6,
|
||||
// childId: 63,
|
||||
// });
|
||||
// }
|
||||
|
||||
onToggleNavbar(true);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
gs_adminDonasi_triggerReview,
|
||||
gs_adminEvent_triggerReview,
|
||||
gs_adminJob_triggerReview,
|
||||
gs_adminVoting_triggerReview,
|
||||
@@ -21,6 +22,7 @@ import {
|
||||
IAdmin_ActivePage,
|
||||
} from "./route_setting/type_of_select_page";
|
||||
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||
|
||||
export default function AdminNotifikasi_ViewCardDrawer({
|
||||
data,
|
||||
@@ -54,6 +56,9 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
const [isAdminVoting_TriggerReview, setIsAdminVoting_TriggerReview] = useAtom(
|
||||
gs_adminVoting_triggerReview
|
||||
);
|
||||
const [isAdminDonasi_TriggerReview, setIsAdminDonasi_TriggerReview] = useAtom(
|
||||
gs_adminDonasi_triggerReview
|
||||
);
|
||||
|
||||
async function onRead() {
|
||||
// ========================== JOB ========================== //
|
||||
@@ -84,6 +89,7 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
setIsAdminJob_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
}
|
||||
// ========================== JOB ========================== //
|
||||
@@ -117,6 +123,7 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
setIsAdminEvent_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
}
|
||||
// ========================== EVENT ========================== //
|
||||
@@ -150,10 +157,42 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
||||
setIsAdminVoting_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
}
|
||||
// ========================== VOTING ========================== //
|
||||
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
if (data.kategoriApp == "DONASI") {
|
||||
const checkDonasi = await adminNotifikasi_findRouterDonasi({
|
||||
appId: data.appId,
|
||||
notifikasiId: data.id,
|
||||
router: router,
|
||||
onLoadCountNotif(val) {
|
||||
onLoadCountNotif(val);
|
||||
},
|
||||
onLoadDataNotifikasi(val) {
|
||||
onLoadDataNotifikasi(val);
|
||||
},
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar({
|
||||
id: val.id,
|
||||
childId: val.childId,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (checkDonasi) {
|
||||
setIsAdminDonasi_TriggerReview(false);
|
||||
setVisible(false);
|
||||
setDataId("");
|
||||
onToggleNavbar(false);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================== DONASI ========================== //
|
||||
|
||||
// // FORUM
|
||||
// e?.kategoriApp === "FORUM" &&
|
||||
// adminNotifikasi_findRouterForum({
|
||||
|
||||
Reference in New Issue
Block a user