'use client'
import { globalRole, LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { ActionIcon } from "@mantine/core";
import { useState } from "react";
import { HiMenu } from "react-icons/hi";
import DrawerDiscussionGeneral from "./drawer_discussion";

export default function NavbarDiscussionGeneral() {
   const [openDrawer, setOpenDrawer] = useState(false)
   const tema = useHookstate(TEMA)
   const roleLogin = useHookstate(globalRole)

   return (
      <>
         <LayoutNavbarNew back={`/home`} title="Diskusi Umum"
            menu={
               roleLogin.get() != 'user' && roleLogin.get() != 'coadmin' &&
               <ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
                  <HiMenu size={20} color='white' />
               </ActionIcon>
            }
         />
         <LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
            <DrawerDiscussionGeneral />
         </LayoutDrawer>
      </>
   );
}