import Styles from "@/constants/Styles"
import { useTheme } from "@/providers/ThemeProvider"
import { AntDesign } from "@expo/vector-icons"
import { router } from "expo-router"
import { useState } from "react"
import { View } from "react-native"
import { useSelector } from "react-redux"
import ButtonMenuHeader from "../buttonMenuHeader"
import DrawerBottom from "../drawerBottom"
import MenuItemRow from "../menuItemRow"
import ModalFilter from "../modalFilter"

export default function HeaderRightProjectList() {
   const { colors } = useTheme();
   const [isVisible, setVisible] = useState(false)
   const [isFilter, setFilter] = useState(false)
   const entityUser = useSelector((state: any) => state.user)

   return (
      <>
         <ButtonMenuHeader onPress={() => { setVisible(true) }} />
         <DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu">
            <View style={Styles.rowItemsCenter}>
               {
                  entityUser.role != "user" && entityUser.role != "coadmin" &&
                  <MenuItemRow
                     icon={<AntDesign name="pluscircle" color={colors.text} size={25} />}
                     title="Tambah Kegiatan"
                     onPress={() => {
                        setVisible(false)
                        router.push('/project/create')
                     }}
                  />
               }
               {
                  // (entityUser.role == "user" || entityUser.role == "coadmin" || entityUser.role == "supadmin" || entityUser.role == "developer") &&
                  <MenuItemRow
                     icon={<AntDesign name="filter" color={colors.text} size={25} />}
                     title="Filter"
                     onPress={() => {
                        setVisible(false)
                        setTimeout(() => {
                           setFilter(true)
                        }, 600)
                     }}
                  />
               }

            </View>
         </DrawerBottom>
         <ModalFilter
            close={() => { setFilter(false) }}
            open={isFilter}
            page="project"
            category={entityUser.role == "admin" || entityUser.role == "cosupadmin" ? 'year-only' : entityUser.role == "supadmin" || entityUser.role == "developer" ? "filter-group" : "filter-data"}
         />
      </>
   )
}