From 8d3c4796ea83480d1060b2cba7fd6b99436c74e8 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Sat, 18 Apr 2026 12:21:53 +0700 Subject: [PATCH] feat: add deleteTransaction function - Add deleteTransaction callback to hook - Use filter to remove by id - Save to AsyncStorage after delete --- hooks/useTransactions.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hooks/useTransactions.ts b/hooks/useTransactions.ts index ba43690..36a4684 100644 --- a/hooks/useTransactions.ts +++ b/hooks/useTransactions.ts @@ -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, }; }; \ No newline at end of file