// import { ILLA_MIXPANEL_EVENT_TYPE } from "@illa-public/mixpanel-utils"
import { FC, useCallback,  useEffect } from "react"
import { useDispatch } from "react-redux"
// import { DropList, DropListItem } from "@illa-design/react"
import { componentsActions } from "@/redux/currentApp/components/componentsSlice"
// import { trackInEditor } from "@/utils/mixpanelHelper"
// import { ShortCutContext } from "@/utils/shortcut/shortcutProvider"
import { ActionMenuProps } from "./interface"

export const ActionMenu: FC<ActionMenuProps> = (props) => {
  const { pageDisplayName, isParentPage, parentPageName, openRenameModal } =
    props
  const dispatch = useDispatch()

  // const shortcut = useContext(ShortCutContext)

  useEffect(() => {
    // trackInEditor(ILLA_MIXPANEL_EVENT_TYPE.SHOW, {
    //   element: "manage_page",
    // })
  }, [])

  const handleClickSetHomePage = useCallback(() => {
    if (!pageDisplayName) return
    // trackInEditor(ILLA_MIXPANEL_EVENT_TYPE.CLICK, {
    //   element: "set_home_page",
    // })
    if (isParentPage) {
      dispatch(
        componentsActions.updateRootNodePropsReducer({
          homepageDisplayName: pageDisplayName,
        }),
      )
    }
    if (!isParentPage && parentPageName) {
      dispatch(
        componentsActions.updateDefaultSubPagePathReducer({
          pageName: parentPageName,
          subPagePath: pageDisplayName,
        }),
      )
    }
  }, [dispatch, isParentPage, pageDisplayName, parentPageName])

console.log(handleClickSetHomePage)
  const handleClickRename = useCallback(() => {
    openRenameModal()
  }, [openRenameModal])
  console.log(handleClickRename)
  return (
    <div>
      DropList
    </div>
    // <DropList minW="184px">
    //   <DropListItem
    //     value="setHomePage"
    //     title={
    //       isParentPage
    //         ? t("editor.page.label_name.set_as_homepage")
    //         : t("editor.page.label_name.set_as_default_subpage")
    //     }
    //     onClick={handleClickSetHomePage}
    //   />
    //   <DropListItem
    //     value="RenameURL"
    //     title={
    //       isParentPage
    //         ? t("widget.page.label.rename_page_url")
    //         : t("widget.page.label.rename_url")
    //     }
    //     onClick={handleClickRename}
    //   />
    //   <DropListItem
    //     value="delete"
    //     title={t("editor.inspect.header.action_menu.delete")}
    //     deleted
    //     onClick={handleDeletePage}
    //   />
    // </DropList>
  )
}

ActionMenu.displayName = "ActionMenu"
