Enhance item management: update API key display, add locker number input, and modify database schema for unique locker numbers
This commit is contained in:
@@ -23,10 +23,10 @@ export const deleteItemById = async (itemId) => {
|
||||
return { success: false };
|
||||
};
|
||||
|
||||
export const createItem = async (item_name, can_borrow_role, in_safe) => {
|
||||
export const createItem = async (item_name, can_borrow_role, lockerNumber) => {
|
||||
const [result] = await pool.query(
|
||||
"INSERT INTO items (item_name, can_borrow_role, in_safe) VALUES (?, ?, ?)",
|
||||
[item_name, can_borrow_role, true]
|
||||
"INSERT INTO items (item_name, can_borrow_role, in_safe, safe_nr) VALUES (?, ?, ?, ?)",
|
||||
[item_name, can_borrow_role, true, lockerNumber]
|
||||
);
|
||||
if (result.affectedRows > 0) return { success: true };
|
||||
return { success: false };
|
||||
|
||||
@@ -31,8 +31,8 @@ router.delete("/delete-item/:id", authenticateAdmin, async (req, res) => {
|
||||
});
|
||||
|
||||
router.post("/create-item", authenticateAdmin, async (req, res) => {
|
||||
const { item_name, can_borrow_role } = req.body;
|
||||
const result = await createItem(item_name, can_borrow_role);
|
||||
const { item_name, can_borrow_role, lockerNumber } = req.body;
|
||||
const result = await createItem(item_name, can_borrow_role, lockerNumber);
|
||||
if (result.success) {
|
||||
return res.status(201).json({ message: "Item created successfully" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user