refactor: modals refactored
This commit is contained in:
@ -9,14 +9,8 @@ import { useDrawersContext } from "@/drawers/DrawersContext";
|
||||
import { DealSchema } from "@/lib/client";
|
||||
|
||||
const DealsTable: FC = () => {
|
||||
const {
|
||||
deals,
|
||||
paginationInfo,
|
||||
page,
|
||||
setPage,
|
||||
dealsFiltersForm,
|
||||
dealsCrud,
|
||||
} = useDealsContext();
|
||||
const { deals, paginationInfo, page, setPage, sortingForm, dealsCrud } =
|
||||
useDealsContext();
|
||||
const { selectedProject } = useProjectsContext();
|
||||
const { openDrawer } = useDrawersContext();
|
||||
|
||||
@ -40,20 +34,20 @@ const DealsTable: FC = () => {
|
||||
return (
|
||||
<Stack
|
||||
gap={"xs"}
|
||||
h={"calc(100vh - 125px)"}>
|
||||
h={"calc(100vh - var(--mantine-spacing-xl) * 4)"}>
|
||||
<BaseTable
|
||||
records={[...deals]}
|
||||
columns={columns}
|
||||
sortStatus={{
|
||||
columnAccessor: dealsFiltersForm.values.sortingField ?? "",
|
||||
direction: dealsFiltersForm.values.sortingDirection,
|
||||
columnAccessor: sortingForm.values.sortingField ?? "",
|
||||
direction: sortingForm.values.sortingDirection,
|
||||
}}
|
||||
onSortStatusChange={sorting => {
|
||||
dealsFiltersForm.setFieldValue(
|
||||
sortingForm.setFieldValue(
|
||||
"sortingField",
|
||||
sorting.columnAccessor
|
||||
);
|
||||
dealsFiltersForm.setFieldValue(
|
||||
sortingForm.setFieldValue(
|
||||
"sortingDirection",
|
||||
sorting.direction
|
||||
);
|
||||
|
||||
@ -35,7 +35,7 @@ const TopToolPanel: FC<Props> = ({ view, setView }) => {
|
||||
title: "Создание проекта",
|
||||
withCloseButton: true,
|
||||
innerProps: {
|
||||
onComplete: projectsCrud.onCreate,
|
||||
onChange: values => projectsCrud.onCreate(values.name),
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -49,9 +49,15 @@ const TopToolPanel: FC<Props> = ({ view, setView }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const viewFiltersModalMap = {
|
||||
table: "dealsTableFiltersModal",
|
||||
board: "dealsBoardFiltersModal",
|
||||
schedule: "dealsScheduleFiltersModal",
|
||||
};
|
||||
|
||||
const onFiltersClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "dealsFiltersModal",
|
||||
modal: viewFiltersModalMap[view],
|
||||
title: "Фильтры",
|
||||
withCloseButton: true,
|
||||
innerProps: {
|
||||
|
||||
@ -29,8 +29,8 @@ const Board: FC<Props> = ({ board }) => {
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}>
|
||||
<InPlaceInput
|
||||
defaultValue={board.name}
|
||||
onComplete={value =>
|
||||
value={board.name}
|
||||
onChange={value =>
|
||||
boardsCrud.onUpdate(board.id, { name: value })
|
||||
}
|
||||
inputStyles={{
|
||||
|
||||
@ -11,7 +11,7 @@ const CreateBoardButton = () => {
|
||||
<Flex style={{ borderBottom: "2px solid gray" }}>
|
||||
<InPlaceInput
|
||||
placeholder={"Название доски"}
|
||||
onComplete={boardsCrud.onCreate}
|
||||
onChange={boardsCrud.onCreate}
|
||||
getChildren={startEditing => (
|
||||
<Box
|
||||
onClick={startEditing}
|
||||
|
||||
@ -17,7 +17,7 @@ const CreateStatusButton = () => {
|
||||
className={styles["inner-container"]}>
|
||||
<InPlaceInput
|
||||
placeholder={"Название колонки"}
|
||||
onComplete={statusesCrud.onCreate}
|
||||
onChange={statusesCrud.onCreate}
|
||||
getChildren={startEditing => (
|
||||
<Center
|
||||
p={"sm"}
|
||||
|
||||
@ -31,8 +31,8 @@ const StatusColumnHeader: FC<Props> = ({ status, isDragging }) => {
|
||||
mb={"xs"}
|
||||
className={styles.header}>
|
||||
<InPlaceInput
|
||||
defaultValue={status.name}
|
||||
onComplete={value => handleSave(value)}
|
||||
value={status.name}
|
||||
onChange={value => handleSave(value)}
|
||||
inputStyles={{
|
||||
input: {
|
||||
height: 25,
|
||||
|
||||
Reference in New Issue
Block a user