Fix: Job
Deskripsi: - Fix notifikasi admi to user - Fix count notifikasi di admin dan user ## No Issue
This commit is contained in:
@@ -23,6 +23,7 @@ export default async function adminNotifikasi_funCreateToUser({
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!create) return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
|
||||
export async function admin_funCheckStatusJob({ id }: { id: string }) {
|
||||
const data = await prisma.job.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
MasterStatus: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (data?.MasterStatus?.name === "Review") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -20,5 +20,6 @@ export default async function adminNotifikasi_getByUserId() {
|
||||
userRoleId: "2",
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,26 @@
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
import _ from "lodash";
|
||||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import { admin_funCheckStatusJob } from "../fun/get/fun_check_status_job";
|
||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||
|
||||
export default async function adminNotifikasi_findRouterJob({
|
||||
export async function adminNotifikasi_findRouterJob({
|
||||
data,
|
||||
router,
|
||||
onChangeNavbar,
|
||||
onToggleNavbar,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
router: AppRouterInstance;
|
||||
onChangeNavbar: (val: any) => void;
|
||||
onToggleNavbar: (val: any) => void;
|
||||
}) {
|
||||
const routeName = "/dev/admin/job/child/";
|
||||
const check = await admin_funCheckStatusJob({ id: data.appId });
|
||||
|
||||
if (data.status === "Review") {
|
||||
router.push(routeName + _.lowerCase(data.status));
|
||||
onChangeNavbar({
|
||||
id: 6,
|
||||
childId: 63,
|
||||
if (check) {
|
||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: data?.id,
|
||||
});
|
||||
}
|
||||
|
||||
if (data.status === "Draft") {
|
||||
router.push(routeName + "review");
|
||||
onChangeNavbar({
|
||||
id: 6,
|
||||
childId: 63,
|
||||
});
|
||||
if (udpateReadNotifikasi.status == 200) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
||||
}
|
||||
|
||||
onToggleNavbar(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
export type IAdmin_ActivePage = "Investasi" | "Donasi" | "Event" | "Vote" | "Job" | "Forum" | "Collaboration"
|
||||
export type IAdmin_ActiveChildId =
|
||||
| "Investasi_1"
|
||||
| "Investasi_2"
|
||||
| "Investasi_3"
|
||||
| "Investasi_4"
|
||||
| "Donasi_1"
|
||||
| "Donasi_2"
|
||||
| "Donasi_3"
|
||||
| "Donasi_4"
|
||||
| "Donasi_5"
|
||||
| "Event_1"
|
||||
| "Event_2"
|
||||
| "Event_3"
|
||||
| "Event_4"
|
||||
| "Event_5"
|
||||
| "Event_6"
|
||||
| "Voting_1"
|
||||
| "Voting_2"
|
||||
| "Voting_3"
|
||||
| "Voting_4"
|
||||
| "Voting_5"
|
||||
| "Job_1"
|
||||
| "Job_2"
|
||||
| "Job_3"
|
||||
| "Job_4"
|
||||
| "Forum_1"
|
||||
| "Forum_2"
|
||||
| "Forum_3"
|
||||
| "Forum_4"
|
||||
| "Collaboration_1"
|
||||
| "Collaboration_2"
|
||||
| "Collaboration_3"
|
||||
| "Collaboration_4";
|
||||
|
||||
|
||||
@@ -1,41 +1,142 @@
|
||||
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 {
|
||||
Badge,
|
||||
Card,
|
||||
Center,
|
||||
Divider,
|
||||
Group,
|
||||
Paper,
|
||||
Stack,
|
||||
Card,
|
||||
Group,
|
||||
Badge,
|
||||
Divider,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { IconChecks, IconCheck } from "@tabler/icons-react";
|
||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
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_funUpdateIsReadById from "./fun/update/fun_update_is_read_by_id";
|
||||
import adminNotifikasi_findRouterDonasi from "./route_setting/donasi";
|
||||
import { adminNotifikasi_findRouterEvent } from "./route_setting/event";
|
||||
import adminNotifikasi_findRouterForum from "./route_setting/forum";
|
||||
import adminNotifikasi_findRouterJob from "./route_setting/job";
|
||||
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||
import adminNotifikasi_findRouterInvestasi from "./route_setting/investasi";
|
||||
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
||||
import {
|
||||
IAdmin_ActiveChildId,
|
||||
IAdmin_ActivePage,
|
||||
} from "./route_setting/type_of_select_page";
|
||||
|
||||
export function ComponentAdmin_UIDrawerNotifikasi({
|
||||
data,
|
||||
onLoadReadNotif,
|
||||
listNotifikasi,
|
||||
onChangeNavbar,
|
||||
onToggleNavbar,
|
||||
onLoadCountNotif,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI[];
|
||||
onLoadReadNotif: (val: any) => void;
|
||||
onChangeNavbar: (val: any) => void;
|
||||
listNotifikasi: MODEL_NOTIFIKASI[];
|
||||
onChangeNavbar: (val: {
|
||||
id: IAdmin_ActivePage;
|
||||
childId: IAdmin_ActiveChildId;
|
||||
}) => void;
|
||||
onToggleNavbar: (val: any) => void;
|
||||
onLoadCountNotif: (val: any) => void;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_NOTIFIKASI[]>(listNotifikasi);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [dataId, setDataId] = useState<string>("");
|
||||
|
||||
async function onRead({ data }: { data: MODEL_NOTIFIKASI }) {
|
||||
// JOB
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
const checkJob = await adminNotifikasi_findRouterJob({
|
||||
data: data,
|
||||
});
|
||||
|
||||
if (checkJob) {
|
||||
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",
|
||||
});
|
||||
|
||||
router.push("/dev/admin/job/child/review");
|
||||
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" &&
|
||||
// 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)) {
|
||||
return (
|
||||
@@ -58,109 +159,22 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
c={"white"}
|
||||
key={e?.id}
|
||||
// withBorder
|
||||
bg={e?.isRead ? "gray.1" : "gray.4"}
|
||||
bg={e?.isRead ? "gray" : AccentColor.darkblue}
|
||||
sx={{
|
||||
borderColor: "gray",
|
||||
borderColor: AccentColor.blue,
|
||||
borderStyle: "solid",
|
||||
borderWidth: "0.5px",
|
||||
borderWidth: "2px",
|
||||
":hover": {
|
||||
backgroundColor: "#C1C2C5",
|
||||
backgroundColor: AccentColor.blue,
|
||||
borderColor: AccentColor.softblue,
|
||||
borderStyle: "solid",
|
||||
borderWidth: "2px",
|
||||
},
|
||||
}}
|
||||
onClick={async () => {
|
||||
// JOB
|
||||
e?.kategoriApp === "JOB" &&
|
||||
adminNotifikasi_findRouterJob({
|
||||
data: e,
|
||||
router: router,
|
||||
onChangeNavbar: (val: any) => {
|
||||
onChangeNavbar(val);
|
||||
},
|
||||
onToggleNavbar: onToggleNavbar,
|
||||
});
|
||||
|
||||
// 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" &&
|
||||
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);
|
||||
},
|
||||
});
|
||||
|
||||
const updateIsRead = await adminNotifikasi_funUpdateIsReadById({
|
||||
notifId: e?.id,
|
||||
});
|
||||
|
||||
if (updateIsRead) {
|
||||
const loadCountNotif =
|
||||
await adminNotifikasi_countNotifikasi();
|
||||
onLoadCountNotif(loadCountNotif);
|
||||
|
||||
const loadDataNotif = await adminNotifikasi_getByUserId();
|
||||
onLoadReadNotif(loadDataNotif);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
onRead({ data: e });
|
||||
// callBackIsNotifikasi(false);
|
||||
}}
|
||||
>
|
||||
@@ -193,12 +207,12 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
||||
</Card.Section>
|
||||
<Card.Section p={"sm"}>
|
||||
<Group position="apart">
|
||||
<Text fz={10} color="gray">
|
||||
<Text fz={10}>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "long",
|
||||
}).format(e?.createdAt)}
|
||||
|
||||
<Text span inherit fz={10} color="gray">
|
||||
<Text span inherit fz={10}>
|
||||
{", "}
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
@@ -207,20 +221,19 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
||||
</Text>
|
||||
{e?.isRead ? (
|
||||
<Group spacing={5}>
|
||||
<IconChecks color="gray" size={10} />
|
||||
<Text fz={10} color="gray">
|
||||
Sudah dilihat
|
||||
</Text>
|
||||
<IconChecks size={10} />
|
||||
<Text fz={10}>Sudah dilihat</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<Group spacing={5}>
|
||||
<IconCheck color="gray" size={10} />
|
||||
<Text fz={10} color="gray">
|
||||
Belum dilihat
|
||||
</Text>
|
||||
<IconCheck size={10} />
|
||||
<Text fz={10}>Belum dilihat</Text>
|
||||
</Group>
|
||||
)}
|
||||
</Group>
|
||||
{visible && dataId === e?.id && (
|
||||
<ComponentGlobal_CardLoadingOverlay />
|
||||
)}
|
||||
</Card.Section>
|
||||
</Card>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user