#feat:
Deskripsi: - Realtime notifikasi ## No Issue
This commit is contained in:
@@ -51,6 +51,7 @@ import adminNotifikasi_getByUserId from "./notifikasi/fun/get/get_notifikasi_by_
|
||||
import adminNotifikasi_funUpdateIsReadById from "./notifikasi/fun/update/fun_update_is_read_by_id";
|
||||
import adminNotifikasi_findRouterJob from "./notifikasi/route_setting/job";
|
||||
import adminNotifikasi_findRouterForum from "./notifikasi/route_setting/forum";
|
||||
import { adminNotifikasi_findRouterVoting } from "./notifikasi/route_setting/voting";
|
||||
|
||||
export default function AdminLayout({
|
||||
children,
|
||||
@@ -297,6 +298,7 @@ export default function AdminLayout({
|
||||
>
|
||||
{children}
|
||||
</AppShell>
|
||||
|
||||
{/* Drawer Mobile View */}
|
||||
<Drawer opened={opened} onClose={() => setOpened(false)} size={"50%"}>
|
||||
<Stack spacing={"xl"}>
|
||||
@@ -389,6 +391,7 @@ function DrawerNotifikasi({
|
||||
},
|
||||
}}
|
||||
onClick={async () => {
|
||||
// JOB
|
||||
e?.kategoriApp === "JOB" &&
|
||||
adminNotifikasi_findRouterJob({
|
||||
data: e,
|
||||
@@ -399,6 +402,7 @@ function DrawerNotifikasi({
|
||||
onToggleNavbar: onToggleNavbar,
|
||||
});
|
||||
|
||||
// FORUM
|
||||
e?.kategoriApp === "FORUM" &&
|
||||
adminNotifikasi_findRouterForum({
|
||||
data: e,
|
||||
@@ -411,6 +415,19 @@ function DrawerNotifikasi({
|
||||
},
|
||||
});
|
||||
|
||||
// VOTE
|
||||
e?.kategoriApp === "VOTING" &&
|
||||
adminNotifikasi_findRouterVoting({
|
||||
data: e,
|
||||
router: router,
|
||||
onChangeNavbar(val) {
|
||||
onChangeNavbar(val);
|
||||
},
|
||||
onToggleNavbar(val) {
|
||||
onToggleNavbar(val);
|
||||
},
|
||||
});
|
||||
|
||||
const updateIsRead = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: e?.id,
|
||||
});
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ActionIcon,
|
||||
Box,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
Title
|
||||
} from "@mantine/core";
|
||||
import Admin_Investasi from "../../investasi/main/view";
|
||||
import { IconChevronsRight } from "@tabler/icons-react";
|
||||
import router from "next/router";
|
||||
import * as echarts from 'echarts';
|
||||
import EChartsReact from "echarts-for-react";
|
||||
|
||||
|
||||
export default function AdminMain({countUser, countPorto}: {countUser: number, countPorto: number} ) {
|
||||
|
||||
@@ -8,10 +8,14 @@ export default async function adminNotifikasi_getByUserId() {
|
||||
const adminId = await user_getOneUserId();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{
|
||||
createdAt: "desc",
|
||||
},
|
||||
],
|
||||
where: {
|
||||
adminId: adminId,
|
||||
userRoleId: "2",
|
||||
|
||||
27
src/app_modules/admin/notifikasi/route_setting/voting.ts
Normal file
27
src/app_modules/admin/notifikasi/route_setting/voting.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
|
||||
export async function adminNotifikasi_findRouterVoting({
|
||||
data,
|
||||
router,
|
||||
onChangeNavbar,
|
||||
onToggleNavbar,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onChangeNavbar: (val: any) => void;
|
||||
onToggleNavbar: (val: any) => void;
|
||||
}) {
|
||||
const path = RouterAdminVote.table_review;
|
||||
|
||||
if (data.status === "Review") {
|
||||
router.push(path, { scroll: false });
|
||||
onChangeNavbar({
|
||||
id: 5,
|
||||
childId: 53,
|
||||
});
|
||||
}
|
||||
|
||||
onToggleNavbar(true);
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
|
||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Modal,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
@@ -23,20 +17,20 @@ import {
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconBan } from "@tabler/icons-react";
|
||||
import { IconEyeShare } from "@tabler/icons-react";
|
||||
import { IconBan, IconEyeShare } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useState } from "react";
|
||||
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||
import toast from "react-simple-toasts";
|
||||
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import moment from "moment";
|
||||
import { useState } from "react";
|
||||
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||
|
||||
export default function AdminVote_TableReview({
|
||||
listVote,
|
||||
@@ -255,17 +249,36 @@ async function onPublish(
|
||||
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
||||
|
||||
setVotingId(voteId);
|
||||
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingPublish(true);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
const res = await AdminVote_funEditStatusPublishById(voteId);
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting publish",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingPublish(true);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onReject(
|
||||
@@ -279,16 +292,36 @@ async function onReject(
|
||||
id: voteId,
|
||||
catatan: catatan,
|
||||
};
|
||||
await AdminEvent_funEditCatatanById(data as any).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
setSaveLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
|
||||
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting anda di tolak !",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
||||
setData(val);
|
||||
setSaveLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,31 @@ import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function AdminVote_funEditStatusPublishById(voteId: string) {
|
||||
|
||||
const updt = await prisma.voting.update({
|
||||
where: {
|
||||
id: voteId,
|
||||
const updt = await prisma.voting.update({
|
||||
where: {
|
||||
id: voteId,
|
||||
},
|
||||
data: {
|
||||
voting_StatusId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
Voting_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
voting_StatusId: "1",
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||
revalidatePath("/dev/admin/vote/main");
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Update Status",
|
||||
};
|
||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||
revalidatePath("/dev/admin/vote/main");
|
||||
|
||||
return {
|
||||
data: updt,
|
||||
status: 200,
|
||||
message: "Berhasil Update Status",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,11 +15,22 @@ export async function AdminEvent_funEditCatatanById(
|
||||
voting_StatusId: "4",
|
||||
catatan: data.catatan,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
Voting_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Update Gagal" };
|
||||
revalidatePath("/dev/admin/event/main");
|
||||
return {
|
||||
data: updt,
|
||||
status: 200,
|
||||
message: "Berhasil Update Status",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user