diff --git a/lib/Screens/allTrips/list_all_plans.dart b/lib/Screens/allTrips/list_all_plans.dart index 84235dd..1841856 100644 --- a/lib/Screens/allTrips/list_all_plans.dart +++ b/lib/Screens/allTrips/list_all_plans.dart @@ -745,7 +745,8 @@ class _ListAllPlansState extends State { cells: [ DataCell( Text( - "${index + 1}", + // "${index + 1}", + "${(currentPage * itemsPerPage) + index + 1}", style: TextStyle( fontSize: 13, fontFamily: "Inter", diff --git a/lib/Screens/authentication/login/login_widget.dart b/lib/Screens/authentication/login/login_widget.dart index f6f62e7..c61d2a4 100644 --- a/lib/Screens/authentication/login/login_widget.dart +++ b/lib/Screens/authentication/login/login_widget.dart @@ -128,13 +128,23 @@ class _LoginWidgetState extends State { print("Token - $token"); await storeUserDetails(token); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Login Successful"), - backgroundColor: Colors.green, // Set background to green - ), + Fluttertoast.showToast( + msg: "You're in!", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.green, + textColor: Colors.white, + fontSize: 16.0, ); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text("Login Successful"), + // backgroundColor: Colors.green, // Set background to green + // ), + // ); + if (userRole == "Travel Agent") { context.go('/listTravelAgentPlan'); } else if (userRole == "Org Admin" || userRole == "Travel Admin") { @@ -151,11 +161,17 @@ class _LoginWidgetState extends State { if (messages is Map && messages.isNotEmpty) { errorMessage = messages.values.first.toString(); } - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Login Failed: $errorMessage"), - backgroundColor: Colors.red, - ), + + Fluttertoast.showToast( + msg: "Login Failed: $errorMessage", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + // webPosition: "center", + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", ); _emailController.clear(); _passwordController.clear(); @@ -169,9 +185,20 @@ class _LoginWidgetState extends State { // ); } } catch (e) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text("Error: $e"))); + // ScaffoldMessenger.of( + // context, + // ).showSnackBar(SnackBar(content: Text("Error: $e"))); + + Fluttertoast.showToast( + msg: "Login Failed: $e", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", + ); } } } @@ -198,27 +225,59 @@ class _LoginWidgetState extends State { _showOtpResetFields = true; // _clearAllFields(); }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("OTP sent to your email"), - backgroundColor: Colors.green, - ), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text("OTP sent to your email"), + // backgroundColor: Colors.green, + // ), + // ); + + Fluttertoast.showToast( + msg: "OTP sent to your email", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.green, + textColor: Colors.white, + fontSize: 16.0, ); } else { print(response); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "${jsonDecode(response.body)['messages']['error']}", - ), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text( + // "${jsonDecode(response.body)['messages']['error']}", + // ), + // + // backgroundColor: Colors.red, + // ), + // ); - backgroundColor: Colors.red, - ), + Fluttertoast.showToast( + msg: "${jsonDecode(response.body)['messages']['error']}", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", ); } } catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red), + // ); + + Fluttertoast.showToast( + msg: "Error: $e", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", ); } } else if (!_isForgotPassword && _showOtpResetFields) { @@ -245,11 +304,21 @@ class _LoginWidgetState extends State { _showOtpResetFields = false; _clearAllFields(); }); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Password reset successfully"), - backgroundColor: Colors.green, - ), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text("Password reset successfully"), + // backgroundColor: Colors.green, + // ), + // ); + + Fluttertoast.showToast( + msg: "Password reset successfully", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.green, + textColor: Colors.white, + fontSize: 16.0, ); } else { print('23'); @@ -258,19 +327,41 @@ class _LoginWidgetState extends State { final errorMessage = responseBody['messages']?['error'] ?? 'An unknown error occurred'; print(errorMessage); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - "Reset failed: $errorMessage", - // "Reset failed: ${jsonDecode(response.body)['message']}", - ), - backgroundColor: Colors.red, - ), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text( + // "Reset failed: $errorMessage", + // // "Reset failed: ${jsonDecode(response.body)['message']}", + // ), + // backgroundColor: Colors.red, + // ), + // ); + + Fluttertoast.showToast( + msg: "Reset failed: $errorMessage", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", ); } } catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red), + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red), + // ); + + Fluttertoast.showToast( + msg: "Error: $e", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0, + webBgColor: "linear-gradient(to right, #dc1c13, #dc1c13)", ); } } else { diff --git a/lib/Screens/dialog/user_selection_dialog.dart b/lib/Screens/dialog/user_selection_dialog.dart index 8842b89..1922436 100644 --- a/lib/Screens/dialog/user_selection_dialog.dart +++ b/lib/Screens/dialog/user_selection_dialog.dart @@ -13,6 +13,7 @@ import '../../widgets/custom_text_traveller.dart'; class UserSelectionDialog extends StatefulWidget { final String title; + final String? currentUser; final Color layoutColorForUser; final void Function(String, String, bool) onSubmit; final void Function() onClose; @@ -23,6 +24,7 @@ class UserSelectionDialog extends StatefulWidget { required this.layoutColorForUser, required this.onSubmit, required this.onClose, + required this.currentUser, }) : super(key: key); @override @@ -202,10 +204,17 @@ class _UserSelectionDialogState extends State { print("Filtering _filterUsersTravellers..."); setState(() { _filteredList.clear(); // Reset the list before filtering - + final excludedUserId = widget.currentUser.toString(); if (query.isEmpty) { _filteredList = [ - ..._users.map((user) => {"type": "user", "data": user}), + // ..._users.map((user) => {"type": "user", "data": user}), + ..._users + .where( + (user) => + (user.userId.toString() == excludedUserId && + user.roleId.toString() == "5"), + ) // ⛔ Exclude user ID 4 + .map((user) => {"type": "user", "data": user}), ]; } else { _filteredList = [ @@ -213,6 +222,10 @@ class _UserSelectionDialogState extends State { .where((user) { print("usersLLL : ${user}"); + if (user.userId.toString() == excludedUserId || + user.roleId.toString() == "5") + return false; + List searchFields = [ "${user.firstName} ${user.lastName}".toLowerCase(), user.email.toLowerCase() ?? "", @@ -335,6 +348,7 @@ class _UserSelectionDialogState extends State { super.initState(); fetchUsers(); fetchTraveller(); + print("SelffsdfcurrentUser - ${widget.currentUser}"); } @override diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index c809e65..558bc06 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -3582,6 +3582,7 @@ class CreateNewPlansState extends State { fetchUserDetails(); }, layoutColorForUser: widget.layoutColor!, + currentUser: selfId, ); }, ); diff --git a/lib/Screens/userManagement/create_user/create_user.dart b/lib/Screens/userManagement/create_user/create_user.dart index 9036a43..1c6fe6e 100644 --- a/lib/Screens/userManagement/create_user/create_user.dart +++ b/lib/Screens/userManagement/create_user/create_user.dart @@ -722,7 +722,7 @@ class _CreateUserFormDetialsState extends State { if (start_Date != null && end_Date != null && end_Date.isBefore(start_Date)) { - print("Invalid Date Range"); + print("Invalid date range"); return; } } catch (e) { diff --git a/lib/Screens/userManagement/create_user/traveller_details.dart b/lib/Screens/userManagement/create_user/traveller_details.dart index e93e168..8b97cd0 100644 --- a/lib/Screens/userManagement/create_user/traveller_details.dart +++ b/lib/Screens/userManagement/create_user/traveller_details.dart @@ -2408,10 +2408,15 @@ class TravellerDetailsState extends State { ); }, ), - dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownDecoratorProps: DropDownDecoratorProps( dropdownSearchDecoration: InputDecoration( border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( + hintText: "Select Seat", + hintStyle: GoogleFonts.poppins( + fontSize: 11.5, + color: Colors.grey, + ), + contentPadding: const EdgeInsets.symmetric( horizontal: 10, vertical: 5, ), @@ -2421,7 +2426,9 @@ class TravellerDetailsState extends State { icon: Icon(Icons.arrow_drop_down), ), dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { + if (selectedItem == null || + selectedItem.isEmpty || + selectedItem['dropdown_value'].toString().isEmpty) { return Text( "Select Seat", // fallback text style: GoogleFonts.poppins( @@ -2431,7 +2438,7 @@ class TravellerDetailsState extends State { ); } return Text( - selectedItem['dropdown_value'] ?? '', + selectedItem['dropdown_value'] ?? 'Select Seat', style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), ); }, @@ -2656,7 +2663,9 @@ class TravellerDetailsState extends State { ), dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { + if (selectedItem == null || + selectedItem.isEmpty || + selectedItem['dropdown_value'].toString().isEmpty) { return Text( "Select Seat", // fallback text style: GoogleFonts.poppins( @@ -2666,14 +2675,14 @@ class TravellerDetailsState extends State { ); } return Text( - selectedItem['dropdown_value'] ?? '', + selectedItem['dropdown_value'] ?? 'Select Seat"', style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), ); }, items: seatOptionsInt, selectedItem: selectedIntenationalSeat == null - ? null + ? {"dropdown_value": "Select Seat"} : {"dropdown_value": selectedIntenationalSeat}, onChanged: widget.isViewMode diff --git a/lib/app.dart b/lib/app.dart index ff0f116..7240633 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -88,6 +88,7 @@ class _MyAppState extends State { throw Exception(errorMessage); } } catch (e) { + router.go('/'); print("Error: $e"); } } @@ -124,6 +125,7 @@ class _MyAppState extends State { apiService.getOrganizationData(); } catch (e) { print('Error decoding token: $e'); + router.go('/'); } } diff --git a/lib/config/apiUrl.dart b/lib/config/apiUrl.dart index 7139bea..eb751b8 100644 --- a/lib/config/apiUrl.dart +++ b/lib/config/apiUrl.dart @@ -1,3 +1,3 @@ //api url -// const String apiUrl = 'http://apitest.tripapprovaltool.com/tstat_be'; -const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be'; +const String apiUrl = 'http://apitest.tripapprovaltool.com/tstat_be'; +// const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be'; diff --git a/lib/data/models/searchUser.dart b/lib/data/models/searchUser.dart index d8e2994..2c143e0 100644 --- a/lib/data/models/searchUser.dart +++ b/lib/data/models/searchUser.dart @@ -6,6 +6,7 @@ class SearchUser { final String mobileNo; final String alternateMobileNo; String? empCode; + final String roleId; SearchUser({ required this.userId, @@ -15,6 +16,7 @@ class SearchUser { required this.mobileNo, required this.alternateMobileNo, this.empCode, + required this.roleId, }); factory SearchUser.fromJson(Map json) { @@ -26,6 +28,7 @@ class SearchUser { mobileNo: json['mobile_no'].toString() ?? '', alternateMobileNo: json['alternate_mobile_no'].toString() ?? '', empCode: json['employee_code'].toString() ?? '', + roleId: json['role_id'].toString() ?? '', ); } } diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index 36adee3..8d8e720 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -537,22 +537,41 @@ class _CustomAppBarState extends State { color: Colors.black, ), ), - Text( - "Last Login: ${userData?["last_login_at"]}" ?? - '', - style: GoogleFonts.poppins( - fontSize: 8.5, - fontWeight: FontWeight.w400, - color: Colors.black, - ), - ), - const Divider(), // 👈 Divider after role + const PopupMenuDivider(), + // const Divider(), // 👈 Divider after role ], ), ), ...filteredItems .map(buildMenuItem) .toList(), // 👈 then normal items + // const PopupMenuDivider(), + PopupMenuItem( + enabled: false, // Not clickable + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Last Login : ", + style: GoogleFonts.poppins( + fontSize: 10, + fontWeight: FontWeight.w500, + color: Colors.grey, + ), + ), + + // SizedBox(width: 10), + Text( + "${userData?["last_login_at"] ?? ''}", + style: GoogleFonts.poppins( + fontSize: 10, + fontWeight: FontWeight.w400, + color: Colors.grey, + ), + ), + ], + ), + ), ]; },