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

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

export default function HeaderRightDiscussionGeneralDetail({ 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="Anggota"
                  onPress={() => {
                     setVisible(false)
                     router.push(`/discussion/member/${id}`)
                  }}
               />
               <MenuItemRow
                  icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
                  title="Edit"
                  onPress={() => {
                     setVisible(false)
                     router.push(`/discussion/edit/${id}`)
                  }}
               />
               <MenuItemRow
                  icon={<MaterialIcons name="close" color="black" size={25} />}
                  title="Tutup Diskusi"
                  onPress={() => {
                     AlertKonfirmasi({
                        title: 'Konfirmasi',
                        desc: 'Apakah anda yakin ingin menutup diskusi?',
                        onPress: () => {
                           setVisible(false)
                           ToastAndroid.show('Berhasil mengubah data', ToastAndroid.SHORT)
                        }
                     })
                  }}
               />
            </View>
            <View style={[Styles.rowItemsCenter, Styles.mt15]}>
               <MenuItemRow
                  icon={<MaterialCommunityIcons name="archive-outline" color="black" size={25} />}
                  title="Arsipkan"
                  onPress={() => {
                     AlertKonfirmasi({
                        title: 'Konfirmasi',
                        desc: 'Apakah anda yakin ingin mengarsipkan diskusi?',
                        onPress: () => {
                           setVisible(false)
                           ToastAndroid.show('Berhasil mengubah data', ToastAndroid.SHORT)
                        }
                     })
                  }}
               />
            </View>
         </DrawerBottom>
      </>
   )
}