diff --git a/packages/client/src/pages/Main/containers/TerritoryTreeBox/TerritoryTreeNode/TerritoryTreeNode.tsx b/packages/client/src/pages/Main/containers/TerritoryTreeBox/TerritoryTreeNode/TerritoryTreeNode.tsx index 31b630b98..abc0534ce 100644 --- a/packages/client/src/pages/Main/containers/TerritoryTreeBox/TerritoryTreeNode/TerritoryTreeNode.tsx +++ b/packages/client/src/pages/Main/containers/TerritoryTreeBox/TerritoryTreeNode/TerritoryTreeNode.tsx @@ -1,5 +1,5 @@ -import { animated, config, useSpring } from "@react-spring/web"; -import { UserEnums } from "@shared/enums"; +import { config, useSpring } from "@react-spring/web"; +import { EntityEnums, UserEnums } from "@shared/enums"; import { ITerritory, IUser } from "@shared/types"; import { IParentTerritory } from "@shared/types/territory"; import { @@ -9,10 +9,11 @@ import { } from "@tanstack/react-query"; import { rootTerritoryId } from "Theme/constants"; import api from "api"; -import { EntityTag } from "components/advanced"; +import { EntityDropzone, EntityTag } from "components/advanced"; import { useSearchParams } from "hooks"; import update from "immutability-helper"; import React, { useCallback, useContext, useEffect, useState } from "react"; +import { toast } from "react-toastify"; import { setDisableTreeScroll } from "redux/features/territoryTree/disableTreeScrollSlice"; import { setTreeInitialized } from "redux/features/territoryTree/treeInitializeSlice"; import { useAppDispatch, useAppSelector } from "redux/hooks"; @@ -180,6 +181,20 @@ export const TerritoryTreeNode: React.FC = ({ } }, [hasChildren, territoryId]); + const moveStatementsMutation = useMutation({ + mutationFn: async (data: { + statements: string[]; + newTerritoryId: string; + }) => await api.statementsBatchMove(data.statements, data.newTerritoryId), + onSuccess: (variables, data) => { + queryClient.invalidateQueries({ queryKey: ["territory"] }); + queryClient.invalidateQueries({ queryKey: ["tree"] }); + toast.info(`statement moved`); + // could be redirected to newTerritory + // setTerritoryId(data.newTerritoryId); + }, + }); + return ( <> <> @@ -203,20 +218,34 @@ export const TerritoryTreeNode: React.FC = ({ right={right} /> - + { + moveStatementsMutation.mutate({ + statements: [newSelectedId], + newTerritoryId: territory.id, + }); + }} + disableTemplatesAccept + categoryTypes={[EntityEnums.Class.Statement]} + disabled={right === UserEnums.RoleMode.Read} + // ideally statements in current T + // excludedActantIds={[territory.data]} + > + +