Fix: Voting

Deskripsi:
- Fix notifikasi admin to user
- Fix notifikasi user to admin
## No Issue
This commit is contained in:
2024-11-20 16:23:05 +08:00
parent 6b8ace772c
commit e65a8d30a2
36 changed files with 1077 additions and 547 deletions

View File

@@ -16,16 +16,16 @@ export function CobaRealtime({ userLoginId }: { userLoginId: string }) {
// });
useShallowEffect(() => {
WibuRealtime.init({
onData: (data) => {
// useShallowEffect(() => {
// WibuRealtime.init({
// onData: (data) => {
console.log(data)
},
project: "hipmi",
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
});
}, []);
// console.log(data)
// },
// project: "hipmi",
// WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
// });
// }, []);
return (
<>

View File

@@ -4,11 +4,12 @@ import { ActionIcon, Box, Button, Stack, Title } from "@mantine/core";
import { useState } from "react";
import { IconPencilPlus } from "@tabler/icons-react";
import _ from "lodash";
import _, { random } from "lodash";
import UIGlobal_LayoutTamplate from "../_global/ui/ui_layout_tamplate";
import { useShallowEffect } from "@mantine/hooks";
import { WibuRealtime } from "wibu";
import { v4 } from "uuid";
import { UIGlobal_LayoutHeaderTamplate } from "../_global/ui";
const newData = Array(20)
.fill(0)
@@ -37,46 +38,46 @@ export default function Coba_TestLoading({
}: {
userLoginId: string;
}) {
// const [data, setData] = useState(data2);
const [data, setData] = useState(data2);
const [openDrawer, setOpenDrawer] = useState(false);
const [newData, setNewData] = useState({});
useShallowEffect(() => {
WibuRealtime.init({
WIBU_REALTIME_TOKEN: process.env.WIBU_REALTIME_KEY as any,
project: "hipmi",
onData(data) {
console.log(data);
},
});
// useShallowEffect(() => {
// WibuRealtime.init({
// WIBU_REALTIME_TOKEN: process.env.WIBU_REALTIME_KEY as any,
// project: "hipmi",
// onData(data) {
// console.log(data);
// },
// });
return () => {
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 () => {
// WibuRealtime.cleanup();
// };
// }, []);
// 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 /> */}
// <Button onClick={() => setOpenDrawer(true)}>Click</Button>
// </UIGlobal_LayoutTamplate>
@@ -84,32 +85,32 @@ export default function Coba_TestLoading({
// );
// Clone data
// return (
// <>
// <Box mt={"lg"}>
// <Stack>
// <Button
// onClick={() => {
// const clone = _.clone(data);
// const dataBaru = clone.map(
// (e) => (
// e.id === 1,
// {
// ...e,
// name: e.id === 1 ? "firman" : e.name,
// age: e.id === 1 ? 30 : e.age,
// }
// )
// );
// setData(dataBaru);
// }}
// >
// Update
// </Button>
// </Stack>
return (
<>
<Box mt={"lg"}>
<Stack>
<Button
onClick={() => {
const clone = _.clone(data);
const dataBaru = clone.map(
(e) => (
e.id === 1,
{
...e,
name: e.id === 1 ? random(50, 100).toString() : e.name,
age: e.id === 1 ? random(1, 25) : e.age,
}
)
);
setData(dataBaru);
}}
>
Update
</Button>
</Stack>
// <pre>{JSON.stringify(data, null, 2)}</pre>
// </Box>
// </>
// );
<pre>{JSON.stringify(data, null, 2)}</pre>
</Box>
</>
);
}