feat: add deleteTransaction function
- Add deleteTransaction callback to hook - Use filter to remove by id - Save to AsyncStorage after delete
This commit is contained in:
parent
2b532c7472
commit
8d3c4796ea
@ -34,10 +34,19 @@ export const useTransactions = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const deleteTransaction = useCallback((id: string) => {
|
||||
setTransactions((prev) => {
|
||||
const updated = prev.filter((t) => t.id !== id);
|
||||
AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(updated));
|
||||
return updated;
|
||||
});
|
||||
}, []);
|
||||
|
||||
return {
|
||||
transactions,
|
||||
loading,
|
||||
addTransaction,
|
||||
deleteTransaction,
|
||||
refresh: loadTransactions,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user