fix bug deleteItem

This commit is contained in:
Ruidy Nemausat 2020-04-23 16:15:59 +02:00
parent 90c1ba0628
commit 8ca0bc3549
2 changed files with 6 additions and 4 deletions

View file

@ -18,8 +18,10 @@ export const itemSlice = createSlice({
...state, ...state,
items: [action.payload, ...state.items], items: [action.payload, ...state.items],
}), }),
deleteItem: (state, action) => deleteItem: (state, action) => ({
state.items.filter((i) => i._id !== action.payload), ...state,
items: state.items.filter((i) => i._id !== action.payload),
}),
setItemsLoading: (state) => ({ ...state, loading: true }), setItemsLoading: (state) => ({ ...state, loading: true }),
}, },
}); });

View file

@ -3,7 +3,7 @@ import mongoose from "mongoose";
import path from "path"; import path from "path";
import moment from "moment"; import moment from "moment";
import helmet from "helmet"; import helmet from "helmet";
// import { MONGO_URI } from "./config/keys.js"; import { MONGO_URI } from "./config/keys.js";
import items from "./routes/api/items.js"; import items from "./routes/api/items.js";
const app = express(); const app = express();
@ -11,7 +11,7 @@ const app = express();
// http port // http port
const PORT = process.env.PORT || 5000; const PORT = process.env.PORT || 5000;
// database connection key // database connection key
const db = process.env.MONGO_URI; // || MONGO_URI; const db = process.env.MONGO_URI || MONGO_URI;
// connection to database // connection to database
mongoose mongoose