fix: acara kalender
Deskripsi: - toast saat hapus acara - realtime saat hapus acara No Issues
This commit is contained in:
@@ -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])
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user