added user delete feture
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/auth_service.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class DrawerPage extends StatelessWidget {
|
||||
@ -76,7 +77,22 @@ class DrawerPage extends StatelessWidget {
|
||||
},
|
||||
) :
|
||||
Container(width: 0, height: 0,),
|
||||
|
||||
indexController.currentUser.length > 0 ?
|
||||
ListTile(
|
||||
leading: const Icon(Icons.delete_forever),
|
||||
title: Text("delete_account".tr),
|
||||
onTap: (){
|
||||
String _token = indexController.currentUser[0]['token'];
|
||||
AuthService.deleteUser(_token).then((value){
|
||||
if(value.isNotEmpty){
|
||||
indexController.logout();
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
Get.snackbar("accounted_deleted".tr, "account_deleted_message".tr);
|
||||
}
|
||||
});
|
||||
},
|
||||
) :
|
||||
Container(width: 0, height: 0,),
|
||||
// ListTile(
|
||||
// leading: const Icon(Icons.person),
|
||||
// title: Text("profile".tr),
|
||||
|
||||
@ -77,6 +77,25 @@ class AuthService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> deleteUser(String token) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String server_url = ConstValues.currentServer();
|
||||
String url = '${server_url}/api/delete-account/';
|
||||
//String url = 'http://localhost:8100/api/register/';
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token ${token}'
|
||||
}
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> UserDetails(int userid) async {
|
||||
List<dynamic> cats = [];
|
||||
|
||||
@ -67,7 +67,10 @@ class StringValues extends Translations{
|
||||
"Not started yet":"Not started yet",
|
||||
"You have not started rogaining yet.":"You have not started rogaining yet.",
|
||||
"Not reached the goal yet": "Not reached the goal yet",
|
||||
"You have not reached the goal yet.":"You have not reached the goal yet."
|
||||
"You have not reached the goal yet.":"You have not reached the goal yet.",
|
||||
"delete_account": "Delete account",
|
||||
"accounted_deleted": "Account deleted",
|
||||
"account_deleted_message": "your account has beed successfully deleted"
|
||||
},
|
||||
'ja_JP': {
|
||||
'drawer_title':'ロゲイニング参加者はログイン するとチェックポイントが参照 できます',
|
||||
@ -135,7 +138,10 @@ class StringValues extends Translations{
|
||||
"Not started yet":"まだ開始されていません",
|
||||
"You have not started rogaining yet.":"あなたはまだロゲイニングを始めていません。",
|
||||
"Not reached the goal yet": "まだ目標に達していない",
|
||||
"You have not reached the goal yet.":"あなたはまだゴールに達していません。"
|
||||
"You have not reached the goal yet.":"あなたはまだゴールに達していません。",
|
||||
"delete_account": "アカウントを削除する",
|
||||
"accounted_deleted": "アカウントが削除されました",
|
||||
"account_deleted_message": "あなたのアカウントは正常に削除されました"
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user