do not allow move item to source box
This commit is contained in:
+4
-1
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user