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?',
|
enText: 'Are you sure you want to delete your account?',
|
||||||
ptText: 'Tem certeza que deseja deletar sua conta?',
|
ptText: 'Tem certeza que deseja deletar sua conta?',
|
||||||
);
|
);
|
||||||
onConfirm() async {
|
onConfirm() async => AuthenticationService.deleteAccount(context);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
showAlertDialog(context, title, content, onConfirm);
|
showAlertDialog(context, title, content, onConfirm);
|
||||||
}
|
}
|
||||||
|
@ -223,7 +182,7 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
enText: 'Are you sure you want to logout?',
|
enText: 'Are you sure you want to logout?',
|
||||||
ptText: 'Tem certeza que deseja sair?',
|
ptText: 'Tem certeza que deseja sair?',
|
||||||
);
|
);
|
||||||
onConfirm() async => AuthenticationService.deleteAccount(context);
|
onConfirm() async => AuthenticationService.signOut(context);
|
||||||
|
|
||||||
showAlertDialog(context, title, content, onConfirm);
|
showAlertDialog(context, title, content, onConfirm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.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 '../../../backend/api_requests/api_calls.dart';
|
||||||
import '../../../flutter_flow/flutter_flow_util.dart';
|
import '../../../flutter_flow/flutter_flow_util.dart';
|
||||||
|
@ -181,17 +182,43 @@ class AuthenticationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> deleteAccount(BuildContext context) async {
|
static Future<void> deleteAccount(BuildContext context) async {
|
||||||
StorageUtil.purge();
|
String content;
|
||||||
context.go(
|
try {
|
||||||
'/welcomePage',
|
await PhpGroup.deleteAccount.call().then((value) {
|
||||||
extra: <String, dynamic>{
|
if (value.jsonBody['error'] == false) {
|
||||||
kTransitionInfoKey: const TransitionInfo(
|
content = FFLocalizations.of(context).getVariableText(
|
||||||
hasTransition: true,
|
enText: 'Account deleted successfully',
|
||||||
transitionType: PageTransitionType.scale,
|
ptText: 'Conta deletada com sucesso',
|
||||||
alignment: Alignment.bottomCenter,
|
);
|
||||||
),
|
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);
|
||||||
|
});
|
||||||
|
} 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