Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { gs_count_ntf } from "@/app/lib/global_state";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
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 { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||
import { IconCheck, IconChecks } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
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 { notifikasi_eventCheckStatus } from "./path/event";
|
||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||
|
||||
export function ComponentNotifiaksi_CardView({
|
||||
@@ -28,8 +28,10 @@ export function ComponentNotifiaksi_CardView({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [loadCountNtf, setLoadCountNtf] = useAtom(gs_count_ntf);
|
||||
|
||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -46,28 +48,48 @@ export function ComponentNotifiaksi_CardView({
|
||||
}}
|
||||
my={"xs"}
|
||||
onClick={async () => {
|
||||
// JOB
|
||||
if (data?.kategoriApp === "JOB") {
|
||||
const checkStatus = await notifikasi_jobCheckStatus({
|
||||
await notifikasi_jobCheckStatus({
|
||||
appId: data.appId,
|
||||
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) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Job",
|
||||
});
|
||||
|
||||
onLoadData(loadListNotifikasi);
|
||||
|
||||
const path = RouterJob.status({
|
||||
id: checkStatus.statusId as string,
|
||||
});
|
||||
|
||||
setJobMenuId(2);
|
||||
router.push(path);
|
||||
setVisible(true);
|
||||
}
|
||||
// EVENT
|
||||
if (data?.kategoriApp === "EVENT") {
|
||||
await notifikasi_eventCheckStatus({
|
||||
appId: data.appId,
|
||||
dataId: data.id,
|
||||
categoryPage: categoryPage,
|
||||
router: router,
|
||||
onLoadDataEvent(val) {
|
||||
onLoadData(val);
|
||||
},
|
||||
onSetVisible(val) {
|
||||
setVisible(val);
|
||||
},
|
||||
onSetEventMenuId(val) {
|
||||
setEventMenuId(val);
|
||||
},
|
||||
onLoadCountNtf(val) {
|
||||
setLoadCountNtf(val);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 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 { 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({
|
||||
data,
|
||||
export async function notifikasi_eventCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onSetPage,
|
||||
onLoadDataEvent,
|
||||
onSetEventMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
appId: string;
|
||||
dataId: string;
|
||||
categoryPage: string
|
||||
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") {
|
||||
onSetPage({
|
||||
menuId: 2,
|
||||
status: data.status,
|
||||
if (check.status == 200) {
|
||||
const loadListNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: categoryPage as any,
|
||||
});
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
// console.log(data)
|
||||
onLoadDataEvent(loadListNotifikasi);
|
||||
|
||||
if (data.status === "Reject") {
|
||||
onSetPage({
|
||||
menuId: 2,
|
||||
status: data.status,
|
||||
const loadCountNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
onLoadCountNtf(loadCountNotifikasi);
|
||||
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
|
||||
if (data.status === "Peserta Event") {
|
||||
router.push(RouterEvent.detail_main + data.appId, { scroll: false });
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
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 { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
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_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||
|
||||
export async function notifikasi_jobCheckStatus({
|
||||
appId,
|
||||
dataId,
|
||||
categoryPage,
|
||||
router,
|
||||
onLoadDataJob,
|
||||
onSetJobMenuId,
|
||||
onSetVisible,
|
||||
onLoadCountNtf,
|
||||
}: {
|
||||
appId: 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({
|
||||
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) {
|
||||
const updateReadNotifikasi = await notifikasi_funUpdateIsReadById({
|
||||
notifId: dataId,
|
||||
});
|
||||
|
||||
if (updateReadNotifikasi.status == 200) {
|
||||
return {
|
||||
success: true,
|
||||
statusId: check.statusId,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
onSetVisible(true);
|
||||
const path = `/dev/job/detail/${check.statusName}/${appId}`;
|
||||
onSetJobMenuId(2);
|
||||
router.push(path, { scroll: false });
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||
|
||||
Reference in New Issue
Block a user