added feature: That no loan can be deleted and edited changelog accordingly
This commit is contained in:
@@ -17,7 +17,10 @@ export const getAllLoans = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteLoanById = async (loanId) => {
|
export const deleteLoanById = async (loanId) => {
|
||||||
const [result] = await pool.query("DELETE FROM loans WHERE id = ?", [loanId]);
|
const [result] = await pool.query(
|
||||||
|
"UPDATE loans SET deleted = true, deleted_admin = true WHERE id = ?",
|
||||||
|
[loanId],
|
||||||
|
);
|
||||||
if (result.affectedRows > 0) return { success: true };
|
if (result.affectedRows > 0) return { success: true };
|
||||||
return { success: false };
|
return { success: false };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ CREATE TABLE loans (
|
|||||||
loaned_items_id json NOT NULL DEFAULT ('[]'),
|
loaned_items_id json NOT NULL DEFAULT ('[]'),
|
||||||
loaned_items_name json NOT NULL DEFAULT ('[]'),
|
loaned_items_name json NOT NULL DEFAULT ('[]'),
|
||||||
deleted bool NOT NULL DEFAULT false,
|
deleted bool NOT NULL DEFAULT false,
|
||||||
|
deleted_admin bool NOT NULL DEFAULT false,
|
||||||
note varchar(500) DEFAULT NULL,
|
note varchar(500) DEFAULT NULL,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
CHECK (loan_code REGEXP '^[0-9]{6}$')
|
CHECK (loan_code REGEXP '^[0-9]{6}$')
|
||||||
|
|||||||
+3
-2
@@ -11,9 +11,10 @@ This update provides some new features for the design. It also contains some imp
|
|||||||
|
|
||||||
## Improvements
|
## Improvements
|
||||||
|
|
||||||
- The overview page now has the note column and is overall better organised
|
- The overview page now shows the note column and is overall better organised.
|
||||||
- I have the error logging for the API route wehre you can take loans improved.
|
- Improved error logging
|
||||||
- If you try to delete a loan that has not been returned yet, you will get an 507 error code.
|
- If you try to delete a loan that has not been returned yet, you will get an 507 error code.
|
||||||
|
- When the admin deletes a loan, the loan will be still visible in the database, but it will be marked as deleted. This is to prevent data loss and to keep track of deleted loans.
|
||||||
|
|
||||||
## Fixed bugs
|
## Fixed bugs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user