Fix: Voting
Deskripsi: - Fix notifikasi admin to user - Fix notifikasi user to admin ## No Issue
This commit is contained in:
@@ -3,7 +3,16 @@
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||
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 _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
@@ -11,6 +20,9 @@ import { useState } from "react";
|
||||
import ComponentVote_CardViewPublish from "../component/card_view_publish";
|
||||
import { vote_getAllListPublish } from "../fun/get/get_all_list_publish";
|
||||
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({
|
||||
dataVote,
|
||||
@@ -20,13 +32,27 @@ export default function Vote_Beranda({
|
||||
const [data, setData] = useState(dataVote);
|
||||
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(() => {
|
||||
onLoad({
|
||||
newData(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
}, [setData]);
|
||||
setIsTriggerVotingBeranda(false);
|
||||
}, [setData, setIsTriggerVotingBeranda]);
|
||||
|
||||
async function onLoad({ newData }: { newData: (val: any) => void }) {
|
||||
const loadData = await vote_getAllListPublish({ page: 1 });
|
||||
@@ -38,8 +64,45 @@ export default function Vote_Beranda({
|
||||
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 (
|
||||
<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
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul voting"
|
||||
|
||||
Reference in New Issue
Block a user