feat: deals filters
This commit is contained in:
@ -1,44 +1,61 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Space } from "@mantine/core";
|
||||
import DealsTable from "@/app/deals/components/desktop/DealsTable/DealsTable";
|
||||
import { Space } from "@mantine/core";
|
||||
import TopToolPanel from "@/app/deals/components/desktop/TopToolPanel/TopToolPanel";
|
||||
import MainBlockHeader from "@/app/deals/components/mobile/MainBlockHeader/MainBlockHeader";
|
||||
import Funnel from "@/app/deals/components/shared/Funnel/Funnel";
|
||||
import { useBoardsContext } from "@/app/deals/contexts/BoardsContext";
|
||||
import { DealsContextProvider } from "@/app/deals/contexts/DealsContext";
|
||||
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||
import { useViewContext } from "@/app/deals/contexts/ViewContext";
|
||||
import PageBlock from "@/components/layout/PageBlock/PageBlock";
|
||||
import DealsTable from "../../desktop/DealsTable/DealsTable";
|
||||
|
||||
const BoardView = () => (
|
||||
<PageBlock>
|
||||
<MainBlockHeader />
|
||||
<Space h="md" />
|
||||
<Funnel />
|
||||
</PageBlock>
|
||||
);
|
||||
|
||||
const TableView = () => (
|
||||
<PageBlock>
|
||||
<DealsTable />
|
||||
</PageBlock>
|
||||
);
|
||||
|
||||
const ScheduleView = () => <PageBlock>-</PageBlock>;
|
||||
|
||||
const PageBody = () => {
|
||||
const { selectedBoard } = useBoardsContext();
|
||||
const { selectedProject } = useProjectsContext();
|
||||
const { view } = useViewContext();
|
||||
|
||||
if (view === "board") {
|
||||
return (
|
||||
<>
|
||||
<MainBlockHeader />
|
||||
<Space h={"md"} />
|
||||
<DealsContextProvider boardId={selectedBoard?.id}>
|
||||
<Funnel />
|
||||
</DealsContextProvider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
const getViewContent = () => {
|
||||
switch (view) {
|
||||
case "board":
|
||||
return <BoardView />;
|
||||
case "table":
|
||||
return <TableView />;
|
||||
default:
|
||||
return <ScheduleView />;
|
||||
}
|
||||
};
|
||||
|
||||
if (view === "table") {
|
||||
return (
|
||||
<Box>
|
||||
<DealsContextProvider
|
||||
withPagination
|
||||
projectId={selectedProject?.id}>
|
||||
<DealsTable />
|
||||
</DealsContextProvider>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
const getContextProps = () => {
|
||||
if (view === "table") {
|
||||
return { withPagination: true, projectId: selectedProject?.id };
|
||||
}
|
||||
return { boardId: selectedBoard?.id };
|
||||
};
|
||||
|
||||
return <>-</>;
|
||||
return (
|
||||
<DealsContextProvider {...getContextProps()}>
|
||||
<TopToolPanel />
|
||||
{getViewContent()}
|
||||
</DealsContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default PageBody;
|
||||
|
||||
Reference in New Issue
Block a user