diff --git a/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardMobile.tsx b/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardMobile.tsx index 132fd38..ded2bd7 100644 --- a/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardMobile.tsx +++ b/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardMobile.tsx @@ -2,15 +2,16 @@ import React, { FC } from "react"; import { Box, Group, Text } from "@mantine/core"; import { modals } from "@mantine/modals"; import BoardMenu from "@/app/deals/components/shared/BoardMenu/BoardMenu"; -import { BoardSchema, UpdateBoardSchema } from "@/lib/client"; +import { useProjectBoardsContext } from "@/app/deals/drawers/ProjectBoardsEditorDrawer/contexts/ProjectBoardsContext"; +import { BoardSchema } from "@/lib/client"; type Props = { board: BoardSchema; - onUpdateBoard: (boardId: number, board: UpdateBoardSchema) => void; - onDeleteBoard: (board: BoardSchema) => void; }; -const BoardMobile: FC = ({ board, onUpdateBoard, onDeleteBoard }) => { +const BoardMobile: FC = ({ board }) => { + const { onUpdateBoard, onDeleteBoard } = useProjectBoardsContext(); + const startEditing = () => { modals.openContextModal({ modal: "enterNameModal", diff --git a/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardsDrawerBody.tsx b/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardsDrawerBody.tsx index 8d55e58..b41fa96 100644 --- a/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardsDrawerBody.tsx +++ b/src/app/deals/drawers/ProjectBoardsEditorDrawer/components/BoardsDrawerBody.tsx @@ -12,7 +12,7 @@ type Props = { }; const BoardsDrawerBody: FC = ({ onClose }) => { - const { boards, onUpdateBoard, onDeleteBoard, project, onCreateBoard } = + const { boards, onUpdateBoard, project, onCreateBoard } = useProjectBoardsContext(); const renderDraggable = () => ( @@ -28,11 +28,7 @@ const BoardsDrawerBody: FC = ({ onClose }) => { return ( {renderDraggable && renderDraggable(board)} - + ); }; diff --git a/src/components/dnd/SortableDnd/SortableDnd.tsx b/src/components/dnd/SortableDnd/SortableDnd.tsx index e7c1379..fb7ebf0 100644 --- a/src/components/dnd/SortableDnd/SortableDnd.tsx +++ b/src/components/dnd/SortableDnd/SortableDnd.tsx @@ -8,7 +8,10 @@ import React, { useState, } from "react"; import { Active, DndContext, DragEndEvent } from "@dnd-kit/core"; -import { restrictToHorizontalAxis } from "@dnd-kit/modifiers"; +import { + restrictToHorizontalAxis, + restrictToVerticalAxis, +} from "@dnd-kit/modifiers"; import { SortableContext } from "@dnd-kit/sortable"; import { LexoRank } from "lexorank"; import { FreeMode, Mousewheel, Scrollbar } from "swiper/modules"; @@ -179,9 +182,13 @@ const SortableDnd = ({ ); + const restrictModifier = vertical + ? restrictToVerticalAxis + : restrictToHorizontalAxis; + return ( setActive(active)} onDragEnd={onDragEndLocal} diff --git a/src/hooks/useStatusesOperations.tsx b/src/hooks/useStatusesOperations.tsx index 166255f..f225ada 100644 --- a/src/hooks/useStatusesOperations.tsx +++ b/src/hooks/useStatusesOperations.tsx @@ -15,7 +15,11 @@ import { updateStatusMutation, } from "@/lib/client/@tanstack/react-query.gen"; import { notifications } from "@/lib/notifications"; -import { getMaxByLexorank, getNewLexorank } from "@/utils/lexorank"; +import { + getMaxByLexorank, + getNewLexorank, + sortByLexorank, +} from "@/utils/lexorank"; type Props = { statuses: StatusSchema[]; @@ -87,16 +91,18 @@ export const useStatusesOperations = ({ }); setStatuses(statuses => - statuses.map(oldStatus => - oldStatus.id !== statusId - ? oldStatus - : { - id: oldStatus.id, - name: status.name ? status.name : oldStatus.name, - lexorank: status.lexorank - ? status.lexorank - : oldStatus.lexorank, - } + sortByLexorank( + statuses.map(oldStatus => + oldStatus.id !== statusId + ? oldStatus + : { + id: oldStatus.id, + name: status.name ? status.name : oldStatus.name, + lexorank: status.lexorank + ? status.lexorank + : oldStatus.lexorank, + } + ) ) ); };