fix deleteAccount
This commit is contained in:
parent
aff16af4a2
commit
fd85a0cfdf
|
@ -168,48 +168,7 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
enText: 'Are you sure you want to delete your account?',
|
||||
ptText: 'Tem certeza que deseja deletar sua conta?',
|
||||
);
|
||||
onConfirm() async {
|
||||
String content;
|
||||
try {
|
||||
await PhpGroup.deleteAccount.call().then((value) {
|
||||
if (value.jsonBody['error'] == false) {
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Account deleted successfully',
|
||||
ptText: 'Conta deletada com sucesso',
|
||||
);
|
||||
|
||||
StorageUtil.purge();
|
||||
|
||||
context.pop();
|
||||
context.go(
|
||||
'/welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}).catchError((err) {
|
||||
context.pop();
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error deleting account',
|
||||
ptText: 'Erro ao deletar conta',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content);
|
||||
});
|
||||
notifyListeners();
|
||||
} catch (err) {
|
||||
context.pop();
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error deleting account',
|
||||
ptText: 'Erro ao deletar conta',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}
|
||||
}
|
||||
onConfirm() async => AuthenticationService.deleteAccount(context);
|
||||
|
||||
showAlertDialog(context, title, content, onConfirm);
|
||||
}
|
||||
|
@ -223,7 +182,7 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
enText: 'Are you sure you want to logout?',
|
||||
ptText: 'Tem certeza que deseja sair?',
|
||||
);
|
||||
onConfirm() async => AuthenticationService.deleteAccount(context);
|
||||
onConfirm() async => AuthenticationService.signOut(context);
|
||||
|
||||
showAlertDialog(context, title, content, onConfirm);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/utils/snackbar_util.dart';
|
||||
|
||||
import '../../../backend/api_requests/api_calls.dart';
|
||||
import '../../../flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -181,7 +182,16 @@ class AuthenticationService {
|
|||
}
|
||||
|
||||
static Future<void> deleteAccount(BuildContext context) async {
|
||||
String content;
|
||||
try {
|
||||
await PhpGroup.deleteAccount.call().then((value) {
|
||||
if (value.jsonBody['error'] == false) {
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Account deleted successfully',
|
||||
ptText: 'Conta deletada com sucesso',
|
||||
);
|
||||
StorageUtil.purge();
|
||||
context.pop();
|
||||
context.go(
|
||||
'/welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
|
@ -193,5 +203,22 @@ class AuthenticationService {
|
|||
},
|
||||
);
|
||||
}
|
||||
}).catchError((err) {
|
||||
context.pop();
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error deleting account',
|
||||
ptText: 'Erro ao deletar conta',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content);
|
||||
});
|
||||
} catch (err) {
|
||||
context.pop();
|
||||
content = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error deleting account',
|
||||
ptText: 'Erro ao deletar conta',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue