diff --git a/src/components/AccountPage/AccountList.js b/src/components/AccountPage/AccountList.js index 6a67f41..cbb8147 100644 --- a/src/components/AccountPage/AccountList.js +++ b/src/components/AccountPage/AccountList.js @@ -13,7 +13,9 @@ class AccountList extends PureComponent { } showList() { - const filteredList = this.props.accounts; + const filteredList = this.props.accounts.filter((item) => { + return item.isDeleted !== 1; + }); if (this.props.loading) { return ; diff --git a/src/components/Dashboard/Overview.js b/src/components/Dashboard/Overview.js index 81bd9f9..b6c08d8 100644 --- a/src/components/Dashboard/Overview.js +++ b/src/components/Dashboard/Overview.js @@ -133,26 +133,30 @@ const Overview = (props) => { props.navigation.navigate('Account'); }} /> - {props.accounts.map((account) => { - const {title, id, openingBalance} = account; + {props.accounts + .filter((item) => { + return item.isDeleted !== 1; + }) + .map((account) => { + const {title, id, openingBalance} = account; - const totalBalance = currencify( - getSum(getTransactionsByAccount(id), account), - ); + const totalBalance = currencify( + getSum(getTransactionsByAccount(id), account), + ); - return ( - { - props.selectAccount(id); - }} - /> - ); - })} + return ( + { + props.selectAccount(id); + }} + /> + ); + })} @@ -238,10 +242,14 @@ const Overview = (props) => { props.transactions, (record) => record.month, ); - - let showHeader = props.selectedItem.category ? groupedRecords[record.month].filter( - (r) => r.categoryId === props.selectedItem.category, - ).indexOf(record) === 0 : groupedRecords[record.month].indexOf(record) === 0; + + let showHeader = props.selectedItem.category + ? groupedRecords[record.month] + .filter( + (r) => r.categoryId === props.selectedItem.category, + ) + .indexOf(record) === 0 + : groupedRecords[record.month].indexOf(record) === 0; return ( {showHeader && ( diff --git a/src/helpers/db.js b/src/helpers/db.js index 5894afc..e38639b 100644 --- a/src/helpers/db.js +++ b/src/helpers/db.js @@ -116,6 +116,19 @@ export const init = () => { }, ); }); + + db.transaction((tx) => { + tx.executeSql( + 'ALTER TABLE accounts ADD COLUMN isDeleted INTEGER', + [], + () => { + resolve(); + }, + (err) => { + reject(err); + }, + ); + }); }); return promise; @@ -242,7 +255,7 @@ export const removeAccount = (id) => { const promise = new Promise((resolve, reject) => { db.transaction((tx) => { tx.executeSql( - 'DELETE FROM accounts where id = (?)', + 'UPDATE accounts SET isDeleted=1 WHERE id=?', [id], (_, result) => { resolve(result);