import Styles from "@/constants/Styles"
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
import { router } from "expo-router"
import { useState } from "react"
import { ToastAndroid, View } from "react-native"
import AlertKonfirmasi from "../alertKonfirmasi"
import ButtonMenuHeader from "../buttonMenuHeader"
import DrawerBottom from "../drawerBottom"
import MenuItemRow from "../menuItemRow"

type Props = {
   id: string | string[]
}

export default function HeaderRightCalendarDetail({ id }: Props) {
   const [isVisible, setVisible] = useState(false)

   return (
      <>
         <ButtonMenuHeader onPress={() => { setVisible(true) }} />
         <DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu">
            <View style={Styles.rowItemsCenter}>
               <MenuItemRow
                  icon={<MaterialIcons name="groups" color="black" size={25} />}
                  title="Tambah Anggota"
                  onPress={() => {
                     setVisible(false)

                  }}
               />
               <MenuItemRow
                  icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
                  title="Edit"
                  onPress={() => {
                     setVisible(false)
                     router.push(`./${id}/edit`)
                  }}
               />
               <MenuItemRow
                  icon={<Ionicons name="trash" color="black" size={25} />}
                  title="Hapus"
                  onPress={() => {
                     AlertKonfirmasi({
                        title: 'Konfirmasi',
                        desc: 'Apakah anda yakin ingin menghapus data?',
                        onPress: () => {
                           setVisible(false)
                           ToastAndroid.show('Berhasil menghapus data', ToastAndroid.SHORT)
                           router.back()
                        }
                     })
                  }}
               />
            </View>
         </DrawerBottom>
      </>
   )
}