Purge data
This commit is contained in:
parent
dd0664fbf7
commit
efdd8c2d1d
|
|
@ -101,6 +101,15 @@ class AuthRepository {
|
|||
return webClient.delete('/companies/$companyId', token, password: password);
|
||||
}
|
||||
|
||||
|
||||
Future<dynamic> purgeData({
|
||||
@required String token,
|
||||
@required String companyId,
|
||||
@required String password,
|
||||
}) async {
|
||||
//return webClient.delete('/companies/$companyId', token, password: password);
|
||||
}
|
||||
|
||||
Future<LoginResponse> sendRequest(
|
||||
{String url, dynamic data, String token, String secret}) async {
|
||||
url += '?first_load=true&include_static=true';
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
|
|||
final recoverRequest = _createRecoverRequest(repository);
|
||||
final addCompany = _createCompany(repository);
|
||||
final deleteCompany = _deleteCompany(repository);
|
||||
final purgeData = _purgeData(repository);
|
||||
|
||||
return [
|
||||
TypedMiddleware<AppState, UserLogout>(userLogout),
|
||||
|
|
@ -40,6 +41,7 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
|
|||
TypedMiddleware<AppState, RecoverPasswordRequest>(recoverRequest),
|
||||
TypedMiddleware<AppState, AddCompany>(addCompany),
|
||||
TypedMiddleware<AppState, DeleteCompanyRequest>(deleteCompany),
|
||||
TypedMiddleware<AppState, PurgeDataRequest>(purgeData),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -278,3 +280,25 @@ Middleware<AppState> _deleteCompany(AuthRepository repository) {
|
|||
next(action);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _purgeData(AuthRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction,
|
||||
NextDispatcher next) async {
|
||||
final action = dynamicAction as DeleteCompanyRequest;
|
||||
final state = store.state;
|
||||
|
||||
repository
|
||||
.purgeData(
|
||||
token: state.credentials.token,
|
||||
password: action.password,
|
||||
companyId: state.company.id)
|
||||
.then((dynamic value) {
|
||||
action.completer.complete(null);
|
||||
store.dispatch(PurgeDataSuccess());
|
||||
}).catchError((Object error) {
|
||||
store.dispatch(PurgeDataFailure(error));
|
||||
});
|
||||
|
||||
next(action);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,11 +99,12 @@ class _AccountManagementState extends State<AccountManagement>
|
|||
],
|
||||
),
|
||||
),
|
||||
/*
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ElevatedButton(
|
||||
label: localization.purgeData.toUpperCase(),
|
||||
color: Colors.orange,
|
||||
color: Colors.red,
|
||||
iconData: Icons.delete,
|
||||
onPressed: () {
|
||||
confirmCallback(
|
||||
|
|
@ -119,6 +120,7 @@ class _AccountManagementState extends State<AccountManagement>
|
|||
},
|
||||
),
|
||||
),
|
||||
*/
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ElevatedButton(
|
||||
|
|
|
|||
Loading…
Reference in New Issue