added MyLoansPage component and integrated loan deletion functionality; updated routing in App and added Header component
This commit is contained in:
@@ -126,9 +126,10 @@ export const getLoansFromDatabase = async () => {
|
||||
};
|
||||
|
||||
export const getUserLoansFromDatabase = async (username) => {
|
||||
const [result] = await pool.query("SELECT * FROM loans WHERE username = ?;", [
|
||||
username,
|
||||
]);
|
||||
const [result] = await pool.query(
|
||||
"SELECT * FROM loans WHERE username = ? AND deleted = 0;",
|
||||
[username]
|
||||
);
|
||||
if (result.length > 0) {
|
||||
return { success: true, data: result };
|
||||
} else if (result.length == 0) {
|
||||
@@ -149,6 +150,18 @@ export const deleteLoanFromDatabase = async (loanId) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const SETdeleteLoanFromDatabase = async (loanId) => {
|
||||
const [result] = await pool.query(
|
||||
"UPDATE loans SET deleted = 1 WHERE id = ?;",
|
||||
[loanId]
|
||||
);
|
||||
if (result.affectedRows > 0) {
|
||||
return { success: true };
|
||||
} else {
|
||||
return { success: false };
|
||||
}
|
||||
};
|
||||
|
||||
export const getBorrowableItemsFromDatabase = async (
|
||||
startDate,
|
||||
endDate,
|
||||
|
||||
Reference in New Issue
Block a user