Bank accounts
This commit is contained in:
parent
efc688d123
commit
f0a18427ab
|
|
@ -112,7 +112,7 @@ class _BankAccountsState extends State<BankAccounts> {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: AppButton(
|
child: AppButton(
|
||||||
label: localization.refresh.toUpperCase(),
|
label: localization.refresh.toUpperCase(),
|
||||||
onPressed: () => viewModel.onConnectAccounts(),
|
onPressed: () => viewModel.onRefreshAccounts(),
|
||||||
iconData: Icons.refresh,
|
iconData: Icons.refresh,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ class BankAccountsVM {
|
||||||
@required this.onCompanyChanged,
|
@required this.onCompanyChanged,
|
||||||
@required this.onSavePressed,
|
@required this.onSavePressed,
|
||||||
@required this.onConnectAccounts,
|
@required this.onConnectAccounts,
|
||||||
|
@required this.onRefreshAccounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
static BankAccountsVM fromStore(Store<AppState> store) {
|
static BankAccountsVM fromStore(Store<AppState> store) {
|
||||||
|
|
@ -58,6 +59,22 @@ class BankAccountsVM {
|
||||||
company: state.uiState.settingsUIState.company,
|
company: state.uiState.settingsUIState.company,
|
||||||
onCompanyChanged: (company) =>
|
onCompanyChanged: (company) =>
|
||||||
store.dispatch(UpdateCompany(company: company)),
|
store.dispatch(UpdateCompany(company: company)),
|
||||||
|
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());
|
||||||
|
print('## RESPONSE: $response');
|
||||||
|
}).catchError((dynamic error) {
|
||||||
|
store.dispatch(StopSaving());
|
||||||
|
showErrorDialog(
|
||||||
|
context: navigatorKey.currentContext, message: '$error');
|
||||||
|
});
|
||||||
|
},
|
||||||
onConnectAccounts: () {
|
onConnectAccounts: () {
|
||||||
final webClient = WebClient();
|
final webClient = WebClient();
|
||||||
final credentials = state.credentials;
|
final credentials = state.credentials;
|
||||||
|
|
@ -96,4 +113,5 @@ class BankAccountsVM {
|
||||||
final CompanyEntity company;
|
final CompanyEntity company;
|
||||||
final Function(CompanyEntity) onCompanyChanged;
|
final Function(CompanyEntity) onCompanyChanged;
|
||||||
final Function onConnectAccounts;
|
final Function onConnectAccounts;
|
||||||
|
final Function onRefreshAccounts;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue