Fix lint and typecheck errors

This commit is contained in:
Joel Jeremy Marquez
2024-12-18 23:01:04 -08:00
parent 009b1161b0
commit 15a74c9943
5 changed files with 105 additions and 114 deletions

View File

@@ -1,12 +1,12 @@
import React, { useState } from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { closeModal } from 'loot-core/client/actions';
import {
linkAccount,
linkAccountSimpleFin,
unlinkAccount,
} from 'loot-core/client/accounts/accountSlice';
import { closeModal } from 'loot-core/client/actions';
import { useAccounts } from '../../hooks/useAccounts';
import { useAppDispatch } from '../../redux';

View File

@@ -4,12 +4,8 @@ import {
type PayloadAction,
} from '@reduxjs/toolkit';
import {
type AccountEntity,
type TransactionEntity,
} from '../../types/models';
import { send } from '../../platform/client/fetch';
import { type AccountEntity, type TransactionEntity } from '../../types/models';
import { addNotification, getAccounts, getPayees } from '../actions';
import * as constants from '../constants';
import { type AppDispatch, type RootState } from '../store';
@@ -39,7 +35,9 @@ type MarkAccountSuccessPayload = {
};
type AccountState = {
failedAccounts: { [key: AccountEntity['id']]: { type: string; code: string } };
failedAccounts: {
[key: AccountEntity['id']]: { type: string; code: string };
};
accountsSyncing: Array<AccountEntity['id']>;
};

View File

@@ -1,106 +0,0 @@
// @ts-strict-ignore
import { send } from '../../platform/client/fetch';
import * as constants from '../constants';
import type {
MarkAccountReadAction,
SetLastTransactionAction,
UpdateNewTransactionsAction,
} from '../state-types/queries';
import { type AppDispatch } from '../store';
import { addNotification } from './notifications';
// Remember the last transaction manually added to the system
export function setLastTransaction(
transaction: SetLastTransactionAction['transaction'],
): SetLastTransactionAction {
return {
type: constants.SET_LAST_TRANSACTION,
transaction,
};
}
export function parseTransactions(filepath, options) {
return async () => {
return await send('transactions-parse-file', {
filepath,
options,
});
};
}
export function importPreviewTransactions(id: string, transactions) {
return async (dispatch: AppDispatch): Promise<boolean> => {
const { errors = [], updatedPreview } = await send('transactions-import', {
accountId: id,
transactions,
isPreview: true,
});
errors.forEach(error => {
dispatch(
addNotification({
type: 'error',
message: error.message,
}),
);
});
return updatedPreview;
};
}
export function importTransactions(id: string, transactions, reconcile = true) {
return async (dispatch: AppDispatch): Promise<boolean> => {
if (!reconcile) {
await send('api/transactions-add', {
accountId: id,
transactions,
});
return true;
}
const {
errors = [],
added,
updated,
} = await send('transactions-import', {
accountId: id,
transactions,
isPreview: false,
});
errors.forEach(error => {
dispatch(
addNotification({
type: 'error',
message: error.message,
}),
);
});
dispatch({
type: constants.SET_NEW_TRANSACTIONS,
newTransactions: added,
matchedTransactions: updated,
updatedAccounts: added.length > 0 ? [id] : [],
});
return added.length > 0 || updated.length > 0;
};
}
export function updateNewTransactions(changedId): UpdateNewTransactionsAction {
return {
type: constants.UPDATE_NEW_TRANSACTIONS,
changedId,
};
}
export function markAccountRead(accountId): MarkAccountReadAction {
return {
type: constants.MARK_ACCOUNT_READ,
accountId,
};
}

View File

@@ -1,5 +1,4 @@
export * from './queries';
export * from './account';
export * from './modals';
export * from './notifications';
export * from './prefs';

View File

@@ -5,6 +5,11 @@ import throttle from 'throttleit';
import { send } from '../../platform/client/fetch';
import { type AccountEntity } from '../../types/models';
import * as constants from '../constants';
import {
type MarkAccountReadAction,
type SetLastTransactionAction,
type UpdateNewTransactionsAction,
} from '../state-types/queries';
import { type AppDispatch, type GetRootState } from '../store';
import { pushModal } from './modals';
@@ -368,6 +373,101 @@ export function forceCloseAccount(accountId) {
return closeAccount(accountId, null, null, true);
}
// Remember the last transaction manually added to the system
export function setLastTransaction(
transaction: SetLastTransactionAction['transaction'],
): SetLastTransactionAction {
return {
type: constants.SET_LAST_TRANSACTION,
transaction,
};
}
export function parseTransactions(filepath, options) {
return async () => {
return await send('transactions-parse-file', {
filepath,
options,
});
};
}
export function importPreviewTransactions(id: string, transactions) {
return async (dispatch: AppDispatch): Promise<boolean> => {
const { errors = [], updatedPreview } = await send('transactions-import', {
accountId: id,
transactions,
isPreview: true,
});
errors.forEach(error => {
dispatch(
addNotification({
type: 'error',
message: error.message,
}),
);
});
return updatedPreview;
};
}
export function importTransactions(id: string, transactions, reconcile = true) {
return async (dispatch: AppDispatch): Promise<boolean> => {
if (!reconcile) {
await send('api/transactions-add', {
accountId: id,
transactions,
});
return true;
}
const {
errors = [],
added,
updated,
} = await send('transactions-import', {
accountId: id,
transactions,
isPreview: false,
});
errors.forEach(error => {
dispatch(
addNotification({
type: 'error',
message: error.message,
}),
);
});
dispatch({
type: constants.SET_NEW_TRANSACTIONS,
newTransactions: added,
matchedTransactions: updated,
updatedAccounts: added.length > 0 ? [id] : [],
});
return added.length > 0 || updated.length > 0;
};
}
export function updateNewTransactions(changedId): UpdateNewTransactionsAction {
return {
type: constants.UPDATE_NEW_TRANSACTIONS,
changedId,
};
}
export function markAccountRead(accountId): MarkAccountReadAction {
return {
type: constants.MARK_ACCOUNT_READ,
accountId,
};
}
const _undo = throttle(() => send('undo'), 100);
const _redo = throttle(() => send('redo'), 100);