feat: wip uncategorize bank transaction

This commit is contained in:
Ahmed Bouhuolia
2024-08-03 23:30:23 +02:00
parent d74337fb94
commit fdf3e34f1c
8 changed files with 91 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
import { uniq } from 'lodash';
import { castArray, uniq } from 'lodash';
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
interface StorePlaidState {
@@ -113,7 +113,10 @@ export const PlaidSlice = createSlice({
state: StorePlaidState,
action: PayloadAction<{ ids: Array<string | number> }>,
) => {
state.transactionsToCategorizeSelected = action.payload.ids;
const ids = castArray(action.payload.ids);
state.transactionsToCategorizeSelected = ids;
state.openMatchingTransactionAside = true;
},
/**
@@ -129,6 +132,7 @@ export const PlaidSlice = createSlice({
...state.transactionsToCategorizeSelected,
action.payload.id,
]);
state.openMatchingTransactionAside = true;
},
/**
@@ -144,6 +148,12 @@ export const PlaidSlice = createSlice({
state.transactionsToCategorizeSelected.filter(
(t) => t !== action.payload.id,
);
if (state.transactionsToCategorizeSelected.length === 0) {
state.openMatchingTransactionAside = false;
} else {
state.openMatchingTransactionAside = true;
}
},
/**
@@ -152,6 +162,7 @@ export const PlaidSlice = createSlice({
*/
resetTransactionsToCategorizeSelected: (state: StorePlaidState) => {
state.transactionsToCategorizeSelected = [];
state.openMatchingTransactionAside = false;
},
/**