Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "npx tsx prisma/seed.ts"
|
"seed": "npx tsx prisma/seed.ts"
|
||||||
|
|||||||
@@ -6,20 +6,18 @@ import adminNotifikasi_getByUserId from "@/app_modules/admin/notifikasi/fun/get/
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import versionUpdate from "../../../../package.json";
|
import versionUpdate from "../../../../package.json";
|
||||||
|
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
const version = versionUpdate.version
|
const version = versionUpdate.version;
|
||||||
|
|
||||||
const dataUser = await funGlobal_getUserById({ userId: userLoginId });
|
const dataUser = await funGlobal_getUserById({ userId: userLoginId });
|
||||||
const listNotifikasi = await adminNotifikasi_getByUserId();
|
const listNotifikasi = await adminNotifikasi_getByUserId({page: 1});
|
||||||
const countNotifikasi = await adminNotifikasi_countNotifikasi();
|
const countNotifikasi = await adminNotifikasi_countNotifikasi();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <AdminLayout
|
{/* <AdminLayout
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Event_DetailDraft } from "@/app_modules/event";
|
|||||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
let eventId = params.id;
|
const eventId = params.id;
|
||||||
const dataEvent = await event_getOneById(eventId);
|
const dataEvent = await event_getOneById(eventId);
|
||||||
return (
|
return (
|
||||||
<Event_DetailDraft eventId={eventId as any} dataEvent={dataEvent as any} />
|
<Event_DetailDraft eventId={eventId as any} dataEvent={dataEvent as any} />
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { LayoutEvent_DetailMain } from "@/app_modules/event";
|
import { LayoutEvent_DetailMain } from "@/app_modules/event";
|
||||||
import { AppShell } from "@mantine/core";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { atom } from "jotai";
|
import { atom } from "jotai";
|
||||||
|
import { atomWithStorage } from "jotai/utils";
|
||||||
|
|
||||||
export type IRealtimeData = {
|
export type IRealtimeData = {
|
||||||
status?: "Publish" | "Review" | "Draft" | "Reject";
|
status?: "Publish" | "Review" | "Draft" | "Reject" | "Peserta Event";
|
||||||
|
|
||||||
appId: string;
|
appId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
pesan: string;
|
pesan: string;
|
||||||
@@ -14,14 +16,18 @@ export type IRealtimeData = {
|
|||||||
| "INVESTASI"
|
| "INVESTASI"
|
||||||
| "COLLABORATION"
|
| "COLLABORATION"
|
||||||
| "FORUM";
|
| "FORUM";
|
||||||
userRole?: "USER" | "ADMIN";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const gs_realtimeData = atom<IRealtimeData | null>(null);
|
export const gs_realtimeData = atom<IRealtimeData | null>(null);
|
||||||
export const gs_admin_ntf = atom<number>(0);
|
export const gs_admin_ntf = atom<number>(0);
|
||||||
export const gs_user_ntf = atom<number>(0);
|
export const gs_user_ntf = atom<number>(0);
|
||||||
|
export const gs_count_ntf = atom<number>(0);
|
||||||
|
|
||||||
|
|
||||||
// job
|
// job
|
||||||
|
export const gs_adminJobTriggerReview = atom<boolean>(false);
|
||||||
|
export const gs_jobTiggerBeranda = atom<boolean>(false);
|
||||||
|
|
||||||
export const gs_job_trigger = atom<boolean>(false)
|
// event
|
||||||
|
export const gs_adminEventTriggerReview = atom<boolean>(false);
|
||||||
|
export const gs_eventTriggerBeranda = atom<boolean>(false);
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import { useAtom } from "jotai";
|
|||||||
import { WibuRealtime } from "wibu-pkg";
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import {
|
import {
|
||||||
gs_admin_ntf,
|
gs_admin_ntf,
|
||||||
gs_job_trigger,
|
gs_adminEventTriggerReview,
|
||||||
|
gs_adminJobTriggerReview,
|
||||||
|
gs_eventTriggerBeranda,
|
||||||
|
gs_jobTiggerBeranda,
|
||||||
gs_realtimeData,
|
gs_realtimeData,
|
||||||
gs_user_ntf,
|
gs_user_ntf,
|
||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
@@ -27,7 +30,21 @@ export default function RealtimeProvider({
|
|||||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
||||||
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
||||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||||
const [triggerJob, setTriggerJob] = useAtom(gs_job_trigger);
|
|
||||||
|
// JOB
|
||||||
|
const [isTriggerJobBeranda, setIsTriggerJobBeranda] =
|
||||||
|
useAtom(gs_jobTiggerBeranda);
|
||||||
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
|
gs_adminJobTriggerReview
|
||||||
|
);
|
||||||
|
|
||||||
|
// EVENT
|
||||||
|
const [isTriggerEventBeranda, setIsTriggerEventBeranca] = useAtom(
|
||||||
|
gs_eventTriggerBeranda
|
||||||
|
);
|
||||||
|
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
||||||
|
gs_adminEventTriggerReview
|
||||||
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
WibuRealtime.init({
|
WibuRealtime.init({
|
||||||
@@ -36,6 +53,7 @@ export default function RealtimeProvider({
|
|||||||
setNewAdminNtf((e) => e + 1);
|
setNewAdminNtf((e) => e + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notifikasi ke semua user , yang datanya di acc admin
|
||||||
if (
|
if (
|
||||||
data.type == "notification" &&
|
data.type == "notification" &&
|
||||||
data.pushNotificationTo == "USER" &&
|
data.pushNotificationTo == "USER" &&
|
||||||
@@ -45,14 +63,52 @@ export default function RealtimeProvider({
|
|||||||
setDataRealtime(data.dataMessage as any);
|
setDataRealtime(data.dataMessage as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JOB
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "JOB"
|
||||||
|
) {
|
||||||
|
setIsAdminJob_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
data.type == "trigger" &&
|
data.type == "trigger" &&
|
||||||
data.pushNotificationTo == "USER" &&
|
data.pushNotificationTo == "USER" &&
|
||||||
data.dataMessage?.kategoriApp == "JOB"
|
data.dataMessage?.kategoriApp == "JOB" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
) {
|
) {
|
||||||
setTriggerJob(true);
|
setIsTriggerJobBeranda(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// EVENT
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "EVENT"
|
||||||
|
) {
|
||||||
|
setIsAdminEvent_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "EVENT" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerEventBeranca(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.status == "Peserta Event" &&
|
||||||
|
userLoginId !== data.dataMessage?.userId
|
||||||
|
) {
|
||||||
|
setNewUserNtf((e) => e + 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
project: "hipmi",
|
project: "hipmi",
|
||||||
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default function Page() {
|
|||||||
pesan: "apa kabar",
|
pesan: "apa kabar",
|
||||||
title: "coba",
|
title: "coba",
|
||||||
kategoriApp: "INVESTASI",
|
kategoriApp: "INVESTASI",
|
||||||
userRole: "ADMIN",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WibuRealtime.setData({
|
WibuRealtime.setData({
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export default function Page() {
|
|||||||
pesan: "apa kabar",
|
pesan: "apa kabar",
|
||||||
title: "coba",
|
title: "coba",
|
||||||
kategoriApp: "INVESTASI",
|
kategoriApp: "INVESTASI",
|
||||||
userRole: "USER",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WibuRealtime.setData({
|
WibuRealtime.setData({
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
import { AdminEvent_ViewDetailPeserta } from "./view_detail_peserta";
|
import { AdminEvent_ViewDetailPeserta } from "./view_detail_peserta";
|
||||||
|
import AdminEvent_ComponentTableReview from "./view_table_review";
|
||||||
|
|
||||||
export { AdminEvent_ViewDetailPeserta };
|
export { AdminEvent_ViewDetailPeserta };
|
||||||
|
export { AdminEvent_ComponentTableReview };
|
||||||
|
|||||||
405
src/app_modules/admin/event/_view/view_table_review.tsx
Normal file
405
src/app_modules/admin/event/_view/view_table_review.tsx
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
import {
|
||||||
|
gs_adminEventTriggerReview,
|
||||||
|
IRealtimeData,
|
||||||
|
} from "@/app/lib/global_state";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { MODEL_EVENT } from "@/app_modules/event/model/interface";
|
||||||
|
import {
|
||||||
|
Affix,
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Center,
|
||||||
|
Group,
|
||||||
|
Modal,
|
||||||
|
Pagination,
|
||||||
|
Paper,
|
||||||
|
rem,
|
||||||
|
ScrollArea,
|
||||||
|
Spoiler,
|
||||||
|
Stack,
|
||||||
|
Table,
|
||||||
|
Text,
|
||||||
|
Textarea,
|
||||||
|
TextInput,
|
||||||
|
Title,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
|
import {
|
||||||
|
IconBan,
|
||||||
|
IconCircleCheck,
|
||||||
|
IconRefresh,
|
||||||
|
IconSearch,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import moment from "moment";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||||
|
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||||
|
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
||||||
|
import { adminEvent_funGetListReview } from "../fun";
|
||||||
|
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
||||||
|
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||||
|
|
||||||
|
export default function AdminEvent_ComponentTableReview({
|
||||||
|
listData,
|
||||||
|
}: {
|
||||||
|
listData: any;
|
||||||
|
}) {
|
||||||
|
const [data, setData] = useState<MODEL_EVENT[]>(listData.data);
|
||||||
|
const [isNPage, setNPage] = useState(listData.nPage);
|
||||||
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
|
const [isSearch, setSearch] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
|
const [catatan, setCatatan] = useState("");
|
||||||
|
const [eventId, setEventId] = useState("");
|
||||||
|
|
||||||
|
// Realtime state
|
||||||
|
const [isAdminTriggerReview, setIsAdminTriggerReview] = useAtom(
|
||||||
|
gs_adminEventTriggerReview
|
||||||
|
);
|
||||||
|
const [isShowReload, setIsShowReload] = useState(false);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (isAdminTriggerReview) {
|
||||||
|
setIsShowReload(true);
|
||||||
|
}
|
||||||
|
}, [isAdminTriggerReview, setIsShowReload]);
|
||||||
|
|
||||||
|
async function onSearch(s: string) {
|
||||||
|
setSearch(s);
|
||||||
|
const loadData = await adminEvent_funGetListReview({
|
||||||
|
page: 1,
|
||||||
|
search: s,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPageClick(p: any) {
|
||||||
|
setActivePage(p);
|
||||||
|
const loadData = await adminEvent_funGetListReview({
|
||||||
|
search: isSearch,
|
||||||
|
page: p,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
const loadData = await adminEvent_funGetListReview({
|
||||||
|
page: 1,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsShowReload(false);
|
||||||
|
setIsAdminTriggerReview(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPublish(eventId: string, tanggal: Date) {
|
||||||
|
if (moment(tanggal).diff(Date.now(), "minutes") < 0)
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
||||||
|
);
|
||||||
|
|
||||||
|
const res = await AdminEvent_funEditStatusPublishById(eventId, "1");
|
||||||
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Event publish",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadData = await adminEvent_funGetListReview({
|
||||||
|
search: isSearch,
|
||||||
|
page: isActivePage,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
|
||||||
|
ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status");
|
||||||
|
} else {
|
||||||
|
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onReject(eventId: string, catatan: string) {
|
||||||
|
if (catatan === "")
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Catatan");
|
||||||
|
const body = {
|
||||||
|
id: eventId,
|
||||||
|
catatan: catatan,
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
||||||
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Event reject",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadData = await adminEvent_funGetListReview({
|
||||||
|
search: isSearch,
|
||||||
|
page: isActivePage,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
close();
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const TableRows = data.map((e, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
<Text>{e?.Author?.username}</Text>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
<Text lineClamp={2}>{e.title}</Text>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
<Text>{e.lokasi}</Text>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
{e.tanggal.toLocaleTimeString([], {
|
||||||
|
timeStyle: "short",
|
||||||
|
hourCycle: "h24",
|
||||||
|
})}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={400}>
|
||||||
|
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
||||||
|
{e.deskripsi}
|
||||||
|
</Spoiler>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<Center>
|
||||||
|
<Stack>
|
||||||
|
<Button
|
||||||
|
color={"green"}
|
||||||
|
leftIcon={<IconCircleCheck />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => onPublish(e.id, e.tanggal)}
|
||||||
|
>
|
||||||
|
Publish
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color={"red"}
|
||||||
|
leftIcon={<IconBan />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
open();
|
||||||
|
setEventId(e.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reject
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack spacing={"xs"} h={"100%"}>
|
||||||
|
<Group
|
||||||
|
position="apart"
|
||||||
|
bg={"orange.4"}
|
||||||
|
p={"xs"}
|
||||||
|
style={{ borderRadius: "6px" }}
|
||||||
|
>
|
||||||
|
<Title order={4}>Review</Title>
|
||||||
|
<TextInput
|
||||||
|
icon={<IconSearch size={20} />}
|
||||||
|
radius={"xl"}
|
||||||
|
placeholder="Masukan judul"
|
||||||
|
onChange={(val) => {
|
||||||
|
onSearch(val.currentTarget.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||||
|
{isShowReload && (
|
||||||
|
<Paper bg={"red"} w={"50%"}>
|
||||||
|
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||||
|
<Center>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
border: `1px solid ${AccentColor.skyblue}`,
|
||||||
|
}}
|
||||||
|
bg={AccentColor.blue}
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
radius={"xl"}
|
||||||
|
opacity={0.8}
|
||||||
|
onClick={() => onLoadData()}
|
||||||
|
leftIcon={<IconRefresh />}
|
||||||
|
>
|
||||||
|
Update Data
|
||||||
|
</Button>
|
||||||
|
</Center>
|
||||||
|
</Affix>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
<Table
|
||||||
|
verticalSpacing={"md"}
|
||||||
|
horizontalSpacing={"md"}
|
||||||
|
p={"md"}
|
||||||
|
w={1500}
|
||||||
|
striped
|
||||||
|
highlightOnHover
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center>Username</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Judul</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Lokasi</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Tipe Acara</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Tanggal</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Jam</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Deskripsi</Center>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th>
|
||||||
|
<Center>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{TableRows}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
|
<Center mt={"xl"}>
|
||||||
|
<Pagination
|
||||||
|
value={isActivePage}
|
||||||
|
total={isNPage}
|
||||||
|
onChange={(val) => {
|
||||||
|
onPageClick(val);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Paper>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
opened={opened}
|
||||||
|
onClose={close}
|
||||||
|
centered
|
||||||
|
withCloseButton={false}
|
||||||
|
size={"md"}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Textarea
|
||||||
|
minRows={2}
|
||||||
|
maxRows={5}
|
||||||
|
maxLength={300}
|
||||||
|
autosize
|
||||||
|
label="Masukan Alasan Penolakan"
|
||||||
|
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||||
|
onChange={(val) => {
|
||||||
|
setCatatan(val.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Group position="right">
|
||||||
|
<Button radius={"xl"} onClick={close}>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
onReject(eventId, catatan);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ export async function adminEvent_funGetListReview({
|
|||||||
skip: skipData,
|
skip: skipData,
|
||||||
take: takeData,
|
take: takeData,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
tanggal: "desc",
|
tanggal: "asc",
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
eventMaster_StatusId: "2",
|
eventMaster_StatusId: "2",
|
||||||
|
|||||||
@@ -1,38 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
|
||||||
import { MODEL_EVENT } from "@/app_modules/event/model/interface";
|
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Stack
|
||||||
Center,
|
|
||||||
Group,
|
|
||||||
Modal,
|
|
||||||
Pagination,
|
|
||||||
Paper,
|
|
||||||
ScrollArea,
|
|
||||||
Spoiler,
|
|
||||||
Stack,
|
|
||||||
Table,
|
|
||||||
Text,
|
|
||||||
Textarea,
|
|
||||||
TextInput,
|
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
|
||||||
import { IconBan, IconCircleCheck, IconSearch } from "@tabler/icons-react";
|
|
||||||
import moment from "moment";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
|
||||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||||
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
import { AdminEvent_ComponentTableReview } from "../_view";
|
||||||
import { adminEvent_funGetListReview } from "../fun";
|
|
||||||
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
|
||||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
|
||||||
|
|
||||||
export default function AdminEvent_TableReview({
|
export default function AdminEvent_TableReview({
|
||||||
listData,
|
listData,
|
||||||
@@ -43,308 +15,10 @@ export default function AdminEvent_TableReview({
|
|||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Event" />
|
<ComponentAdminGlobal_HeaderTamplate name="Event" />
|
||||||
<TableStatus listData={listData} />
|
<AdminEvent_ComponentTableReview listData={listData} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listData }: { listData: any }) {
|
|
||||||
const router = useRouter();
|
|
||||||
const [data, setData] = useState<MODEL_EVENT[]>(listData.data);
|
|
||||||
const [isNPage, setNPage] = useState(listData.nPage);
|
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
|
||||||
const [isSearch, setSearch] = useState("");
|
|
||||||
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
|
||||||
const [catatan, setCatatan] = useState("");
|
|
||||||
const [eventId, setEventId] = useState("");
|
|
||||||
|
|
||||||
// const dataEvent = {} as Prisma.UserUncheckedCreateInput;
|
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
|
||||||
setSearch(s);
|
|
||||||
const loadData = await adminEvent_funGetListReview({
|
|
||||||
page: 1,
|
|
||||||
search: s,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
|
||||||
setActivePage(p);
|
|
||||||
const loadData = await adminEvent_funGetListReview({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onPublish(eventId: string, tanggal: Date) {
|
|
||||||
if (moment(tanggal).diff(Date.now(), "minutes") < 0)
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
|
||||||
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
|
||||||
);
|
|
||||||
|
|
||||||
const res = await AdminEvent_funEditStatusPublishById(eventId, "1");
|
|
||||||
if (res.status === 200) {
|
|
||||||
const dataNotif = {
|
|
||||||
appId: res.data?.id,
|
|
||||||
status: res.data?.EventMaster_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "EVENT",
|
|
||||||
title: "Event 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 })
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadData = await adminEvent_funGetListReview({
|
|
||||||
search: isSearch,
|
|
||||||
page: isActivePage,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status");
|
|
||||||
} else {
|
|
||||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onReject(eventId: string, catatan: string) {
|
|
||||||
if (catatan === "")
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Catatan");
|
|
||||||
const body = {
|
|
||||||
id: eventId,
|
|
||||||
catatan: catatan,
|
|
||||||
};
|
|
||||||
|
|
||||||
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
|
||||||
if (res.status === 200) {
|
|
||||||
const dataNotif = {
|
|
||||||
appId: res.data?.id,
|
|
||||||
status: res.data?.EventMaster_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "EVENT",
|
|
||||||
title: "Event 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 })
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadData = await adminEvent_funGetListReview({
|
|
||||||
search: isSearch,
|
|
||||||
page: isActivePage,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
close();
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const TableRows = data.map((e, i) => (
|
|
||||||
<tr key={i}>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
<Text>{e?.Author?.username}</Text>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
<Text lineClamp={2}>{e.title}</Text>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
<Text>{e.lokasi}</Text>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
{e.tanggal.toLocaleTimeString([], {
|
|
||||||
timeStyle: "short",
|
|
||||||
hourCycle: "h24",
|
|
||||||
})}
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={400}>
|
|
||||||
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
|
|
||||||
{e.deskripsi}
|
|
||||||
</Spoiler>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>
|
|
||||||
<Center>
|
|
||||||
<Stack>
|
|
||||||
<Button
|
|
||||||
color={"green"}
|
|
||||||
leftIcon={<IconCircleCheck />}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => onPublish(e.id, e.tanggal)}
|
|
||||||
>
|
|
||||||
Publish
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
color={"red"}
|
|
||||||
leftIcon={<IconBan />}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
open();
|
|
||||||
setEventId(e.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Reject
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Stack spacing={"xs"} h={"100%"}>
|
|
||||||
<Group
|
|
||||||
position="apart"
|
|
||||||
bg={"orange.4"}
|
|
||||||
p={"xs"}
|
|
||||||
style={{ borderRadius: "6px" }}
|
|
||||||
>
|
|
||||||
<Title order={4}>Review</Title>
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
|
||||||
<Table
|
|
||||||
verticalSpacing={"md"}
|
|
||||||
horizontalSpacing={"md"}
|
|
||||||
p={"md"}
|
|
||||||
w={1500}
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<Center>Username</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Judul</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Lokasi</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Tipe Acara</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Tanggal</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Jam</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Deskripsi</Center>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th>
|
|
||||||
<Center>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{TableRows}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={isActivePage}
|
|
||||||
total={isNPage}
|
|
||||||
onChange={(val) => {
|
|
||||||
onPageClick(val);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Center>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Modal
|
|
||||||
opened={opened}
|
|
||||||
onClose={close}
|
|
||||||
centered
|
|
||||||
withCloseButton={false}
|
|
||||||
size={"md"}
|
|
||||||
>
|
|
||||||
<Stack>
|
|
||||||
<Textarea
|
|
||||||
minRows={2}
|
|
||||||
maxRows={5}
|
|
||||||
maxLength={300}
|
|
||||||
autosize
|
|
||||||
label="Masukan Alasan Penolakan"
|
|
||||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
|
||||||
onChange={(val) => {
|
|
||||||
setCatatan(val.target.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Group position="right">
|
|
||||||
<Button radius={"xl"} onClick={close}>
|
|
||||||
Batal
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
onReject(eventId, catatan);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
3
src/app_modules/admin/job/_view/index.ts
Normal file
3
src/app_modules/admin/job/_view/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import AdminJob_ViewTavleReview from "./view_table_review";
|
||||||
|
|
||||||
|
export { AdminJob_ViewTavleReview };
|
||||||
450
src/app_modules/admin/job/_view/view_table_review.tsx
Normal file
450
src/app_modules/admin/job/_view/view_table_review.tsx
Normal file
@@ -0,0 +1,450 @@
|
|||||||
|
import { RouterAdminGlobal } from "@/app/lib";
|
||||||
|
import {
|
||||||
|
gs_adminJobTriggerReview,
|
||||||
|
IRealtimeData,
|
||||||
|
} from "@/app/lib/global_state";
|
||||||
|
import { ComponentGlobal_InputCountDown } from "@/app_modules/_global/component";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
||||||
|
import {
|
||||||
|
Center,
|
||||||
|
Spoiler,
|
||||||
|
Button,
|
||||||
|
Stack,
|
||||||
|
Modal,
|
||||||
|
Textarea,
|
||||||
|
Group,
|
||||||
|
TextInput,
|
||||||
|
Paper,
|
||||||
|
ScrollArea,
|
||||||
|
Table,
|
||||||
|
Pagination,
|
||||||
|
Text,
|
||||||
|
Affix,
|
||||||
|
rem,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import {
|
||||||
|
IconPhotoCheck,
|
||||||
|
IconEyeShare,
|
||||||
|
IconBan,
|
||||||
|
IconSearch,
|
||||||
|
IconRefresh,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||||
|
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
||||||
|
import { AdminJob_funEditCatatanById } from "../fun/edit/fun_edit_catatan_by_id";
|
||||||
|
import { AdminJob_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
||||||
|
import adminJob_getListReview from "../fun/get/get_list_review";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
|
||||||
|
export default function AdminJob_ViewTavleReview({
|
||||||
|
listReview,
|
||||||
|
}: {
|
||||||
|
listReview: any;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [data, setData] = useState<MODEL_JOB[]>(listReview.data);
|
||||||
|
const [nPage, setNPage] = useState(listReview.nPage);
|
||||||
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
|
const [reject, setReject] = useState(false);
|
||||||
|
const [jobId, setJobId] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [catatan, setCatatan] = useState("");
|
||||||
|
|
||||||
|
// Realtime
|
||||||
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
|
gs_adminJobTriggerReview
|
||||||
|
);
|
||||||
|
const [isShowReload, setIsShowReload] = useState(false);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (isAdminJob_TriggerReview) {
|
||||||
|
setIsShowReload(true);
|
||||||
|
}
|
||||||
|
}, [isAdminJob_TriggerReview, setIsShowReload]);
|
||||||
|
|
||||||
|
// useShallowEffect(() => {
|
||||||
|
// onLoadData({
|
||||||
|
// onSuccessLoad(val) {
|
||||||
|
// setData(val.data);
|
||||||
|
// setNPage(val.nPage);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// }, [setData, setNPage]);
|
||||||
|
// async function onLoadData({
|
||||||
|
// onSuccessLoad,
|
||||||
|
// }: {
|
||||||
|
// onSuccessLoad: (val: any) => any;
|
||||||
|
// }) {
|
||||||
|
// const loadData = await adminJob_getListReview({ page: 1 });
|
||||||
|
// onSuccessLoad(loadData);
|
||||||
|
// }
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
const loadData = await adminJob_getListReview({ page: 1 });
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsShowReload(false);
|
||||||
|
setIsAdminJob_TriggerReview(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSearch(s: string) {
|
||||||
|
setSearch(s);
|
||||||
|
setActivePage(1);
|
||||||
|
const loadData = await adminJob_getListReview({
|
||||||
|
page: 1,
|
||||||
|
search: s,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPageClick(p: any) {
|
||||||
|
setActivePage(p);
|
||||||
|
const loadData = await adminJob_getListReview({
|
||||||
|
search: isSearch,
|
||||||
|
page: p,
|
||||||
|
});
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rowTable = data?.map((e, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
<td>
|
||||||
|
<Center w={150}>
|
||||||
|
<Text>{e?.Author?.username}</Text>
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Spoiler
|
||||||
|
w={200}
|
||||||
|
maxHeight={50}
|
||||||
|
hideLabel="sembunyikan"
|
||||||
|
showLabel="tampilkan"
|
||||||
|
>
|
||||||
|
{e.title}
|
||||||
|
</Spoiler>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Center w={200}>
|
||||||
|
{e.imageId ? (
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading && jobId == e?.id}
|
||||||
|
color="green"
|
||||||
|
radius={"xl"}
|
||||||
|
leftIcon={<IconPhotoCheck />}
|
||||||
|
onClick={() => {
|
||||||
|
setJobId(e?.id);
|
||||||
|
setIsLoading(true);
|
||||||
|
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Lihat
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Center w={150}>
|
||||||
|
<Text fw={"bold"} fz={"xs"} fs={"italic"}>
|
||||||
|
Tidak ada poster
|
||||||
|
</Text>
|
||||||
|
</Center>
|
||||||
|
)}
|
||||||
|
</Center>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Spoiler
|
||||||
|
hideLabel="sembunyikan"
|
||||||
|
w={400}
|
||||||
|
maxHeight={50}
|
||||||
|
showLabel="tampilkan"
|
||||||
|
>
|
||||||
|
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
||||||
|
</Spoiler>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Spoiler
|
||||||
|
hideLabel="sembunyikan"
|
||||||
|
w={400}
|
||||||
|
maxHeight={50}
|
||||||
|
showLabel="tampilkan"
|
||||||
|
>
|
||||||
|
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
||||||
|
</Spoiler>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Stack>
|
||||||
|
<Stack align="center">
|
||||||
|
<Button
|
||||||
|
color={"green"}
|
||||||
|
leftIcon={<IconEyeShare />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() =>
|
||||||
|
onPublish({
|
||||||
|
jobId: e?.id,
|
||||||
|
onLoadData(val: any) {
|
||||||
|
setData(val.data);
|
||||||
|
setNPage(val.nPage);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Publish
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color={"red"}
|
||||||
|
leftIcon={<IconBan />}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
setReject(true);
|
||||||
|
setJobId(e.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reject
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Modal
|
||||||
|
opened={reject}
|
||||||
|
onClose={() => {
|
||||||
|
setReject(false);
|
||||||
|
}}
|
||||||
|
withCloseButton={false}
|
||||||
|
size={"sm"}
|
||||||
|
centered
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Stack spacing={5}>
|
||||||
|
<Textarea
|
||||||
|
minRows={2}
|
||||||
|
maxRows={5}
|
||||||
|
maxLength={300}
|
||||||
|
autosize
|
||||||
|
label={<Text fw={"bold"}>Alasan Penolakan</Text>}
|
||||||
|
placeholder="Masukkan alasan penolakan lowongan ini"
|
||||||
|
onChange={(val) => setCatatan(val.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
<ComponentGlobal_InputCountDown
|
||||||
|
maxInput={300}
|
||||||
|
lengthInput={catatan.length}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Group position="right">
|
||||||
|
<Button radius={"xl"} onClick={() => setReject(false)}>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
style={{ transition: "0.5s" }}
|
||||||
|
disabled={catatan === "" ? true : false}
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
onReject({
|
||||||
|
jobId: jobId,
|
||||||
|
catatan: catatan,
|
||||||
|
onLoadData(val) {
|
||||||
|
setData(val.data);
|
||||||
|
setNPage(val.nPage);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setReject(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Stack spacing={"xs"} h={"100%"}>
|
||||||
|
<ComponentAdminGlobal_TitlePage
|
||||||
|
name="Review"
|
||||||
|
color="orange.4"
|
||||||
|
component={
|
||||||
|
<TextInput
|
||||||
|
icon={<IconSearch size={20} />}
|
||||||
|
radius={"xl"}
|
||||||
|
placeholder="Masukan judul"
|
||||||
|
onChange={(val) => {
|
||||||
|
onSearch(val.currentTarget.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||||
|
{isShowReload && (
|
||||||
|
<Paper bg={"red"} w={"50%"}>
|
||||||
|
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||||
|
<Center>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
border: `1px solid ${AccentColor.skyblue}`,
|
||||||
|
}}
|
||||||
|
bg={AccentColor.blue}
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
radius={"xl"}
|
||||||
|
opacity={0.8}
|
||||||
|
onClick={() => onLoadData()}
|
||||||
|
leftIcon={<IconRefresh />}
|
||||||
|
>
|
||||||
|
Update Data
|
||||||
|
</Button>
|
||||||
|
</Center>
|
||||||
|
</Affix>
|
||||||
|
</Paper>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
<Table
|
||||||
|
verticalSpacing={"md"}
|
||||||
|
horizontalSpacing={"md"}
|
||||||
|
p={"md"}
|
||||||
|
w={"100%"}
|
||||||
|
h={"100%"}
|
||||||
|
striped
|
||||||
|
highlightOnHover
|
||||||
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<Center>Author</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Text>Judul</Text>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Poster</Center>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Text>Syarat Ketentuan</Text>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Text>Deskripsi</Text>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<Center>Aksi</Center>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>{rowTable}</tbody>
|
||||||
|
</Table>
|
||||||
|
</ScrollArea>
|
||||||
|
<Center mt={"xl"}>
|
||||||
|
<Pagination
|
||||||
|
value={activePage}
|
||||||
|
total={nPage}
|
||||||
|
onChange={(val) => {
|
||||||
|
onPageClick(val);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
</Paper>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onPublish({
|
||||||
|
jobId,
|
||||||
|
onLoadData,
|
||||||
|
}: {
|
||||||
|
jobId: string;
|
||||||
|
onLoadData: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const publish = await AdminJob_funEditStatusPublishById(jobId);
|
||||||
|
if (publish.status === 200) {
|
||||||
|
const loadData = await adminJob_getListReview({ page: 1 });
|
||||||
|
onLoadData(loadData);
|
||||||
|
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: publish.data?.id as any,
|
||||||
|
status: publish.data?.MasterStatus?.name as any,
|
||||||
|
userId: publish.data?.authorId as any,
|
||||||
|
pesan: publish.data?.title as any,
|
||||||
|
kategoriApp: "JOB",
|
||||||
|
title: "Job publish",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createNotifikasi = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (createNotifikasi.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(publish.message);
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(publish.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onReject({
|
||||||
|
jobId,
|
||||||
|
catatan,
|
||||||
|
onLoadData,
|
||||||
|
}: {
|
||||||
|
jobId: string;
|
||||||
|
catatan: string;
|
||||||
|
onLoadData: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const reject = await AdminJob_funEditCatatanById(jobId, catatan);
|
||||||
|
|
||||||
|
if (reject.status === 200) {
|
||||||
|
const loadData = await adminJob_getListReview({ page: 1 });
|
||||||
|
onLoadData(loadData);
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(reject.message);
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: reject.data?.id as any,
|
||||||
|
status: reject.data?.MasterStatus?.name as any,
|
||||||
|
userId: reject.data?.authorId as any,
|
||||||
|
pesan: reject.data?.title as any,
|
||||||
|
kategoriApp: "JOB",
|
||||||
|
title: "Job reject",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createRejectNotifikasi = await adminNotifikasi_funCreateToUser({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (createRejectNotifikasi.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(reject.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,43 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterAdminGlobal } from "@/app/lib";
|
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
|
||||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
import { Stack } from "@mantine/core";
|
||||||
import { MODEL_JOB } from "@/app_modules/job/model/interface";
|
import { AdminJob_ViewTavleReview } from "../../_view";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
Group,
|
|
||||||
Modal,
|
|
||||||
Pagination,
|
|
||||||
Paper,
|
|
||||||
ScrollArea,
|
|
||||||
Spoiler,
|
|
||||||
Stack,
|
|
||||||
Table,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
Textarea,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
|
||||||
import {
|
|
||||||
IconBan,
|
|
||||||
IconEyeShare,
|
|
||||||
IconPhotoCheck,
|
|
||||||
IconSearch,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { AdminJob_funEditCatatanById } from "../../fun/edit/fun_edit_catatan_by_id";
|
|
||||||
import { AdminJob_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
|
||||||
import adminJob_getListReview from "../../fun/get/get_list_review";
|
|
||||||
import { IRealtimeData } from "@/app/lib/global_state";
|
|
||||||
import { WibuRealtime } from "wibu-pkg";
|
|
||||||
|
|
||||||
export default function AdminJob_TableReview({
|
export default function AdminJob_TableReview({
|
||||||
dataReview,
|
dataReview,
|
||||||
@@ -48,374 +13,8 @@ export default function AdminJob_TableReview({
|
|||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
<ComponentAdminGlobal_HeaderTamplate name="Job Vacancy" />
|
||||||
<TableStatus listReview={dataReview} />
|
<AdminJob_ViewTavleReview listReview={dataReview} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listReview }: { listReview: any }) {
|
|
||||||
const router = useRouter();
|
|
||||||
const [data, setData] = useState<MODEL_JOB[]>(listReview.data);
|
|
||||||
const [nPage, setNPage] = useState(listReview.nPage);
|
|
||||||
const [activePage, setActivePage] = useState(1);
|
|
||||||
const [isSearch, setSearch] = useState("");
|
|
||||||
|
|
||||||
const [reject, setReject] = useState(false);
|
|
||||||
const [jobId, setJobId] = useState("");
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const [catatan, setCatatan] = useState("");
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
onLoadData({
|
|
||||||
onSuccessLoad(val) {
|
|
||||||
setData(val.data);
|
|
||||||
setNPage(val.nPage);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, [setData, setNPage]);
|
|
||||||
|
|
||||||
async function onLoadData({
|
|
||||||
onSuccessLoad,
|
|
||||||
}: {
|
|
||||||
onSuccessLoad: (val: any) => any;
|
|
||||||
}) {
|
|
||||||
const loadData = await adminJob_getListReview({ page: 1 });
|
|
||||||
onSuccessLoad(loadData);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
|
||||||
setSearch(s);
|
|
||||||
setActivePage(1);
|
|
||||||
const loadData = await adminJob_getListReview({
|
|
||||||
page: 1,
|
|
||||||
search: s,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onPageClick(p: any) {
|
|
||||||
setActivePage(p);
|
|
||||||
const loadData = await adminJob_getListReview({
|
|
||||||
search: isSearch,
|
|
||||||
page: p,
|
|
||||||
});
|
|
||||||
setData(loadData.data as any);
|
|
||||||
setNPage(loadData.nPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
const rowTable = data?.map((e, i) => (
|
|
||||||
<tr key={i}>
|
|
||||||
<td>
|
|
||||||
<Center w={150}>
|
|
||||||
<Text>{e?.Author?.username}</Text>
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Spoiler
|
|
||||||
w={200}
|
|
||||||
maxHeight={50}
|
|
||||||
hideLabel="sembunyikan"
|
|
||||||
showLabel="tampilkan"
|
|
||||||
>
|
|
||||||
{e.title}
|
|
||||||
</Spoiler>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Center w={200}>
|
|
||||||
{e.imageId ? (
|
|
||||||
<Button
|
|
||||||
loaderPosition="center"
|
|
||||||
loading={isLoading && jobId == e?.id}
|
|
||||||
color="green"
|
|
||||||
radius={"xl"}
|
|
||||||
leftIcon={<IconPhotoCheck />}
|
|
||||||
onClick={() => {
|
|
||||||
setJobId(e?.id);
|
|
||||||
setIsLoading(true);
|
|
||||||
router.push(RouterAdminGlobal.preview_image({ id: e.imageId }));
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Lihat
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Center w={150}>
|
|
||||||
<Text fw={"bold"} fz={"xs"} fs={"italic"}>
|
|
||||||
Tidak ada poster
|
|
||||||
</Text>
|
|
||||||
</Center>
|
|
||||||
)}
|
|
||||||
</Center>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Spoiler
|
|
||||||
hideLabel="sembunyikan"
|
|
||||||
w={400}
|
|
||||||
maxHeight={50}
|
|
||||||
showLabel="tampilkan"
|
|
||||||
>
|
|
||||||
<div dangerouslySetInnerHTML={{ __html: e.content }} />
|
|
||||||
</Spoiler>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Spoiler
|
|
||||||
hideLabel="sembunyikan"
|
|
||||||
w={400}
|
|
||||||
maxHeight={50}
|
|
||||||
showLabel="tampilkan"
|
|
||||||
>
|
|
||||||
<div dangerouslySetInnerHTML={{ __html: e.deskripsi }} />
|
|
||||||
</Spoiler>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Stack>
|
|
||||||
<Stack align="center">
|
|
||||||
<Button
|
|
||||||
color={"green"}
|
|
||||||
leftIcon={<IconEyeShare />}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() =>
|
|
||||||
onPublish({
|
|
||||||
jobId: e?.id,
|
|
||||||
onLoadData(val: any) {
|
|
||||||
setData(val.data);
|
|
||||||
setNPage(val.nPage);
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Publish
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
color={"red"}
|
|
||||||
leftIcon={<IconBan />}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
setReject(true);
|
|
||||||
setJobId(e.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Reject
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Modal
|
|
||||||
opened={reject}
|
|
||||||
onClose={() => {
|
|
||||||
setReject(false);
|
|
||||||
}}
|
|
||||||
withCloseButton={false}
|
|
||||||
size={"sm"}
|
|
||||||
centered
|
|
||||||
>
|
|
||||||
<Stack>
|
|
||||||
<Stack spacing={5}>
|
|
||||||
<Textarea
|
|
||||||
minRows={2}
|
|
||||||
maxRows={5}
|
|
||||||
maxLength={300}
|
|
||||||
autosize
|
|
||||||
label={<Text fw={"bold"}>Alasan Penolakan</Text>}
|
|
||||||
placeholder="Masukkan alasan penolakan lowongan ini"
|
|
||||||
onChange={(val) => setCatatan(val.currentTarget.value)}
|
|
||||||
/>
|
|
||||||
<ComponentGlobal_InputCountDown
|
|
||||||
maxInput={300}
|
|
||||||
lengthInput={catatan.length}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
<Group position="right">
|
|
||||||
<Button radius={"xl"} onClick={() => setReject(false)}>
|
|
||||||
Batal
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
style={{ transition: "0.5s" }}
|
|
||||||
disabled={catatan === "" ? true : false}
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
onReject({
|
|
||||||
jobId: jobId,
|
|
||||||
catatan: catatan,
|
|
||||||
onLoadData(val) {
|
|
||||||
setData(val.data);
|
|
||||||
setNPage(val.nPage);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
setReject(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<Stack spacing={"xs"} h={"100%"}>
|
|
||||||
<ComponentAdminGlobal_TitlePage
|
|
||||||
name="Review"
|
|
||||||
color="orange.4"
|
|
||||||
component={
|
|
||||||
<TextInput
|
|
||||||
icon={<IconSearch size={20} />}
|
|
||||||
radius={"xl"}
|
|
||||||
placeholder="Masukan judul"
|
|
||||||
onChange={(val) => {
|
|
||||||
onSearch(val.currentTarget.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
|
||||||
<Table
|
|
||||||
verticalSpacing={"md"}
|
|
||||||
horizontalSpacing={"md"}
|
|
||||||
p={"md"}
|
|
||||||
w={"100%"}
|
|
||||||
h={"100%"}
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<Center>Author</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Text>Judul</Text>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Poster</Center>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Text>Syarat Ketentuan</Text>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Text>Deskripsi</Text>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<Center>Aksi</Center>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>{rowTable}</tbody>
|
|
||||||
</Table>
|
|
||||||
</ScrollArea>
|
|
||||||
<Center mt={"xl"}>
|
|
||||||
<Pagination
|
|
||||||
value={activePage}
|
|
||||||
total={nPage}
|
|
||||||
onChange={(val) => {
|
|
||||||
onPageClick(val);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Center>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onPublish({
|
|
||||||
jobId,
|
|
||||||
onLoadData,
|
|
||||||
}: {
|
|
||||||
jobId: string;
|
|
||||||
onLoadData: (val: any) => void;
|
|
||||||
}) {
|
|
||||||
const publish = await AdminJob_funEditStatusPublishById(jobId);
|
|
||||||
if (publish.status === 200) {
|
|
||||||
const loadData = await adminJob_getListReview({ page: 1 });
|
|
||||||
onLoadData(loadData);
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
appId: publish.data?.id as any,
|
|
||||||
status: publish.data?.MasterStatus?.name as any,
|
|
||||||
userId: publish.data?.authorId as any,
|
|
||||||
pesan: publish.data?.title as any,
|
|
||||||
kategoriApp: "JOB",
|
|
||||||
title: "Job publish",
|
|
||||||
};
|
|
||||||
|
|
||||||
const createNotifikasi = await adminNotifikasi_funCreateToUser({
|
|
||||||
data: dataNotifikasi as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (createNotifikasi.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "trigger",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(publish.message);
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(publish.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onReject({
|
|
||||||
jobId,
|
|
||||||
catatan,
|
|
||||||
onLoadData,
|
|
||||||
}: {
|
|
||||||
jobId: string;
|
|
||||||
catatan: string;
|
|
||||||
onLoadData: (val: any) => void;
|
|
||||||
}) {
|
|
||||||
const reject = await AdminJob_funEditCatatanById(jobId, catatan);
|
|
||||||
|
|
||||||
if (reject.status === 200) {
|
|
||||||
const loadData = await adminJob_getListReview({ page: 1 });
|
|
||||||
onLoadData(loadData);
|
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(reject.message);
|
|
||||||
|
|
||||||
// const dataNotif = {
|
|
||||||
// appId: reject.data?.id as any,
|
|
||||||
// status: reject.data?.MasterStatus?.name as any,
|
|
||||||
// userId: reject.data?.authorId as any,
|
|
||||||
// pesan: reject.data?.title as any,
|
|
||||||
// kategoriApp: "JOB",
|
|
||||||
// title: "Job anda ditolak !",
|
|
||||||
// };
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
appId: reject.data?.id as any,
|
|
||||||
status: reject.data?.MasterStatus?.name as any,
|
|
||||||
userId: reject.data?.authorId as any,
|
|
||||||
pesan: reject.data?.title as any,
|
|
||||||
kategoriApp: "JOB",
|
|
||||||
title: "Job reject",
|
|
||||||
};
|
|
||||||
|
|
||||||
const createRejectNotifikasi = await adminNotifikasi_funCreateToUser({
|
|
||||||
data: dataNotifikasi as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (createRejectNotifikasi.status === 201) {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "USER",
|
|
||||||
dataMessage: dataNotifikasi,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(reject.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -189,10 +189,10 @@ export default function AdminLayout({
|
|||||||
</Box>
|
</Box>
|
||||||
));
|
));
|
||||||
|
|
||||||
async function onLoadNotifikasi() {
|
// async function onLoadNotifikasi() {
|
||||||
const loadNotif = await adminNotifikasi_getByUserId();
|
// const loadNotif = await adminNotifikasi_getByUserId();
|
||||||
setDataNotif(loadNotif as any);
|
// setDataNotif(loadNotif as any);
|
||||||
}
|
// }
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mqtt_client.subscribe("ADMIN");
|
mqtt_client.subscribe("ADMIN");
|
||||||
@@ -226,7 +226,7 @@ export default function AdminLayout({
|
|||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsNotif(true);
|
setIsNotif(true);
|
||||||
onLoadNotifikasi();
|
// onLoadNotifikasi();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Indicator
|
<Indicator
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export function Admin_NewLayout({
|
|||||||
user: MODEL_USER;
|
user: MODEL_USER;
|
||||||
countNotifikasi: number;
|
countNotifikasi: number;
|
||||||
listNotifikasi: MODEL_NOTIFIKASI[];
|
listNotifikasi: MODEL_NOTIFIKASI[];
|
||||||
version: string
|
version: string;
|
||||||
}) {
|
}) {
|
||||||
const matches = useMediaQuery("(min-width: 1024px)");
|
const matches = useMediaQuery("(min-width: 1024px)");
|
||||||
const [dataUser, setDataUser] = useState(user);
|
const [dataUser, setDataUser] = useState(user);
|
||||||
@@ -66,7 +66,7 @@ export function Admin_NewLayout({
|
|||||||
}, [newAdminNtf, setNewAdminNtf]);
|
}, [newAdminNtf, setNewAdminNtf]);
|
||||||
|
|
||||||
async function onLoadListNotifikasi() {
|
async function onLoadListNotifikasi() {
|
||||||
const loadNotifikasi = await adminNotifikasi_getByUserId();
|
const loadNotifikasi = await adminNotifikasi_getByUserId({ page: 1 });
|
||||||
|
|
||||||
setDataNotifikasi(loadNotifikasi as []);
|
setDataNotifikasi(loadNotifikasi as []);
|
||||||
setDrawerNotifikasi(true);
|
setDrawerNotifikasi(true);
|
||||||
@@ -189,6 +189,7 @@ export function Admin_NewLayout({
|
|||||||
size={"xs"}
|
size={"xs"}
|
||||||
>
|
>
|
||||||
<ComponentAdmin_UIDrawerNotifikasi
|
<ComponentAdmin_UIDrawerNotifikasi
|
||||||
|
newAdminNtf={newAdminNtf}
|
||||||
listNotifikasi={dataNotifikasi}
|
listNotifikasi={dataNotifikasi}
|
||||||
onChangeNavbar={(val: { id: string; childId: string }) => {
|
onChangeNavbar={(val: { id: string; childId: string }) => {
|
||||||
setActiveId(val.id);
|
setActiveId(val.id);
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
|
export async function admin_funEventCheckStatus({ id }: { id: string }) {
|
||||||
|
const data = await prisma.event.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
EventMaster_Status: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return { status: 400, message: "Id tidak ditemukan", statusName: "" };
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
message: "Id ditemukan",
|
||||||
|
statusName: _.lowerCase(data.EventMaster_Status?.name),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,10 +3,16 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
|
||||||
export default async function adminNotifikasi_getByUserId() {
|
export default async function adminNotifikasi_getByUserId({page}: {page: number}) {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
|
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await prisma.notifikasi.findMany({
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{
|
{
|
||||||
isRead: "asc",
|
isRead: "asc",
|
||||||
|
|||||||
3
src/app_modules/admin/notifikasi/fun/get/index.ts
Normal file
3
src/app_modules/admin/notifikasi/fun/get/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { admin_funEventCheckStatus } from "./fun_event_check_status";
|
||||||
|
|
||||||
|
export { admin_funEventCheckStatus };
|
||||||
@@ -2,27 +2,36 @@ import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
|
|||||||
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
||||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
|
import { admin_funEventCheckStatus } from "../fun/get";
|
||||||
|
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||||
|
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||||
|
|
||||||
export async function adminNotifikasi_findRouterEvent({
|
export async function adminNotifikasi_findRouterEvent({
|
||||||
data,
|
data,
|
||||||
router,
|
|
||||||
onChangeNavbar,
|
|
||||||
onToggleNavbar,
|
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
data: MODEL_NOTIFIKASI;
|
||||||
router: AppRouterInstance;
|
|
||||||
onChangeNavbar: (val: any) => void;
|
|
||||||
onToggleNavbar: (val: any) => void;
|
|
||||||
}) {
|
}) {
|
||||||
const path = RouterAdminEvent.table_review
|
const check = await admin_funEventCheckStatus({id: data.appId})
|
||||||
|
|
||||||
if (data.status === "Review") {
|
if (check.status == 200) {
|
||||||
router.push(path, { scroll: false });
|
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||||
onChangeNavbar({
|
notifId: data?.id,
|
||||||
id: 4,
|
|
||||||
childId: 43,
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
onToggleNavbar(true);
|
if (udpateReadNotifikasi.status == 200) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
statusName: check.statusName,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
statusName: "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,33 @@
|
|||||||
import { AccentColor } from "@/app_modules/_global/color";
|
|
||||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
|
||||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
|
||||||
import {
|
import {
|
||||||
Badge,
|
gs_adminEventTriggerReview,
|
||||||
Card,
|
gs_adminJobTriggerReview,
|
||||||
Center,
|
} from "@/app/lib/global_state";
|
||||||
Divider,
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
Group,
|
import { Center, Loader, Paper, Text } from "@mantine/core";
|
||||||
Paper,
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
Stack,
|
import { useAtom } from "jotai";
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import adminNotifikasi_countNotifikasi from "./fun/count/count_is_read";
|
import adminNotifikasi_countNotifikasi from "./fun/count/count_is_read";
|
||||||
import adminNotifikasi_getByUserId from "./fun/get/get_notifikasi_by_user_id";
|
import adminNotifikasi_getByUserId from "./fun/get/get_notifikasi_by_user_id";
|
||||||
|
import { adminNotifikasi_findRouterEvent } from "./route_setting/event";
|
||||||
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
||||||
import {
|
import {
|
||||||
IAdmin_ActiveChildId,
|
IAdmin_ActiveChildId,
|
||||||
IAdmin_ActivePage,
|
IAdmin_ActivePage,
|
||||||
} from "./route_setting/type_of_select_page";
|
} from "./route_setting/type_of_select_page";
|
||||||
|
import AdminNotifikasi_ViewCardDrawer from "./view_card_drawer";
|
||||||
|
|
||||||
export function ComponentAdmin_UIDrawerNotifikasi({
|
export function ComponentAdmin_UIDrawerNotifikasi({
|
||||||
|
newAdminNtf,
|
||||||
listNotifikasi,
|
listNotifikasi,
|
||||||
onChangeNavbar,
|
onChangeNavbar,
|
||||||
onToggleNavbar,
|
onToggleNavbar,
|
||||||
onLoadCountNotif,
|
onLoadCountNotif,
|
||||||
}: {
|
}: {
|
||||||
|
newAdminNtf: number;
|
||||||
listNotifikasi: MODEL_NOTIFIKASI[];
|
listNotifikasi: MODEL_NOTIFIKASI[];
|
||||||
onChangeNavbar: (val: {
|
onChangeNavbar: (val: {
|
||||||
id: IAdmin_ActivePage;
|
id: IAdmin_ActivePage;
|
||||||
@@ -37,107 +36,20 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
|||||||
onToggleNavbar: (val: any) => void;
|
onToggleNavbar: (val: any) => void;
|
||||||
onLoadCountNotif: (val: any) => void;
|
onLoadCountNotif: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
|
||||||
const [data, setData] = useState<MODEL_NOTIFIKASI[]>(listNotifikasi);
|
const [data, setData] = useState<MODEL_NOTIFIKASI[]>(listNotifikasi);
|
||||||
const [visible, setVisible] = useState(false);
|
const [activePage, setActivePage] = useState<number>(1);
|
||||||
const [dataId, setDataId] = useState<string>("");
|
|
||||||
|
|
||||||
async function onRead({ data }: { data: MODEL_NOTIFIKASI }) {
|
useShallowEffect(() => {
|
||||||
// JOB
|
if (newAdminNtf != 0) {
|
||||||
if (data?.kategoriApp === "JOB") {
|
onLoadData(setData);
|
||||||
const checkJob = await adminNotifikasi_findRouterJob({
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (checkJob?.success) {
|
|
||||||
setVisible(true);
|
|
||||||
setDataId(data.id);
|
|
||||||
|
|
||||||
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
|
||||||
onLoadCountNotif(loadCountNotif);
|
|
||||||
|
|
||||||
const loadListNotifikasi = await adminNotifikasi_getByUserId();
|
|
||||||
setData(loadListNotifikasi as any);
|
|
||||||
|
|
||||||
if (loadCountNotif && loadListNotifikasi) {
|
|
||||||
onChangeNavbar({
|
|
||||||
id: "Job",
|
|
||||||
childId: "Job_3",
|
|
||||||
});
|
|
||||||
|
|
||||||
const path = `/dev/admin/job/child/${checkJob.statusName}`;
|
|
||||||
|
|
||||||
router.push(path);
|
|
||||||
setVisible(false);
|
|
||||||
setDataId("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}, [newAdminNtf, setData]);
|
||||||
|
|
||||||
// // FORUM
|
async function onLoadData(setData: any) {
|
||||||
// e?.kategoriApp === "FORUM" &&
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
// adminNotifikasi_findRouterForum({
|
page: activePage,
|
||||||
// data: e,
|
});
|
||||||
// router: router,
|
setData(loadListNotifikasi as any);
|
||||||
// onChangeNavbar(val) {
|
|
||||||
// onChangeNavbar(val);
|
|
||||||
// },
|
|
||||||
// onToggleNavbar(val) {
|
|
||||||
// onToggleNavbar(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // VOTE
|
|
||||||
// e?.kategoriApp === "VOTING" &&
|
|
||||||
// adminNotifikasi_findRouterVoting({
|
|
||||||
// data: e,
|
|
||||||
// router: router,
|
|
||||||
// onChangeNavbar(val) {
|
|
||||||
// onChangeNavbar(val);
|
|
||||||
// },
|
|
||||||
// onToggleNavbar(val) {
|
|
||||||
// onToggleNavbar(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // EVENT
|
|
||||||
// e?.kategoriApp === "EVENT" &&
|
|
||||||
// adminNotifikasi_findRouterEvent({
|
|
||||||
// data: e,
|
|
||||||
// router: router,
|
|
||||||
// onChangeNavbar(val) {
|
|
||||||
// onChangeNavbar(val);
|
|
||||||
// },
|
|
||||||
// onToggleNavbar(val) {
|
|
||||||
// onToggleNavbar(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // DONASI
|
|
||||||
// e.kategoriApp === "DONASI" &&
|
|
||||||
// adminNotifikasi_findRouterDonasi({
|
|
||||||
// data: e,
|
|
||||||
// router: router,
|
|
||||||
// onChangeNavbar(val) {
|
|
||||||
// onChangeNavbar(val);
|
|
||||||
// },
|
|
||||||
// onToggleNavbar(val) {
|
|
||||||
// onToggleNavbar(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // INVESTASI
|
|
||||||
// e.kategoriApp === "INVESTASI" &&
|
|
||||||
// adminNotifikasi_findRouterInvestasi({
|
|
||||||
// data: e,
|
|
||||||
// router: router,
|
|
||||||
// onChangeNavbar(val) {
|
|
||||||
// onChangeNavbar(val);
|
|
||||||
// },
|
|
||||||
// onToggleNavbar(val) {
|
|
||||||
// onToggleNavbar(val);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.isEmpty(data)) {
|
if (_.isEmpty(data)) {
|
||||||
@@ -155,91 +67,42 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Paper h={"100%"}>
|
<Paper h={"100%"}>
|
||||||
<Stack>
|
<ScrollOnly
|
||||||
{data.map((e, i) => (
|
height="90vh"
|
||||||
<Card
|
renderLoading={() => (
|
||||||
style={{
|
<Center mt={"lg"}>
|
||||||
transition: "0.5s",
|
<Loader color={"yellow"} />
|
||||||
}}
|
</Center>
|
||||||
c={"white"}
|
)}
|
||||||
key={e?.id}
|
data={data}
|
||||||
bg={e?.isRead ? "gray" : AccentColor.darkblue}
|
setData={setData}
|
||||||
sx={{
|
moreData={async () => {
|
||||||
borderColor: AccentColor.blue,
|
const loadData = await adminNotifikasi_getByUserId({
|
||||||
borderStyle: "solid",
|
page: activePage + 1,
|
||||||
borderWidth: "2px",
|
});
|
||||||
":hover": {
|
|
||||||
backgroundColor: AccentColor.blue,
|
setActivePage((val) => val + 1);
|
||||||
borderColor: AccentColor.softblue,
|
|
||||||
borderStyle: "solid",
|
return loadData;
|
||||||
borderWidth: "2px",
|
}}
|
||||||
},
|
>
|
||||||
}}
|
{(item) => (
|
||||||
onClick={async () => {
|
<AdminNotifikasi_ViewCardDrawer
|
||||||
onRead({ data: e });
|
data={item}
|
||||||
// callBackIsNotifikasi(false);
|
activePage={activePage}
|
||||||
}}
|
onChangeNavbar={(val) => onChangeNavbar(val)}
|
||||||
>
|
onLoadCountNotif={(val) => onLoadCountNotif(val)}
|
||||||
<Card.Section p={"sm"}>
|
onToggleNavbar={(val) => onToggleNavbar(val)}
|
||||||
<Stack spacing={"xs"}>
|
onLoadDataNotifikasi={(val) => setData(val)}
|
||||||
<Group position="apart">
|
/>
|
||||||
<Text fw={"bold"} fz={10}>
|
)}
|
||||||
# {e?.kategoriApp}
|
</ScrollOnly>
|
||||||
</Text>
|
|
||||||
{e?.status ? (
|
{/* <Stack>
|
||||||
<Badge fz={10} size="sm">
|
{data.map((e, i) => (
|
||||||
{e?.status}
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
<Divider color="gray.3" />
|
|
||||||
</Stack>
|
|
||||||
</Card.Section>
|
|
||||||
<Card.Section px={"sm"} pb={"sm"}>
|
|
||||||
<Stack spacing={0}>
|
|
||||||
<Text lineClamp={2} fw={"bold"} fz={"xs"}>
|
|
||||||
{e?.title}
|
|
||||||
</Text>
|
|
||||||
<Text lineClamp={2} fz={"xs"}>
|
|
||||||
{e?.pesan}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Card.Section>
|
|
||||||
<Card.Section p={"sm"}>
|
|
||||||
<Group position="apart">
|
|
||||||
<Text fz={10}>
|
|
||||||
{new Intl.DateTimeFormat("id-ID", {
|
|
||||||
dateStyle: "long",
|
|
||||||
}).format(e?.createdAt)}
|
|
||||||
|
|
||||||
<Text span inherit fz={10}>
|
|
||||||
{", "}
|
|
||||||
{new Intl.DateTimeFormat("id-ID", {
|
|
||||||
timeStyle: "short",
|
|
||||||
}).format(e?.createdAt)}
|
|
||||||
</Text>
|
|
||||||
</Text>
|
|
||||||
{e?.isRead ? (
|
|
||||||
<Group spacing={5}>
|
|
||||||
<IconChecks size={10} />
|
|
||||||
<Text fz={10}>Sudah dilihat</Text>
|
|
||||||
</Group>
|
|
||||||
) : (
|
|
||||||
<Group spacing={5}>
|
|
||||||
<IconCheck size={10} />
|
|
||||||
<Text fz={10}>Belum dilihat</Text>
|
|
||||||
</Group>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
{visible && dataId === e?.id && (
|
|
||||||
<ComponentGlobal_CardLoadingOverlay />
|
|
||||||
)}
|
|
||||||
</Card.Section>
|
|
||||||
</Card>
|
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack> */}
|
||||||
</Paper>
|
</Paper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
296
src/app_modules/admin/notifikasi/view_card_drawer.tsx
Normal file
296
src/app_modules/admin/notifikasi/view_card_drawer.tsx
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
import {
|
||||||
|
gs_adminJobTriggerReview,
|
||||||
|
gs_adminEventTriggerReview,
|
||||||
|
} from "@/app/lib/global_state";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
||||||
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
|
import { Card, Stack, Group, Badge, Divider, Text } from "@mantine/core";
|
||||||
|
import { IconChecks, IconCheck } from "@tabler/icons-react";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import adminNotifikasi_countNotifikasi from "./fun/count/count_is_read";
|
||||||
|
import adminNotifikasi_getByUserId from "./fun/get/get_notifikasi_by_user_id";
|
||||||
|
import { adminNotifikasi_findRouterEvent } from "./route_setting/event";
|
||||||
|
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
||||||
|
import {
|
||||||
|
IAdmin_ActivePage,
|
||||||
|
IAdmin_ActiveChildId,
|
||||||
|
} from "./route_setting/type_of_select_page";
|
||||||
|
|
||||||
|
export default function AdminNotifikasi_ViewCardDrawer({
|
||||||
|
data,
|
||||||
|
activePage,
|
||||||
|
onChangeNavbar,
|
||||||
|
onToggleNavbar,
|
||||||
|
onLoadCountNotif,
|
||||||
|
onLoadDataNotifikasi,
|
||||||
|
}: {
|
||||||
|
data: MODEL_NOTIFIKASI;
|
||||||
|
activePage: number;
|
||||||
|
onChangeNavbar: (val: {
|
||||||
|
id: IAdmin_ActivePage;
|
||||||
|
childId: IAdmin_ActiveChildId;
|
||||||
|
}) => void;
|
||||||
|
onToggleNavbar: (val: any) => void;
|
||||||
|
onLoadCountNotif: (val: any) => void;
|
||||||
|
onLoadDataNotifikasi: (val: any) => void;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [dataId, setDataId] = useState<string>("");
|
||||||
|
|
||||||
|
// Realtime
|
||||||
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
|
gs_adminJobTriggerReview
|
||||||
|
);
|
||||||
|
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
||||||
|
gs_adminEventTriggerReview
|
||||||
|
);
|
||||||
|
|
||||||
|
async function onRead({ data }: { data: MODEL_NOTIFIKASI }) {
|
||||||
|
// JOB
|
||||||
|
if (data?.kategoriApp === "JOB") {
|
||||||
|
const checkJob = await adminNotifikasi_findRouterJob({
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkJob?.success) {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
|
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||||
|
onLoadCountNotif(loadCountNotif);
|
||||||
|
|
||||||
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
|
page: activePage,
|
||||||
|
});
|
||||||
|
onLoadDataNotifikasi(loadListNotifikasi as any);
|
||||||
|
|
||||||
|
if (loadCountNotif && loadListNotifikasi) {
|
||||||
|
const path = `/dev/admin/job/child/${checkJob.statusName}`;
|
||||||
|
|
||||||
|
if (checkJob.statusName == "publish") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkJob.statusName == "review") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_3",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkJob.statusName == "reject") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_4",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsAdminJob_TriggerReview(false);
|
||||||
|
router.push(path);
|
||||||
|
setVisible(false);
|
||||||
|
setDataId("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EVENT
|
||||||
|
if (data.kategoriApp == "EVENT") {
|
||||||
|
const checkEvent = await adminNotifikasi_findRouterEvent({
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkEvent?.success) {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
|
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||||
|
onLoadCountNotif(loadCountNotif);
|
||||||
|
|
||||||
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
|
page: activePage,
|
||||||
|
});
|
||||||
|
onLoadDataNotifikasi(loadListNotifikasi as any);
|
||||||
|
|
||||||
|
if (loadCountNotif && loadListNotifikasi) {
|
||||||
|
const path = `/dev/admin/event/table/${checkEvent.statusName}`;
|
||||||
|
|
||||||
|
if (checkEvent.statusName == "publish") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkEvent.statusName == "review") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_3",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkEvent.statusName == "reject") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_4",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsAdminEvent_TriggerReview(false);
|
||||||
|
router.push(path);
|
||||||
|
setVisible(false);
|
||||||
|
setDataId("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// // FORUM
|
||||||
|
// e?.kategoriApp === "FORUM" &&
|
||||||
|
// adminNotifikasi_findRouterForum({
|
||||||
|
// data: e,
|
||||||
|
// router: router,
|
||||||
|
// onChangeNavbar(val) {
|
||||||
|
// onChangeNavbar(val);
|
||||||
|
// },
|
||||||
|
// onToggleNavbar(val) {
|
||||||
|
// onToggleNavbar(val);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // VOTE
|
||||||
|
// e?.kategoriApp === "VOTING" &&
|
||||||
|
// adminNotifikasi_findRouterVoting({
|
||||||
|
// data: e,
|
||||||
|
// router: router,
|
||||||
|
// onChangeNavbar(val) {
|
||||||
|
// onChangeNavbar(val);
|
||||||
|
// },
|
||||||
|
// onToggleNavbar(val) {
|
||||||
|
// onToggleNavbar(val);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // EVENT
|
||||||
|
// e?.kategoriApp === "EVENT" &&
|
||||||
|
//
|
||||||
|
|
||||||
|
// // DONASI
|
||||||
|
// e.kategoriApp === "DONASI" &&
|
||||||
|
// adminNotifikasi_findRouterDonasi({
|
||||||
|
// data: e,
|
||||||
|
// router: router,
|
||||||
|
// onChangeNavbar(val) {
|
||||||
|
// onChangeNavbar(val);
|
||||||
|
// },
|
||||||
|
// onToggleNavbar(val) {
|
||||||
|
// onToggleNavbar(val);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // INVESTASI
|
||||||
|
// e.kategoriApp === "INVESTASI" &&
|
||||||
|
// adminNotifikasi_findRouterInvestasi({
|
||||||
|
// data: e,
|
||||||
|
// router: router,
|
||||||
|
// onChangeNavbar(val) {
|
||||||
|
// onChangeNavbar(val);
|
||||||
|
// },
|
||||||
|
// onToggleNavbar(val) {
|
||||||
|
// onToggleNavbar(val);
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
}}
|
||||||
|
mb={"md"}
|
||||||
|
c={"white"}
|
||||||
|
key={data.id}
|
||||||
|
bg={data.isRead ? "gray" : AccentColor.darkblue}
|
||||||
|
sx={{
|
||||||
|
borderColor: AccentColor.blue,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderWidth: "2px",
|
||||||
|
":hover": {
|
||||||
|
backgroundColor: AccentColor.blue,
|
||||||
|
borderColor: AccentColor.softblue,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderWidth: "2px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onClick={async () => {
|
||||||
|
onRead({ data: data });
|
||||||
|
// callBackIsNotifikasi(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Card.Section p={"sm"}>
|
||||||
|
<Stack spacing={"xs"}>
|
||||||
|
<Group position="apart">
|
||||||
|
<Text fw={"bold"} fz={10}>
|
||||||
|
# {data.kategoriApp}
|
||||||
|
</Text>
|
||||||
|
{data.status ? (
|
||||||
|
<Badge fz={10} size="sm">
|
||||||
|
{data.status}
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
<Divider color="gray.3" />
|
||||||
|
</Stack>
|
||||||
|
</Card.Section>
|
||||||
|
<Card.Section px={"sm"} pb={"sm"}>
|
||||||
|
<Stack spacing={0}>
|
||||||
|
<Text lineClamp={2} fw={"bold"} fz={"xs"}>
|
||||||
|
{data.title}
|
||||||
|
</Text>
|
||||||
|
<Text lineClamp={2} fz={"xs"}>
|
||||||
|
{data.pesan}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Card.Section>
|
||||||
|
<Card.Section p={"sm"}>
|
||||||
|
<Group position="apart">
|
||||||
|
<Text fz={10}>
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
dateStyle: "long",
|
||||||
|
}).format(data.createdAt)}
|
||||||
|
|
||||||
|
<Text span inherit fz={10}>
|
||||||
|
{", "}
|
||||||
|
{new Intl.DateTimeFormat("id-ID", {
|
||||||
|
timeStyle: "short",
|
||||||
|
}).format(data.createdAt)}
|
||||||
|
</Text>
|
||||||
|
</Text>
|
||||||
|
{data.isRead ? (
|
||||||
|
<Group spacing={5}>
|
||||||
|
<IconChecks size={10} />
|
||||||
|
<Text fz={10}>Sudah dilihat</Text>
|
||||||
|
</Group>
|
||||||
|
) : (
|
||||||
|
<Group spacing={5}>
|
||||||
|
<IconCheck size={10} />
|
||||||
|
<Text fz={10}>Belum dilihat</Text>
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
{visible && dataId === data.id && (
|
||||||
|
<ComponentGlobal_CardLoadingOverlay />
|
||||||
|
)}
|
||||||
|
</Card.Section>
|
||||||
|
</Card>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
|
ComponentGlobal_NotifikasiGagal,
|
||||||
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||||
|
import { Button } from "@mantine/core";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import moment from "moment";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import { Event_funCreate } from "../../fun/create/fun_create";
|
||||||
|
import { gs_event_hotMenu } from "../../global_state";
|
||||||
|
|
||||||
|
export default function Event_ComponentCreateButton({ value }: { value: any }) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
async function onSave() {
|
||||||
|
const res = await Event_funCreate(value);
|
||||||
|
|
||||||
|
if (res.status === 201) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Event baru",
|
||||||
|
};
|
||||||
|
|
||||||
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
setHotMenu(1);
|
||||||
|
setLoading(true);
|
||||||
|
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
}}
|
||||||
|
disabled={
|
||||||
|
value.title === "" ||
|
||||||
|
value.lokasi === "" ||
|
||||||
|
value.deskripsi === "" ||
|
||||||
|
value.eventMaster_TipeAcaraId === 0 ||
|
||||||
|
value.tanggal === "function Date() { [native code] }" ||
|
||||||
|
moment(value.tanggal).diff(moment(), "minutes") < 0
|
||||||
|
}
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading ? true : false}
|
||||||
|
radius={"xl"}
|
||||||
|
mt={"xl"}
|
||||||
|
onClick={() => {
|
||||||
|
onSave();
|
||||||
|
}}
|
||||||
|
bg={MainColor.yellow}
|
||||||
|
color="yellow"
|
||||||
|
c={"black"}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import Event_ComponentCreateButton from "./button/button_create_event";
|
||||||
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
||||||
|
|
||||||
export { Event_ComponentSkeletonDetailData };
|
export { Event_ComponentSkeletonDetailData };
|
||||||
|
export { Event_ComponentCreateButton };
|
||||||
|
|||||||
@@ -1,23 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
|
||||||
import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface";
|
import { MODEL_DEFAULT_MASTER_OLD } from "@/app_modules/model_global/interface";
|
||||||
import { Button, Select, Stack, TextInput, Textarea } from "@mantine/core";
|
import { Select, Stack, TextInput, Textarea } from "@mantine/core";
|
||||||
import { DateTimePicker } from "@mantine/dates";
|
import { DateTimePicker } from "@mantine/dates";
|
||||||
import { useAtom } from "jotai";
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Event_ComponentCreateButton } from "../component";
|
||||||
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
|
||||||
import { Event_funCreate } from "../fun/create/fun_create";
|
|
||||||
import { gs_event_hotMenu } from "../global_state";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
|
||||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
|
||||||
|
|
||||||
export default function Event_Create({
|
export default function Event_Create({
|
||||||
listTipeAcara,
|
listTipeAcara,
|
||||||
@@ -26,11 +16,9 @@ export default function Event_Create({
|
|||||||
listTipeAcara: MODEL_DEFAULT_MASTER_OLD[];
|
listTipeAcara: MODEL_DEFAULT_MASTER_OLD[];
|
||||||
authorId: string;
|
authorId: string;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
|
||||||
const [listTipe, setListTipe] = useState(listTipeAcara);
|
const [listTipe, setListTipe] = useState(listTipeAcara);
|
||||||
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
|
||||||
const [isTime, setIsTime] = useState(false);
|
const [isTime, setIsTime] = useState(false);
|
||||||
const [isLoading, setLoading] = useState(false);
|
|
||||||
|
|
||||||
const [value, setValue] = useState({
|
const [value, setValue] = useState({
|
||||||
title: "",
|
title: "",
|
||||||
@@ -159,81 +147,8 @@ export default function Event_Create({
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Event_ComponentCreateButton value={value} />
|
||||||
style={{
|
|
||||||
transition: "0.5s",
|
|
||||||
}}
|
|
||||||
disabled={
|
|
||||||
value.title === "" ||
|
|
||||||
value.lokasi === "" ||
|
|
||||||
value.deskripsi === "" ||
|
|
||||||
value.eventMaster_TipeAcaraId === 0 ||
|
|
||||||
value.tanggal === "function Date() { [native code] }" ||
|
|
||||||
moment(value.tanggal).diff(moment(), "minutes") < 0
|
|
||||||
}
|
|
||||||
loaderPosition="center"
|
|
||||||
loading={isLoading ? true : false}
|
|
||||||
radius={"xl"}
|
|
||||||
mt={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
onSave(router, value, setHotMenu, setLoading);
|
|
||||||
}}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSave(
|
|
||||||
router: AppRouterInstance,
|
|
||||||
value: any,
|
|
||||||
setHotMenu: any,
|
|
||||||
setLoading: any
|
|
||||||
) {
|
|
||||||
// if (_.values(value).includes(""))
|
|
||||||
// return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
|
||||||
// if (value.eventMaster_TipeAcaraId === 0)
|
|
||||||
// return ComponentGlobal_NotifikasiPeringatan("Pilih Tipe Acara");
|
|
||||||
// if (moment(value.tanggal).format() === "Invalid date")
|
|
||||||
// return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
|
|
||||||
// if (
|
|
||||||
// moment(value.tanggal.toISOString().toString()).diff(moment(), "minutes") < 0
|
|
||||||
// )
|
|
||||||
// return null;
|
|
||||||
|
|
||||||
const res = await Event_funCreate(value);
|
|
||||||
if (res.status === 201) {
|
|
||||||
const dataNotif: any = {
|
|
||||||
appId: res.data?.id as any,
|
|
||||||
status: res.data?.EventMaster_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "EVENT",
|
|
||||||
title: "Event baru",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
|
||||||
data: dataNotif as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
mqtt_client.publish(
|
|
||||||
"ADMIN",
|
|
||||||
JSON.stringify({
|
|
||||||
count: 1,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
setHotMenu(1);
|
|
||||||
setLoading(true);
|
|
||||||
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
@@ -7,11 +8,11 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_glo
|
|||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
|
||||||
import { Button, Group, Stack } from "@mantine/core";
|
import { Button, Group, Stack } from "@mantine/core";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { Event_ComponentSkeletonDetailData } from "../../component";
|
import { Event_ComponentSkeletonDetailData } from "../../component";
|
||||||
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
import ComponentEvent_DetailData from "../../component/detail/detail_data";
|
||||||
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
|
||||||
@@ -27,8 +28,6 @@ export default function Event_DetailDraft({
|
|||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState<MODEL_EVENT | null>(dataEvent);
|
const [data, setData] = useState<MODEL_EVENT | null>(dataEvent);
|
||||||
|
|
||||||
console.log(data, "ini data dipage");
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -83,7 +82,16 @@ function ButtonAction({
|
|||||||
|
|
||||||
const res = await Event_funEditStatusById("2", eventId);
|
const res = await Event_funEditStatusById("2", eventId);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const dataNotif: any = {
|
// const dataNotif: any = {
|
||||||
|
// appId: res.data?.id as any,
|
||||||
|
// status: res.data?.EventMaster_Status?.name as any,
|
||||||
|
// userId: res.data?.authorId as any,
|
||||||
|
// pesan: res.data?.title as any,
|
||||||
|
// kategoriApp: "EVENT",
|
||||||
|
// title: "Mengajukan review",
|
||||||
|
// };
|
||||||
|
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id as any,
|
appId: res.data?.id as any,
|
||||||
status: res.data?.EventMaster_Status?.name as any,
|
status: res.data?.EventMaster_Status?.name as any,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
@@ -93,20 +101,24 @@ function ButtonAction({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"ADMIN",
|
type: "notification",
|
||||||
JSON.stringify({
|
pushNotificationTo: "ADMIN",
|
||||||
count: 1,
|
});
|
||||||
})
|
|
||||||
);
|
WibuRealtime.setData({
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
type: "trigger",
|
||||||
setLoadingAjukan(true);
|
pushNotificationTo: "ADMIN",
|
||||||
router.replace(RouterEvent.status({ id: "2" }));
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
|
setLoadingAjukan(true);
|
||||||
|
router.replace(RouterEvent.status({ id: "2" }));
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
|||||||
import { MODEL_EVENT, MODEL_EVENT_PESERTA } from "../../model/interface";
|
import { MODEL_EVENT, MODEL_EVENT_PESERTA } from "../../model/interface";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
|
||||||
export default function Event_DetailMain({
|
export default function Event_DetailMain({
|
||||||
dataEvent,
|
dataEvent,
|
||||||
@@ -82,29 +84,35 @@ async function onJoin(
|
|||||||
|
|
||||||
const res = await Event_funJoinEvent(body as any);
|
const res = await Event_funJoinEvent(body as any);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (userLoginId !== res.data?.Event?.authorId) {
|
// const dataNotif = {
|
||||||
const dataNotif = {
|
// appId: res?.data?.Event?.id,
|
||||||
appId: res?.data?.Event?.id,
|
// userId: res?.data?.Event?.authorId,
|
||||||
userId: res?.data?.Event?.authorId,
|
// pesan: res?.data?.Event?.title,
|
||||||
pesan: res?.data?.Event?.title,
|
// status: "Peserta Event",
|
||||||
status: "Peserta Event",
|
// kategoriApp: "EVENT",
|
||||||
kategoriApp: "EVENT",
|
// title: "Peserta baru telah masuk !",
|
||||||
title: "Peserta baru telah masuk !",
|
// };
|
||||||
};
|
|
||||||
|
|
||||||
const createNotifikasi = await notifikasiToUser_funCreate({
|
const dataNotifikasi: IRealtimeData = {
|
||||||
data: dataNotif as any,
|
appId: res?.data?.Event?.id as any,
|
||||||
|
status: "Peserta Event" as any,
|
||||||
|
userId: res.data?.Event?.authorId as any,
|
||||||
|
pesan: res.data?.Event?.title as any,
|
||||||
|
kategoriApp: "EVENT",
|
||||||
|
title: "Peserta baru event anda !",
|
||||||
|
};
|
||||||
|
|
||||||
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
|
data: dataNotifikasi as any,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (createNotifikasi.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "USER",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (createNotifikasi.status === 201) {
|
|
||||||
mqtt_client.publish(
|
|
||||||
"USER",
|
|
||||||
JSON.stringify({
|
|
||||||
userId: dataNotif.userId,
|
|
||||||
count: 1,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const resPeserta = await Event_getListPesertaById(eventId);
|
const resPeserta = await Event_getListPesertaById(eventId);
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { gs_eventTriggerBeranda } from "@/app/lib/global_state";
|
||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
import { Box, Center, Loader } from "@mantine/core";
|
import { Affix, Box, Button, Center, Loader, rem } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { ScrollOnly } from "next-scroll-loader";
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ComponentEvent_CardBeranda } from "../component/card_view/card_beranda";
|
import { ComponentEvent_CardBeranda } from "../component/card_view/card_beranda";
|
||||||
import { event_getListAllPublish } from "../fun/get/get_list_all_publish";
|
import { event_getListAllPublish } from "../fun/get/get_list_all_publish";
|
||||||
import { MODEL_EVENT } from "../model/interface";
|
import { MODEL_EVENT } from "../model/interface";
|
||||||
@@ -19,23 +22,70 @@ export default function Event_Beranda({
|
|||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState(dataEvent);
|
const [data, setData] = useState(dataEvent);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
// Realtime
|
||||||
|
const [isTriggerEventBeranda, setIsTriggerEventBeranca] = useAtom(
|
||||||
|
gs_eventTriggerBeranda
|
||||||
|
);
|
||||||
|
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoad({
|
onLoadData({
|
||||||
onPublish(val) {
|
onPublish(val) {
|
||||||
setData(val);
|
setData(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, [setData]);
|
}, [setData]);
|
||||||
|
|
||||||
async function onLoad({ onPublish }: { onPublish: (val: any) => void }) {
|
useShallowEffect(() => {
|
||||||
|
if (isTriggerEventBeranda) {
|
||||||
|
setIsShowUpdate(true);
|
||||||
|
}
|
||||||
|
}, [isTriggerEventBeranda, setIsShowUpdate]);
|
||||||
|
|
||||||
|
async function onLoadData({ onPublish }: { onPublish: (val: any) => void }) {
|
||||||
|
setIsLoading(true);
|
||||||
const loadData = await event_getListAllPublish({ page: 1 });
|
const loadData = await event_getListAllPublish({ page: 1 });
|
||||||
onPublish(loadData);
|
onPublish(loadData);
|
||||||
|
|
||||||
|
setIsShowUpdate(false);
|
||||||
|
setIsTriggerEventBeranca(false);
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box>
|
<Box>
|
||||||
|
{isShowUpdate && (
|
||||||
|
<Affix position={{ top: rem(100) }} w={"100%"}>
|
||||||
|
<Center>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
transition: "0.5s",
|
||||||
|
border: `1px solid ${AccentColor.skyblue}`,
|
||||||
|
}}
|
||||||
|
bg={AccentColor.blue}
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={isLoading}
|
||||||
|
radius={"xl"}
|
||||||
|
opacity={0.8}
|
||||||
|
onClick={() => {
|
||||||
|
onLoadData({
|
||||||
|
onPublish(val) {
|
||||||
|
setData(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update beranda
|
||||||
|
</Button>
|
||||||
|
</Center>
|
||||||
|
</Affix>
|
||||||
|
)}
|
||||||
|
|
||||||
<ComponentGlobal_CreateButton path={RouterEvent.create} />
|
<ComponentGlobal_CreateButton path={RouterEvent.create} />
|
||||||
{_.isEmpty(data) ? (
|
{_.isEmpty(data) ? (
|
||||||
<ComponentGlobal_IsEmptyData />
|
<ComponentGlobal_IsEmptyData />
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { useShallowEffect } from "@mantine/hooks";
|
|||||||
import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
import { IconBell, IconUserSearch } from "@tabler/icons-react";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { MODEL_USER } from "../model/interface";
|
import { MODEL_USER } from "../model/interface";
|
||||||
|
|
||||||
export function ComponentHome_ButtonHeaderLeft({
|
export function ComponentHome_ButtonHeaderLeft({
|
||||||
@@ -61,47 +61,27 @@ export function ComponentHome_ButtonHeaderRight({
|
|||||||
const [isLoadingBell, setIsLoadingBell] = useState(false);
|
const [isLoadingBell, setIsLoadingBell] = useState(false);
|
||||||
|
|
||||||
// Notifikasi
|
// Notifikasi
|
||||||
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
// const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
// const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useEffect(() => {
|
||||||
// console.log(newUserNtf, "new notif");
|
|
||||||
// console.log(countNtf, "count ntf");
|
|
||||||
setCountNtf(countNtf + newUserNtf);
|
|
||||||
setNewUserNtf(0);
|
|
||||||
|
|
||||||
onLoadNotifikasi({
|
|
||||||
onLoad(val) {
|
|
||||||
console.log(val, "total notif");
|
|
||||||
setCountNtf(val);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, [newUserNtf, setCountNtf]);
|
|
||||||
|
|
||||||
// useShallowEffect(() => {
|
|
||||||
// mqtt_client.subscribe("USER");
|
|
||||||
|
|
||||||
// mqtt_client.on("message", (topic: any, message: any) => {
|
|
||||||
// // console.log(topic);
|
|
||||||
// const data = JSON.parse(message.toString());
|
|
||||||
|
|
||||||
// if (data.userId === dataUser.id) {
|
|
||||||
// setCountNtf(countNtf + data.count);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// onLoadNotifikasi({
|
// onLoadNotifikasi({
|
||||||
// onLoad(val) {
|
// onLoad(val) {
|
||||||
// setCountNtf(val);
|
// setCountNtf(val);
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
// }, [countNtf]);
|
// }, [setCountNtf]);
|
||||||
|
|
||||||
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
// useShallowEffect(() => {
|
||||||
const loadNotif = await notifikasi_countUserNotifikasi();
|
// setCountNtf(countNtf + newUserNtf);
|
||||||
onLoad(loadNotif);
|
// setNewUserNtf(0);
|
||||||
}
|
// }, [newUserNtf, setCountNtf]);
|
||||||
|
|
||||||
|
// async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
|
// const loadNotif = await notifikasi_countUserNotifikasi();
|
||||||
|
// onLoad(loadNotif);
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -116,13 +96,12 @@ export function ComponentHome_ButtonHeaderRight({
|
|||||||
});
|
});
|
||||||
setCategoryPage("Semua");
|
setCategoryPage("Semua");
|
||||||
setIsLoadingBell(true);
|
setIsLoadingBell(true);
|
||||||
// setActiveKategori("Semua");
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isLoadingBell ? (
|
{isLoadingBell ? (
|
||||||
<Loader color={AccentColor.yellow} size={20} />
|
<Loader color={AccentColor.yellow} size={20} />
|
||||||
) : countNtf === 0 ? (
|
) : countNotifikasi === 0 ? (
|
||||||
<IconBell color="white" />
|
<IconBell color="white" />
|
||||||
) : (
|
) : (
|
||||||
<Indicator
|
<Indicator
|
||||||
@@ -130,7 +109,7 @@ export function ComponentHome_ButtonHeaderRight({
|
|||||||
color={MainColor.yellow}
|
color={MainColor.yellow}
|
||||||
label={
|
label={
|
||||||
<Text fz={10} c={MainColor.darkblue}>
|
<Text fz={10} c={MainColor.darkblue}>
|
||||||
{countNtf > 99 ? "99+" : countNtf}
|
{countNotifikasi > 99 ? "99+" : countNotifikasi}
|
||||||
</Text>
|
</Text>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import UIGlobal_LayoutHeaderTamplate from "../_global/ui/ui_header_tamplate";
|
import UIGlobal_LayoutHeaderTamplate from "../_global/ui/ui_header_tamplate";
|
||||||
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
||||||
import { MODEL_JOB } from "../job/model/interface";
|
import { MODEL_JOB } from "../job/model/interface";
|
||||||
@@ -7,6 +10,10 @@ import {
|
|||||||
} from "./component/button_header";
|
} from "./component/button_header";
|
||||||
import { Home_UiFooter, Home_UiView } from "./component/ui_home";
|
import { Home_UiFooter, Home_UiView } from "./component/ui_home";
|
||||||
import { MODEL_USER } from "./model/interface";
|
import { MODEL_USER } from "./model/interface";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { gs_count_ntf, gs_user_ntf } from "@/app/lib/global_state";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import notifikasi_countUserNotifikasi from "../notifikasi/fun/count/fun_count_by_id";
|
||||||
|
|
||||||
export default function HomeView({
|
export default function HomeView({
|
||||||
dataUser,
|
dataUser,
|
||||||
@@ -17,8 +24,29 @@ export default function HomeView({
|
|||||||
dataJob: MODEL_JOB[];
|
dataJob: MODEL_JOB[];
|
||||||
countNotifikasi: number;
|
countNotifikasi: number;
|
||||||
}) {
|
}) {
|
||||||
|
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||||
|
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||||
|
const [countLoadNtf, setCountLoadNtf] = useAtom(gs_count_ntf);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadNotifikasi({
|
||||||
|
onLoad(val) {
|
||||||
|
setCountNtf(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
setCountNtf(countLoadNtf as any);
|
||||||
|
}, [countLoadNtf, setCountNtf]);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
setCountNtf(countNtf + newUserNtf);
|
||||||
|
setNewUserNtf(0);
|
||||||
|
}, [newUserNtf, setCountNtf]);
|
||||||
|
|
||||||
|
async function onLoadNotifikasi({ onLoad }: { onLoad: (val: any) => void }) {
|
||||||
|
const loadNotif = await notifikasi_countUserNotifikasi();
|
||||||
|
onLoad(loadNotif);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -32,7 +60,7 @@ export default function HomeView({
|
|||||||
customButtonRight={
|
customButtonRight={
|
||||||
<ComponentHome_ButtonHeaderRight
|
<ComponentHome_ButtonHeaderRight
|
||||||
dataUser={dataUser}
|
dataUser={dataUser}
|
||||||
countNotifikasi={countNotifikasi}
|
countNotifikasi={countNtf}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ function Job_ComponentButtonSaveCreate({
|
|||||||
|
|
||||||
if (createNoFile.status === 201) {
|
if (createNoFile.status === 201) {
|
||||||
const dataNotifikasi: IRealtimeData = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
userRole: "ADMIN",
|
|
||||||
appId: createNoFile.data?.id as any,
|
appId: createNoFile.data?.id as any,
|
||||||
status: createNoFile.data?.MasterStatus?.name as any,
|
status: createNoFile.data?.MasterStatus?.name as any,
|
||||||
userId: createNoFile.data?.authorId as any,
|
userId: createNoFile.data?.authorId as any,
|
||||||
@@ -58,6 +57,12 @@ function Job_ComponentButtonSaveCreate({
|
|||||||
pushNotificationTo: "ADMIN",
|
pushNotificationTo: "ADMIN",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
setHotMenu(2);
|
setHotMenu(2);
|
||||||
router.replace(RouterJob.status({ id: "2" }));
|
router.replace(RouterJob.status({ id: "2" }));
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -82,9 +87,8 @@ function Job_ComponentButtonSaveCreate({
|
|||||||
|
|
||||||
if (createWithFile.status === 201) {
|
if (createWithFile.status === 201) {
|
||||||
const dataNotifikasi: IRealtimeData = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
userRole: "ADMIN",
|
|
||||||
appId: createWithFile.data?.id as any,
|
appId: createWithFile.data?.id as any,
|
||||||
status: "Review",
|
status: createWithFile.data?.MasterStatus?.name as any,
|
||||||
userId: createWithFile.data?.authorId as any,
|
userId: createWithFile.data?.authorId as any,
|
||||||
pesan: createWithFile.data?.title as any,
|
pesan: createWithFile.data?.title as any,
|
||||||
kategoriApp: "JOB",
|
kategoriApp: "JOB",
|
||||||
@@ -101,6 +105,12 @@ function Job_ComponentButtonSaveCreate({
|
|||||||
pushNotificationTo: "ADMIN",
|
pushNotificationTo: "ADMIN",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
setHotMenu(2);
|
setHotMenu(2);
|
||||||
router.replace(RouterJob.status({ id: "2" }));
|
router.replace(RouterJob.status({ id: "2" }));
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@@ -8,23 +8,17 @@ export function Job_ComponentButtonUpdateBeranda({
|
|||||||
onSetData,
|
onSetData,
|
||||||
onSetIsNewPost,
|
onSetIsNewPost,
|
||||||
}: {
|
}: {
|
||||||
onSetData: (val : {data: any[]}) => void;
|
onSetData: (val: any[]) => void;
|
||||||
onSetIsNewPost: (val: any) => void;
|
onSetIsNewPost: (val: any) => void;
|
||||||
}) {
|
}) {
|
||||||
const [scroll, scrollTo] = useWindowScroll();
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
async function onLoadData() {
|
async function onLoadNewData() {
|
||||||
setIsLoading(true)
|
setIsLoading(true);
|
||||||
const loadData = await job_getAllListPublish({ page: 1 });
|
const loadData = await job_getAllListPublish({ page: 1 });
|
||||||
|
onSetData(loadData);
|
||||||
if (loadData) {
|
onSetIsNewPost(false);
|
||||||
onSetData({
|
setIsLoading(false);
|
||||||
data: loadData,
|
|
||||||
});
|
|
||||||
onSetIsNewPost(false);
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -40,8 +34,8 @@ export function Job_ComponentButtonUpdateBeranda({
|
|||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={isLoading ? true : false}
|
loading={isLoading ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
opacity={scroll.y > 0 ? 0.5 : 0.8}
|
opacity={0.8}
|
||||||
onClick={() => onLoadData()}
|
onClick={() => onLoadNewData()}
|
||||||
>
|
>
|
||||||
Update beranda
|
Update beranda
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { MODEL_JOB } from "../../model/interface";
|
|||||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
import { job_getOneById } from "../../fun/get/get_one_by_id";
|
import { job_getOneById } from "../../fun/get/get_one_by_id";
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
|
||||||
export default function Job_DetailDraft({
|
export default function Job_DetailDraft({
|
||||||
dataJob,
|
dataJob,
|
||||||
@@ -71,7 +73,7 @@ function ButtonAction({ jobId, imageId }: { jobId: string; imageId: string }) {
|
|||||||
if (update.status === 200) {
|
if (update.status === 200) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: update.data?.id as any,
|
appId: update.data?.id as any,
|
||||||
status: update.data?.MasterStatus?.name as any,
|
status: update.data?.MasterStatus?.name as any,
|
||||||
userId: update.data?.authorId as any,
|
userId: update.data?.authorId as any,
|
||||||
@@ -81,11 +83,20 @@ function ButtonAction({ jobId, imageId }: { jobId: string; imageId: string }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { gs_job_trigger } from "@/app/lib/global_state";
|
import { gs_jobTiggerBeranda } from "@/app/lib/global_state";
|
||||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||||
@@ -10,29 +10,35 @@ import { IconSearch } from "@tabler/icons-react";
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { ScrollOnly } from "next-scroll-loader";
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
|
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
|
||||||
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
|
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
|
||||||
import { MODEL_JOB } from "../../model/interface";
|
import { MODEL_JOB } from "../../model/interface";
|
||||||
|
import { Job_ComponentButtonUpdateBeranda } from "../../component";
|
||||||
|
|
||||||
export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||||
const [data, setData] = useState(listData);
|
const [data, setData] = useState(listData);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [isSearch, setIsSearch] = useState("");
|
const [isSearch, setIsSearch] = useState("");
|
||||||
// const [isNewPost, setIsNewPost] = useState(false);
|
|
||||||
const [triggerJob, setTriggerJob] = useAtom(gs_job_trigger);
|
// Notifikasi
|
||||||
|
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||||
|
const [isTriggerJob, setIsTriggerJob] = useAtom(gs_jobTiggerBeranda);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (triggerJob) {
|
onLoadNewData({
|
||||||
// setIsNewPost(true);
|
onLoad(val) {
|
||||||
setTriggerJob(false);
|
setData(val);
|
||||||
onLoadNewData({
|
},
|
||||||
onLoad(val) {
|
});
|
||||||
setData(val);
|
}, [setData]);
|
||||||
},
|
|
||||||
});
|
useShallowEffect(() => {
|
||||||
|
if (isTriggerJob) {
|
||||||
|
setIsShowUpdate(true);
|
||||||
|
// setIsTriggerJob(false);
|
||||||
}
|
}
|
||||||
}, [triggerJob, setData]);
|
}, [isTriggerJob, setIsShowUpdate]);
|
||||||
|
|
||||||
async function onSearch(text: string) {
|
async function onSearch(text: string) {
|
||||||
setIsSearch(text);
|
setIsSearch(text);
|
||||||
@@ -52,16 +58,16 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack my={1} spacing={30}>
|
<Stack my={1} spacing={30}>
|
||||||
{/* {isNewPost && (
|
{isShowUpdate && (
|
||||||
<Job_ComponentButtonUpdateBeranda
|
<Job_ComponentButtonUpdateBeranda
|
||||||
onSetIsNewPost={(val) => {
|
onSetIsNewPost={(val) => {
|
||||||
setIsNewPost(val);
|
setIsShowUpdate(val);
|
||||||
}}
|
}}
|
||||||
onSetData={(val: { data: any[] }) => {
|
onSetData={(val: any[]) => {
|
||||||
setData(val.data);
|
setData(val);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
|
|
||||||
<ComponentGlobal_CreateButton path={RouterJob.create} />
|
<ComponentGlobal_CreateButton path={RouterJob.create} />
|
||||||
|
|
||||||
@@ -97,7 +103,6 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
|||||||
page: activePage + 1,
|
page: activePage + 1,
|
||||||
search: isSearch,
|
search: isSearch,
|
||||||
});
|
});
|
||||||
console.log(loadData, "load daat");
|
|
||||||
|
|
||||||
setActivePage((val) => val + 1);
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { ComponentNotifiaksi_CardView } from "../component";
|
|||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||||
import { gs_notifikasi_kategori_app } from "../lib";
|
import { gs_notifikasi_kategori_app } from "../lib";
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
|
||||||
export default function Notifikasi_UiEvent({
|
export default function Notifikasi_UiEvent({
|
||||||
listNotifikasi,
|
listNotifikasi,
|
||||||
@@ -21,6 +22,18 @@ export default function Notifikasi_UiEvent({
|
|||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData(setData);
|
||||||
|
}, [setData]);
|
||||||
|
|
||||||
|
async function onLoadData(setData: any) {
|
||||||
|
const listNotifikasi = await notifikasi_getByUserId({
|
||||||
|
page: 1,
|
||||||
|
kategoriApp: "Event",
|
||||||
|
});
|
||||||
|
setData(listNotifikasi);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box>
|
<Box>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { ComponentNotifiaksi_CardView } from "../component";
|
|||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||||
import { gs_notifikasi_kategori_app } from "../lib";
|
import { gs_notifikasi_kategori_app } from "../lib";
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
|
||||||
export default function Notifikasi_UiJob({
|
export default function Notifikasi_UiJob({
|
||||||
listNotifikasi,
|
listNotifikasi,
|
||||||
@@ -21,6 +22,18 @@ export default function Notifikasi_UiJob({
|
|||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData(setData);
|
||||||
|
}, [setData]);
|
||||||
|
|
||||||
|
async function onLoadData(setData: any) {
|
||||||
|
const listNotifikasi = await notifikasi_getByUserId({
|
||||||
|
page: 1,
|
||||||
|
kategoriApp: "Job",
|
||||||
|
});
|
||||||
|
setData(listNotifikasi);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box>
|
<Box>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import Notifikasi_ViewNewMain from "./view_new_notifikasi";
|
import Notifikasi_ViewNewMain from "./view_card_job";
|
||||||
|
|
||||||
export { Notifikasi_ViewNewMain };
|
export { Notifikasi_ViewNewMain };
|
||||||
|
|||||||
6
src/app_modules/notifikasi/_view/view_card_job.tsx
Normal file
6
src/app_modules/notifikasi/_view/view_card_job.tsx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default function Notifikasi_ViewCardJob(){
|
||||||
|
return<>
|
||||||
|
|
||||||
|
|
||||||
|
</>
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
export default function Notifikasi_ViewNewMain(){
|
|
||||||
return<>
|
|
||||||
|
|
||||||
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
import { gs_count_ntf } from "@/app/lib/global_state";
|
||||||
import {
|
import {
|
||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
||||||
|
import { gs_event_hotMenu } from "@/app_modules/event/global_state";
|
||||||
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
import { gs_job_hot_menu } from "@/app_modules/job/global_state";
|
||||||
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
|
||||||
import { gs_notifikasi_kategori_app } from "../lib";
|
|
||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
|
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
@@ -28,8 +28,10 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [loadCountNtf, setLoadCountNtf] = useAtom(gs_count_ntf);
|
||||||
|
|
||||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||||
|
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -46,28 +48,48 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
}}
|
}}
|
||||||
my={"xs"}
|
my={"xs"}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
// JOB
|
||||||
if (data?.kategoriApp === "JOB") {
|
if (data?.kategoriApp === "JOB") {
|
||||||
const checkStatus = await notifikasi_jobCheckStatus({
|
await notifikasi_jobCheckStatus({
|
||||||
appId: data.appId,
|
appId: data.appId,
|
||||||
dataId: data.id,
|
dataId: data.id,
|
||||||
|
categoryPage: categoryPage,
|
||||||
|
router: router,
|
||||||
|
onLoadDataJob(val) {
|
||||||
|
onLoadData(val);
|
||||||
|
},
|
||||||
|
onSetJobMenuId(val) {
|
||||||
|
setJobMenuId(val);
|
||||||
|
},
|
||||||
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
onLoadCountNtf(val) {
|
||||||
|
setLoadCountNtf(val);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (checkStatus?.success) {
|
// EVENT
|
||||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
if (data?.kategoriApp === "EVENT") {
|
||||||
page: 1,
|
await notifikasi_eventCheckStatus({
|
||||||
kategoriApp: "Job",
|
appId: data.appId,
|
||||||
});
|
dataId: data.id,
|
||||||
|
categoryPage: categoryPage,
|
||||||
onLoadData(loadListNotifikasi);
|
router: router,
|
||||||
|
onLoadDataEvent(val) {
|
||||||
const path = RouterJob.status({
|
onLoadData(val);
|
||||||
id: checkStatus.statusId as string,
|
},
|
||||||
});
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
setJobMenuId(2);
|
},
|
||||||
router.push(path);
|
onSetEventMenuId(val) {
|
||||||
setVisible(true);
|
setEventMenuId(val);
|
||||||
}
|
},
|
||||||
|
onLoadCountNtf(val) {
|
||||||
|
setLoadCountNtf(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "FORUM" &&
|
// data?.kategoriApp === "FORUM" &&
|
||||||
|
|||||||
@@ -1,36 +1,53 @@
|
|||||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
import { MODEL_NOTIFIKASI } from "../../model/interface";
|
import { notifikasi_funEventCheckStatus } from "../../fun";
|
||||||
|
import notifikasi_getByUserId from "../../fun/get/get_notifiaksi_by_id";
|
||||||
|
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||||
|
import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||||
|
|
||||||
export function redirectEventPage({
|
export async function notifikasi_eventCheckStatus({
|
||||||
data,
|
appId,
|
||||||
|
dataId,
|
||||||
|
categoryPage,
|
||||||
router,
|
router,
|
||||||
onSetPage,
|
onLoadDataEvent,
|
||||||
|
onSetEventMenuId,
|
||||||
|
onSetVisible,
|
||||||
|
onLoadCountNtf,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
dataId: string;
|
||||||
|
categoryPage: string
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onSetPage: (val: any) => void;
|
onLoadDataEvent: (val: any) => void;
|
||||||
|
onSetEventMenuId(val: number): void;
|
||||||
|
onSetVisible(val: boolean): void;
|
||||||
|
onLoadCountNtf(val: number): void;
|
||||||
}) {
|
}) {
|
||||||
const path = RouterEvent.status({id: ""});
|
const check = await notifikasi_funEventCheckStatus({ id: appId });
|
||||||
|
|
||||||
if (data.status === "Publish") {
|
if (check.status == 200) {
|
||||||
onSetPage({
|
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||||
menuId: 2,
|
page: 1,
|
||||||
status: data.status,
|
kategoriApp: categoryPage as any,
|
||||||
});
|
});
|
||||||
router.push(path, { scroll: false });
|
onLoadDataEvent(loadListNotifikasi);
|
||||||
}
|
|
||||||
// console.log(data)
|
|
||||||
|
|
||||||
if (data.status === "Reject") {
|
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
onSetPage({
|
onLoadCountNtf(loadCountNotifikasi);
|
||||||
menuId: 2,
|
|
||||||
status: data.status,
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
router.push(path, { scroll: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.status === "Peserta Event") {
|
if (updateReadNotifikasi.status == 200) {
|
||||||
router.push(RouterEvent.detail_main + data.appId, { scroll: false });
|
onSetVisible(true);
|
||||||
|
|
||||||
|
const path = `/dev/event/detail/${check.statusName}/${appId}`;
|
||||||
|
onSetEventMenuId(1);
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,52 @@
|
|||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
import { notifikasi_funJobCheckStatus } from "../../fun/check/fun_check_job_status";
|
import { notifikasi_funJobCheckStatus } from "../../fun/check/fun_check_job_status";
|
||||||
|
import notifikasi_getByUserId from "../../fun/get/get_notifiaksi_by_id";
|
||||||
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||||
|
import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||||
|
|
||||||
export async function notifikasi_jobCheckStatus({
|
export async function notifikasi_jobCheckStatus({
|
||||||
appId,
|
appId,
|
||||||
dataId,
|
dataId,
|
||||||
|
categoryPage,
|
||||||
|
router,
|
||||||
|
onLoadDataJob,
|
||||||
|
onSetJobMenuId,
|
||||||
|
onSetVisible,
|
||||||
|
onLoadCountNtf,
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
dataId: string;
|
dataId: string;
|
||||||
|
categoryPage:string
|
||||||
|
router: AppRouterInstance;
|
||||||
|
onLoadDataJob: (val: any) => void;
|
||||||
|
onSetJobMenuId(val: number): void;
|
||||||
|
onSetVisible(val: boolean): void;
|
||||||
|
onLoadCountNtf(val: number): void;
|
||||||
}) {
|
}) {
|
||||||
const check = await notifikasi_funJobCheckStatus({
|
const check = await notifikasi_funJobCheckStatus({
|
||||||
id: appId,
|
id: appId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||||
|
page: 1,
|
||||||
|
kategoriApp: categoryPage as any,
|
||||||
|
});
|
||||||
|
onLoadDataJob(loadListNotifikasi);
|
||||||
|
|
||||||
|
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
|
onLoadCountNtf(loadCountNotifikasi);
|
||||||
|
|
||||||
if (check.status == 200) {
|
if (check.status == 200) {
|
||||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||||
notifId: dataId,
|
notifId: dataId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updateReadNotifikasi.status == 200) {
|
if (updateReadNotifikasi.status == 200) {
|
||||||
return {
|
onSetVisible(true);
|
||||||
success: true,
|
const path = `/dev/job/detail/${check.statusName}/${appId}`;
|
||||||
statusId: check.statusId,
|
onSetJobMenuId(2);
|
||||||
};
|
router.push(path, { scroll: false });
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
|
export async function notifikasi_funEventCheckStatus({ id }: { id: string }) {
|
||||||
|
const data = await prisma.event.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
EventMaster_Status: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return { status: 400, message: "Job tidak ditemukan", statusName: "" };
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
message: "Berhasil di cek",
|
||||||
|
statusName: _.lowerCase(data.EventMaster_Status?.name),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
"use server";
|
|
||||||
|
|
||||||
import { prisma } from "@/app/lib";
|
import { prisma } from "@/app/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export async function notifikasi_funJobCheckStatus({ id }: { id: string }) {
|
export async function notifikasi_funJobCheckStatus({ id }: { id: string }) {
|
||||||
const data = await prisma.job.findUnique({
|
const data = await prisma.job.findUnique({
|
||||||
@@ -10,16 +9,15 @@ export async function notifikasi_funJobCheckStatus({ id }: { id: string }) {
|
|||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
masterStatusId: true
|
MasterStatus: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return { status: 400, message: "Job tidak ditemukan", statusId: "" };
|
return { status: 400, message: "Job tidak ditemukan", statusName: "" };
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Berhasil di cek",
|
message: "Berhasil di cek",
|
||||||
statusId: data.masterStatusId,
|
statusName: _.lowerCase(data.MasterStatus?.name),
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
|
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
|
||||||
export default async function notifikasi_countUserNotifikasi() {
|
export default async function notifikasi_countUserNotifikasi() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
@@ -14,5 +16,6 @@ export default async function notifikasi_countUserNotifikasi() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
revalidatePath(RouterHome.main_home);
|
||||||
return count.length;
|
return count.length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,8 @@ export default async function notifikasi_getByUserId({
|
|||||||
kategoriApp,
|
kategoriApp,
|
||||||
}: {
|
}: {
|
||||||
page: number;
|
page: number;
|
||||||
kategoriApp?: ICategoryapp
|
kategoriApp?: ICategoryapp;
|
||||||
}) {
|
}) {
|
||||||
console.log(page, "ini page");
|
|
||||||
console.log(kategoriApp, "ini kategori");
|
|
||||||
|
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
const takeData = 10;
|
const takeData = 10;
|
||||||
const skipData = page * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { notifikasi_funEventCheckStatus } from "./check/fun_check_event_status";
|
||||||
import notifikasiToAdmin_funCreate from "./create/create_notif_to_admin";
|
import notifikasiToAdmin_funCreate from "./create/create_notif_to_admin";
|
||||||
import notifikasiToUser_funCreate from "./create/create_notif_to_user";
|
import notifikasiToUser_funCreate from "./create/create_notif_to_user";
|
||||||
import { notifikasiToUser_CreateGroupCollaboration } from "./create/create_notif_to_user_collaboration";
|
import { notifikasiToUser_CreateGroupCollaboration } from "./create/create_notif_to_user_collaboration";
|
||||||
@@ -7,3 +8,4 @@ export { notifikasiToAdmin_funCreate };
|
|||||||
export { notifikasiToUser_CreateGroupCollaboration };
|
export { notifikasiToUser_CreateGroupCollaboration };
|
||||||
export { notifikasiToUser_CreateKabarDonasi };
|
export { notifikasiToUser_CreateKabarDonasi };
|
||||||
export { notifikasiToUser_funCreate };
|
export { notifikasiToUser_funCreate };
|
||||||
|
export { notifikasi_funEventCheckStatus };
|
||||||
|
|||||||
Reference in New Issue
Block a user