Skip to content

Commit

Permalink
Fix category map using lowest weight suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Nov 22, 2023
1 parent 7d7841e commit e74e1c1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/settings/templates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ const Templates = ({ isMobile }) => {
useEffect(() => {
setCategoryOptions(prepareOptions(categories, 'category'));
setSubCategoryOptions(prepareOptions(categories, 'subCategory'));
setCategoryMap(
categories.reduce((o, c) => ({ ...o, [c.subCategory]: c.category }), {})
);
const tempMap = {};
categories.forEach(({ category, subCategory }) => {
if (!tempMap[subCategory]) {
tempMap[subCategory] = category;
}
});
setCategoryMap(tempMap);
}, [ categories ]);

const postProcess = (row, newRows, verb) => {
Expand Down
10 changes: 7 additions & 3 deletions src/transactions/add-transaction-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ const AddTransactionDialog = ({
useEffect(() => {
setCategoryOptions(prepareOptions(categories, 'category'));
setSubCategoryOptions(prepareOptions(categories, 'subCategory'));
setCategoryMap(
categories.reduce((o, c) => ({ ...o, [c.subCategory]: c.category }), {})
);
const tempMap = {};
categories.forEach(({ category, subCategory }) => {
if (!tempMap[subCategory]) {
tempMap[subCategory] = category;
}
});
setCategoryMap(tempMap);
}, [ categories ]);

useEffect(() => {
Expand Down
10 changes: 7 additions & 3 deletions src/transactions/bulk-transaction-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ const BulkTransactionDialog = ({
useEffect(() => {
setCategoryOptions(prepareOptions(categories, 'category'));
setSubCategoryOptions(prepareOptions(categories, 'subCategory'));
setCategoryMap(
categories.reduce((o, c) => ({ ...o, [c.subCategory]: c.category }), {})
);
const tempMap = {};
categories.forEach(({ category, subCategory }) => {
if (!tempMap[subCategory]) {
tempMap[subCategory] = category;
}
});
setCategoryMap(tempMap);
}, [ categories ]);

const submit = (event) => {
Expand Down
10 changes: 7 additions & 3 deletions src/transactions/transactions-import.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ const TransactionsImport = ({ setImportMode, selectedAccount }) => {
useEffect(() => {
setCategoryOptions(prepareOptions(categories, 'category'));
setSubCategoryOptions(prepareOptions(categories, 'subCategory'));
setCategoryMap(
categories.reduce((o, c) => ({ ...o, [c.subCategory]: c.category }), {})
);
const tempMap = {};
categories.forEach(({ category, subCategory }) => {
if (!tempMap[subCategory]) {
tempMap[subCategory] = category;
}
});
setCategoryMap(tempMap);
}, [ categories ]);

const maxGridSize = {
Expand Down

0 comments on commit e74e1c1

Please sign in to comment.