Fix: Voting
Deskripsi: - Fix notifikasi admin to user - Fix notifikasi user to admin ## No Issue
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.1.3",
|
"version": "1.1.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "npx tsx prisma/seed.ts"
|
"seed": "npx tsx prisma/seed.ts"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { AdminEvent_TableReview } from "@/app_modules/admin/event";
|
import { AdminEvent_TableReview } from "@/app_modules/admin/event";
|
||||||
import { adminEvent_funGetListReview } from "@/app_modules/admin/event/fun";
|
import { adminEvent_funGetListReview } from "@/app_modules/admin/event/fun";
|
||||||
import { AdminEvent_getListTableByStatusId } from "@/app_modules/admin/event/fun/get/get_list_table_by_status_id";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const listReview = await adminEvent_funGetListReview({ page: 1 });
|
const listReview = await adminEvent_funGetListReview({ page: 1 });
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import { atom } from "jotai";
|
import { atom } from "jotai";
|
||||||
import { atomWithStorage } from "jotai/utils";
|
|
||||||
|
|
||||||
export type IRealtimeData = {
|
export type IRealtimeData = {
|
||||||
status?: "Publish" | "Review" | "Draft" | "Reject" | "Peserta Event";
|
status?:
|
||||||
|
| "Publish"
|
||||||
|
| "Review"
|
||||||
|
| "Draft"
|
||||||
|
| "Reject"
|
||||||
|
// EVNET
|
||||||
|
| "Peserta Event"
|
||||||
|
// VOTING
|
||||||
|
| "Voting Masuk";
|
||||||
|
|
||||||
appId: string;
|
appId: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -23,11 +30,14 @@ 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);
|
export const gs_count_ntf = atom<number>(0);
|
||||||
|
|
||||||
|
|
||||||
// job
|
// job
|
||||||
export const gs_adminJobTriggerReview = atom<boolean>(false);
|
export const gs_adminJob_triggerReview = atom<boolean>(false);
|
||||||
export const gs_jobTiggerBeranda = atom<boolean>(false);
|
export const gs_jobTiggerBeranda = atom<boolean>(false);
|
||||||
|
|
||||||
// event
|
// event
|
||||||
export const gs_adminEventTriggerReview = atom<boolean>(false);
|
export const gs_adminEvent_triggerReview = atom<boolean>(false);
|
||||||
export const gs_eventTriggerBeranda = atom<boolean>(false);
|
export const gs_eventTriggerBeranda = atom<boolean>(false);
|
||||||
|
|
||||||
|
// voting
|
||||||
|
export const gs_adminVoting_triggerReview = atom<boolean>(false);
|
||||||
|
export const gs_votingTiggerBeranda = atom<boolean>(false);
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import { useAtom } from "jotai";
|
|||||||
import { WibuRealtime } from "wibu-pkg";
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import {
|
import {
|
||||||
gs_admin_ntf,
|
gs_admin_ntf,
|
||||||
gs_adminEventTriggerReview,
|
gs_adminEvent_triggerReview,
|
||||||
gs_adminJobTriggerReview,
|
gs_adminJob_triggerReview,
|
||||||
|
gs_adminVoting_triggerReview,
|
||||||
gs_eventTriggerBeranda,
|
gs_eventTriggerBeranda,
|
||||||
gs_jobTiggerBeranda,
|
gs_jobTiggerBeranda,
|
||||||
gs_realtimeData,
|
gs_realtimeData,
|
||||||
gs_user_ntf,
|
gs_user_ntf,
|
||||||
|
gs_votingTiggerBeranda,
|
||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
} from "./global_state";
|
} from "./global_state";
|
||||||
|
|
||||||
@@ -35,15 +37,23 @@ export default function RealtimeProvider({
|
|||||||
const [isTriggerJobBeranda, setIsTriggerJobBeranda] =
|
const [isTriggerJobBeranda, setIsTriggerJobBeranda] =
|
||||||
useAtom(gs_jobTiggerBeranda);
|
useAtom(gs_jobTiggerBeranda);
|
||||||
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
gs_adminJobTriggerReview
|
gs_adminJob_triggerReview
|
||||||
);
|
);
|
||||||
|
|
||||||
// EVENT
|
// EVENT
|
||||||
const [isTriggerEventBeranda, setIsTriggerEventBeranca] = useAtom(
|
const [isTriggerEventBeranda, setIsTriggerEventBeranda] = useAtom(
|
||||||
gs_eventTriggerBeranda
|
gs_eventTriggerBeranda
|
||||||
);
|
);
|
||||||
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
||||||
gs_adminEventTriggerReview
|
gs_adminEvent_triggerReview
|
||||||
|
);
|
||||||
|
|
||||||
|
// VOTING
|
||||||
|
const [isTriggerVotingBeranda, setIsTriggerVotingBeranda] = useAtom(
|
||||||
|
gs_votingTiggerBeranda
|
||||||
|
);
|
||||||
|
const [isAdminVoting_TriggerReview, setIsAdminVoting_TriggerReview] = useAtom(
|
||||||
|
gs_adminVoting_triggerReview
|
||||||
);
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
@@ -63,7 +73,7 @@ export default function RealtimeProvider({
|
|||||||
setDataRealtime(data.dataMessage as any);
|
setDataRealtime(data.dataMessage as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
// JOB
|
// ---------------------- JOB ------------------------- //
|
||||||
if (
|
if (
|
||||||
data.type == "trigger" &&
|
data.type == "trigger" &&
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
@@ -80,8 +90,9 @@ export default function RealtimeProvider({
|
|||||||
) {
|
) {
|
||||||
setIsTriggerJobBeranda(true);
|
setIsTriggerJobBeranda(true);
|
||||||
}
|
}
|
||||||
|
// ---------------------- JOB ------------------------- //
|
||||||
|
|
||||||
// EVENT
|
// ---------------------- EVENT ------------------------- //
|
||||||
if (
|
if (
|
||||||
data.type == "trigger" &&
|
data.type == "trigger" &&
|
||||||
data.pushNotificationTo == "ADMIN" &&
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
@@ -96,7 +107,7 @@ export default function RealtimeProvider({
|
|||||||
data.dataMessage?.kategoriApp == "EVENT" &&
|
data.dataMessage?.kategoriApp == "EVENT" &&
|
||||||
data.dataMessage.status == "Publish"
|
data.dataMessage.status == "Publish"
|
||||||
) {
|
) {
|
||||||
setIsTriggerEventBeranca(true);
|
setIsTriggerEventBeranda(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -107,6 +118,35 @@ export default function RealtimeProvider({
|
|||||||
) {
|
) {
|
||||||
setNewUserNtf((e) => e + 1);
|
setNewUserNtf((e) => e + 1);
|
||||||
}
|
}
|
||||||
|
// ---------------------- EVENT ------------------------- //
|
||||||
|
|
||||||
|
// ---------------------- VOTING ------------------------- //
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "ADMIN" &&
|
||||||
|
data.dataMessage?.kategoriApp == "VOTING"
|
||||||
|
) {
|
||||||
|
setIsAdminVoting_TriggerReview(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "trigger" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.kategoriApp == "VOTING" &&
|
||||||
|
data.dataMessage.status == "Publish"
|
||||||
|
) {
|
||||||
|
setIsTriggerVotingBeranda(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.type == "notification" &&
|
||||||
|
data.pushNotificationTo == "USER" &&
|
||||||
|
data.dataMessage?.status == "Voting Masuk" &&
|
||||||
|
userLoginId !== data.dataMessage?.userId
|
||||||
|
) {
|
||||||
|
setNewUserNtf((e) => e + 1);
|
||||||
|
}
|
||||||
|
// ---------------------- VOTING ------------------------- //
|
||||||
},
|
},
|
||||||
|
|
||||||
project: "hipmi",
|
project: "hipmi",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import Coba_TestLoading from "@/app_modules/zCoba";
|
||||||
import { CobaRealtime } from "@/app_modules/zCoba/coba_realtime";
|
import { CobaRealtime } from "@/app_modules/zCoba/coba_realtime";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
@@ -10,8 +11,8 @@ export default async function Page() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CobaRealtime userLoginId={userLoginId} />
|
{/* <CobaRealtime userLoginId={userLoginId} /> */}
|
||||||
{/* <Coba_TestLoading userLoginId={userLoginId} /> */}
|
<Coba_TestLoading userLoginId={userLoginId} />
|
||||||
{/* <ComponentGlobal_UI_LayoutTamplate /> */}
|
{/* <ComponentGlobal_UI_LayoutTamplate /> */}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { atomWithStorage } from "jotai/utils";
|
import { atomWithStorage } from "jotai/utils";
|
||||||
|
import { IAdmin_ActiveChildId, IAdmin_ActivePage } from "../notifikasi/route_setting/type_of_select_page";
|
||||||
|
|
||||||
export const gs_admin_navbar_menu = atomWithStorage<string>(
|
export const gs_admin_navbar_menu = atomWithStorage<IAdmin_ActivePage | null>(
|
||||||
"gs_admin_navbar_menu",
|
"gs_admin_navbar_menu",
|
||||||
"Main"
|
"Main"
|
||||||
);
|
);
|
||||||
|
|
||||||
export const gs_admin_navbar_subMenu = atomWithStorage<string | null>(
|
export const gs_admin_navbar_subMenu = atomWithStorage<IAdmin_ActiveChildId | string>(
|
||||||
"gs_admin_navbar_submenu",
|
"gs_admin_navbar_submenu",
|
||||||
null
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
export const gs_admin_navbar_isActive_dropdown = atomWithStorage<boolean>(
|
export const gs_admin_navbar_isActive_dropdown = atomWithStorage<boolean>(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
gs_adminEventTriggerReview,
|
gs_adminEvent_triggerReview,
|
||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
} from "@/app/lib/global_state";
|
} from "@/app/lib/global_state";
|
||||||
import { AccentColor } from "@/app_modules/_global/color";
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
@@ -63,7 +63,7 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
|
|
||||||
// Realtime state
|
// Realtime state
|
||||||
const [isAdminTriggerReview, setIsAdminTriggerReview] = useAtom(
|
const [isAdminTriggerReview, setIsAdminTriggerReview] = useAtom(
|
||||||
gs_adminEventTriggerReview
|
gs_adminEvent_triggerReview
|
||||||
);
|
);
|
||||||
const [isShowReload, setIsShowReload] = useState(false);
|
const [isShowReload, setIsShowReload] = useState(false);
|
||||||
|
|
||||||
@@ -289,27 +289,25 @@ export default function AdminEvent_ComponentTableReview({
|
|||||||
|
|
||||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||||
{isShowReload && (
|
{isShowReload && (
|
||||||
<Paper bg={"red"} w={"50%"}>
|
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
<Center>
|
||||||
<Center>
|
<Button
|
||||||
<Button
|
style={{
|
||||||
style={{
|
transition: "0.5s",
|
||||||
transition: "0.5s",
|
border: `1px solid ${AccentColor.skyblue}`,
|
||||||
border: `1px solid ${AccentColor.skyblue}`,
|
}}
|
||||||
}}
|
bg={AccentColor.blue}
|
||||||
bg={AccentColor.blue}
|
loaderPosition="center"
|
||||||
loaderPosition="center"
|
loading={isLoading}
|
||||||
loading={isLoading}
|
radius={"xl"}
|
||||||
radius={"xl"}
|
opacity={0.8}
|
||||||
opacity={0.8}
|
onClick={() => onLoadData()}
|
||||||
onClick={() => onLoadData()}
|
leftIcon={<IconRefresh />}
|
||||||
leftIcon={<IconRefresh />}
|
>
|
||||||
>
|
Update Data
|
||||||
Update Data
|
</Button>
|
||||||
</Button>
|
</Center>
|
||||||
</Center>
|
</Affix>
|
||||||
</Affix>
|
|
||||||
</Paper>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RouterAdminGlobal } from "@/app/lib";
|
import { RouterAdminGlobal } from "@/app/lib";
|
||||||
import {
|
import {
|
||||||
gs_adminJobTriggerReview,
|
gs_adminJob_triggerReview,
|
||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
} from "@/app/lib/global_state";
|
} from "@/app/lib/global_state";
|
||||||
import { ComponentGlobal_InputCountDown } from "@/app_modules/_global/component";
|
import { ComponentGlobal_InputCountDown } from "@/app_modules/_global/component";
|
||||||
@@ -63,7 +63,7 @@ export default function AdminJob_ViewTavleReview({
|
|||||||
|
|
||||||
// Realtime
|
// Realtime
|
||||||
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
gs_adminJobTriggerReview
|
gs_adminJob_triggerReview
|
||||||
);
|
);
|
||||||
const [isShowReload, setIsShowReload] = useState(false);
|
const [isShowReload, setIsShowReload] = useState(false);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const listAdminPage = [
|
|||||||
// Main Dashboard
|
// Main Dashboard
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Main Dashboard",
|
name: "Dashboard",
|
||||||
path: RouterAdminDashboard.main_admin,
|
path: RouterAdminDashboard.main_admin,
|
||||||
icon: <IconHome />,
|
icon: <IconHome />,
|
||||||
child: [],
|
child: [],
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export function Admin_NewLayout({
|
|||||||
<Stack style={{ color: "white" }}>
|
<Stack style={{ color: "white" }}>
|
||||||
<Admin_UiNavbar
|
<Admin_UiNavbar
|
||||||
userRoleId={userRoleId}
|
userRoleId={userRoleId}
|
||||||
activeId={activeId}
|
activeId={activeId as any}
|
||||||
activeChildId={activeChildId as any}
|
activeChildId={activeChildId as any}
|
||||||
setActiveId={setActiveId}
|
setActiveId={setActiveId}
|
||||||
setActiveChildId={setActiveChildId}
|
setActiveChildId={setActiveChildId}
|
||||||
@@ -186,13 +186,13 @@ export function Admin_NewLayout({
|
|||||||
opened={isDrawerNotifikasi}
|
opened={isDrawerNotifikasi}
|
||||||
onClose={() => setDrawerNotifikasi(false)}
|
onClose={() => setDrawerNotifikasi(false)}
|
||||||
position="right"
|
position="right"
|
||||||
size={"xs"}
|
size={"sm"}
|
||||||
>
|
>
|
||||||
<ComponentAdmin_UIDrawerNotifikasi
|
<ComponentAdmin_UIDrawerNotifikasi
|
||||||
newAdminNtf={newAdminNtf}
|
newAdminNtf={newAdminNtf}
|
||||||
listNotifikasi={dataNotifikasi}
|
listNotifikasi={dataNotifikasi}
|
||||||
onChangeNavbar={(val: { id: string; childId: string }) => {
|
onChangeNavbar={(val: { id: string; childId: string }) => {
|
||||||
setActiveId(val.id);
|
setActiveId(val.id as any);
|
||||||
setActiveChildId(val.childId);
|
setActiveChildId(val.childId);
|
||||||
}}
|
}}
|
||||||
onToggleNavbar={(val: any) => {
|
onToggleNavbar={(val: any) => {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const newListAdminPage = [
|
|||||||
// Main Dashboard
|
// Main Dashboard
|
||||||
{
|
{
|
||||||
id: "Main",
|
id: "Main",
|
||||||
name: "Main Dashboard",
|
name: "Dashboard",
|
||||||
path: RouterAdminDashboard.main_admin,
|
path: RouterAdminDashboard.main_admin,
|
||||||
icon: <IconHome />,
|
icon: <IconHome />,
|
||||||
child: [],
|
child: [],
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
|
export async function admin_funVotingCheckStatus({ id }: { id: string }) {
|
||||||
|
const data = await prisma.voting.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
Voting_Status: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return { status: 400, message: "Id tidak ditemukan", statusName: "" };
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
message: "Id ditemukan",
|
||||||
|
statusName: _.lowerCase(data.Voting_Status?.name),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,37 +1,82 @@
|
|||||||
import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
|
|
||||||
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
|
||||||
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";
|
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||||
|
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||||
|
import { admin_funEventCheckStatus } from "../fun/get";
|
||||||
|
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||||
|
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||||
|
import { IAdmin_ActiveChildId, IAdmin_ActivePage } from "./type_of_select_page";
|
||||||
|
|
||||||
export async function adminNotifikasi_findRouterEvent({
|
export async function adminNotifikasi_findRouterEvent({
|
||||||
data,
|
appId,
|
||||||
|
notifikasiId,
|
||||||
|
router,
|
||||||
|
activePage,
|
||||||
|
onLoadCountNotif,
|
||||||
|
onLoadDataNotifikasi,
|
||||||
|
onChangeNavbar,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
notifikasiId: string;
|
||||||
|
router: AppRouterInstance;
|
||||||
|
activePage: number;
|
||||||
|
onLoadCountNotif: (val: any) => void;
|
||||||
|
onLoadDataNotifikasi: (val: any) => void;
|
||||||
|
onChangeNavbar: (val: {
|
||||||
|
id: IAdmin_ActivePage;
|
||||||
|
childId: IAdmin_ActiveChildId;
|
||||||
|
}) => void;
|
||||||
}) {
|
}) {
|
||||||
const check = await admin_funEventCheckStatus({id: data.appId})
|
const check = await admin_funEventCheckStatus({ id: appId });
|
||||||
|
|
||||||
if (check.status == 200) {
|
if (check.status == 200) {
|
||||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||||
notifId: data?.id,
|
notifId: notifikasiId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (udpateReadNotifikasi.status == 200) {
|
if (udpateReadNotifikasi.status == 200) {
|
||||||
return {
|
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||||
success: true,
|
onLoadCountNotif(loadCountNotif);
|
||||||
statusName: check.statusName,
|
|
||||||
};
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
} else {
|
page: 1,
|
||||||
return {
|
});
|
||||||
success: false,
|
onLoadDataNotifikasi(loadListNotifikasi);
|
||||||
statusName: "",
|
|
||||||
};
|
const path = `/dev/admin/event/table/${check.statusName}`;
|
||||||
|
|
||||||
|
if (check.statusName == "draft") {
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||||
|
"Status telah dirubah oleh user"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (check.statusName == "publish") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "review") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_3",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "reject") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Event",
|
||||||
|
childId: "Event_4",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,31 +2,82 @@ import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
|||||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||||
import { admin_funCheckStatusJob } from "../fun/get/fun_check_status_job";
|
import { admin_funCheckStatusJob } from "../fun/get/fun_check_status_job";
|
||||||
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
import adminNotifikasi_funUpdateIsReadById from "../fun/update/fun_update_is_read_by_id";
|
||||||
|
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||||
|
import adminNotifikasi_countNotifikasi from "../fun/count/count_is_read";
|
||||||
|
import adminNotifikasi_getByUserId from "../fun/get/get_notifikasi_by_user_id";
|
||||||
|
import { IAdmin_ActivePage, IAdmin_ActiveChildId } from "./type_of_select_page";
|
||||||
|
|
||||||
export async function adminNotifikasi_findRouterJob({
|
export async function adminNotifikasi_findRouterJob({
|
||||||
data,
|
appId,
|
||||||
|
notifikasiId,
|
||||||
|
router,
|
||||||
|
activePage,
|
||||||
|
onLoadCountNotif,
|
||||||
|
onLoadDataNotifikasi,
|
||||||
|
onChangeNavbar,
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
notifikasiId: string;
|
||||||
|
router: AppRouterInstance;
|
||||||
|
activePage: number;
|
||||||
|
onLoadCountNotif: (val: any) => void;
|
||||||
|
onLoadDataNotifikasi: (val: any) => void;
|
||||||
|
onChangeNavbar: (val: {
|
||||||
|
id: IAdmin_ActivePage;
|
||||||
|
childId: IAdmin_ActiveChildId;
|
||||||
|
}) => void;
|
||||||
}) {
|
}) {
|
||||||
const check = await admin_funCheckStatusJob({ id: data.appId });
|
const check = await admin_funCheckStatusJob({ id: appId });
|
||||||
|
|
||||||
if (check.status == 200) {
|
if (check.status == 200) {
|
||||||
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
const udpateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||||
notifId: data?.id,
|
notifId: notifikasiId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (udpateReadNotifikasi.status == 200) {
|
if (udpateReadNotifikasi.status == 200) {
|
||||||
return {
|
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||||
success: true,
|
onLoadCountNotif(loadCountNotif);
|
||||||
statusName: check.statusName,
|
|
||||||
};
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
} else {
|
page: 1,
|
||||||
return {
|
});
|
||||||
success: false,
|
onLoadDataNotifikasi(loadListNotifikasi);
|
||||||
statusName: ""
|
|
||||||
};
|
const path = `/dev/admin/job/child/${check.statusName}`;
|
||||||
|
|
||||||
|
if (check.statusName == "draft") {
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||||
|
"Status telah dirubah oleh user"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (check.statusName == "publish") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "review") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_3",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "reject") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Job",
|
||||||
|
childId: "Job_4",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
ComponentAdminGlobal_NotifikasiPeringatan("Status telah dirubah oleh user");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export type IAdmin_ActivePage = "Investasi" | "Donasi" | "Event" | "Vote" | "Job" | "Forum" | "Collaboration"
|
export type IAdmin_ActivePage = "Main" | "Investasi" | "Donasi" | "Event" | "Voting" | "Job" | "Forum" | "Collaboration"
|
||||||
export type IAdmin_ActiveChildId =
|
export type IAdmin_ActiveChildId =
|
||||||
| "Investasi_1"
|
| "Investasi_1"
|
||||||
| "Investasi_2"
|
| "Investasi_2"
|
||||||
|
|||||||
@@ -1,27 +1,84 @@
|
|||||||
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_funVotingCheckStatus } from "../fun/get/fun_voting_check_status";
|
||||||
|
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 { IAdmin_ActiveChildId, IAdmin_ActivePage } from "./type_of_select_page";
|
||||||
|
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||||
|
|
||||||
export async function adminNotifikasi_findRouterVoting({
|
export async function adminNotifikasi_findRouterVoting({
|
||||||
data,
|
appId,
|
||||||
|
notifikasiId,
|
||||||
router,
|
router,
|
||||||
|
activePage,
|
||||||
|
onLoadCountNotif,
|
||||||
|
onLoadDataNotifikasi,
|
||||||
onChangeNavbar,
|
onChangeNavbar,
|
||||||
onToggleNavbar,
|
|
||||||
}: {
|
}: {
|
||||||
data: MODEL_NOTIFIKASI;
|
appId: string;
|
||||||
|
notifikasiId: string;
|
||||||
router: AppRouterInstance;
|
router: AppRouterInstance;
|
||||||
onChangeNavbar: (val: any) => void;
|
activePage: number;
|
||||||
onToggleNavbar: (val: any) => void;
|
onLoadCountNotif: (val: any) => void;
|
||||||
|
onLoadDataNotifikasi: (val: any) => void;
|
||||||
|
onChangeNavbar: (val: {
|
||||||
|
id: IAdmin_ActivePage;
|
||||||
|
childId: IAdmin_ActiveChildId;
|
||||||
|
}) => void;
|
||||||
}) {
|
}) {
|
||||||
const path = RouterAdminVote.table_review;
|
const check = await admin_funVotingCheckStatus({ id: appId });
|
||||||
|
|
||||||
if (data.status === "Review") {
|
if (check.status == 200) {
|
||||||
router.push(path, { scroll: false });
|
const updateReadNotifikasi = await adminNotifikasi_funUpdateIsReadById({
|
||||||
onChangeNavbar({
|
notifId: notifikasiId,
|
||||||
id: 5,
|
|
||||||
childId: 53,
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
onToggleNavbar(true);
|
if (updateReadNotifikasi.status == 200) {
|
||||||
|
const loadCountNotif = await adminNotifikasi_countNotifikasi();
|
||||||
|
onLoadCountNotif(loadCountNotif);
|
||||||
|
|
||||||
|
const loadListNotifikasi = await adminNotifikasi_getByUserId({
|
||||||
|
page: 1,
|
||||||
|
});
|
||||||
|
onLoadDataNotifikasi(loadListNotifikasi);
|
||||||
|
|
||||||
|
const path = `/dev/admin/vote/child/table_${check.statusName}`;
|
||||||
|
|
||||||
|
if (check.statusName == "draft") {
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||||
|
"Status telah dirubah oleh user"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (check.statusName == "publish") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Voting",
|
||||||
|
childId: "Voting_2",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "review") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Voting",
|
||||||
|
childId: "Voting_3",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.statusName == "reject") {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: "Voting",
|
||||||
|
childId: "Voting_4",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
ComponentAdminGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,10 @@
|
|||||||
import {
|
|
||||||
gs_adminEventTriggerReview,
|
|
||||||
gs_adminJobTriggerReview,
|
|
||||||
} from "@/app/lib/global_state";
|
|
||||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
import { Center, Loader, Paper, Text } from "@mantine/core";
|
import { Box, Center, Loader, Paper, Stack, Text } 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 { useRouter } from "next/navigation";
|
|
||||||
import { useState } from "react";
|
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_getByUserId from "./fun/get/get_notifikasi_by_user_id";
|
||||||
import { adminNotifikasi_findRouterEvent } from "./route_setting/event";
|
|
||||||
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
|
||||||
import {
|
import {
|
||||||
IAdmin_ActiveChildId,
|
IAdmin_ActiveChildId,
|
||||||
IAdmin_ActivePage,
|
IAdmin_ActivePage,
|
||||||
@@ -67,42 +58,39 @@ export function ComponentAdmin_UIDrawerNotifikasi({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Paper h={"100%"}>
|
<Paper h={"100%"}>
|
||||||
<ScrollOnly
|
<Stack>
|
||||||
height="90vh"
|
{/* <Box bg={"red"}>apa ini</Box> */}
|
||||||
renderLoading={() => (
|
<ScrollOnly
|
||||||
<Center mt={"lg"}>
|
height="90vh"
|
||||||
<Loader color={"yellow"} />
|
renderLoading={() => (
|
||||||
</Center>
|
<Center mt={"lg"}>
|
||||||
)}
|
<Loader color={"yellow"} />
|
||||||
data={data}
|
</Center>
|
||||||
setData={setData}
|
)}
|
||||||
moreData={async () => {
|
data={data}
|
||||||
const loadData = await adminNotifikasi_getByUserId({
|
setData={setData}
|
||||||
page: activePage + 1,
|
moreData={async () => {
|
||||||
});
|
const loadData = await adminNotifikasi_getByUserId({
|
||||||
|
page: activePage + 1,
|
||||||
|
});
|
||||||
|
|
||||||
setActivePage((val) => val + 1);
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
return loadData;
|
return loadData;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<AdminNotifikasi_ViewCardDrawer
|
<AdminNotifikasi_ViewCardDrawer
|
||||||
data={item}
|
data={item}
|
||||||
activePage={activePage}
|
activePage={activePage}
|
||||||
onChangeNavbar={(val) => onChangeNavbar(val)}
|
onChangeNavbar={(val) => onChangeNavbar(val)}
|
||||||
onLoadCountNotif={(val) => onLoadCountNotif(val)}
|
onLoadCountNotif={(val) => onLoadCountNotif(val)}
|
||||||
onToggleNavbar={(val) => onToggleNavbar(val)}
|
onToggleNavbar={(val) => onToggleNavbar(val)}
|
||||||
onLoadDataNotifikasi={(val) => setData(val)}
|
onLoadDataNotifikasi={(val) => setData(val)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ScrollOnly>
|
</ScrollOnly>
|
||||||
|
</Stack>
|
||||||
{/* <Stack>
|
|
||||||
{data.map((e, i) => (
|
|
||||||
|
|
||||||
))}
|
|
||||||
</Stack> */}
|
|
||||||
</Paper>
|
</Paper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
import {
|
import {
|
||||||
gs_adminJobTriggerReview,
|
gs_adminEvent_triggerReview,
|
||||||
gs_adminEventTriggerReview,
|
gs_adminJob_triggerReview,
|
||||||
|
gs_adminVoting_triggerReview,
|
||||||
} from "@/app/lib/global_state";
|
} from "@/app/lib/global_state";
|
||||||
import { AccentColor } from "@/app_modules/_global/color";
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
import { ComponentGlobal_CardLoadingOverlay } from "@/app_modules/_global/component";
|
||||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
import { Card, Stack, Group, Badge, Divider, Text } from "@mantine/core";
|
import { Badge, Card, Divider, Group, Stack, Text } from "@mantine/core";
|
||||||
import { IconChecks, IconCheck } 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 { ComponentAdminGlobal_NotifikasiPeringatan } from "../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||||
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_findRouterEvent } from "./route_setting/event";
|
||||||
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
import { adminNotifikasi_findRouterJob } from "./route_setting/job";
|
||||||
import {
|
import {
|
||||||
IAdmin_ActivePage,
|
|
||||||
IAdmin_ActiveChildId,
|
IAdmin_ActiveChildId,
|
||||||
|
IAdmin_ActivePage,
|
||||||
} from "./route_setting/type_of_select_page";
|
} from "./route_setting/type_of_select_page";
|
||||||
|
import { adminNotifikasi_findRouterVoting } from "./route_setting/voting";
|
||||||
|
|
||||||
export default function AdminNotifikasi_ViewCardDrawer({
|
export default function AdminNotifikasi_ViewCardDrawer({
|
||||||
data,
|
data,
|
||||||
@@ -43,112 +46,113 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
|
|
||||||
// Realtime
|
// Realtime
|
||||||
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
const [isAdminJob_TriggerReview, setIsAdminJob_TriggerReview] = useAtom(
|
||||||
gs_adminJobTriggerReview
|
gs_adminJob_triggerReview
|
||||||
);
|
);
|
||||||
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
const [isAdminEvent_TriggerReview, setIsAdminEvent_TriggerReview] = useAtom(
|
||||||
gs_adminEventTriggerReview
|
gs_adminEvent_triggerReview
|
||||||
|
);
|
||||||
|
const [isAdminVoting_TriggerReview, setIsAdminVoting_TriggerReview] = useAtom(
|
||||||
|
gs_adminVoting_triggerReview
|
||||||
);
|
);
|
||||||
|
|
||||||
async function onRead({ data }: { data: MODEL_NOTIFIKASI }) {
|
async function onRead() {
|
||||||
// JOB
|
// ========================== JOB ========================== //
|
||||||
if (data?.kategoriApp === "JOB") {
|
if (data?.kategoriApp === "JOB") {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
const checkJob = await adminNotifikasi_findRouterJob({
|
const checkJob = await adminNotifikasi_findRouterJob({
|
||||||
data: data,
|
appId: data.appId,
|
||||||
|
notifikasiId: data.id,
|
||||||
|
router: router,
|
||||||
|
activePage: activePage,
|
||||||
|
onLoadCountNotif(val) {
|
||||||
|
onLoadCountNotif(val);
|
||||||
|
},
|
||||||
|
onLoadDataNotifikasi(val) {
|
||||||
|
onLoadDataNotifikasi(val);
|
||||||
|
},
|
||||||
|
onChangeNavbar(val) {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: val.id,
|
||||||
|
childId: val.childId,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (checkJob?.success) {
|
if (checkJob) {
|
||||||
setVisible(true);
|
setIsAdminJob_TriggerReview(false);
|
||||||
setDataId(data.id);
|
setVisible(false);
|
||||||
|
setDataId("");
|
||||||
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("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ========================== JOB ========================== //
|
||||||
|
|
||||||
|
// ========================== EVENT ========================== //
|
||||||
|
|
||||||
// EVENT
|
|
||||||
if (data.kategoriApp == "EVENT") {
|
if (data.kategoriApp == "EVENT") {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
const checkEvent = await adminNotifikasi_findRouterEvent({
|
const checkEvent = await adminNotifikasi_findRouterEvent({
|
||||||
data: data,
|
appId: data.appId,
|
||||||
|
notifikasiId: data.id,
|
||||||
|
router: router,
|
||||||
|
activePage: activePage,
|
||||||
|
onLoadCountNotif(val) {
|
||||||
|
onLoadCountNotif(val);
|
||||||
|
},
|
||||||
|
onLoadDataNotifikasi(val) {
|
||||||
|
onLoadDataNotifikasi(val);
|
||||||
|
},
|
||||||
|
onChangeNavbar(val) {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: val.id,
|
||||||
|
childId: val.childId,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (checkEvent?.success) {
|
if (checkEvent) {
|
||||||
setVisible(true);
|
setIsAdminEvent_TriggerReview(false);
|
||||||
setDataId(data.id);
|
setVisible(false);
|
||||||
|
setDataId("");
|
||||||
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("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ========================== EVENT ========================== //
|
||||||
|
|
||||||
|
// ========================== VOTING ========================== //
|
||||||
|
|
||||||
|
if (data.kategoriApp == "VOTING") {
|
||||||
|
setVisible(true);
|
||||||
|
setDataId(data.id);
|
||||||
|
|
||||||
|
const checkVoting = await adminNotifikasi_findRouterVoting({
|
||||||
|
router: router,
|
||||||
|
appId: data.appId,
|
||||||
|
notifikasiId: data.id,
|
||||||
|
activePage: activePage,
|
||||||
|
onLoadCountNotif(val) {
|
||||||
|
onLoadCountNotif(val);
|
||||||
|
},
|
||||||
|
onLoadDataNotifikasi(val) {
|
||||||
|
onLoadDataNotifikasi(val);
|
||||||
|
},
|
||||||
|
onChangeNavbar(val) {
|
||||||
|
onChangeNavbar({
|
||||||
|
id: val.id,
|
||||||
|
childId: val.childId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkVoting) {
|
||||||
|
setIsAdminVoting_TriggerReview(false);
|
||||||
|
setVisible(false);
|
||||||
|
setDataId("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ========================== VOTING ========================== //
|
||||||
|
|
||||||
// // FORUM
|
// // FORUM
|
||||||
// e?.kategoriApp === "FORUM" &&
|
// e?.kategoriApp === "FORUM" &&
|
||||||
@@ -213,7 +217,7 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
style={{
|
style={{
|
||||||
transition: "0.5s",
|
transition: "0.5s",
|
||||||
}}
|
}}
|
||||||
mb={"md"}
|
mb={"15px"}
|
||||||
c={"white"}
|
c={"white"}
|
||||||
key={data.id}
|
key={data.id}
|
||||||
bg={data.isRead ? "gray" : AccentColor.darkblue}
|
bg={data.isRead ? "gray" : AccentColor.darkblue}
|
||||||
@@ -228,9 +232,8 @@ export default function AdminNotifikasi_ViewCardDrawer({
|
|||||||
borderWidth: "2px",
|
borderWidth: "2px",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClick={async () => {
|
onClick={() => {
|
||||||
onRead({ data: data });
|
onRead();
|
||||||
// callBackIsNotifikasi(false);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card.Section p={"sm"}>
|
<Card.Section p={"sm"}>
|
||||||
|
|||||||
@@ -6,28 +6,35 @@ import { useShallowEffect } from "@mantine/hooks";
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { gs_admin_hotMenu } from "../global_state";
|
import { gs_admin_hotMenu } from "../global_state";
|
||||||
|
import {
|
||||||
|
gs_admin_navbar_menu,
|
||||||
|
gs_admin_navbar_subMenu,
|
||||||
|
} from "../_admin_global/new_global_state";
|
||||||
|
import { IAdmin_ActivePage } from "../notifikasi/route_setting/type_of_select_page";
|
||||||
|
|
||||||
export default function SplashDashboardAdmin() {
|
export default function SplashDashboardAdmin() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [active, setActive] = useAtom(gs_admin_hotMenu);
|
const [activeId, setActiveId] = useAtom(gs_admin_navbar_menu);
|
||||||
|
const [activeChildId, setActiveChildId] = useAtom(gs_admin_navbar_subMenu);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push(RouterAdminDashboard.main_admin);
|
router.push(RouterAdminDashboard.main_admin);
|
||||||
setActive(1);
|
setActiveId("Main");
|
||||||
|
setActiveChildId("");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Center h={"100vh"}>
|
<Center h={"100vh"}>
|
||||||
<Stack spacing={0} >
|
<Stack spacing={0}>
|
||||||
<Title>Welcome Admin</Title>
|
<Title>Welcome Admin</Title>
|
||||||
|
|
||||||
<AspectRatio ratio={1 / 1} mah={700} maw={700}>
|
<AspectRatio ratio={1 / 1} mah={700} maw={700}>
|
||||||
<Image src={"/aset/logo/logo-hipmi.png"} alt="Logo" />
|
<Image src={"/aset/logo/logo-hipmi.png"} alt="Logo" />
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||||
import {
|
import {
|
||||||
|
Affix,
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
@@ -10,6 +11,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Pagination,
|
Pagination,
|
||||||
Paper,
|
Paper,
|
||||||
|
rem,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Spoiler,
|
Spoiler,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -19,21 +21,31 @@ import {
|
|||||||
TextInput,
|
TextInput,
|
||||||
Title,
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconBan, IconCircleCheck, IconSearch } from "@tabler/icons-react";
|
import {
|
||||||
import { useRouter } from "next/navigation";
|
IconBan,
|
||||||
|
IconCircleCheck,
|
||||||
|
IconRefresh,
|
||||||
|
IconSearch,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
|
||||||
|
import {
|
||||||
|
gs_adminVoting_triggerReview,
|
||||||
|
IRealtimeData,
|
||||||
|
} from "@/app/lib/global_state";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||||
import mqtt_client from "@/util/mqtt_client";
|
import mqtt_client from "@/util/mqtt_client";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { adminVote_funGetListReview } from "../../fun";
|
import { adminVote_funGetListReview } from "../../fun";
|
||||||
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||||
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||||
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
|
|
||||||
|
|
||||||
export default function AdminVote_TableReview({
|
export default function AdminVote_TableReview({
|
||||||
listVote,
|
listVote,
|
||||||
@@ -51,18 +63,40 @@ export default function AdminVote_TableReview({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TableStatus({ listData }: { listData: any }) {
|
function TableStatus({ listData }: { listData: any }) {
|
||||||
const router = useRouter();
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
|
const [data, setData] = useState<MODEL_VOTING[]>(listData.data);
|
||||||
|
const [isNPage, setNPage] = useState(listData.nPage);
|
||||||
const [votingId, setVotingId] = useState("");
|
const [votingId, setVotingId] = useState("");
|
||||||
const [catatan, setCatatan] = useState("");
|
const [catatan, setCatatan] = useState("");
|
||||||
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
||||||
const [isSaveLoading, setSaveLoading] = useState(false);
|
const [isSaveLoading, setSaveLoading] = useState(false);
|
||||||
|
|
||||||
const [isNPage, setNPage] = useState(listData.nPage);
|
|
||||||
const [isActivePage, setActivePage] = useState(1);
|
const [isActivePage, setActivePage] = useState(1);
|
||||||
const [isSearch, setSearch] = useState("");
|
const [isSearch, setSearch] = useState("");
|
||||||
|
|
||||||
|
// Realtine
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [isAdminVoting_TriggerReview, setIsAdminVoting_TriggerReview] = useAtom(
|
||||||
|
gs_adminVoting_triggerReview
|
||||||
|
);
|
||||||
|
const [isShowReload, setIsShowReload] = useState(false);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (isAdminVoting_TriggerReview) {
|
||||||
|
setIsShowReload(true);
|
||||||
|
}
|
||||||
|
}, [isAdminVoting_TriggerReview, setIsShowReload]);
|
||||||
|
|
||||||
|
async function onLoadData() {
|
||||||
|
const loadData = await adminVote_funGetListReview({ page: 1 });
|
||||||
|
|
||||||
|
setData(loadData.data as any);
|
||||||
|
setNPage(loadData.nPage);
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsShowReload(false);
|
||||||
|
setIsAdminVoting_TriggerReview(false);
|
||||||
|
}
|
||||||
|
|
||||||
async function onSearch(s: string) {
|
async function onSearch(s: string) {
|
||||||
setSearch(s);
|
setSearch(s);
|
||||||
const loadData = await adminVote_funGetListReview({
|
const loadData = await adminVote_funGetListReview({
|
||||||
@@ -135,13 +169,16 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
leftIcon={<IconCircleCheck />}
|
leftIcon={<IconCircleCheck />}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
onPublish(
|
onPublish({
|
||||||
e.id,
|
voteId: e.id,
|
||||||
setData,
|
awalVote: e.awalVote,
|
||||||
e.awalVote,
|
setLoadingPublish: setLoadingPublish,
|
||||||
setLoadingPublish,
|
setVotingId: setVotingId,
|
||||||
setVotingId
|
setData(val) {
|
||||||
)
|
setData(val.data);
|
||||||
|
setNPage(val.nPage);
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Publish
|
Publish
|
||||||
@@ -185,6 +222,28 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||||
|
{isShowReload && (
|
||||||
|
<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>
|
||||||
|
)}
|
||||||
|
|
||||||
<ScrollArea w={"100%"} h={"90%"}>
|
<ScrollArea w={"100%"} h={"90%"}>
|
||||||
<Table
|
<Table
|
||||||
verticalSpacing={"md"}
|
verticalSpacing={"md"}
|
||||||
@@ -264,7 +323,20 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
loading={isSaveLoading ? true : false}
|
loading={isSaveLoading ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onReject(votingId, setData, catatan, close, setSaveLoading);
|
onReject({
|
||||||
|
catatan: catatan,
|
||||||
|
voteId: votingId,
|
||||||
|
setData(val) {
|
||||||
|
setData(val.data);
|
||||||
|
setNPage(val.nPage);
|
||||||
|
},
|
||||||
|
close: () => {
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
setSaveLoading(val) {
|
||||||
|
setSaveLoading(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
@@ -276,13 +348,19 @@ function TableStatus({ listData }: { listData: any }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPublish(
|
async function onPublish({
|
||||||
voteId: string,
|
voteId,
|
||||||
setData: any,
|
setData,
|
||||||
awalVote: Date,
|
awalVote,
|
||||||
setLoadingPublish: any,
|
setLoadingPublish,
|
||||||
setVotingId: any
|
setVotingId,
|
||||||
) {
|
}: {
|
||||||
|
voteId: string;
|
||||||
|
setData: (val: { data: any[]; nPage: number }) => void;
|
||||||
|
awalVote: Date;
|
||||||
|
setLoadingPublish: (val: boolean) => void;
|
||||||
|
setVotingId: (val: string) => void;
|
||||||
|
}) {
|
||||||
const hariIni = new Date();
|
const hariIni = new Date();
|
||||||
const cekHari = moment(awalVote).diff(hariIni, "days");
|
const cekHari = moment(awalVote).diff(hariIni, "days");
|
||||||
|
|
||||||
@@ -292,8 +370,10 @@ async function onPublish(
|
|||||||
setVotingId(voteId);
|
setVotingId(voteId);
|
||||||
const res = await AdminVote_funEditStatusPublishById(voteId);
|
const res = await AdminVote_funEditStatusPublishById(voteId);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const dataNotif = {
|
setLoadingPublish(true);
|
||||||
appId: res.data?.id,
|
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as string,
|
||||||
status: res.data?.Voting_Status?.name as any,
|
status: res.data?.Voting_Status?.name as any,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
pesan: res.data?.title as any,
|
pesan: res.data?.title as any,
|
||||||
@@ -302,33 +382,48 @@ async function onPublish(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"USER",
|
type: "notification",
|
||||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
pushNotificationTo: "USER",
|
||||||
);
|
dataMessage: dataNotifikasi,
|
||||||
}
|
});
|
||||||
|
|
||||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
WibuRealtime.setData({
|
||||||
setData(val);
|
type: "trigger",
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
pushNotificationTo: "USER",
|
||||||
setLoadingPublish(true);
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const loadData = await adminVote_funGetListReview({ page: 1 });
|
||||||
|
setData({
|
||||||
|
data: loadData.data,
|
||||||
|
nPage: loadData.nPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
setLoadingPublish(false);
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onReject(
|
async function onReject({
|
||||||
voteId: string,
|
voteId,
|
||||||
setData: any,
|
catatan,
|
||||||
catatan: string,
|
close,
|
||||||
close: any,
|
setSaveLoading,
|
||||||
setSaveLoading: any
|
setData,
|
||||||
) {
|
}: {
|
||||||
|
voteId: string;
|
||||||
|
catatan: string;
|
||||||
|
close: any;
|
||||||
|
setSaveLoading: (val: boolean) => void;
|
||||||
|
setData: (val: { data: any[]; nPage: number }) => void;
|
||||||
|
}) {
|
||||||
const data = {
|
const data = {
|
||||||
id: voteId,
|
id: voteId,
|
||||||
catatan: catatan,
|
catatan: catatan,
|
||||||
@@ -337,8 +432,17 @@ async function onReject(
|
|||||||
const res = await AdminEvent_funEditCatatanById(data as any);
|
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setSaveLoading(true);
|
setSaveLoading(true);
|
||||||
const dataNotif = {
|
// const dataNotif = {
|
||||||
appId: res.data?.id,
|
// appId: res.data?.id,
|
||||||
|
// status: res.data?.Voting_Status?.name as any,
|
||||||
|
// userId: res.data?.authorId as any,
|
||||||
|
// pesan: res.data?.title as any,
|
||||||
|
// kategoriApp: "VOTING",
|
||||||
|
// title: "Voting anda di tolak !",
|
||||||
|
// };
|
||||||
|
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as string,
|
||||||
status: res.data?.Voting_Status?.name as any,
|
status: res.data?.Voting_Status?.name as any,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
pesan: res.data?.title as any,
|
pesan: res.data?.title as any,
|
||||||
@@ -347,22 +451,25 @@ async function onReject(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await adminNotifikasi_funCreateToUser({
|
const notif = await adminNotifikasi_funCreateToUser({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"USER",
|
type: "notification",
|
||||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
pushNotificationTo: "USER",
|
||||||
);
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await AdminVote_getListTableByStatusId("2").then((val) => {
|
const loadData = await adminVote_funGetListReview({ page: 1 });
|
||||||
setData(val);
|
setData({
|
||||||
setSaveLoading(false);
|
data: loadData.data,
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
nPage: loadData.nPage,
|
||||||
close();
|
|
||||||
});
|
});
|
||||||
|
setSaveLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
close();
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
|
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
|
||||||
import { Button, Stack } from "@mantine/core";
|
import { Button, Stack } from "@mantine/core";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
|
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
|
||||||
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
|
||||||
import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta_by_id";
|
import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta_by_id";
|
||||||
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
|
||||||
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
|
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 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,
|
||||||
@@ -84,42 +83,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) {
|
||||||
// const dataNotif = {
|
|
||||||
// appId: res?.data?.Event?.id,
|
|
||||||
// userId: res?.data?.Event?.authorId,
|
|
||||||
// pesan: res?.data?.Event?.title,
|
|
||||||
// status: "Peserta Event",
|
|
||||||
// kategoriApp: "EVENT",
|
|
||||||
// title: "Peserta baru telah masuk !",
|
|
||||||
// };
|
|
||||||
|
|
||||||
const dataNotifikasi: IRealtimeData = {
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const resPeserta = await Event_getListPesertaById(eventId);
|
const resPeserta = await Event_getListPesertaById(eventId);
|
||||||
setPeserta(resPeserta);
|
setPeserta(resPeserta);
|
||||||
|
|
||||||
const resTotal = await Event_countTotalPesertaById(eventId);
|
const resTotal = await Event_countTotalPesertaById(eventId);
|
||||||
setTotal(resTotal);
|
setTotal(resTotal);
|
||||||
|
|
||||||
|
if (userLoginId !== res.data?.Event?.authorId) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { useState } from "react";
|
|||||||
import { MODEL_NOTIFIKASI } from "../model/interface";
|
import { MODEL_NOTIFIKASI } from "../model/interface";
|
||||||
import { notifikasi_eventCheckStatus } from "./path/event";
|
import { notifikasi_eventCheckStatus } from "./path/event";
|
||||||
import { notifikasi_jobCheckStatus } from "./path/job";
|
import { notifikasi_jobCheckStatus } from "./path/job";
|
||||||
|
import { gs_vote_hotMenu } from "@/app_modules/vote/global_state";
|
||||||
|
import { notifikasi_votingCheckStatus } from "./path/voting";
|
||||||
|
|
||||||
export function ComponentNotifiaksi_CardView({
|
export function ComponentNotifiaksi_CardView({
|
||||||
data,
|
data,
|
||||||
@@ -32,6 +34,7 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
|
|
||||||
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
const [jobMenuId, setJobMenuId] = useAtom(gs_job_hot_menu);
|
||||||
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
const [eventMenuId, setEventMenuId] = useAtom(gs_event_hotMenu);
|
||||||
|
const [votingMenu, setVotingMenu] = useAtom(gs_vote_hotMenu);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -92,6 +95,27 @@ export function ComponentNotifiaksi_CardView({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data?.kategoriApp === "VOTING") {
|
||||||
|
await notifikasi_votingCheckStatus({
|
||||||
|
appId: data.appId,
|
||||||
|
dataId: data.id,
|
||||||
|
categoryPage: categoryPage,
|
||||||
|
router: router,
|
||||||
|
onLoadDataEvent(val) {
|
||||||
|
onLoadData(val);
|
||||||
|
},
|
||||||
|
onSetVisible(val) {
|
||||||
|
setVisible(val);
|
||||||
|
},
|
||||||
|
onSetEventMenuId(val) {
|
||||||
|
setVotingMenu(val);
|
||||||
|
},
|
||||||
|
onLoadCountNtf(val) {
|
||||||
|
setLoadCountNtf(val);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// data?.kategoriApp === "FORUM" &&
|
// data?.kategoriApp === "FORUM" &&
|
||||||
// redirectDetailForumPage({
|
// redirectDetailForumPage({
|
||||||
// data: data,
|
// data: data,
|
||||||
|
|||||||
@@ -1,36 +1,57 @@
|
|||||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||||
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 { MODEL_NOTIFIKASI } from "../../model/interface";
|
||||||
|
import { notifikasi_funVotingCheckStatus } from "../../fun/check/fun_check_voting_status";
|
||||||
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
import notifikasi_countUserNotifikasi from "../../fun/count/fun_count_by_id";
|
||||||
|
import notifikasi_getByUserId from "../../fun/get/get_notifiaksi_by_id";
|
||||||
|
import notifikasi_funUpdateIsReadById from "../../fun/update/fun_update_is_read_by_user_id";
|
||||||
|
|
||||||
export function redirectVotingPage({
|
export async function notifikasi_votingCheckStatus({
|
||||||
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 = RouterVote.status({ id: "" });
|
const check = await notifikasi_funVotingCheckStatus({ 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 (updateReadNotifikasi.status == 200) {
|
||||||
|
onSetVisible(true);
|
||||||
|
|
||||||
|
const path = `/dev/vote/detail/${check.statusName}/${appId}`;
|
||||||
|
onSetEventMenuId(1);
|
||||||
|
router.push(path, { scroll: false });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Status tidak ditemukan");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.status === "Voting Masuk") {
|
|
||||||
router.push(RouterVote.main_detail + data.appId, { scroll: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
|
export async function notifikasi_funVotingCheckStatus({ id }: { id: string }) {
|
||||||
|
const data = await prisma.voting.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
Voting_Status: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return { status: 400, message: "Job tidak ditemukan", statusName: "" };
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
message: "Berhasil di cek",
|
||||||
|
statusName: _.lowerCase(data.Voting_Status?.name),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||||
@@ -7,7 +8,6 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_
|
|||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
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 {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
@@ -23,12 +23,11 @@ import { IconMinus, IconPlus } from "@tabler/icons-react";
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
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 { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import { Vote_funCreate } from "../fun/create/create_vote";
|
import { Vote_funCreate } from "../fun/create/create_vote";
|
||||||
import { gs_vote_hotMenu } from "../global_state";
|
import { gs_vote_hotMenu } from "../global_state";
|
||||||
import { MODEL_VOTING } from "../model/interface";
|
|
||||||
|
|
||||||
export default function Vote_Create() {
|
export default function Vote_Create() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -53,6 +52,60 @@ export default function Vote_Create() {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
async function onSave() {
|
||||||
|
if (_.values(data).includes(""))
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||||
|
|
||||||
|
const cekAwalVote = moment(data.awalVote).format();
|
||||||
|
if (cekAwalVote === "Invalid date")
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
|
||||||
|
|
||||||
|
const cekAkhirVote = moment(data.akhirVote).format();
|
||||||
|
if (cekAkhirVote === "Invalid date")
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
|
||||||
|
|
||||||
|
if (_.values(listVote.map((e) => e.value)).includes(""))
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Pilihan Voting");
|
||||||
|
|
||||||
|
// console.log("berhasil");
|
||||||
|
|
||||||
|
const res = await Vote_funCreate(data as any, listVote);
|
||||||
|
if (res.status === 201) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Voting 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,
|
||||||
|
});
|
||||||
|
|
||||||
|
setHotMenu(2);
|
||||||
|
router.replace(RouterVote.status({ id: "2" }));
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
setIsLoading(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack px={"sm"} spacing={"xl"} mb={"xl"}>
|
<Stack px={"sm"} spacing={"xl"} mb={"xl"}>
|
||||||
@@ -208,7 +261,7 @@ export default function Vote_Create() {
|
|||||||
mt={"lg"}
|
mt={"lg"}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSave(router, setHotMenu, data as any, listVote, setIsLoading);
|
onSave();
|
||||||
}}
|
}}
|
||||||
c={"black"}
|
c={"black"}
|
||||||
bg={MainColor.yellow}
|
bg={MainColor.yellow}
|
||||||
@@ -223,59 +276,3 @@ export default function Vote_Create() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSave(
|
|
||||||
router: AppRouterInstance,
|
|
||||||
setHotMenu: any,
|
|
||||||
data: MODEL_VOTING,
|
|
||||||
listVote: any[],
|
|
||||||
setIsLoading: any
|
|
||||||
) {
|
|
||||||
if (_.values(data).includes(""))
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
|
||||||
|
|
||||||
const cekAwalVote = moment(data.awalVote).format();
|
|
||||||
if (cekAwalVote === "Invalid date")
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
|
|
||||||
|
|
||||||
const cekAkhirVote = moment(data.akhirVote).format();
|
|
||||||
if (cekAkhirVote === "Invalid date")
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Tanggal");
|
|
||||||
|
|
||||||
if (_.values(listVote.map((e) => e.value)).includes(""))
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Pilihan Voting");
|
|
||||||
|
|
||||||
// console.log("berhasil");
|
|
||||||
|
|
||||||
const res = await Vote_funCreate(data, listVote);
|
|
||||||
if (res.status === 201) {
|
|
||||||
const dataNotif: any = {
|
|
||||||
appId: res.data?.id as any,
|
|
||||||
status: res.data?.Voting_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "VOTING",
|
|
||||||
title: "Voting baru",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
|
||||||
data: dataNotif as any,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (notif.status === 201) {
|
|
||||||
mqtt_client.publish(
|
|
||||||
"ADMIN",
|
|
||||||
JSON.stringify({
|
|
||||||
count: 1,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
setHotMenu(2);
|
|
||||||
router.replace(RouterVote.status({ id: "2" }));
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
|
||||||
setIsLoading(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detai
|
|||||||
import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id";
|
||||||
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export default function Vote_DetailDraft({
|
export default function Vote_DetailDraft({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -24,13 +29,21 @@ export default function Vote_DetailDraft({
|
|||||||
dataVote: MODEL_VOTING;
|
dataVote: MODEL_VOTING;
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState(dataVote);
|
const [data, setData] = useState(dataVote);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
onLoadData(setData);
|
||||||
|
}, [setData]);
|
||||||
|
|
||||||
|
async function onLoadData(setData: any) {
|
||||||
|
const loadData = await voting_funGetOneVotingbyId(dataVote.id);
|
||||||
|
setData(loadData);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={"xl"}>
|
<Stack spacing={"xl"}>
|
||||||
{dataVote?.catatan ? (
|
{dataVote?.catatan && (
|
||||||
<ComponentGlobal_BoxInformation isReport informasi={data?.catatan} />
|
<ComponentGlobal_BoxInformation isReport informasi={data?.catatan} />
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
)}
|
||||||
<ComponentVote_DetailDataSebelumPublish data={data} />
|
<ComponentVote_DetailDataSebelumPublish data={data} />
|
||||||
<ButtonAction voteId={data.id} awalVote={data.awalVote} />
|
<ButtonAction voteId={data.id} awalVote={data.awalVote} />
|
||||||
@@ -60,7 +73,7 @@ function ButtonAction({
|
|||||||
|
|
||||||
const res = await Vote_funEditStatusByStatusId(voteId, "2");
|
const res = await Vote_funEditStatusByStatusId(voteId, "2");
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const dataNotif: any = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id as any,
|
appId: res.data?.id as any,
|
||||||
status: res.data?.Voting_Status?.name as any,
|
status: res.data?.Voting_Status?.name as any,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
@@ -70,16 +83,20 @@ 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({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Ajukan Review", 2000);
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Ajukan Review", 2000);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import {
|
|||||||
AccentColor,
|
AccentColor,
|
||||||
MainColor,
|
MainColor,
|
||||||
} from "@/app_modules/_global/color/color_pallet";
|
} from "@/app_modules/_global/color/color_pallet";
|
||||||
import { ComponentGlobal_AvatarAndUsername, ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
import {
|
||||||
|
ComponentGlobal_AvatarAndUsername,
|
||||||
|
ComponentGlobal_CardStyles,
|
||||||
|
} from "@/app_modules/_global/component";
|
||||||
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";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||||
@@ -19,7 +22,7 @@ import {
|
|||||||
Radio,
|
Radio,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
Title
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
@@ -28,6 +31,8 @@ import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_votin
|
|||||||
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
import { Vote_funCreateHasil } from "../../fun/create/create_hasil";
|
||||||
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
|
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
|
||||||
export default function Vote_MainDetail({
|
export default function Vote_MainDetail({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -88,7 +93,9 @@ function TampilanDataVoting({
|
|||||||
<>
|
<>
|
||||||
<ComponentGlobal_CardStyles>
|
<ComponentGlobal_CardStyles>
|
||||||
<Stack>
|
<Stack>
|
||||||
<ComponentGlobal_AvatarAndUsername profile={dataVote?.Author?.Profile as any}/>
|
<ComponentGlobal_AvatarAndUsername
|
||||||
|
profile={dataVote?.Author?.Profile as any}
|
||||||
|
/>
|
||||||
{/* <ComponentGlobal_AuthorNameOnHeader
|
{/* <ComponentGlobal_AuthorNameOnHeader
|
||||||
authorName={dataVote?.Author.Profile.name}
|
authorName={dataVote?.Author.Profile.name}
|
||||||
imagesId={dataVote?.Author.Profile.imagesId}
|
imagesId={dataVote?.Author.Profile.imagesId}
|
||||||
@@ -218,7 +225,6 @@ function TampilanDataVoting({
|
|||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -238,27 +244,25 @@ async function onVote(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (userLoginId !== res?.data?.Voting?.authorId) {
|
if (userLoginId !== res?.data?.Voting?.authorId) {
|
||||||
const dataNotif = {
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res?.data?.Voting?.id,
|
appId: res?.data?.Voting?.id as string,
|
||||||
userId: res?.data?.Voting?.authorId,
|
userId: res?.data?.Voting?.authorId as string,
|
||||||
pesan: res?.pilihan,
|
pesan: res?.pilihan as string,
|
||||||
status: "Voting Masuk",
|
status: "Voting Masuk",
|
||||||
kategoriApp: "VOTING",
|
kategoriApp: "VOTING",
|
||||||
title: "User lain telah melakukan voting !",
|
title: "User lain telah melakukan voting !",
|
||||||
};
|
};
|
||||||
|
|
||||||
const createNotifikasi = await notifikasiToUser_funCreate({
|
const createNotifikasi = await notifikasiToUser_funCreate({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (createNotifikasi.status === 201) {
|
if (createNotifikasi.status === 201) {
|
||||||
mqtt_client.publish(
|
WibuRealtime.setData({
|
||||||
"USER",
|
type: "notification",
|
||||||
JSON.stringify({
|
pushNotificationTo: "USER",
|
||||||
userId: dataNotif.userId,
|
dataMessage: dataNotifikasi,
|
||||||
count: 1,
|
});
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||||
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, Stack } from "@mantine/core";
|
import { Button, Stack } from "@mantine/core";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish";
|
||||||
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id";
|
||||||
import { MODEL_VOTING } from "../../model/interface";
|
import { MODEL_VOTING } from "../../model/interface";
|
||||||
|
import { voting_checkStatus } from "../../fun";
|
||||||
|
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
|
||||||
|
|
||||||
export default function Vote_DetailReview({
|
export default function Vote_DetailReview({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -22,47 +25,65 @@ export default function Vote_DetailReview({
|
|||||||
<>
|
<>
|
||||||
<Stack spacing={"xl"}>
|
<Stack spacing={"xl"}>
|
||||||
<ComponentVote_DetailDataSebelumPublish data={dataVote as any} />
|
<ComponentVote_DetailDataSebelumPublish data={dataVote as any} />
|
||||||
<ButtonAction voteId={dataVote.id} />
|
<ButtonAction
|
||||||
|
voteId={dataVote.id}
|
||||||
|
statusId={dataVote.voting_StatusId}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonAction({ voteId }: { voteId: string }) {
|
function ButtonAction({
|
||||||
|
voteId,
|
||||||
|
statusId,
|
||||||
|
}: {
|
||||||
|
voteId: string;
|
||||||
|
statusId: string;
|
||||||
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
const res = await Vote_funEditStatusByStatusId(voteId, "3");
|
const check = await voting_checkStatus({ id: voteId });
|
||||||
if (res.status === 200) {
|
|
||||||
const dataNotif: any = {
|
|
||||||
appId: res.data?.id as any,
|
|
||||||
status: res.data?.Voting_Status?.name as any,
|
|
||||||
userId: res.data?.authorId as any,
|
|
||||||
pesan: res.data?.title as any,
|
|
||||||
kategoriApp: "VOTING",
|
|
||||||
title: "Membatalkan review",
|
|
||||||
};
|
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
if (check) {
|
||||||
data: dataNotif as any,
|
const res = await Vote_funEditStatusByStatusId(voteId, "3");
|
||||||
});
|
if (res.status === 200) {
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
|
appId: res.data?.id as any,
|
||||||
|
status: res.data?.Voting_Status?.name as any,
|
||||||
|
userId: res.data?.authorId as any,
|
||||||
|
pesan: res.data?.title as any,
|
||||||
|
kategoriApp: "VOTING",
|
||||||
|
title: "Membatalkan review",
|
||||||
|
};
|
||||||
|
|
||||||
if (notif.status === 201) {
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
mqtt_client.publish(
|
data: dataNotifikasi as any,
|
||||||
"ADMIN",
|
});
|
||||||
JSON.stringify({
|
|
||||||
count: 1,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
|
if (notif.status === 201) {
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
});
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "trigger",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
dataMessage: dataNotifikasi,
|
||||||
|
});
|
||||||
|
}
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Batalkan Review", 2000);
|
ComponentGlobal_NotifikasiBerhasil("Berhasil Batalkan Review", 2000);
|
||||||
router.replace(RouterVote.status({ id: "3" }));
|
router.replace(RouterVote.status({ id: "3" }));
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiPeringatan("Voting telah di terima admin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@@ -92,7 +113,10 @@ function ButtonAction({ voteId }: { voteId: string }) {
|
|||||||
loading={isLoading ? true : false}
|
loading={isLoading ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
color="green"
|
color="green"
|
||||||
onClick={() => onUpdate()}
|
onClick={() => {
|
||||||
|
onUpdate();
|
||||||
|
console.log(statusId);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
|
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
|
||||||
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_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||||
@@ -9,14 +10,14 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
Grid,
|
|
||||||
Group,
|
Group,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
Textarea,
|
Textarea
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { DatePickerInput } from "@mantine/dates";
|
import { DatePickerInput } from "@mantine/dates";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconPlus, IconTrash } from "@tabler/icons-react";
|
import { IconPlus, IconTrash } from "@tabler/icons-react";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -24,14 +25,12 @@ import moment from "moment";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Vote_funEditById } from "../fun/edit/fun_edit_by_id";
|
import { Vote_funEditById } from "../fun/edit/fun_edit_by_id";
|
||||||
|
import { Vote_getListDaftarNamaById } from "../fun/get/get_list_daftar_vote_by_id";
|
||||||
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
|
import { gs_vote_hotMenu, gs_vote_status } from "../global_state";
|
||||||
import {
|
import {
|
||||||
MODEL_VOTING,
|
MODEL_VOTING,
|
||||||
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
MODEL_VOTING_DAFTAR_NAMA_VOTE,
|
||||||
} from "../model/interface";
|
} from "../model/interface";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
|
||||||
import { Vote_getListDaftarNamaById } from "../fun/get/get_list_daftar_vote_by_id";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color/color_pallet";
|
|
||||||
|
|
||||||
export default function Vote_Edit({
|
export default function Vote_Edit({
|
||||||
dataVote,
|
dataVote,
|
||||||
|
|||||||
@@ -7,6 +7,17 @@ export async function Vote_funEditStatusByStatusId(
|
|||||||
voteId: string,
|
voteId: string,
|
||||||
statusId: string
|
statusId: string
|
||||||
) {
|
) {
|
||||||
|
// if (statusId !== "2") {
|
||||||
|
// const checkStatus = await prisma.voting.findFirst({
|
||||||
|
// where: {
|
||||||
|
// id: voteId,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if (checkStatus?.voting_StatusId != "2")
|
||||||
|
// return { status: 400, message: "Status sudah diubah admin" };
|
||||||
|
// }
|
||||||
|
|
||||||
const updt = await prisma.voting.update({
|
const updt = await prisma.voting.update({
|
||||||
where: {
|
where: {
|
||||||
id: voteId,
|
id: voteId,
|
||||||
|
|||||||
21
src/app_modules/vote/fun/get/fun_check_status.ts
Normal file
21
src/app_modules/vote/fun/get/fun_check_status.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { prisma } from "@/app/lib";
|
||||||
|
|
||||||
|
export async function voting_checkStatus({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
const checkStatus = await prisma.voting.findFirst({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if(checkStatus?.voting_StatusId == "2") return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
// if (checkStatus?.voting_StatusId == "2") return true;
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { voting_funUpdateIsArsipById } from "./edit/fun_update_is_arsip_by_id";
|
import { voting_funUpdateIsArsipById } from "./edit/fun_update_is_arsip_by_id";
|
||||||
|
import { voting_checkStatus } from "./get/fun_check_status";
|
||||||
import { voting_getMasterStatus } from "./get/get_list_status_voting";
|
import { voting_getMasterStatus } from "./get/get_list_status_voting";
|
||||||
import { vote_funGetAllByStatusId } from "./get/status/get_all_by_status_id";
|
import { vote_funGetAllByStatusId } from "./get/status/get_all_by_status_id";
|
||||||
|
|
||||||
export { voting_funUpdateIsArsipById };
|
export { voting_funUpdateIsArsipById };
|
||||||
export { vote_funGetAllByStatusId };
|
export { vote_funGetAllByStatusId };
|
||||||
export { voting_getMasterStatus };
|
export { voting_getMasterStatus };
|
||||||
|
export { voting_checkStatus };
|
||||||
|
|||||||
@@ -3,7 +3,16 @@
|
|||||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||||
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, Stack, TextInput } from "@mantine/core";
|
import {
|
||||||
|
Affix,
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Center,
|
||||||
|
Loader,
|
||||||
|
rem,
|
||||||
|
Stack,
|
||||||
|
TextInput,
|
||||||
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { ScrollOnly } from "next-scroll-loader";
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
@@ -11,6 +20,9 @@ import { useState } from "react";
|
|||||||
import ComponentVote_CardViewPublish from "../component/card_view_publish";
|
import ComponentVote_CardViewPublish from "../component/card_view_publish";
|
||||||
import { vote_getAllListPublish } from "../fun/get/get_all_list_publish";
|
import { vote_getAllListPublish } from "../fun/get/get_all_list_publish";
|
||||||
import { MODEL_VOTING } from "../model/interface";
|
import { MODEL_VOTING } from "../model/interface";
|
||||||
|
import { gs_votingTiggerBeranda } from "@/app/lib/global_state";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
|
||||||
export default function Vote_Beranda({
|
export default function Vote_Beranda({
|
||||||
dataVote,
|
dataVote,
|
||||||
@@ -20,13 +32,27 @@ export default function Vote_Beranda({
|
|||||||
const [data, setData] = useState(dataVote);
|
const [data, setData] = useState(dataVote);
|
||||||
const [activePage, setActivePage] = useState(1);
|
const [activePage, setActivePage] = useState(1);
|
||||||
|
|
||||||
|
// Realtime
|
||||||
|
const [isTriggerVotingBeranda, setIsTriggerVotingBeranda] = useAtom(
|
||||||
|
gs_votingTiggerBeranda
|
||||||
|
);
|
||||||
|
const [isShowUpdate, setIsShowUpdate] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (isTriggerVotingBeranda) {
|
||||||
|
setIsShowUpdate(true);
|
||||||
|
}
|
||||||
|
}, [isTriggerVotingBeranda, setIsShowUpdate]);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoad({
|
onLoad({
|
||||||
newData(val) {
|
newData(val) {
|
||||||
setData(val);
|
setData(val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, [setData]);
|
setIsTriggerVotingBeranda(false);
|
||||||
|
}, [setData, setIsTriggerVotingBeranda]);
|
||||||
|
|
||||||
async function onLoad({ newData }: { newData: (val: any) => void }) {
|
async function onLoad({ newData }: { newData: (val: any) => void }) {
|
||||||
const loadData = await vote_getAllListPublish({ page: 1 });
|
const loadData = await vote_getAllListPublish({ page: 1 });
|
||||||
@@ -38,8 +64,45 @@ export default function Vote_Beranda({
|
|||||||
setData(loadSearch as any);
|
setData(loadSearch as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onLoadData({ onPublish }: { onPublish: (val: any) => void }) {
|
||||||
|
setIsLoading(true);
|
||||||
|
const loadData = await vote_getAllListPublish({ page: 1 });
|
||||||
|
onPublish(loadData);
|
||||||
|
|
||||||
|
setIsShowUpdate(false);
|
||||||
|
setIsTriggerVotingBeranda(false);
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack mt={"1vh"}>
|
<Stack mt={"1vh"}>
|
||||||
|
{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>
|
||||||
|
)}
|
||||||
|
|
||||||
<TextInput
|
<TextInput
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
placeholder="Masukan judul voting"
|
placeholder="Masukan judul voting"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export interface MODEL_VOTING {
|
|||||||
Author: MODEL_USER;
|
Author: MODEL_USER;
|
||||||
Voting_DaftarNamaVote: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
|
Voting_DaftarNamaVote: MODEL_VOTING_DAFTAR_NAMA_VOTE[];
|
||||||
isArsip: boolean;
|
isArsip: boolean;
|
||||||
|
voting_StatusId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MODEL_VOTING_DAFTAR_NAMA_VOTE {
|
export interface MODEL_VOTING_DAFTAR_NAMA_VOTE {
|
||||||
|
|||||||
@@ -16,16 +16,16 @@ export function CobaRealtime({ userLoginId }: { userLoginId: string }) {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
WibuRealtime.init({
|
// WibuRealtime.init({
|
||||||
onData: (data) => {
|
// onData: (data) => {
|
||||||
|
|
||||||
console.log(data)
|
// console.log(data)
|
||||||
},
|
// },
|
||||||
project: "hipmi",
|
// project: "hipmi",
|
||||||
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
// WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
||||||
});
|
// });
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import { ActionIcon, Box, Button, Stack, Title } from "@mantine/core";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { IconPencilPlus } from "@tabler/icons-react";
|
import { IconPencilPlus } from "@tabler/icons-react";
|
||||||
import _ from "lodash";
|
import _, { random } from "lodash";
|
||||||
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { WibuRealtime } from "wibu";
|
import { WibuRealtime } from "wibu";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
import { UIGlobal_LayoutHeaderTamplate } from "../_global/ui";
|
||||||
|
|
||||||
const newData = Array(20)
|
const newData = Array(20)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
@@ -37,46 +38,46 @@ export default function Coba_TestLoading({
|
|||||||
}: {
|
}: {
|
||||||
userLoginId: string;
|
userLoginId: string;
|
||||||
}) {
|
}) {
|
||||||
// const [data, setData] = useState(data2);
|
const [data, setData] = useState(data2);
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [newData, setNewData] = useState({});
|
const [newData, setNewData] = useState({});
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
WibuRealtime.init({
|
// WibuRealtime.init({
|
||||||
WIBU_REALTIME_TOKEN: process.env.WIBU_REALTIME_KEY as any,
|
// WIBU_REALTIME_TOKEN: process.env.WIBU_REALTIME_KEY as any,
|
||||||
project: "hipmi",
|
// project: "hipmi",
|
||||||
onData(data) {
|
// onData(data) {
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
return () => {
|
// return () => {
|
||||||
WibuRealtime.cleanup();
|
// WibuRealtime.cleanup();
|
||||||
};
|
// };
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Stack w={200} p={"lg"}>
|
|
||||||
<Title>User {userLoginId}</Title>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
WibuRealtime.setData({
|
|
||||||
id: v4(),
|
|
||||||
userId: userLoginId,
|
|
||||||
data: `Ini dari user ${userLoginId}`,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Cek
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
// return (
|
// return (
|
||||||
// <>
|
// <>
|
||||||
// <UIGlobal_LayoutTamplate>
|
// <Stack w={200} p={"lg"}>
|
||||||
|
// <Title>User {userLoginId}</Title>
|
||||||
|
// <Button
|
||||||
|
// onClick={() => {
|
||||||
|
// WibuRealtime.setData({
|
||||||
|
// id: v4(),
|
||||||
|
// userId: userLoginId,
|
||||||
|
// data: `Ini dari user ${userLoginId}`,
|
||||||
|
// });
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// Cek
|
||||||
|
// </Button>
|
||||||
|
// </Stack>
|
||||||
|
// </>
|
||||||
|
// );
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <>
|
||||||
|
// <UIGlobal_LayoutTamplate header={<UIGlobal_LayoutHeaderTamplate title="Coba" />}>
|
||||||
// {/* <CreateButton /> */}
|
// {/* <CreateButton /> */}
|
||||||
// <Button onClick={() => setOpenDrawer(true)}>Click</Button>
|
// <Button onClick={() => setOpenDrawer(true)}>Click</Button>
|
||||||
// </UIGlobal_LayoutTamplate>
|
// </UIGlobal_LayoutTamplate>
|
||||||
@@ -84,32 +85,32 @@ export default function Coba_TestLoading({
|
|||||||
// );
|
// );
|
||||||
|
|
||||||
// Clone data
|
// Clone data
|
||||||
// return (
|
return (
|
||||||
// <>
|
<>
|
||||||
// <Box mt={"lg"}>
|
<Box mt={"lg"}>
|
||||||
// <Stack>
|
<Stack>
|
||||||
// <Button
|
<Button
|
||||||
// onClick={() => {
|
onClick={() => {
|
||||||
// const clone = _.clone(data);
|
const clone = _.clone(data);
|
||||||
// const dataBaru = clone.map(
|
const dataBaru = clone.map(
|
||||||
// (e) => (
|
(e) => (
|
||||||
// e.id === 1,
|
e.id === 1,
|
||||||
// {
|
{
|
||||||
// ...e,
|
...e,
|
||||||
// name: e.id === 1 ? "firman" : e.name,
|
name: e.id === 1 ? random(50, 100).toString() : e.name,
|
||||||
// age: e.id === 1 ? 30 : e.age,
|
age: e.id === 1 ? random(1, 25) : e.age,
|
||||||
// }
|
}
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// setData(dataBaru);
|
setData(dataBaru);
|
||||||
// }}
|
}}
|
||||||
// >
|
>
|
||||||
// Update
|
Update
|
||||||
// </Button>
|
</Button>
|
||||||
// </Stack>
|
</Stack>
|
||||||
|
|
||||||
// <pre>{JSON.stringify(data, null, 2)}</pre>
|
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||||
// </Box>
|
</Box>
|
||||||
// </>
|
</>
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user