feat: edit expense
This commit is contained in:
parent
deda54152b
commit
5b71fa74b1
11 changed files with 273 additions and 41 deletions
|
|
@ -42,6 +42,21 @@ export const addCategory = async (name: string, color: string, type: string, all
|
|||
}
|
||||
}
|
||||
|
||||
export const updateExpense = async (guid: string, name: string, category_guid: string, datetime: string, amount: number) => {
|
||||
|
||||
//needs user input validation for type and color (should be validated by this function)
|
||||
|
||||
try {
|
||||
await db.transactionAsync(async (tx) => {
|
||||
await tx.executeSqlAsync("UPDATE expense SET name = ?, category_guid = ?, datetime = ?, amount = ? WHERE guid = ?", [name, category_guid, datetime, amount, guid]
|
||||
);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Error updating expense: ", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const addExpense = async (name: string, category_guid: string, datetime: string, amount: number) => {
|
||||
|
||||
//needs user input validation for type and color (should be validated by this function)
|
||||
|
|
|
|||
Reference in a new issue