mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: wip uncategorize bank transaction
This commit is contained in:
@@ -243,8 +243,7 @@ export function useCategorizeTransaction(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`cashflow/transactions/${id}/categorize`, values),
|
||||
(values) => apiRequest.post(`cashflow/transactions/categorize`, values),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate queries.
|
||||
@@ -279,7 +278,6 @@ export function useUncategorizeTransaction(props) {
|
||||
queryClient.invalidateQueries(
|
||||
t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY,
|
||||
);
|
||||
|
||||
// Invalidate bank account summary.
|
||||
queryClient.invalidateQueries('BANK_ACCOUNT_SUMMARY_META');
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user