Merge pull request #327 from bipproduction/amalia/06-nov-24
Amalia/06 nov 24
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { DetailEventDivision } from '@/module/calender';
|
import { DetailEventDivision } from '@/module/calender';
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
function Page() {
|
function Page() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kalender", data: dataFix }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kalender", data: dataFix, user: user.id }, { status: 200 });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan kalender, data tidak ditemukan (error: 500)", }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan kalender, data tidak ditemukan (error: 500)", }, { status: 500 });
|
||||||
@@ -139,13 +139,16 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
isActive: false
|
isActive: false
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
dateStart: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus data acara kalender', table: 'divisionCalendar', data: id })
|
const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus data acara kalender', table: 'divisionCalendar', data: id })
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menghapus acara kalender", data }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menghapus acara kalender", data, user: user.id }, { status: 200 });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({ success: false, message: "Gagal menghapus kalender, coba lagi nanti (error: 500)", }, { status: 500 }
|
return NextResponse.json({ success: false, message: "Gagal menghapus kalender, coba lagi nanti (error: 500)", }, { 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.8", mode: "staging" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "0.1.9", 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 });
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ export default function CreateCalenderDivisionCaleder() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<DateInput
|
<DateInput
|
||||||
|
valueFormat='DD-MM-YYYY'
|
||||||
required
|
required
|
||||||
styles={{
|
styles={{
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
import React, { useState } from 'react';
|
import { LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
||||||
import { globalCalender } from '../lib/val_calender';
|
import { funGetSearchMemberDivision, IDataMemberDivision } from '@/module/division_new';
|
||||||
import { useParams, useRouter } from 'next/navigation';
|
|
||||||
import { funGetDivisionById, funGetSearchMemberDivision, IDataMemberDivision } from '@/module/division_new';
|
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import toast from 'react-hot-toast';
|
import { Carousel } from '@mantine/carousel';
|
||||||
|
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Indicator, rem, Stack, Text, TextInput } from '@mantine/core';
|
||||||
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
||||||
import { LayoutNavbarNew, SkeletonList, SkeletonSingle, TEMA } from '@/module/_global';
|
import { useParams } from 'next/navigation';
|
||||||
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Group, Indicator, rem, Stack, Text, TextInput } from '@mantine/core';
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
import { FaCheck } from 'react-icons/fa6';
|
import { FaCheck } from 'react-icons/fa6';
|
||||||
import { HiChevronLeft, HiMagnifyingGlass } from 'react-icons/hi2';
|
import { HiChevronLeft, HiMagnifyingGlass } from 'react-icons/hi2';
|
||||||
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
||||||
import { Carousel } from '@mantine/carousel';
|
import { globalCalender } from '../lib/val_calender';
|
||||||
|
|
||||||
export default function CreateUserCalender({ onClose }: { onClose: (val: any) => void }) {
|
export default function CreateUserCalender({ onClose }: { onClose: (val: any) => void }) {
|
||||||
const router = useRouter()
|
|
||||||
const param = useParams<{ id: string }>()
|
const param = useParams<{ id: string }>()
|
||||||
const [selectedFiles, setSelectedFiles] = useState<any>([])
|
const [selectedFiles, setSelectedFiles] = useState<any>([])
|
||||||
const [isData, setData] = useState<IDataMemberDivision[]>([])
|
const [isData, setData] = useState<IDataMemberDivision[]>([])
|
||||||
@@ -34,11 +33,9 @@ export default function CreateUserCalender({ onClose }: { onClose: (val: any) =>
|
|||||||
if (member.length > 0) {
|
if (member.length > 0) {
|
||||||
setSelectedFiles(JSON.parse(JSON.stringify(member.get())))
|
setSelectedFiles(JSON.parse(JSON.stringify(member.get())))
|
||||||
}
|
}
|
||||||
setLoading(false)
|
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
toast.error("Gagal mendapatkan anggota, coba lagi nanti");
|
toast.error("Gagal mendapatkan anggota, coba lagi nanti");
|
||||||
@@ -103,6 +100,7 @@ export default function CreateUserCalender({ onClose }: { onClose: (val: any) =>
|
|||||||
async function fetchGetMember(val: string) {
|
async function fetchGetMember(val: string) {
|
||||||
setSearchQuery(val)
|
setSearchQuery(val)
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const res = await funGetSearchMemberDivision('?search=' + val, param.id);
|
const res = await funGetSearchMemberDivision('?search=' + val, param.id);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
setData(res.data)
|
setData(res.data)
|
||||||
@@ -111,6 +109,8 @@ export default function CreateUserCalender({ onClose }: { onClose: (val: any) =>
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import React, { useState } from 'react';
|
import { keyWibu, LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
||||||
import { useParams, useRouter } from 'next/navigation';
|
|
||||||
import { funGetSearchMemberDivision, IDataMemberDivision } from '@/module/division_new';
|
import { funGetSearchMemberDivision, IDataMemberDivision } from '@/module/division_new';
|
||||||
import toast from 'react-hot-toast';
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { Carousel } from '@mantine/carousel';
|
||||||
|
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Indicator, rem, Stack, Text, TextInput } from '@mantine/core';
|
||||||
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
||||||
import { LayoutNavbarNew, SkeletonList, SkeletonSingle, TEMA } from '@/module/_global';
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
import { ActionIcon, Avatar, Box, Button, Center, Divider, Flex, Grid, Group, Indicator, rem, Stack, Text, TextInput } from '@mantine/core';
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
import { FaCheck } from 'react-icons/fa6';
|
import { FaCheck } from 'react-icons/fa6';
|
||||||
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
import { HiMagnifyingGlass } from 'react-icons/hi2';
|
||||||
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
import { IoArrowBackOutline, IoClose } from 'react-icons/io5';
|
||||||
import { Carousel } from '@mantine/carousel';
|
|
||||||
import { funAddMemberCalender, funGetOneCalender } from '../lib/api_calender';
|
import { funAddMemberCalender, funGetOneCalender } from '../lib/api_calender';
|
||||||
import { IDataDetailByIdCalender, IDataDetailByIdMember } from '../lib/type_calender';
|
import { IDataDetailByIdCalender, IDataDetailByIdMember } from '../lib/type_calender';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useWibuRealtime } from 'wibu-realtime';
|
||||||
|
|
||||||
export default function CreateUserDetailCalender() {
|
export default function CreateUserDetailCalender() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -27,6 +28,11 @@ export default function CreateUserDetailCalender() {
|
|||||||
const [searchQuery, setSearchQuery] = useState('')
|
const [searchQuery, setSearchQuery] = useState('')
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
||||||
|
const [loadingSubmit, setLoadingSubmit] = useState(false)
|
||||||
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
|
project: "sdm"
|
||||||
|
})
|
||||||
|
|
||||||
async function getData() {
|
async function getData() {
|
||||||
try {
|
try {
|
||||||
@@ -88,9 +94,13 @@ export default function CreateUserDetailCalender() {
|
|||||||
if (selectedFiles.length == 0) {
|
if (selectedFiles.length == 0) {
|
||||||
return toast.error("Error! silahkan pilih anggota")
|
return toast.error("Error! silahkan pilih anggota")
|
||||||
}
|
}
|
||||||
|
setLoadingSubmit(true)
|
||||||
const res = await funAddMemberCalender(String(isDataCalender?.idCalendar), selectedFiles)
|
const res = await funAddMemberCalender(String(isDataCalender?.idCalendar), selectedFiles)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
setDataRealtime([{
|
||||||
|
category: "calendar-detail",
|
||||||
|
id: isDataCalender?.idCalendar,
|
||||||
|
}])
|
||||||
toast.success(res.message)
|
toast.success(res.message)
|
||||||
router.push('./')
|
router.push('./')
|
||||||
} else {
|
} else {
|
||||||
@@ -99,6 +109,8 @@ export default function CreateUserDetailCalender() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Gagal menambahkan anggota, coba lagi nanti");
|
toast.error("Gagal menambahkan anggota, coba lagi nanti");
|
||||||
|
} finally {
|
||||||
|
setLoadingSubmit(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +302,7 @@ export default function CreateUserDetailCalender() {
|
|||||||
backgroundColor: `${tema.get().bgUtama}`,
|
backgroundColor: `${tema.get().bgUtama}`,
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
|
loading={loadingSubmit}
|
||||||
c={"white"}
|
c={"white"}
|
||||||
bg={tema.get().utama}
|
bg={tema.get().utama}
|
||||||
size="lg"
|
size="lg"
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { LayoutDrawer, LayoutNavbarNew, SkeletonList, SkeletonSingle, TEMA } from '@/module/_global';
|
import { keyWibu, LayoutDrawer, LayoutNavbarNew, SkeletonList, TEMA } from '@/module/_global';
|
||||||
import { ActionIcon, Avatar, Box, Center, CopyButton, Divider, Flex, Grid, Group, SimpleGrid, Skeleton, Spoiler, Stack, Text, Tooltip } from '@mantine/core';
|
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||||
import React, { useState } from 'react';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { BsCalendar2Event, BsCalendarDate } from 'react-icons/bs';
|
import { ActionIcon, Avatar, Box, Center, CopyButton, Divider, Flex, Grid, Group, SimpleGrid, Spoiler, Stack, Text, Tooltip } from '@mantine/core';
|
||||||
import { MdEventNote, MdOutlineFormatListBulleted } from "react-icons/md";
|
|
||||||
import { LuClock, LuCopy, LuLink } from "react-icons/lu";
|
|
||||||
import { FaCheck, FaUser } from 'react-icons/fa6';
|
|
||||||
import { TbCopy } from 'react-icons/tb';
|
|
||||||
import { HiMenu } from 'react-icons/hi';
|
|
||||||
import DrawerDetailEvent from './drawer_detail_event';
|
|
||||||
import { useParams, useRouter } from 'next/navigation';
|
|
||||||
import { funDeleteMemberCalender, funGetOneCalender } from '../lib/api_calender';
|
|
||||||
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 { IDataDetailByIdCalender, IDataDetailByIdMember } from '../lib/type_calender';
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
import SkeletonDetailEvent from './skeleton_detail_event';
|
import { useState } from 'react';
|
||||||
import { IoIosCloseCircle } from 'react-icons/io';
|
|
||||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { BsCalendar2Event, BsCalendarDate } from 'react-icons/bs';
|
||||||
|
import { FaCheck, FaUser } from 'react-icons/fa6';
|
||||||
|
import { HiMenu } from 'react-icons/hi';
|
||||||
|
import { IoIosCloseCircle } from 'react-icons/io';
|
||||||
|
import { LuClock, LuLink } from "react-icons/lu";
|
||||||
|
import { MdOutlineFormatListBulleted } from "react-icons/md";
|
||||||
|
import { TbCopy } from 'react-icons/tb';
|
||||||
|
import { useWibuRealtime } from 'wibu-realtime';
|
||||||
|
import { funDeleteMemberCalender, funGetOneCalender } from '../lib/api_calender';
|
||||||
|
import { IDataDetailByIdCalender, IDataDetailByIdMember } from '../lib/type_calender';
|
||||||
|
import DrawerDetailEvent from './drawer_detail_event';
|
||||||
|
import SkeletonDetailEvent from './skeleton_detail_event';
|
||||||
|
|
||||||
export default function DetailEventDivision() {
|
export default function DetailEventDivision() {
|
||||||
const param = useParams<{ id: string, detail: string }>()
|
const param = useParams<{ id: string, detail: string }>()
|
||||||
@@ -35,16 +36,22 @@ export default function DetailEventDivision() {
|
|||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
const isMobile2 = useMediaQuery("(max-width: 460px)");
|
const isMobile2 = useMediaQuery("(max-width: 460px)");
|
||||||
const isMobile = useMediaQuery('(max-width: 369px)');
|
const isMobile = useMediaQuery('(max-width: 369px)');
|
||||||
|
const [loadingDelete, setLoadingDelete] = useState(false)
|
||||||
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
|
project: "sdm"
|
||||||
|
})
|
||||||
|
const [isUserLogin, setUserLogin] = useState('')
|
||||||
|
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async (loading: boolean) => {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(loading)
|
||||||
const response = await funGetOneCalender(param.detail)
|
const response = await funGetOneCalender(param.detail)
|
||||||
|
setUserLogin(response.user)
|
||||||
setDataCalender(response.data.calender)
|
setDataCalender(response.data.calender)
|
||||||
setDataAnggota(response.data.member)
|
setDataAnggota(response.data.member)
|
||||||
setLengthMember(response.data.total)
|
setLengthMember(response.data.total)
|
||||||
setLoading(false)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -53,16 +60,34 @@ export default function DetailEventDivision() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
getData()
|
getData(true)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'calendar-detail' && i.id == isDataCalender?.idCalendar)) {
|
||||||
|
getData(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'calendar-detail-delete' && i.id == isDataCalender?.idCalendar && i.idUserFrom != isUserLogin)) {
|
||||||
|
toast.error("Data telah di hapus, anda akan beralih ke halaman list acara")
|
||||||
|
setTimeout(() => {
|
||||||
|
router.push(`/division/${param.id}/calender`)
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
}, [dataRealTime])
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
try {
|
try {
|
||||||
|
setLoadingDelete(true)
|
||||||
const res = await funDeleteMemberCalender(String(isDataCalender?.idCalendar), { idUser: dataChoose.id });
|
const res = await funDeleteMemberCalender(String(isDataCalender?.idCalendar), { idUser: dataChoose.id });
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
setDataRealtime([{
|
||||||
|
category: "calendar-detail",
|
||||||
|
id: isDataCalender?.idCalendar,
|
||||||
|
}])
|
||||||
toast.success(res.message)
|
toast.success(res.message)
|
||||||
setDataChoose({ id: '', name: '' })
|
setDataChoose({ id: '', name: '' })
|
||||||
getData()
|
getData(false)
|
||||||
setOpenDrawer(false)
|
setOpenDrawer(false)
|
||||||
setOpenDrawerUser(false)
|
setOpenDrawerUser(false)
|
||||||
} else {
|
} else {
|
||||||
@@ -71,6 +96,9 @@ export default function DetailEventDivision() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Gagal mengeluarkan anggota, coba lagi nanti");
|
toast.error("Gagal mengeluarkan anggota, coba lagi nanti");
|
||||||
|
} finally {
|
||||||
|
setLoadingDelete(false)
|
||||||
|
setOpenModal(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,16 +460,17 @@ export default function DetailEventDivision() {
|
|||||||
</Box>
|
</Box>
|
||||||
</LayoutDrawer>
|
</LayoutDrawer>
|
||||||
|
|
||||||
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
|
<LayoutModal loading={loadingDelete} opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||||
description="Apakah Anda yakin ingin mengeluarkan anggota?"
|
description="Apakah Anda yakin ingin mengeluarkan anggota?"
|
||||||
onYes={(val) => {
|
onYes={(val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
onSubmit()
|
onSubmit()
|
||||||
}
|
} else {
|
||||||
setOpenModal(false)
|
setOpenModal(false)
|
||||||
|
}
|
||||||
}} />
|
}} />
|
||||||
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
||||||
<DrawerDetailEvent idCalendar={String(isDataCalender?.idCalendar)} />
|
<DrawerDetailEvent idCalendar={String(isDataCalender?.idCalendar)} close={() => { setOpenDrawer(false) }} />
|
||||||
</LayoutDrawer>
|
</LayoutDrawer>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { TEMA } from '@/module/_global';
|
import { keyWibu, TEMA } from '@/module/_global';
|
||||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||||
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
|
import { Box, Flex, SimpleGrid, Stack, Text } from '@mantine/core';
|
||||||
import { useParams, useRouter } from 'next/navigation';
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
@@ -9,30 +9,50 @@ import { MdDelete, MdEdit } from 'react-icons/md';
|
|||||||
import { funDeleteCalenderById } from '../lib/api_calender';
|
import { funDeleteCalenderById } from '../lib/api_calender';
|
||||||
import { FaUsers } from 'react-icons/fa6';
|
import { FaUsers } from 'react-icons/fa6';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { useWibuRealtime } from 'wibu-realtime';
|
||||||
|
|
||||||
export default function DrawerDetailEvent({ idCalendar }: { idCalendar: string }) {
|
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 }>()
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const [loadingDelete, setLoadingDelete] = useState(false)
|
||||||
|
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||||
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
|
project: "sdm"
|
||||||
|
})
|
||||||
|
|
||||||
async function fetchDeleteCalender(val: boolean) {
|
async function fetchDeleteCalender(val: boolean) {
|
||||||
try {
|
try {
|
||||||
if (val) {
|
if (val) {
|
||||||
|
setLoadingDelete(true)
|
||||||
const response = await funDeleteCalenderById(idCalendar)
|
const response = await funDeleteCalenderById(idCalendar)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
setDataRealtime([
|
||||||
|
{
|
||||||
|
category: "calendar-detail-delete",
|
||||||
|
id: idCalendar,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: "calendar-event",
|
||||||
|
division: param.id,
|
||||||
|
date: response.data.dateStart,
|
||||||
|
idUserFrom: response.user
|
||||||
|
}
|
||||||
|
])
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
setModal(false)
|
|
||||||
router.push(`/division/${param.id}/calender`)
|
router.push(`/division/${param.id}/calender`)
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setModal(false)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
setModal(false)
|
|
||||||
toast.error("Gagal hapus acara, coba lagi nanti");
|
toast.error("Gagal hapus acara, coba lagi nanti");
|
||||||
|
} finally {
|
||||||
|
close(true)
|
||||||
|
setLoadingDelete(false)
|
||||||
|
setModal(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +92,7 @@ export default function DrawerDetailEvent({ idCalendar }: { idCalendar: string }
|
|||||||
</Flex>
|
</Flex>
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Stack>
|
</Stack>
|
||||||
<LayoutModal 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) => { fetchDeleteCalender(val) }} />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -54,17 +54,16 @@ export default function ListDivisionTask() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
fetchData(false)
|
||||||
|
}, [isPage])
|
||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
fetchData(true);
|
fetchData(true);
|
||||||
}, [status, searchQuery]);
|
}, [status, searchQuery]);
|
||||||
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
fetchData(false)
|
|
||||||
}, [isPage])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = async () => {
|
const handleScroll = async () => {
|
||||||
if (containerRef && containerRef.current) {
|
if (containerRef && containerRef.current) {
|
||||||
@@ -249,8 +248,8 @@ export default function ListDivisionTask() {
|
|||||||
</Card.Section>
|
</Card.Section>
|
||||||
<Box pt={10}>
|
<Box pt={10}>
|
||||||
<Progress.Root size="xl" radius="xl" style={{ border: `1px solid ${'#BDBDBD'}` }}>
|
<Progress.Root size="xl" radius="xl" style={{ border: `1px solid ${'#BDBDBD'}` }}>
|
||||||
<Progress.Section value={v.progress} color="yellow" striped >
|
<Progress.Section value={_.isNull(v.progress) ? 0 : v.progress} color="yellow" striped >
|
||||||
<Progress.Label>{v.progress}%</Progress.Label>
|
<Progress.Label>{_.isNull(v.progress) ? 0 : v.progress}%</Progress.Label>
|
||||||
</Progress.Section>
|
</Progress.Section>
|
||||||
</Progress.Root>
|
</Progress.Root>
|
||||||
<Text my={10}>{v.desc}</Text>
|
<Text my={10}>{v.desc}</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user