do not allow move item to source box

This commit is contained in:
np.w
2021-02-19 20:11:20 -06:00
parent 52b22ebcae
commit 6d72ee24ad
2 changed files with 4 additions and 2 deletions
+4 -1
View File
@@ -33,6 +33,7 @@ function App() {
const [isMoving, setIsMoving] = useState(false);
const [moveItemID, setMoveItemID] = useState(null);
const [moveItemBoxID, setMoveItemBoxID] = useState(null);
//fetch all box data
useEffect(() => {
@@ -182,6 +183,7 @@ function App() {
return false;
}
const handleSelectMoveBox = async (boxData, event) => {
setMoveItemBoxID(null);
setMoveItemID(null);
setIsMoving(false);
await moveItem(moveItemID,boxData._id);
@@ -272,6 +274,7 @@ function App() {
setShowModalItem(true);
}
const handleMoveItem = (boxID, itemID) => {
setMoveItemBoxID(boxID);
setMoveItemID(itemID);
setIsMoving(true);
/*highlight which boxes available to move to*/
@@ -396,7 +399,7 @@ function App() {
{filteredData.map((box, index) => {
return (
<Box
isMoving={isMoving}
isMoving={box._id !== moveItemBoxID && isMoving}
key={index}
boxData={box}
boxHandler={boxHandler}
-1
View File
@@ -111,7 +111,6 @@ app.delete('/box/:boxId/item/:itemId', async (request, response) => {
const box = await getBox(boxID);
response.send(box);
});
//move item
app.post('/box/item/:itemId/:boxIdTarget', async (request, response) => {
const itemID = request.params.itemId;