Bank accounts

This commit is contained in:
Hillel Coren 2022-09-12 13:30:48 +03:00
parent d755332f89
commit 6747786a89
4 changed files with 28 additions and 3 deletions

View File

@ -256,6 +256,5 @@ BankAccountState _setLoadedBankAccounts(
BankAccountState _setLoadedCompany(
BankAccountState bankAccountState, LoadCompanySuccess action) {
final company = action.userCompany.company;
print('## setLoadedCompany: ${company.bankAccounts}');
return bankAccountState.loadBankAccounts(company.bankAccounts);
}

View File

@ -43,6 +43,7 @@ class AppBottomBar extends StatefulWidget {
this.iconButtons = const [],
this.onPaymentTypeChanged,
this.paymentTypes = const [],
this.onRefreshPressed,
});
final EntityType entityType;
@ -66,6 +67,7 @@ class AppBottomBar extends StatefulWidget {
final List<IconButton> iconButtons;
final List<PaymentTypeEntity> paymentTypes;
final Function onPaymentTypeChanged;
final Function onRefreshPressed;
@override
_AppBottomBarState createState() => _AppBottomBarState();
@ -545,7 +547,9 @@ class _AppBottomBarState extends State<AppBottomBar> {
? localization.refreshData
: '',
child: InkWell(
onTap: () => store.dispatch(RefreshData()),
onTap: () => widget.onRefreshPressed != null
? widget.onRefreshPressed()
: store.dispatch(RefreshData()),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Icon(Icons.refresh),

View File

@ -117,6 +117,7 @@ class BankAccountScreen extends StatelessWidget {
store.dispatch(FilterBankAccountsByCustom3(value)),
onSelectedCustom4: (value) =>
store.dispatch(FilterBankAccountsByCustom4(value)),
onRefreshPressed: viewModel.onRefreshAccounts,
),
floatingActionButton: state.prefState.isMenuFloated
? FloatingActionButton(

View File

@ -7,7 +7,10 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/redux/bank_account/bank_account_actions.dart';
import 'package:invoiceninja_flutter/redux/bank_account/bank_account_selectors.dart';
import 'package:redux/redux.dart';
import 'package:invoiceninja_flutter/data/web_client.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'bank_account_screen.dart';
class BankAccountScreenBuilder extends StatelessWidget {
@ -33,6 +36,7 @@ class BankAccountScreenVM {
@required this.userCompany,
@required this.onEntityAction,
@required this.bankAccountMap,
@required this.onRefreshAccounts,
});
final bool isInMultiselect;
@ -40,6 +44,7 @@ class BankAccountScreenVM {
final List<String> bankAccountList;
final Function(BuildContext, List<BaseEntity>, EntityAction) onEntityAction;
final BuiltMap<String, BankAccountEntity> bankAccountMap;
final Function onRefreshAccounts;
static BankAccountScreenVM fromStore(Store<AppState> store) {
final state = store.state;
@ -57,6 +62,22 @@ class BankAccountScreenVM {
onEntityAction: (BuildContext context, List<BaseEntity> bankAccounts,
EntityAction action) =>
handleBankAccountAction(context, bankAccounts, action),
onRefreshAccounts: () {
final webClient = WebClient();
final credentials = state.credentials;
final url = '${credentials.url}/bank_integrations/refresh_accounts';
store.dispatch(StartSaving());
webClient.post(url, credentials.token).then((dynamic response) {
store.dispatch(StopSaving());
store.dispatch(RefreshData());
}).catchError((dynamic error) {
store.dispatch(StopSaving());
showErrorDialog(
context: navigatorKey.currentContext, message: '$error');
});
},
);
}
}