From 8d69ea08702f49bb274beaadfdb46642e4bc63ee Mon Sep 17 00:00:00 2001 From: Errietta Erry Kostala Date: Mon, 10 Feb 2020 14:07:00 +0100 Subject: [PATCH] 6.8.0-pre (#42) * add the ability to categorise by description, MVP tho * 6.8.0-pre --- package-lock.json | 2 +- package.json | 2 +- .../CategoriseTransactionComponent.tsx | 64 +++++++++++++++++-- src/components/Report/ReportComponent.tsx | 49 ++++++++++---- src/lib/Util/Util.ts | 5 ++ 5 files changed, 101 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 32a16b2..8081c05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hyperbudget-frontend", - "version": "6.7.0", + "version": "6.8.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 44e614c..be0becb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperbudget-frontend", - "version": "6.7.0", + "version": "6.8.0-pre", "description": "", "main": "src/index.tsx", "scripts": { diff --git a/src/components/Category/CategoriseTransactionComponent.tsx b/src/components/Category/CategoriseTransactionComponent.tsx index 7bb0311..77468d4 100644 --- a/src/components/Category/CategoriseTransactionComponent.tsx +++ b/src/components/Category/CategoriseTransactionComponent.tsx @@ -4,16 +4,24 @@ import { Category, FormattedTransaction } from '@hyperbudget/hyperbudget-core'; +import { CategorisationType } from '../../lib/Util/Util'; + interface CategoriseTransactionState { - categoriesForceAdd: Set, - categoriesForceRemove: Set, + categoriesForceAdd: Set; + categoriesForceRemove: Set; + categorisationType: CategorisationType; + txnDescriptionMatch: string; }; interface CategoriseTransactionProps { categories: Category[]; transaction: FormattedTransaction; onDoneCategorise: () => void; - onSaveCustomCategories: (forceAdd: Set, forceRm: Set) => void; + onSaveCustomCategories: ( + forceAdd: Set, forceRm: Set, + categorisationType: CategorisationType, + txnDescriptionMatch: string, + ) => void; }; export class CategoriseTransactionComponent extends React.Component @@ -53,10 +61,12 @@ export class CategoriseTransactionComponent extends React.Component this.state = { categoriesForceAdd: new Set(), categoriesForceRemove: new Set(), + categorisationType: CategorisationType.IDENTIFIER, + txnDescriptionMatch: this.props.transaction.description, }; } - inputChanged(evt): void { + selectedCategoriesChanged(evt): void { const checkbox = evt.target; const catId = checkbox.value; console.log(checkbox.checked); @@ -79,6 +89,24 @@ export class CategoriseTransactionComponent extends React.Component } } + selectedTypeChanged(evt): void { + const radio = evt.target; + const selectedType: CategorisationType = Number(radio.value); + + this.setState({ + categorisationType: selectedType, + }) + } + + txnDescriptionChanged(evt): void { + const text = evt.target; + const description = text.value; + + this.setState({ + txnDescriptionMatch: description, + }) + } + render () { return (
@@ -95,7 +123,7 @@ export class CategoriseTransactionComponent extends React.Component this.shownCategories.map((category, idx) => (