Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -39,7 +39,6 @@ function Job_ComponentButtonSaveCreate({
|
||||
|
||||
if (createNoFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
userRole: "ADMIN",
|
||||
appId: createNoFile.data?.id as any,
|
||||
status: createNoFile.data?.MasterStatus?.name as any,
|
||||
userId: createNoFile.data?.authorId as any,
|
||||
@@ -58,6 +57,12 @@ function Job_ComponentButtonSaveCreate({
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
@@ -82,9 +87,8 @@ function Job_ComponentButtonSaveCreate({
|
||||
|
||||
if (createWithFile.status === 201) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
userRole: "ADMIN",
|
||||
appId: createWithFile.data?.id as any,
|
||||
status: "Review",
|
||||
status: createWithFile.data?.MasterStatus?.name as any,
|
||||
userId: createWithFile.data?.authorId as any,
|
||||
pesan: createWithFile.data?.title as any,
|
||||
kategoriApp: "JOB",
|
||||
@@ -101,6 +105,12 @@ function Job_ComponentButtonSaveCreate({
|
||||
pushNotificationTo: "ADMIN",
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "ADMIN",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
setHotMenu(2);
|
||||
router.replace(RouterJob.status({ id: "2" }));
|
||||
setIsLoading(true);
|
||||
|
||||
@@ -8,23 +8,17 @@ export function Job_ComponentButtonUpdateBeranda({
|
||||
onSetData,
|
||||
onSetIsNewPost,
|
||||
}: {
|
||||
onSetData: (val : {data: any[]}) => void;
|
||||
onSetData: (val: any[]) => void;
|
||||
onSetIsNewPost: (val: any) => void;
|
||||
}) {
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
async function onLoadData() {
|
||||
setIsLoading(true)
|
||||
async function onLoadNewData() {
|
||||
setIsLoading(true);
|
||||
const loadData = await job_getAllListPublish({ page: 1 });
|
||||
|
||||
if (loadData) {
|
||||
onSetData({
|
||||
data: loadData,
|
||||
});
|
||||
onSetIsNewPost(false);
|
||||
setIsLoading(false);
|
||||
}
|
||||
onSetData(loadData);
|
||||
onSetIsNewPost(false);
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -40,10 +34,10 @@ export function Job_ComponentButtonUpdateBeranda({
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
radius={"xl"}
|
||||
opacity={scroll.y > 0 ? 0.5 : 0.8}
|
||||
onClick={() => onLoadData()}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadNewData()}
|
||||
>
|
||||
Update beranda
|
||||
Update beranda
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
|
||||
@@ -18,6 +18,8 @@ import { MODEL_JOB } from "../../model/interface";
|
||||
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||
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({
|
||||
dataJob,
|
||||
@@ -71,7 +73,7 @@ function ButtonAction({ jobId, imageId }: { jobId: string; imageId: string }) {
|
||||
if (update.status === 200) {
|
||||
setLoading(true);
|
||||
|
||||
const dataNotif = {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: update.data?.id as any,
|
||||
status: update.data?.MasterStatus?.name 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({
|
||||
data: dataNotif as any,
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"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 ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||
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 _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
|
||||
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { Job_ComponentButtonUpdateBeranda } from "../../component";
|
||||
|
||||
export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
const [data, setData] = useState(listData);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
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(() => {
|
||||
if (triggerJob) {
|
||||
// setIsNewPost(true);
|
||||
setTriggerJob(false);
|
||||
onLoadNewData({
|
||||
onLoad(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
onLoadNewData({
|
||||
onLoad(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
}, [setData]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isTriggerJob) {
|
||||
setIsShowUpdate(true);
|
||||
// setIsTriggerJob(false);
|
||||
}
|
||||
}, [triggerJob, setData]);
|
||||
}, [isTriggerJob, setIsShowUpdate]);
|
||||
|
||||
async function onSearch(text: string) {
|
||||
setIsSearch(text);
|
||||
@@ -52,16 +58,16 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
return (
|
||||
<>
|
||||
<Stack my={1} spacing={30}>
|
||||
{/* {isNewPost && (
|
||||
{isShowUpdate && (
|
||||
<Job_ComponentButtonUpdateBeranda
|
||||
onSetIsNewPost={(val) => {
|
||||
setIsNewPost(val);
|
||||
setIsShowUpdate(val);
|
||||
}}
|
||||
onSetData={(val: { data: any[] }) => {
|
||||
setData(val.data);
|
||||
onSetData={(val: any[]) => {
|
||||
setData(val);
|
||||
}}
|
||||
/>
|
||||
)} */}
|
||||
)}
|
||||
|
||||
<ComponentGlobal_CreateButton path={RouterJob.create} />
|
||||
|
||||
@@ -97,7 +103,6 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
page: activePage + 1,
|
||||
search: isSearch,
|
||||
});
|
||||
console.log(loadData, "load daat");
|
||||
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user