Bank accounts
This commit is contained in:
parent
d755332f89
commit
6747786a89
|
|
@ -256,6 +256,5 @@ BankAccountState _setLoadedBankAccounts(
|
||||||
BankAccountState _setLoadedCompany(
|
BankAccountState _setLoadedCompany(
|
||||||
BankAccountState bankAccountState, LoadCompanySuccess action) {
|
BankAccountState bankAccountState, LoadCompanySuccess action) {
|
||||||
final company = action.userCompany.company;
|
final company = action.userCompany.company;
|
||||||
print('## setLoadedCompany: ${company.bankAccounts}');
|
|
||||||
return bankAccountState.loadBankAccounts(company.bankAccounts);
|
return bankAccountState.loadBankAccounts(company.bankAccounts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class AppBottomBar extends StatefulWidget {
|
||||||
this.iconButtons = const [],
|
this.iconButtons = const [],
|
||||||
this.onPaymentTypeChanged,
|
this.onPaymentTypeChanged,
|
||||||
this.paymentTypes = const [],
|
this.paymentTypes = const [],
|
||||||
|
this.onRefreshPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
final EntityType entityType;
|
final EntityType entityType;
|
||||||
|
|
@ -66,6 +67,7 @@ class AppBottomBar extends StatefulWidget {
|
||||||
final List<IconButton> iconButtons;
|
final List<IconButton> iconButtons;
|
||||||
final List<PaymentTypeEntity> paymentTypes;
|
final List<PaymentTypeEntity> paymentTypes;
|
||||||
final Function onPaymentTypeChanged;
|
final Function onPaymentTypeChanged;
|
||||||
|
final Function onRefreshPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AppBottomBarState createState() => _AppBottomBarState();
|
_AppBottomBarState createState() => _AppBottomBarState();
|
||||||
|
|
@ -545,7 +547,9 @@ class _AppBottomBarState extends State<AppBottomBar> {
|
||||||
? localization.refreshData
|
? localization.refreshData
|
||||||
: '',
|
: '',
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => store.dispatch(RefreshData()),
|
onTap: () => widget.onRefreshPressed != null
|
||||||
|
? widget.onRefreshPressed()
|
||||||
|
: store.dispatch(RefreshData()),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Icon(Icons.refresh),
|
child: Icon(Icons.refresh),
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ class BankAccountScreen extends StatelessWidget {
|
||||||
store.dispatch(FilterBankAccountsByCustom3(value)),
|
store.dispatch(FilterBankAccountsByCustom3(value)),
|
||||||
onSelectedCustom4: (value) =>
|
onSelectedCustom4: (value) =>
|
||||||
store.dispatch(FilterBankAccountsByCustom4(value)),
|
store.dispatch(FilterBankAccountsByCustom4(value)),
|
||||||
|
onRefreshPressed: viewModel.onRefreshAccounts,
|
||||||
),
|
),
|
||||||
floatingActionButton: state.prefState.isMenuFloated
|
floatingActionButton: state.prefState.isMenuFloated
|
||||||
? FloatingActionButton(
|
? FloatingActionButton(
|
||||||
|
|
|
||||||
|
|
@ -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_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/bank_account/bank_account_selectors.dart';
|
import 'package:invoiceninja_flutter/redux/bank_account/bank_account_selectors.dart';
|
||||||
import 'package:redux/redux.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';
|
import 'bank_account_screen.dart';
|
||||||
|
|
||||||
class BankAccountScreenBuilder extends StatelessWidget {
|
class BankAccountScreenBuilder extends StatelessWidget {
|
||||||
|
|
@ -33,6 +36,7 @@ class BankAccountScreenVM {
|
||||||
@required this.userCompany,
|
@required this.userCompany,
|
||||||
@required this.onEntityAction,
|
@required this.onEntityAction,
|
||||||
@required this.bankAccountMap,
|
@required this.bankAccountMap,
|
||||||
|
@required this.onRefreshAccounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool isInMultiselect;
|
final bool isInMultiselect;
|
||||||
|
|
@ -40,6 +44,7 @@ class BankAccountScreenVM {
|
||||||
final List<String> bankAccountList;
|
final List<String> bankAccountList;
|
||||||
final Function(BuildContext, List<BaseEntity>, EntityAction) onEntityAction;
|
final Function(BuildContext, List<BaseEntity>, EntityAction) onEntityAction;
|
||||||
final BuiltMap<String, BankAccountEntity> bankAccountMap;
|
final BuiltMap<String, BankAccountEntity> bankAccountMap;
|
||||||
|
final Function onRefreshAccounts;
|
||||||
|
|
||||||
static BankAccountScreenVM fromStore(Store<AppState> store) {
|
static BankAccountScreenVM fromStore(Store<AppState> store) {
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
|
|
@ -57,6 +62,22 @@ class BankAccountScreenVM {
|
||||||
onEntityAction: (BuildContext context, List<BaseEntity> bankAccounts,
|
onEntityAction: (BuildContext context, List<BaseEntity> bankAccounts,
|
||||||
EntityAction action) =>
|
EntityAction action) =>
|
||||||
handleBankAccountAction(context, bankAccounts, 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');
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue