refactor: moved logic from columns to table
This commit is contained in:
@ -1,14 +1,41 @@
|
||||
import { FC } from "react";
|
||||
import { FC, useCallback } from "react";
|
||||
import { IconMoodSad } from "@tabler/icons-react";
|
||||
import { Group, Pagination, Stack, Text } from "@mantine/core";
|
||||
import useDealsTableColumns from "@/app/deals/components/desktop/DealsTable/useDealsTableColumns";
|
||||
import { useDealsContext } from "@/app/deals/contexts/DealsContext";
|
||||
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||
import BaseTable from "@/components/ui/BaseTable/BaseTable";
|
||||
import { useDrawersContext } from "@/drawers/DrawersContext";
|
||||
import { DealSchema } from "@/lib/client";
|
||||
|
||||
const DealsTable: FC = () => {
|
||||
const { deals, paginationInfo, page, setPage, dealsFiltersForm } =
|
||||
useDealsContext();
|
||||
const columns = useDealsTableColumns();
|
||||
const {
|
||||
deals,
|
||||
paginationInfo,
|
||||
page,
|
||||
setPage,
|
||||
dealsFiltersForm,
|
||||
dealsCrud,
|
||||
} = useDealsContext();
|
||||
const { selectedProject } = useProjectsContext();
|
||||
const { openDrawer } = useDrawersContext();
|
||||
|
||||
const onEditClick = useCallback(
|
||||
(deal: DealSchema) => {
|
||||
if (!selectedProject) return;
|
||||
openDrawer({
|
||||
key: "dealEditorDrawer",
|
||||
props: {
|
||||
deal,
|
||||
dealsCrud,
|
||||
project: selectedProject,
|
||||
},
|
||||
});
|
||||
},
|
||||
[openDrawer, dealsCrud]
|
||||
);
|
||||
|
||||
const columns = useDealsTableColumns({ onEditClick });
|
||||
|
||||
return (
|
||||
<Stack
|
||||
|
||||
Reference in New Issue
Block a user