From 400a7a2ec058a51d83a808161bf54c4151a3cafe Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Thu, 12 Jun 2025 19:04:06 +0530 Subject: [PATCH] userlist --- lib/Screens/itnerary/taxi.dart | 2 +- lib/services/apiService.dart | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/lib/Screens/itnerary/taxi.dart b/lib/Screens/itnerary/taxi.dart index 0d389f8..573561c 100644 --- a/lib/Screens/itnerary/taxi.dart +++ b/lib/Screens/itnerary/taxi.dart @@ -311,7 +311,7 @@ class _TaxiScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Number of Passenger", + "Number of Passenger *", style: GoogleFonts.poppins( fontSize: 12, fontWeight: FontWeight.w500, diff --git a/lib/services/apiService.dart b/lib/services/apiService.dart index dca8153..b6c515a 100644 --- a/lib/services/apiService.dart +++ b/lib/services/apiService.dart @@ -897,6 +897,72 @@ class ApiService { } } + // download the Template for bulk upload the user + Future getDownloadUserTemplateForUpload() async { + + final String apiUrldata = '$apiUrl/api/user/userUploadTemplate'; // download the Template for bulk upload user => api + + // final String apiUrldata = '$apiUrl/auth/googlelogin'; + + final token = await getToken(); + + if (token == null) { + throw Exception('Token not found. Please log in.'); + } + + final response = await http.get( + Uri.parse(apiUrldata), + headers: { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }, + ); + + if (response.statusCode == 200) { + try { + print("XL Dowloaded"); + + // Create a blob from the response body + final blob = html.Blob([response.bodyBytes]); + + // Generate a download URL for the blob + final url = html.Url.createObjectUrlFromBlob(blob); + + // Create a link element to trigger the download + final anchor = + html.AnchorElement(href: url) + ..setAttribute('download', 'user_file.xlsx') + ..click(); + + // Revoke the download URL to free up resources + html.Url.revokeObjectUrl(url); + } catch (e) { + throw Exception('Error parsing response: $e'); + } + } else if (response.statusCode == 404) { + // showDialog( + // context: context, + // builder: (BuildContext context) { + // return AlertDialog( + // title: Text('File not found.'), + // // content: Text('File not found.'), + // actions: [ + // TextButton( + // child: Text('OK'), + // onPressed: () { + // Navigator.of(context).pop(); // Close the dialog + // }, + // ), + // ], + // ); + // }, + // ); + } else { + throw Exception('Failed to load plans'); + } + } + + //---------------------------------------User Management----------------------------------- Future> getSingleUser(int userId) async {