Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -11,6 +11,7 @@ import { ComponentNotifiaksi_CardView } from "../component";
|
||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||
import { gs_notifikasi_kategori_app } from "../lib";
|
||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
|
||||
export default function Notifikasi_UiEvent({
|
||||
listNotifikasi,
|
||||
@@ -21,6 +22,18 @@ export default function Notifikasi_UiEvent({
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
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 (
|
||||
<>
|
||||
<Box>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ComponentNotifiaksi_CardView } from "../component";
|
||||
import notifikasi_getByUserId from "../fun/get/get_notifiaksi_by_id";
|
||||
import { gs_notifikasi_kategori_app } from "../lib";
|
||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
|
||||
export default function Notifikasi_UiJob({
|
||||
listNotifikasi,
|
||||
@@ -21,6 +22,18 @@ export default function Notifikasi_UiJob({
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
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 (
|
||||
<>
|
||||
<Box>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import Notifikasi_ViewNewMain from "./view_new_notifikasi";
|
||||
import Notifikasi_ViewNewMain from "./view_card_job";
|
||||
|
||||
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";
|
||||
|
||||
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");
|
||||
|
||||
@@ -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";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function notifikasi_funJobCheckStatus({ id }: { id: string }) {
|
||||
const data = await prisma.job.findUnique({
|
||||
@@ -10,16 +9,15 @@ export async function notifikasi_funJobCheckStatus({ id }: { id: string }) {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
masterStatusId: true
|
||||
MasterStatus: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return { status: 400, message: "Job tidak ditemukan", statusId: "" };
|
||||
return { status: 400, message: "Job tidak ditemukan", statusName: "" };
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil di cek",
|
||||
statusId: data.masterStatusId,
|
||||
statusName: _.lowerCase(data.MasterStatus?.name),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function notifikasi_countUserNotifikasi() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
@@ -14,5 +16,6 @@ export default async function notifikasi_countUserNotifikasi() {
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath(RouterHome.main_home);
|
||||
return count.length;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,8 @@ export default async function notifikasi_getByUserId({
|
||||
kategoriApp,
|
||||
}: {
|
||||
page: number;
|
||||
kategoriApp?: ICategoryapp
|
||||
kategoriApp?: ICategoryapp;
|
||||
}) {
|
||||
console.log(page, "ini page");
|
||||
console.log(kategoriApp, "ini kategori");
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const takeData = 10;
|
||||
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 notifikasiToUser_funCreate from "./create/create_notif_to_user";
|
||||
import { notifikasiToUser_CreateGroupCollaboration } from "./create/create_notif_to_user_collaboration";
|
||||
@@ -7,3 +8,4 @@ export { notifikasiToAdmin_funCreate };
|
||||
export { notifikasiToUser_CreateGroupCollaboration };
|
||||
export { notifikasiToUser_CreateKabarDonasi };
|
||||
export { notifikasiToUser_funCreate };
|
||||
export { notifikasi_funEventCheckStatus };
|
||||
|
||||
Reference in New Issue
Block a user