fixed bug: onReturn & onTake functions are know functioaning

This commit is contained in:
2025-09-03 15:24:04 +02:00
parent c0ae12185a
commit 5291752403

View File

@@ -299,9 +299,15 @@ export const onTake = async (loanId) => {
[loanId] [loanId]
); );
if (items.length === 0) return { success: false };
const itemIds = Array.isArray(items[0].loaned_items_id)
? items[0].loaned_items_id
: JSON.parse(items[0].loaned_items_id || "[]");
const [setItemStates] = await pool.query( const [setItemStates] = await pool.query(
"UPDATE items SET inSafe = 0 WHERE id IN (?)", "UPDATE items SET inSafe = 0 WHERE id IN (?)",
[items.map((item) => item.loaned_items_id)] [itemIds]
); );
const [result] = await pool.query( const [result] = await pool.query(
@@ -321,9 +327,15 @@ export const onReturn = async (loanId) => {
[loanId] [loanId]
); );
if (items.length === 0) return { success: false };
const itemIds = Array.isArray(items[0].loaned_items_id)
? items[0].loaned_items_id
: JSON.parse(items[0].loaned_items_id || "[]");
const [setItemStates] = await pool.query( const [setItemStates] = await pool.query(
"UPDATE items SET inSafe = 1 WHERE id IN (?)", "UPDATE items SET inSafe = 1 WHERE id IN (?)",
[items.map((item) => item.loaned_items_id)] [itemIds]
); );
const [result] = await pool.query( const [result] = await pool.query(