From fa00f90f8aa01948279e0e9996c196f334fcb43e Mon Sep 17 00:00:00 2001 From: venbaittech Date: Fri, 1 Aug 2025 18:30:41 +0530 Subject: [PATCH] FIX_TRACKER --- .../itnerary_list/accomodation_list.dart | 22 +- lib/Screens/itnerary_list/forex_list.dart | 18 +- lib/Screens/myTemplates/templateForex.dart | 39 +- lib/Screens/organization/orgSetup.dart | 2 +- .../listTravelAgent.dart | 108 +- .../personalDetailsTravelAgent.dart | 328 ++++--- .../create_user/office_details.dart | 53 +- lib/Screens/userManagement/user_List.dart | 929 ++++++++++-------- 8 files changed, 822 insertions(+), 677 deletions(-) diff --git a/lib/Screens/itnerary_list/accomodation_list.dart b/lib/Screens/itnerary_list/accomodation_list.dart index 03eb333..0096465 100644 --- a/lib/Screens/itnerary_list/accomodation_list.dart +++ b/lib/Screens/itnerary_list/accomodation_list.dart @@ -445,16 +445,14 @@ class _AccomodationListWidgetState extends State { item["destination_city"], ), SizedBox(height: 5), - _buildDateTimeRow( + _buildRow( "Check (in)", - formatDate(item["checkin_date"]!), - formatTime(item["checkin_time"]!), + "${formatDate(item["checkin_date"]!)} ${formatTime(item["checkin_time"]!)}", ), SizedBox(height: 5), - _buildDateTimeRow( + _buildRow( "Check (out)", - formatDate(item["checkout_date"]!), - formatTime(item["checkout_time"]!), + "${formatDate(item["checkout_date"]!)} ${formatTime(item["checkout_time"]!)}", ), SizedBox(height: 5), _buildRow("Comments:", item["comments"] ?? "N/A"), @@ -630,13 +628,11 @@ class _AccomodationListWidgetState extends State { SizedBox( // color: Colors.yellowAccent.shade100, width: 100, - child: Expanded( - child: Text( - title, - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + child: Text( + title, + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), ), diff --git a/lib/Screens/itnerary_list/forex_list.dart b/lib/Screens/itnerary_list/forex_list.dart index 07ad3c1..0f52467 100644 --- a/lib/Screens/itnerary_list/forex_list.dart +++ b/lib/Screens/itnerary_list/forex_list.dart @@ -321,13 +321,16 @@ class _ForexListWidgetState extends State { Row( // mainAxisAlignment: MainAxisAlignment.end, children: [ - Text( - getRequestForCountry(item["country_code"]!.toString()), - style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: - isDesktop ? FontWeight.w800 : FontWeight.w600, - color: !isDesktop ? Colors.black : Color(0xFF575A74), + Expanded( + flex: 1, + child: Text( + getRequestForCountry(item["country_code"]!.toString()), + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: + isDesktop ? FontWeight.w800 : FontWeight.w600, + color: !isDesktop ? Colors.black : Color(0xFF575A74), + ), ), ), Spacer(), @@ -357,7 +360,6 @@ class _ForexListWidgetState extends State { ), ), ), - SizedBox(width: 10), item['forex_id'] != null ? IconButton( icon: Icon( diff --git a/lib/Screens/myTemplates/templateForex.dart b/lib/Screens/myTemplates/templateForex.dart index 8dfb1af..9fa8287 100644 --- a/lib/Screens/myTemplates/templateForex.dart +++ b/lib/Screens/myTemplates/templateForex.dart @@ -578,8 +578,6 @@ class TemplateForexState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - - Row( children: [ Container( @@ -587,15 +585,13 @@ class TemplateForexState extends State { isDesktop: isDesktop, breadcrumbItems: [ BreadcrumbItem( - title: 'Org Settings', - tooltip: 'Go To Organization Settings', - onTap: (context) { - context.go("/OrganizationSettings"); - } - ), - BreadcrumbItem( - title: 'Forex', + title: 'Org Settings', + tooltip: 'Go To Organization Settings', + onTap: (context) { + context.go("/OrganizationSettings"); + }, ), + BreadcrumbItem(title: 'Forex'), ], ), ), @@ -788,7 +784,7 @@ class TemplateForexState extends State { ), Container( padding: const EdgeInsets.all(16), - height: MediaQuery.of(context).size.height * 0.5, + height: MediaQuery.of(context).size.height * 0.45, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all(color: Color(0xFFD6D5E6), width: 0.5), @@ -862,17 +858,18 @@ class TemplateForexState extends State { SizedBox(width: 10), SizedBox( child: ElevatedButton( - onPressed: isDisable - ? null - : () async { - setState(() { - isDisable = true; - }); + onPressed: + isDisable + ? null + : () async { + setState(() { + isDisable = true; + }); - await handleSubmit(); - // You can get text from commentController.text - // Navigator.of(context).pop(); // Close the modal - }, + await handleSubmit(); + // You can get text from commentController.text + // Navigator.of(context).pop(); // Close the modal + }, style: ElevatedButton.styleFrom( backgroundColor: layoutColor, // backgroundColor: widget.layoutColor, diff --git a/lib/Screens/organization/orgSetup.dart b/lib/Screens/organization/orgSetup.dart index 4eb929d..096d91f 100644 --- a/lib/Screens/organization/orgSetup.dart +++ b/lib/Screens/organization/orgSetup.dart @@ -1131,7 +1131,7 @@ class _OrgSetUpState extends State { padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), ), onPressed: () { - context.go('/listPlan'); + context.go('/OrganizationSettings'); }, child: Text("Cancel", style: GoogleFonts.poppins(fontSize: 12)), ), diff --git a/lib/Screens/userManagement/create_traveller_agent/listTravelAgent.dart b/lib/Screens/userManagement/create_traveller_agent/listTravelAgent.dart index 2da32d5..5b77749 100644 --- a/lib/Screens/userManagement/create_traveller_agent/listTravelAgent.dart +++ b/lib/Screens/userManagement/create_traveller_agent/listTravelAgent.dart @@ -18,10 +18,10 @@ import '../../../services/apiService.dart'; import '../../../utils/pagination.dart'; import '../../../widgets/custom_breadcrumb_navigation.dart'; import '../../../widgets/popup_travelAgentList_action.dart'; + /// import '../../../widgets/custom_popup.dart'; /// import '../../../../widgets/popup_TravelAgentList_action.dart'; - class TravelAgentListScreen extends StatefulWidget { @override _TravelAgentListScreenState createState() => _TravelAgentListScreenState(); @@ -144,7 +144,8 @@ class _TravelAgentListScreenState extends State { Future> fetchUsers() async { // return []; orgId = await getOrgId(); - final String apiUrlData = '$apiUrl/api/agentList?org_id=$orgId&for=table_view'; + final String apiUrlData = + '$apiUrl/api/agentList?org_id=$orgId&for=table_view'; final String? token = await getToken(); print("Fetch Users"); @@ -459,15 +460,13 @@ class _TravelAgentListScreenState extends State { isDesktop: isDesktop, breadcrumbItems: [ BreadcrumbItem( - title: 'Org Settings', - tooltip: 'Go To Organization Settings', - onTap: (context) { - context.go("/OrganizationSettings"); - } - ), - BreadcrumbItem( - title: 'Travel Agent', + title: 'Org Settings', + tooltip: 'Go To Organization Settings', + onTap: (context) { + context.go("/OrganizationSettings"); + }, ), + BreadcrumbItem(title: 'Travel Agent'), ], ), ), @@ -483,8 +482,8 @@ class _TravelAgentListScreenState extends State { ), if (isDesktop) SizedBox(width: MediaQuery.of(context).size.width * 0.03), - // SizedBox(width: MediaQuery.of(context).size.width * 0.23), - // SizedBox(width: MediaQuery.of(context).size.width * 0.15), + // SizedBox(width: MediaQuery.of(context).size.width * 0.23), + // SizedBox(width: MediaQuery.of(context).size.width * 0.15), if (isDesktop) Container( width: MediaQuery.of(context).size.width * 0.2, @@ -844,11 +843,12 @@ class _TravelAgentListScreenState extends State { DataCell( Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ GestureDetector( child: Tooltip( - message: 'Edit Travel Agent Details', + message: + 'Edit Travel Agent Details', child: Image.asset( 'assets/images/IconsImg/edit.png', width: 20, @@ -858,12 +858,18 @@ class _TravelAgentListScreenState extends State { onTap: () async { // Navigator.pop(context); // Close the menu // final userId = user['user_id']; - final userId = int.parse(user['user_id'].toString()); - final usersData = await apiService.getSingleUser(userId); - context.go("/CreateTravelAgent", extra: { - "selectedUser": usersData, - "isViewMode": false, - }); + final userId = int.parse( + user['user_id'].toString(), + ); + final usersData = await apiService + .getSingleUser(userId); + context.go( + "/CreateTravelAgent", + extra: { + "selectedUser": usersData, + "isViewMode": false, + }, + ); }, ), ], @@ -911,32 +917,48 @@ class _TravelAgentListScreenState extends State { ), ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - GestureDetector( - child: Tooltip( - message: 'Edit Travel Agent Details', - child: Image.asset( - 'assets/images/IconsImg/edit.png', - width: 20, - height: 15, - ), + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + GestureDetector( + child: Tooltip( + message: + 'Edit Travel Agent Details', + child: Image.asset( + 'assets/images/IconsImg/edit.png', + width: 20, + height: 15, ), - onTap: () async { - Navigator.pop(context); // Close the menu - final userId = int.parse(user['user_id'].toString()); - final usersData = await apiService.getSingleUser(userId); - context.go("/CreateTravelAgent", extra: { + ), + onTap: () async { + // Navigator.pop(context); // Close the menu + // final userId = user['user_id']; + final userId = int.parse( + user['user_id'].toString(), + ); + final usersData = await apiService + .getSingleUser(userId); + context.go( + "/CreateTravelAgent", + extra: { "selectedUser": usersData, "isViewMode": false, - }); - }, - ), - ], - ), + }, + ); + }, + // onTap: () async { + // Navigator.pop(context); // Close the menu + // final userId = int.parse(user['user_id'].toString()); + // final usersData = await apiService.getSingleUser(userId); + // context.go("/CreateTravelAgent", extra: { + // "selectedUser": usersData, + // "isViewMode": false, + // }); + // }, + ), + ], + ), // UserActionsMenu( // user: user, // getUserDetails: @@ -1043,7 +1065,7 @@ class _TravelAgentListScreenState extends State { children: [ Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( "${user['company_name'] ?? ''}", diff --git a/lib/Screens/userManagement/create_traveller_agent/personalDetailsTravelAgent.dart b/lib/Screens/userManagement/create_traveller_agent/personalDetailsTravelAgent.dart index 6b38e4f..28a6e02 100644 --- a/lib/Screens/userManagement/create_traveller_agent/personalDetailsTravelAgent.dart +++ b/lib/Screens/userManagement/create_traveller_agent/personalDetailsTravelAgent.dart @@ -806,7 +806,10 @@ class PersonalDetailsState extends State { CustomTextFieldUserWrapper( isFocused: focusStates["FnameFocused"] ?? false, isDesktop: widget.isDesktop, - width: MediaQuery.of(context).size.width * 0.12, + width: + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.12 + : null, child: SizedBox( height: 40, child: TextField( @@ -858,7 +861,10 @@ class PersonalDetailsState extends State { CustomTextFieldUserWrapper( isFocused: focusStates["LnameFocused"] ?? false, isDesktop: widget.isDesktop, - width: MediaQuery.of(context).size.width * 0.12, + width: + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.12 + : null, child: SizedBox( height: 40, child: TextField( @@ -1210,7 +1216,10 @@ class PersonalDetailsState extends State { CustomTextFieldUserWrapper( isFocused: focusStates["mobileNumberFocused"] ?? false, isDesktop: widget.isDesktop, - width: MediaQuery.of(context).size.width * 0.12, + width: + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.12 + : null, child: SizedBox( height: 40, child: TextField( @@ -1274,7 +1283,10 @@ class PersonalDetailsState extends State { // isFocused: false, isFocused: focusStates["alternateMobileFocused"] ?? false, isDesktop: widget.isDesktop, - width: MediaQuery.of(context).size.width * 0.12, + width: + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.12 + : null, child: SizedBox( height: 40, child: TextField( @@ -1353,161 +1365,175 @@ class PersonalDetailsState extends State { padding: const EdgeInsets.symmetric(horizontal: 0), isDesktop: widget.isDesktop, child: SizedBox( - height: 40, - width: double.infinity, - child: Focus( - focusNode: focusNodes["countryFocusNode"], - onFocusChange: (hasFocus) { - setState(() { - focusStates["countryFocused"] = hasFocus; - }); - }, - child: GestureDetector( - onTap: () { - // Request focus when user taps - focusNodes["countryFocusNode"]?.requestFocus(); - }, - child: DropdownSearch( - selectedItem: countryMap[selectedCountry], - enabled: !widget.isViewMode, - popupProps: PopupProps.menu( - showSearchBox: true, // Enables search functionality - fit: FlexFit.loose, // Allows flexible height - menuProps: const MenuProps(backgroundColor: Colors.white), - itemBuilder: - // (context, item, isSelected) => Container( - // padding: EdgeInsets.symmetric( - // horizontal: 10, - // vertical: 6, - // ), - // child: Text( - // item, - // style: GoogleFonts.poppins(fontSize: 11.5), - // ), - // ), - (context, item, isSelected) { - print("contryItem - $item"); - final match = RegExp(r'^(.*)\s\((.*)\)$').firstMatch(item); - final countryName = match?.group(1) ?? ''; - final countryCode = match?.group(2) ?? ''; - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10.0, - vertical: 6.0, - ), - child: Padding( - // padding: const EdgeInsets.all(3.0), - padding: EdgeInsets.symmetric(horizontal: 2, vertical: 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - countryName, - style: GoogleFonts.poppins(fontSize: 11.5), - ), - Text( - countryCode, - style: GoogleFonts.poppins( - fontSize: 11.5, - color: Colors.grey, - ), - ), - ], - ), - ), - ); + height: 40, + width: double.infinity, + child: Focus( + focusNode: focusNodes["countryFocusNode"], + onFocusChange: (hasFocus) { + setState(() { + focusStates["countryFocused"] = hasFocus; + }); + }, + child: GestureDetector( + onTap: () { + // Request focus when user taps + focusNodes["countryFocusNode"]?.requestFocus(); }, - constraints: BoxConstraints(maxHeight: 180), - searchFieldProps: TextFieldProps( - decoration: InputDecoration( - hintText: "Search Country...", - contentPadding: EdgeInsets.symmetric( - horizontal: 3, - vertical: 3, - ), - ), - ), - ), - items: countryMap.values.toList(), - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - // border: InputBorder.none, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: - (focusStates["countryFocused"] ?? false) - ? (layoutColor ?? Colors.blue) - : Colors.white, - // width: 0.5, - ), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: - (focusStates["countryFocused"] ?? false) - ? (layoutColor ?? Colors.blue) - : Colors.white, - // width: 0.5, - // const Color(0xFFD6D5E6), - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color : (layoutColor ?? Colors.grey), width: 1), - ), - contentPadding: EdgeInsets.symmetric(horizontal: 10.0, vertical: 8.0,), - // contentPadding: EdgeInsets.symmetric(horizontal: 1), - ), - ), - dropdownBuilder: - (context, selectedItem) => Align( - // Center-align selected item - alignment: Alignment.centerLeft, - child: Text( - selectedItem ?? "Select Country", - style: GoogleFonts.poppins( - fontSize: 12, - color: Colors.black, + child: DropdownSearch( + selectedItem: countryMap[selectedCountry], + enabled: !widget.isViewMode, + popupProps: PopupProps.menu( + showSearchBox: true, // Enables search functionality + fit: FlexFit.loose, // Allows flexible height + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: + // (context, item, isSelected) => Container( + // padding: EdgeInsets.symmetric( + // horizontal: 10, + // vertical: 6, + // ), + // child: Text( + // item, + // style: GoogleFonts.poppins(fontSize: 11.5), + // ), + // ), + (context, item, isSelected) { + print("contryItem - $item"); + final match = RegExp( + r'^(.*)\s\((.*)\)$', + ).firstMatch(item); + final countryName = match?.group(1) ?? ''; + final countryCode = match?.group(2) ?? ''; + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0, + vertical: 6.0, + ), + child: Padding( + // padding: const EdgeInsets.all(3.0), + padding: EdgeInsets.symmetric( + horizontal: 2, + vertical: 3, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + countryName, + style: GoogleFonts.poppins(fontSize: 11.5), + ), + Text( + countryCode, + style: GoogleFonts.poppins( + fontSize: 11.5, + color: Colors.grey, + ), + ), + ], + ), + ), + ); + }, + constraints: BoxConstraints(maxHeight: 180), + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search Country...", + contentPadding: EdgeInsets.symmetric( + horizontal: 3, + vertical: 3, + ), ), ), ), + items: countryMap.values.toList(), + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + // border: InputBorder.none, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: + (focusStates["countryFocused"] ?? false) + ? (layoutColor ?? Colors.blue) + : Colors.white, + // width: 0.5, + ), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: + (focusStates["countryFocused"] ?? false) + ? (layoutColor ?? Colors.blue) + : Colors.white, + // width: 0.5, + // const Color(0xFFD6D5E6), + ), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: (layoutColor ?? Colors.grey), + width: 1, + ), + ), + contentPadding: EdgeInsets.symmetric( + horizontal: 10.0, + vertical: 8.0, + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 1), + ), + ), + dropdownBuilder: + (context, selectedItem) => Align( + // Center-align selected item + alignment: Alignment.centerLeft, + child: Text( + selectedItem ?? "Select Country", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ), - // onChanged: widget.isViewMode - // ? null - // : (String? newValue) { - // setState(() { - // // Find the country_code based on selected country_name - // selectedCountry = countryMap.entries - // .firstWhere((entry) => entry.value == newValue) - // .key; - // - // // if (selectedCountry!.isNotEmpty) { - // // errorMessages.remove("country_code"); - // // } - // }); - // widget.onCountryChanged?.call(newValue); - // }, - onChanged: - widget.isViewMode - ? null - : (String? newValue) { - if (newValue == null) return; + // onChanged: widget.isViewMode + // ? null + // : (String? newValue) { + // setState(() { + // // Find the country_code based on selected country_name + // selectedCountry = countryMap.entries + // .firstWhere((entry) => entry.value == newValue) + // .key; + // + // // if (selectedCountry!.isNotEmpty) { + // // errorMessages.remove("country_code"); + // // } + // }); + // widget.onCountryChanged?.call(newValue); + // }, + onChanged: + widget.isViewMode + ? null + : (String? newValue) { + if (newValue == null) return; - final countryCode = - countryMap.entries - .firstWhere((entry) => entry.value == newValue) - .key; + final countryCode = + countryMap.entries + .firstWhere( + (entry) => entry.value == newValue, + ) + .key; - setState(() { - selectedCountry = countryCode; - }); + setState(() { + selectedCountry = countryCode; + }); - widget.onCountryChanged?.call( - countryCode, - ); // ✅ send code not name - }, - ),),), + widget.onCountryChanged?.call( + countryCode, + ); // ✅ send code not name + }, + ), + ), + ), ), ), ], diff --git a/lib/Screens/userManagement/create_user/office_details.dart b/lib/Screens/userManagement/create_user/office_details.dart index 95eae48..c0271e5 100644 --- a/lib/Screens/userManagement/create_user/office_details.dart +++ b/lib/Screens/userManagement/create_user/office_details.dart @@ -388,32 +388,35 @@ class OfficeDetailsState extends State { ), ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 20), - _buildFirstRow(widget.isDesktop), - if (widget.isDesktop) SizedBox(height: 10), - _buildSecondRow(widget.isDesktop), - if (widget.isDesktop) SizedBox(height: 10), - _buildThirdRow(widget.isDesktop), - if (widget.isDesktop) SizedBox(height: 10), - Divider(thickness: 0.2, color: Colors.blueGrey.shade100), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Delegation", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w500, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 20), + _buildFirstRow(widget.isDesktop), + if (widget.isDesktop) SizedBox(height: 10), + _buildSecondRow(widget.isDesktop), + if (widget.isDesktop) SizedBox(height: 10), + _buildThirdRow(widget.isDesktop), + if (widget.isDesktop) SizedBox(height: 10), + Divider(thickness: 0.2, color: Colors.blueGrey.shade100), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Delegation", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w500, + ), ), - ), - ], - ), - SizedBox(height: 15), - _buildFourthRow(widget.isDesktop), - ], + ], + ), + SizedBox(height: 15), + _buildFourthRow(widget.isDesktop), + ], + ), ), ); } diff --git a/lib/Screens/userManagement/user_List.dart b/lib/Screens/userManagement/user_List.dart index bebdd02..2712a67 100644 --- a/lib/Screens/userManagement/user_List.dart +++ b/lib/Screens/userManagement/user_List.dart @@ -225,222 +225,294 @@ class _UserListScreenState extends State { print("handDel - $userId"); } - void _showConfirmationDialog(String subtitle, List successList, List> failedList) { + void _showConfirmationDialog( + String subtitle, + List successList, + List> failedList, + ) { _dialogShown = true; showDialog( context: context, - builder: (context) => AlertDialog( - // title: Text("User Details"), - title: Text("Upload Status - $subtitle", style: GoogleFonts.poppins( - fontSize: 18, - fontWeight: FontWeight.w600, - color: Colors.black, - ), overflow: TextOverflow.ellipsis), - content: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Text(subtitle, style: TextStyle(fontWeight: FontWeight.bold)), - // - // SizedBox(height: 12), - Text("Success Report :", style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, + builder: + (context) => AlertDialog( + // title: Text("User Details"), + title: Text( + "Upload Status - $subtitle", + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w600, color: Colors.black, - )), - // if (successList.isNotEmpty) - // ...successList.asMap().entries.map((entry) => Text("${entry.key + 1}) ${entry.value} created.")) - if (successList.isNotEmpty) - SizedBox( - height: 250, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: DataTable( - columns: [ - DataColumn( - label: Text( - 'S.No', - style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Colors.black, - ), - ), - ), - DataColumn( - label: Text( - 'Data', - style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Colors.black, - ), - ), - ) - ], - rows: successList.asMap().entries.map((entry) { - final newIndex = entry.key + 1; - final data = entry.value?.toString().trim().isNotEmpty == true - ? entry.value.toString() - : '-'; - - return DataRow( - cells: [ - DataCell( - Text( - '$newIndex', - style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - ), - ), - ), - DataCell( - SizedBox( - width: 460, - child: Text( - data, - style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - ), - overflow: TextOverflow.ellipsis, - ), - ), - ), - ], - ); - }).toList(), + ), + overflow: TextOverflow.ellipsis, ), - ), - ), - ) - else - Text("-- no data. --",style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w200, - color: Colors.black, - )), - SizedBox(height: 12), - // Text("Failed Report :", style: TextStyle(fontWeight: FontWeight.bold)), - Text("Failed Report :", style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - )), - // if (failedList.isNotEmpty) - // ...failedList.asMap().entries.map((entry) { - // final data = entry.value["data"] ?? "-"; - // final reason = entry.value["reason"] ?? "Unknown error"; - // return Text("${entry.key + 1}) $data - unable to create due to \"$reason\"."); - // }) - - if (failedList.isNotEmpty) - SizedBox( - height: 250, // Vertical scroll height - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, // Enable horizontal scrolling - child: SingleChildScrollView( - scrollDirection: Axis.vertical, // Enable vertical scrolling - child: DataTable( - columns: [ - DataColumn(label: Text('S.No', style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Colors.black, - ))), - DataColumn(label: Text('Data', style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Colors.black, - ))), - DataColumn(label: Text('Reason', style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Colors.black, - ))), - ], - rows: failedList.asMap().entries.map((entry) { - final index = entry.key + 1; - final rawData = entry.value['data']; - final data = (rawData == null || rawData.toString().trim().isEmpty) ? '-' : rawData.toString(); - final reason = entry.value['reason'] ?? 'Unknown error'; - - return DataRow(cells: [ - DataCell(Text('$index',style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - ))), - DataCell(SizedBox( - width: 180, - child: Text(data, style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - ), overflow: TextOverflow.ellipsis), - )), - DataCell(SizedBox( - width: 280, - child: Text(reason, style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Colors.black, - ),overflow: TextOverflow.ellipsis), - )), - ]); - }).toList(), - ), + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Text(subtitle, style: TextStyle(fontWeight: FontWeight.bold)), + // + // SizedBox(height: 12), + Text( + "Success Report :", + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, ), ), - ) - else - Text("-- no data. --",style: GoogleFonts.poppins( - fontSize: 14, - fontWeight: FontWeight.w200, - color: Colors.black, - )), + // if (successList.isNotEmpty) + // ...successList.asMap().entries.map((entry) => Text("${entry.key + 1}) ${entry.value} created.")) + if (successList.isNotEmpty) + SizedBox( + height: 250, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: DataTable( + columns: [ + DataColumn( + label: Text( + 'S.No', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + DataColumn( + label: Text( + 'Data', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + ], + rows: + successList.asMap().entries.map((entry) { + final newIndex = entry.key + 1; + final data = + entry.value + ?.toString() + .trim() + .isNotEmpty == + true + ? entry.value.toString() + : '-'; + + return DataRow( + cells: [ + DataCell( + Text( + '$newIndex', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + ), + ), + DataCell( + SizedBox( + width: 460, + child: Text( + data, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + overflow: TextOverflow.ellipsis, + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ), + ) + else + Text( + "-- no data. --", + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w200, + color: Colors.black, + ), + ), + SizedBox(height: 12), + // Text("Failed Report :", style: TextStyle(fontWeight: FontWeight.bold)), + Text( + "Failed Report :", + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + ), + + // if (failedList.isNotEmpty) + // ...failedList.asMap().entries.map((entry) { + // final data = entry.value["data"] ?? "-"; + // final reason = entry.value["reason"] ?? "Unknown error"; + // return Text("${entry.key + 1}) $data - unable to create due to \"$reason\"."); + // }) + if (failedList.isNotEmpty) + SizedBox( + height: 250, // Vertical scroll height + child: SingleChildScrollView( + scrollDirection: + Axis.horizontal, // Enable horizontal scrolling + child: SingleChildScrollView( + scrollDirection: + Axis.vertical, // Enable vertical scrolling + child: DataTable( + columns: [ + DataColumn( + label: Text( + 'S.No', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + DataColumn( + label: Text( + 'Data', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + DataColumn( + label: Text( + 'Reason', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + ], + rows: + failedList.asMap().entries.map((entry) { + final index = entry.key + 1; + final rawData = entry.value['data']; + final data = + (rawData == null || + rawData.toString().trim().isEmpty) + ? '-' + : rawData.toString(); + final reason = + entry.value['reason'] ?? 'Unknown error'; + + return DataRow( + cells: [ + DataCell( + Text( + '$index', + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + ), + ), + DataCell( + SizedBox( + width: 180, + child: Text( + data, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + overflow: TextOverflow.ellipsis, + ), + ), + ), + DataCell( + SizedBox( + width: 280, + child: Text( + reason, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + overflow: TextOverflow.ellipsis, + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ), + ) + else + Text( + "-- no data. --", + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w200, + color: Colors.black, + ), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + _dialogShown = false; + }, + child: Text("Close"), + ), ], ), - ), - actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - _dialogShown = false; - }, - child: Text("Close"), - ), - ], - ), ); } - Future handleDownload() async { final result = await apiService.getDownloadUserTemplateForUpload(); - final String displayBackgroundColor = result['status'] ? '#28a745' : '#dc1c13'; - final Color displayColor = result['status'] ? Colors.green : Colors.redAccent; + final String displayBackgroundColor = + result['status'] ? '#28a745' : '#dc1c13'; + final Color displayColor = + result['status'] ? Colors.green : Colors.redAccent; final String displayMessage = result['message']; // final bool status = result['status'] == true; Fluttertoast.showToast( - msg: displayMessage , + msg: displayMessage, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 2, backgroundColor: displayColor, textColor: Colors.white, fontSize: 18.0, - webBgColor: "linear-gradient(to right, $displayBackgroundColor, $displayBackgroundColor)", + webBgColor: + "linear-gradient(to right, $displayBackgroundColor, $displayBackgroundColor)", ); } + Future handleUpload() async { final Completer completer = Completer(); @@ -540,10 +612,15 @@ class _UserListScreenState extends State { final status = responseData['status'] ?? ''; final data = responseData['data'] ?? {}; - final List successList = List.from(data['successfulUsers'] ?? []); - final List> failedList = List>.from( - (data['failedUsers'] ?? []).map((item) => Map.from(item)), + final List successList = List.from( + data['successfulUsers'] ?? [], ); + final List> failedList = + List>.from( + (data['failedUsers'] ?? []).map( + (item) => Map.from(item), + ), + ); _showConfirmationDialog(message, successList, failedList); @@ -565,10 +642,10 @@ class _UserListScreenState extends State { // Refresh list if needed refreshUserList(); - } else { // For non-200 responses - final errorMsg = 'Failed to upload file: ${response.reasonPhrase}'; + final errorMsg = + 'Failed to upload file: ${response.reasonPhrase}'; Fluttertoast.showToast( msg: errorMsg, toastLength: Toast.LENGTH_SHORT, @@ -581,7 +658,6 @@ class _UserListScreenState extends State { ); print(errorMsg); } - } } return completer.future; // Wait for upload to finish before proceeding @@ -768,8 +844,7 @@ class _UserListScreenState extends State { @override Widget build(BuildContext context) { - return - ResponsiveBuilder( + return ResponsiveBuilder( builder: (context, sizingInfo) { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; @@ -958,32 +1033,33 @@ class _UserListScreenState extends State { // height: 25, // ), // tooltip: 'User Bulk Upload', - // onPressed: () { - // handleUpload(); - // }, + // onPressed: () { + // handleUpload(); + // }, // ), // UPLOAD BUTTON Align( alignment: Alignment.centerLeft, - child: _isUploading - ? const SizedBox( - width: 28, - height: 28, - child: CircularProgressIndicator(strokeWidth: 3), - ) - : IconButton( - icon: Image.asset( - 'assets/images/IconsImg/upload.png', - width: 25, - height: 25, - ), - tooltip: 'User Bulk Upload', - onPressed: () async { - setState(() => _isUploading = true); - await handleUpload(); - setState(() => _isUploading = false); - }, - ), + child: + _isUploading + ? const SizedBox( + width: 28, + height: 28, + child: CircularProgressIndicator(strokeWidth: 3), + ) + : IconButton( + icon: Image.asset( + 'assets/images/IconsImg/upload.png', + width: 25, + height: 25, + ), + tooltip: 'User Bulk Upload', + onPressed: () async { + setState(() => _isUploading = true); + await handleUpload(); + setState(() => _isUploading = false); + }, + ), ), // Spacer(), SizedBox(width: 5), @@ -1086,7 +1162,7 @@ class _UserListScreenState extends State { ], ), const SizedBox(height: 10), - FutureBuilder>( + FutureBuilder>( future: futureUsers, builder: (context, snapshot) { final adjHgt = MediaQuery.of(context).size.height; @@ -1283,7 +1359,7 @@ class _UserListScreenState extends State { DataCell( Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ GestureDetector( child: Tooltip( @@ -1297,199 +1373,205 @@ class _UserListScreenState extends State { onTap: () async { // Navigator.pop(context); // Close the menu // final userId = user['user_id']; - final userId = int.parse(user['user_id'].toString()); - final usersData = await apiService.getSingleUser(userId); - context.go("/CreateUserDetails", extra: { - "selectedUser": usersData, - "isViewMode": false, - }); + final userId = int.parse( + user['user_id'].toString(), + ); + final usersData = await apiService + .getSingleUser(userId); + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": usersData, + "isViewMode": false, + }, + ); }, ), ], ), ), // DataCell( - // UserActionsMenu( - // user: user, - // getUserDetails: - // (id) => - // apiService.getSingleUser(id), - // ), - // PopupMenuButton( - // color: Colors.white, - // padding: EdgeInsets.zero, - // offset: Offset(0, 30), - // icon: Icon( - // Icons.more_vert, - // color: Color(0xFF475569), - // size: 14, - // ), - // itemBuilder: (context) => [ - // CustomPopupMenuEntry( - // child: Container( - // padding: EdgeInsets.symmetric( - // horizontal: 8, vertical: 8), - // child: Row( - // mainAxisSize: MainAxisSize.min, - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // IconButton( - // icon: Icon( - // Icons.remove_red_eye, - // color: - // Color(0xFF475569), - // size: 18), - // onPressed: () async { - // print( - // "USerDAta1 - $user"); - // // Fetch the user data properly with await - // Map - // usersData = - // await apiService - // .getSingleUser(user[ - // 'user_id'] - // is String - // ? int.parse(user[ - // 'user_id']) - // : user[ - // 'user_id']); - // - // print( - // "USerDAta2 - $usersData"); - // - // // userSingleData = - // // await apiService - // // .getSingleUser(user[ - // // 'user_id']); - // - // context.go( - // "/CreateUserDetails", - // extra: { - // "selectedUser": - // usersData, - // "isViewMode": true - // }, - // ); - // }), - // IconButton( - // icon: Image.asset( - // 'assets/images/IconsImg/edit.png', - // width: 20, - // height: 15), - // onPressed: () async { - // // Fetch the user data properly with await - // Map - // usersData = - // await apiService - // .getSingleUser(user[ - // 'user_id'] - // is String - // ? int.parse(user[ - // 'user_id']) - // : user[ - // 'user_id']); - // - // print( - // "USerDAta2 - $usersData"); - // context.go( - // "/CreateUserDetails", - // extra: { - // "selectedUser": - // usersData, - // "isViewMode": false - // }, - // ); - // }, - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // Row( - // children: [ - // MouseRegion( - // cursor: user['is_active'] == "0" - // ? SystemMouseCursors.forbidden - // : SystemMouseCursors.click, - // child: IconButton( - // icon: Icon(Icons.remove_red_eye, - // size: 18, - // color: user['is_active'] == "0" - // ? Colors.grey - // : Color(0xFF475569)), - // onPressed: user['is_active'] == "0" - // ? null - // : () { - // context.go( - // "/CreateUserDetails", - // extra: { - // "selectedUser": user, - // "isViewMode": true - // }, - // ); - // }, - // ), - // ), - // - // MouseRegion( - // cursor: user['is_active'] == "0" - // ? SystemMouseCursors.forbidden - // : SystemMouseCursors.click, - // child: GestureDetector( - // onTap: user['is_active'] == "0" - // ? null - // : () { - // - // }, - // child: Image.asset( - // 'assets/images/IconsImg/edit.png', - // width: 20, - // height: 15), - // ), - // ), - // - // // MouseRegion( - // // cursor: user['is_active'] == "0" - // // ? SystemMouseCursors - // // .forbidden - // // : SystemMouseCursors.click, - // // child: IconButton( - // // icon: Icon(Icons.edit, - // // color: - // // user['is_active'] == - // // "0" - // // ? Colors.grey - // // : Colors.green), - // // onPressed: - // // user['is_active'] == "0" - // // ? null - // // : () { - // // print( - // // "USER: $user"); - // // - // // // final userJson = jsonEncode( - // // // user); // Convert user map to string - // // // final encodedUser = - // // // Uri.encodeComponent( - // // // userJson); - // // - // // context.go( - // // "/CreateUserDetails", - // // extra: { - // // "selectedUser": - // // user, - // // "isViewMode": - // // false - // // }, - // // ); - // // }, - // // ), - // // ), - // ], - // ), + // UserActionsMenu( + // user: user, + // getUserDetails: + // (id) => + // apiService.getSingleUser(id), + // ), + // PopupMenuButton( + // color: Colors.white, + // padding: EdgeInsets.zero, + // offset: Offset(0, 30), + // icon: Icon( + // Icons.more_vert, + // color: Color(0xFF475569), + // size: 14, + // ), + // itemBuilder: (context) => [ + // CustomPopupMenuEntry( + // child: Container( + // padding: EdgeInsets.symmetric( + // horizontal: 8, vertical: 8), + // child: Row( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: + // MainAxisAlignment.center, + // children: [ + // IconButton( + // icon: Icon( + // Icons.remove_red_eye, + // color: + // Color(0xFF475569), + // size: 18), + // onPressed: () async { + // print( + // "USerDAta1 - $user"); + // // Fetch the user data properly with await + // Map + // usersData = + // await apiService + // .getSingleUser(user[ + // 'user_id'] + // is String + // ? int.parse(user[ + // 'user_id']) + // : user[ + // 'user_id']); + // + // print( + // "USerDAta2 - $usersData"); + // + // // userSingleData = + // // await apiService + // // .getSingleUser(user[ + // // 'user_id']); + // + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": + // usersData, + // "isViewMode": true + // }, + // ); + // }), + // IconButton( + // icon: Image.asset( + // 'assets/images/IconsImg/edit.png', + // width: 20, + // height: 15), + // onPressed: () async { + // // Fetch the user data properly with await + // Map + // usersData = + // await apiService + // .getSingleUser(user[ + // 'user_id'] + // is String + // ? int.parse(user[ + // 'user_id']) + // : user[ + // 'user_id']); + // + // print( + // "USerDAta2 - $usersData"); + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": + // usersData, + // "isViewMode": false + // }, + // ); + // }, + // ), + // ], + // ), + // ), + // ), + // ], + // ), + // Row( + // children: [ + // MouseRegion( + // cursor: user['is_active'] == "0" + // ? SystemMouseCursors.forbidden + // : SystemMouseCursors.click, + // child: IconButton( + // icon: Icon(Icons.remove_red_eye, + // size: 18, + // color: user['is_active'] == "0" + // ? Colors.grey + // : Color(0xFF475569)), + // onPressed: user['is_active'] == "0" + // ? null + // : () { + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": user, + // "isViewMode": true + // }, + // ); + // }, + // ), + // ), + // + // MouseRegion( + // cursor: user['is_active'] == "0" + // ? SystemMouseCursors.forbidden + // : SystemMouseCursors.click, + // child: GestureDetector( + // onTap: user['is_active'] == "0" + // ? null + // : () { + // + // }, + // child: Image.asset( + // 'assets/images/IconsImg/edit.png', + // width: 20, + // height: 15), + // ), + // ), + // + // // MouseRegion( + // // cursor: user['is_active'] == "0" + // // ? SystemMouseCursors + // // .forbidden + // // : SystemMouseCursors.click, + // // child: IconButton( + // // icon: Icon(Icons.edit, + // // color: + // // user['is_active'] == + // // "0" + // // ? Colors.grey + // // : Colors.green), + // // onPressed: + // // user['is_active'] == "0" + // // ? null + // // : () { + // // print( + // // "USER: $user"); + // // + // // // final userJson = jsonEncode( + // // // user); // Convert user map to string + // // // final encodedUser = + // // // Uri.encodeComponent( + // // // userJson); + // // + // // context.go( + // // "/CreateUserDetails", + // // extra: { + // // "selectedUser": + // // user, + // // "isViewMode": + // // false + // // }, + // // ); + // // }, + // // ), + // // ), + // ], + // ), // ), ], ); @@ -1534,7 +1616,7 @@ class _UserListScreenState extends State { ), Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ GestureDetector( child: Tooltip( @@ -1546,14 +1628,31 @@ class _UserListScreenState extends State { ), ), onTap: () async { - Navigator.pop(context); // Close the menu - final userId = int.parse(user['user_id'].toString()); - final usersData = await apiService.getSingleUser(userId); - context.go("/CreateUserDetails", extra: { - "selectedUser": usersData, - "isViewMode": true, - }); + // Navigator.pop(context); // Close the menu + // final userId = user['user_id']; + final userId = int.parse( + user['user_id'].toString(), + ); + final usersData = await apiService + .getSingleUser(userId); + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": usersData, + "isViewMode": false, + }, + ); }, + + // onTap: () async { + // Navigator.pop(context); // Close the menu + // final userId = int.parse(user['user_id'].toString()); + // final usersData = await apiService.getSingleUser(userId); + // context.go("/CreateUserDetails", extra: { + // "selectedUser": usersData, + // "isViewMode": true, + // }); + // }, ), ], ),