import { CaretDownOutlined, FolderAddOutlined } from '@ant-design/icons';
import { Button, Dropdown, MenuProps, Space, Typography } from 'antd';
import cn from 'classnames';
import React from 'react';
import { withRouter } from 'react-router-dom';
import { useStore } from 'App/mstore';
import { observer } from 'mobx-react-lite';
import { hasSiteId, siteChangeAvailable } from 'App/routes';
import { Icon } from 'UI';
import { useModal } from 'Components/ModalContext';
import ProjectForm from 'Components/Client/Projects/ProjectForm';
import Project from '@/mstore/types/project';
import { useTranslation } from 'react-i18next';
const { Text } = Typography;
function ProjectDropdown(props: { location: any }) {
const mstore = useStore();
const { t } = useTranslation();
const { projectsStore, searchStore, searchStoreLive, userStore, aiFiltersStore } = mstore;
const { account } = userStore;
const sites = projectsStore.list;
const { siteId } = projectsStore;
const { setSiteId } = projectsStore;
const { initProject } = projectsStore;
const { location } = props;
const isAdmin = account.admin || account.superAdmin;
const activeSite = sites.find((s) => s.id === siteId);
const showCurrent =
hasSiteId(location.pathname) || siteChangeAvailable(location.pathname);
const { openModal, closeModal } = useModal();
const handleSiteChange = async (newSiteId: string) => {
mstore.initClient();
aiFiltersStore.clearFilters();
setSiteId(newSiteId);
searchStore.clearSearch();
searchStore.clearList();
searchStoreLive.clearSearch();
// await customFieldStore.fetchList(newSiteId);
// await searchStore.fetchSavedSearchList()
};
const onClose = (pro: Project) => {
console.log('onClose', pro);
closeModal();
if (pro.projectId) {
void handleSiteChange(pro.projectId.toString());
}
};
const addProjectClickHandler = () => {
initProject({});
openModal(