forked from yaso_meth/mih-project
Create User API Class
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_err
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_env/env.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
@@ -11,17 +12,20 @@ import 'package:supertokens_flutter/supertokens.dart';
|
||||
class MihUserApis {
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
static Future<bool> deleteAccount(
|
||||
static Future<void> deleteAccount(
|
||||
String app_id,
|
||||
BuildContext context,
|
||||
) async {
|
||||
loadingPopUp(context);
|
||||
var response = await http.delete(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/user/delete/all/$app_id"),
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/user/delete/all/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{"app_id": app_id}),
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"app_id": app_id,
|
||||
"env": AppEnviroment.getEnv(),
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -29,15 +33,21 @@ class MihUserApis {
|
||||
print(error);
|
||||
});
|
||||
if (await SuperTokens.doesSessionExist() == false) {
|
||||
Navigator.of(context).pop();
|
||||
// Navigator.of(context).popAndPushNamed(
|
||||
// '/',
|
||||
// arguments: AuthArguments(true, false),
|
||||
// );
|
||||
Navigator.of(context).pop(); // Pop loading dialog
|
||||
Navigator.of(context).pop(); // Pop delete account dialog
|
||||
Navigator.of(context).pop(); // Pop Mzansi Profile
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
'/',
|
||||
arguments: AuthArguments(true, false),
|
||||
); //Pop and push to login page
|
||||
successPopUp(
|
||||
"Account Deleted Successfully",
|
||||
context,
|
||||
); // Show success message.
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
Navigator.of(context).pop(); // Pop loading dialog
|
||||
internetConnectionPopUp(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user