Merge pull request #335 from bipproduction/amalia/11-nov-24
fix: diskusi
This commit is contained in:
@@ -170,6 +170,25 @@ export async function POST(request: Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userRoleLogin != "cosupadmin") {
|
||||||
|
const ketuaGrup = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idUserRole: "cosupadmin",
|
||||||
|
idGroup: user.idGroup
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
dataNotif.push({
|
||||||
|
idUserTo: ketuaGrup?.id,
|
||||||
|
idUserFrom: userId,
|
||||||
|
category: 'division/' + idDivision + '/discussion',
|
||||||
|
idContent: data.id,
|
||||||
|
title: 'Diskusi Baru',
|
||||||
|
desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotif
|
data: dataNotif
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -59,11 +59,16 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
|||||||
setLoadingDelete(true)
|
setLoadingDelete(true)
|
||||||
const response = await funDeleteDiscussion(id)
|
const response = await funDeleteDiscussion(id)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setDataRealtime([{
|
setDataRealtime([
|
||||||
category: "discussion-delete",
|
{
|
||||||
id: id,
|
category: "discussion-delete",
|
||||||
user: response.user
|
id: id,
|
||||||
}])
|
user: response.user
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: "division/" + param.id + "/discussion",
|
||||||
|
}
|
||||||
|
])
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
onSuccess(false)
|
onSuccess(false)
|
||||||
router.push(`/division/${param.id}/discussion`)
|
router.push(`/division/${param.id}/discussion`)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { currentScroll, globalNotifPage, ReloadButtonTop, TEMA } from "@/module/_global";
|
import { currentScroll, globalNotifPage, keyWibu, ReloadButtonTop, TEMA } from "@/module/_global";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
import { Avatar, Badge, Box, Divider, Flex, Grid, Group, Skeleton, Spoiler, Text, TextInput } from "@mantine/core";
|
import { Avatar, Badge, Box, Divider, Flex, Grid, Group, Skeleton, Spoiler, Text, TextInput } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
@@ -9,6 +9,7 @@ import { useEffect, useState } from "react";
|
|||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { GrChatOption } from "react-icons/gr";
|
import { GrChatOption } from "react-icons/gr";
|
||||||
import { HiMagnifyingGlass } from "react-icons/hi2";
|
import { HiMagnifyingGlass } from "react-icons/hi2";
|
||||||
|
import { useWibuRealtime } from "wibu-realtime";
|
||||||
import { funGetAllDiscussion } from "../lib/api_discussion";
|
import { funGetAllDiscussion } from "../lib/api_discussion";
|
||||||
import { IDataDiscussion } from "../lib/type_discussion";
|
import { IDataDiscussion } from "../lib/type_discussion";
|
||||||
|
|
||||||
@@ -24,6 +25,10 @@ export default function ListDiscussion({ id }: { id: string }) {
|
|||||||
const [isPage, setPage] = useState(1)
|
const [isPage, setPage] = useState(1)
|
||||||
const notifLoadPage = useHookstate(globalNotifPage)
|
const notifLoadPage = useHookstate(globalNotifPage)
|
||||||
const [isRefresh, setRefresh] = useState(false)
|
const [isRefresh, setRefresh] = useState(false)
|
||||||
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
|
project: "sdm"
|
||||||
|
})
|
||||||
|
|
||||||
const getData = async (loading: boolean) => {
|
const getData = async (loading: boolean) => {
|
||||||
try {
|
try {
|
||||||
@@ -83,6 +88,12 @@ export default function ListDiscussion({ id }: { id: string }) {
|
|||||||
}
|
}
|
||||||
}, [notifLoadPage.get().load])
|
}, [notifLoadPage.get().load])
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'division/' + param.id + '/discussion')) {
|
||||||
|
setRefresh(true)
|
||||||
|
}
|
||||||
|
}, [dataRealTime])
|
||||||
|
|
||||||
function onRefresh() {
|
function onRefresh() {
|
||||||
notifLoadPage.set({
|
notifLoadPage.set({
|
||||||
category: '',
|
category: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user