upd: calendar division
Deskripsi: - load list data event - indicator kalender - detail data event kalender - mengeluarkan anggota - menambahkan anggota - menghapus event kalender - riwayat event kalender - nb : tambah dan edit kalender blm selesai karena input tgl susahh No Issues
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import Styles from "@/constants/Styles"
|
||||
import { apiDeleteCalendar } from "@/lib/api"
|
||||
import { setUpdateCalendar } from "@/lib/calendarUpdate"
|
||||
import { useAuthSession } from "@/providers/AuthProvider"
|
||||
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
|
||||
import { router } from "expo-router"
|
||||
import { useState } from "react"
|
||||
import { ToastAndroid, View } from "react-native"
|
||||
import { useDispatch, useSelector } from "react-redux"
|
||||
import AlertKonfirmasi from "../alertKonfirmasi"
|
||||
import ButtonMenuHeader from "../buttonMenuHeader"
|
||||
import DrawerBottom from "../drawerBottom"
|
||||
@@ -14,6 +18,28 @@ type Props = {
|
||||
|
||||
export default function HeaderRightCalendarDetail({ id }: Props) {
|
||||
const [isVisible, setVisible] = useState(false)
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const update = useSelector((state: any) => state.calendarUpdate)
|
||||
const dispatch = useDispatch()
|
||||
|
||||
async function handleDeleteCalendar() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiDeleteCalendar({ user: hasil }, String(id));
|
||||
if (response.success) {
|
||||
dispatch(setUpdateCalendar({ ...update, data: !update.data }));
|
||||
ToastAndroid.show(response.message, ToastAndroid.SHORT);
|
||||
router.back()
|
||||
} else {
|
||||
ToastAndroid.show(response.message, ToastAndroid.SHORT);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
ToastAndroid.show('Terjadi kesalahan', ToastAndroid.SHORT);
|
||||
} finally {
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -25,7 +51,7 @@ export default function HeaderRightCalendarDetail({ id }: Props) {
|
||||
title="Tambah Anggota"
|
||||
onPress={() => {
|
||||
setVisible(false)
|
||||
|
||||
router.push(`./${id}/add-member`)
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
@@ -42,11 +68,9 @@ export default function HeaderRightCalendarDetail({ id }: Props) {
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Konfirmasi',
|
||||
desc: 'Apakah anda yakin ingin menghapus data?',
|
||||
desc: 'Apakah anda yakin ingin menghapus data ini? Data ini akan mempengaruhi semua data yang terkait',
|
||||
onPress: () => {
|
||||
setVisible(false)
|
||||
ToastAndroid.show('Berhasil menghapus data', ToastAndroid.SHORT)
|
||||
router.back()
|
||||
handleDeleteCalendar()
|
||||
}
|
||||
})
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user