Merge pull request #332 from bipproduction/amalia/08-nov-24
Amalia/08 nov 24
This commit is contained in:
@@ -87,7 +87,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
totalComments: comments.length,
|
totalComments: comments.length,
|
||||||
};
|
};
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: response }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: response, user: user.id }, { status: 200 });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -175,7 +175,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus data diskusi', table: 'divisionDisscussion', data: id })
|
const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus data diskusi', table: 'divisionDisscussion', data: id })
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menghapus diskusi" }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menghapus diskusi", user: user.id }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal menghapus diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal menghapus diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
return NextResponse.json({ success: true, version: "0.1.9", mode: "staging" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "0.2.0", mode: "staging" }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default function DateEventDivision() {
|
|||||||
const [isMonth, setMonth] = useState<any>(moment().month() + 1)
|
const [isMonth, setMonth] = useState<any>(moment().month() + 1)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const isMobile = useMediaQuery('(max-width: 369px)');
|
const isMobile = useMediaQuery('(max-width: 369px)');
|
||||||
|
const [isDateChoose, setDataChoose] = useState<any>(moment().format('YYYY-MM-DD'))
|
||||||
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
WIBU_REALTIME_TOKEN: keyWibu,
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
project: "sdm"
|
project: "sdm"
|
||||||
@@ -37,7 +38,6 @@ export default function DateEventDivision() {
|
|||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
setLoading(false)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
toast.error("Gagal mendapatkan list acara")
|
toast.error("Gagal mendapatkan list acara")
|
||||||
@@ -63,6 +63,7 @@ export default function DateEventDivision() {
|
|||||||
|
|
||||||
async function changeMonth(value: any) {
|
async function changeMonth(value: any) {
|
||||||
const monthKlik = moment(value).format('MM')
|
const monthKlik = moment(value).format('MM')
|
||||||
|
setDataChoose(value)
|
||||||
if (monthKlik != isMonth) {
|
if (monthKlik != isMonth) {
|
||||||
setMonth(monthKlik)
|
setMonth(monthKlik)
|
||||||
getIndicator(value)
|
getIndicator(value)
|
||||||
@@ -99,7 +100,7 @@ export default function DateEventDivision() {
|
|||||||
getIndicator(isDate)
|
getIndicator(isDate)
|
||||||
getData(isDate, false)
|
getData(isDate, false)
|
||||||
} else if (dataRealTime && dataRealTime.some((i: any) => i.category == 'calendar-event' && i.division == param.id && i.date != isDate)) {
|
} else if (dataRealTime && dataRealTime.some((i: any) => i.category == 'calendar-event' && i.division == param.id && i.date != isDate)) {
|
||||||
getIndicator(isDate)
|
getIndicator(isDateChoose)
|
||||||
}
|
}
|
||||||
}, [dataRealTime])
|
}, [dataRealTime])
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export default function DetailEventDivision() {
|
|||||||
toast.error("Data telah di hapus, anda akan beralih ke halaman list acara")
|
toast.error("Data telah di hapus, anda akan beralih ke halaman list acara")
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push(`/division/${param.id}/calender`)
|
router.push(`/division/${param.id}/calender`)
|
||||||
}, 2000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
}, [dataRealTime])
|
}, [dataRealTime])
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { FaUsers } from 'react-icons/fa6';
|
|||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { useWibuRealtime } from 'wibu-realtime';
|
import { useWibuRealtime } from 'wibu-realtime';
|
||||||
|
|
||||||
export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: string, close: (val:boolean) => void }) {
|
export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: string, close: (val: boolean) => void }) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
const param = useParams<{ id: string, detail: string }>()
|
const param = useParams<{ id: string, detail: string }>()
|
||||||
@@ -22,9 +22,8 @@ export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: s
|
|||||||
project: "sdm"
|
project: "sdm"
|
||||||
})
|
})
|
||||||
|
|
||||||
async function fetchDeleteCalender(val: boolean) {
|
async function fetchDeleteCalender() {
|
||||||
try {
|
try {
|
||||||
if (val) {
|
|
||||||
setLoadingDelete(true)
|
setLoadingDelete(true)
|
||||||
const response = await funDeleteCalenderById(idCalendar)
|
const response = await funDeleteCalenderById(idCalendar)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
@@ -32,12 +31,12 @@ export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: s
|
|||||||
{
|
{
|
||||||
category: "calendar-detail-delete",
|
category: "calendar-detail-delete",
|
||||||
id: idCalendar,
|
id: idCalendar,
|
||||||
|
idUserFrom: response.user
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
category: "calendar-event",
|
category: "calendar-event",
|
||||||
division: param.id,
|
division: param.id,
|
||||||
date: response.data.dateStart,
|
date: response.data.dateStart,
|
||||||
idUserFrom: response.user
|
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
@@ -45,7 +44,6 @@ export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: s
|
|||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Gagal hapus acara, coba lagi nanti");
|
toast.error("Gagal hapus acara, coba lagi nanti");
|
||||||
@@ -94,7 +92,13 @@ export default function DrawerDetailEvent({ idCalendar, close }: { idCalendar: s
|
|||||||
</Stack>
|
</Stack>
|
||||||
<LayoutModal loading={loadingDelete} opened={isModal} onClose={() => setModal(false)}
|
<LayoutModal loading={loadingDelete} opened={isModal} onClose={() => setModal(false)}
|
||||||
description="Apakah Anda yakin ingin menghapus data acara ini? Data ini akan mempengaruhi semua data yang terkait"
|
description="Apakah Anda yakin ingin menghapus data acara ini? Data ini akan mempengaruhi semua data yang terkait"
|
||||||
onYes={(val) => { fetchDeleteCalender(val) }} />
|
onYes={(val) => {
|
||||||
|
if (val) {
|
||||||
|
fetchDeleteCalender()
|
||||||
|
} else {
|
||||||
|
setModal(false)
|
||||||
|
}
|
||||||
|
}} />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ActionIcon, Avatar, Badge, Box, Center, Divider, Flex, Grid, Group, rem
|
|||||||
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
|
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import "moment/locale/id";
|
import "moment/locale/id";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { 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";
|
||||||
@@ -26,8 +26,10 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
const refresh = useHookstate(globalRefreshDiscussion)
|
const refresh = useHookstate(globalRefreshDiscussion)
|
||||||
const roleLogin = useHookstate(globalRole)
|
const roleLogin = useHookstate(globalRole)
|
||||||
const [isCreator, setCreator] = useState(false)
|
const [isCreator, setCreator] = useState(false)
|
||||||
|
const [isUser, setUser] = useState('')
|
||||||
const adminLogin = useHookstate(globalIsAdminDivision)
|
const adminLogin = useHookstate(globalIsAdminDivision)
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const router = useRouter()
|
||||||
const isMobile = useMediaQuery('(max-width: 369px)');
|
const isMobile = useMediaQuery('(max-width: 369px)');
|
||||||
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
||||||
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
@@ -42,6 +44,7 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
setData(response.data)
|
setData(response.data)
|
||||||
setIsLoad(false)
|
setIsLoad(false)
|
||||||
setCreator(response.data.isCreator)
|
setCreator(response.data.isCreator)
|
||||||
|
setUser(response.user)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -57,6 +60,13 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'discussion-detail' && i.id == id)) {
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'discussion-detail' && i.id == id)) {
|
||||||
getData(false)
|
getData(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'discussion-delete' && i.id == id && i.user != isUser)) {
|
||||||
|
toast.error("Data telah di hapus, anda akan beralih ke halaman list diskusi")
|
||||||
|
setTimeout(() => {
|
||||||
|
router.push(`/division/${param.id}/discussion`)
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
}, [dataRealTime])
|
}, [dataRealTime])
|
||||||
|
|
||||||
async function reloadData() {
|
async function reloadData() {
|
||||||
|
|||||||
@@ -55,10 +55,15 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
|||||||
|
|
||||||
async function fetchDeleteDiscussion(val: boolean) {
|
async function fetchDeleteDiscussion(val: boolean) {
|
||||||
try {
|
try {
|
||||||
setLoadingDelete(true)
|
|
||||||
if (val) {
|
if (val) {
|
||||||
|
setLoadingDelete(true)
|
||||||
const response = await funDeleteDiscussion(id)
|
const response = await funDeleteDiscussion(id)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
setDataRealtime([{
|
||||||
|
category: "discussion-delete",
|
||||||
|
id: id,
|
||||||
|
user: response.user
|
||||||
|
}])
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
onSuccess(false)
|
onSuccess(false)
|
||||||
router.push(`/division/${param.id}/discussion`)
|
router.push(`/division/${param.id}/discussion`)
|
||||||
|
|||||||
@@ -45,15 +45,15 @@ export default function ListDiscussion({ id }: { id: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
getData(false)
|
||||||
|
}, [isPage])
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
getData(true)
|
getData(true)
|
||||||
}, [searchQuery])
|
}, [searchQuery])
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
getData(false)
|
|
||||||
}, [isPage])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = async () => {
|
const handleScroll = async () => {
|
||||||
if (containerRef && containerRef.current) {
|
if (containerRef && containerRef.current) {
|
||||||
@@ -78,7 +78,6 @@ export default function ListDiscussion({ id }: { id: string }) {
|
|||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
console.log(notifLoadPage.get())
|
|
||||||
if (notifLoadPage.get().category == 'division/' + param.id + '/discussion' && notifLoadPage.get().load == true) {
|
if (notifLoadPage.get().category == 'division/' + param.id + '/discussion' && notifLoadPage.get().load == true) {
|
||||||
setRefresh(true)
|
setRefresh(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user