import { useAdminCreateBatchJob, useAdminCreateCollection } from "medusa-react"
import { useEffect, useState } from "react"
import { useLocation, useNavigate } from "react-router-dom"
import { useTranslation } from "react-i18next"
import Fade from "../../../components/atoms/fade-wrapper"
import Spacer from "../../../components/atoms/spacer"
import WidgetContainer from "../../../components/extensions/widget-container"
import Button from "../../../components/fundamentals/button"
import ExportIcon from "../../../components/fundamentals/icons/export-icon"
import PlusIcon from "../../../components/fundamentals/icons/plus-icon"
import UploadIcon from "../../../components/fundamentals/icons/upload-icon"
import BodyCard from "../../../components/organisms/body-card"
import TableViewHeader from "../../../components/organisms/custom-table-header"
import ExportModal from "../../../components/organisms/export-modal"
import AddCollectionModal from "../../../components/templates/collection-modal"
import CollectionsTable from "../../../components/templates/collections-table"
import ProductTable from "../../../components/templates/product-table"
import useNotification from "../../../hooks/use-notification"
import useToggleState from "../../../hooks/use-toggle-state"
import { usePolling } from "../../../providers/polling-provider"
import { useWidgets } from "../../../providers/widget-provider"
import { getErrorMessage } from "../../../utils/error-messages"
import ImportProducts from "../batch-job/import"
import NewProduct from "../new"
const VIEWS = ["products", "collections"]
const Overview = () => {
const { t } = useTranslation()
const navigate = useNavigate()
const location = useLocation()
const [view, setView] = useState("products")
const {
state: createProductState,
close: closeProductCreate,
open: openProductCreate,
} = useToggleState(
!location.search.includes("view=collections") &&
location.search.includes("modal=new")
)
const { resetInterval } = usePolling()
const createBatchJob = useAdminCreateBatchJob()
const notification = useNotification()
const createCollection = useAdminCreateCollection()
const { getWidgets } = useWidgets()
useEffect(() => {
if (location.search.includes("?view=collections")) {
setView("collections")
}
}, [location])
useEffect(() => {
location.search = ""
}, [view])
const CurrentView = () => {
switch (view) {
case "products":
return