diff --git a/lib/Screens/authentication/login/login_widget.dart b/lib/Screens/authentication/login/login_widget.dart index d7666e3..4b238f7 100644 --- a/lib/Screens/authentication/login/login_widget.dart +++ b/lib/Screens/authentication/login/login_widget.dart @@ -157,6 +157,9 @@ class _LoginWidgetState extends State { final token = data['token']; // Assuming the token is in response // final userId = data['user_id'].toString(); + final prefs = await SharedPreferences.getInstance(); + prefs.clear(); + print("CLEARINGGG-- "); print("Token - $token"); await storeUserDetails(token); diff --git a/lib/Screens/group/group.dart b/lib/Screens/group/group.dart index 145726a..bb83be3 100644 --- a/lib/Screens/group/group.dart +++ b/lib/Screens/group/group.dart @@ -263,9 +263,10 @@ class _groupState extends State { if (response.statusCode == 200 || response.statusCode == 201) { print("GRPDATA"); - await apiService.handleTokenRefresh(context, userId!); + print("Group submitted successfully!"); print("Response: ${response.body}"); + await apiService.handleTokenRefresh(context, userId!); context.go('/group'); } else if (response.statusCode == 403) { print("403-FORB"); diff --git a/lib/Screens/group/groupDetails.dart b/lib/Screens/group/groupDetails.dart index 43b0670..083d51b 100644 --- a/lib/Screens/group/groupDetails.dart +++ b/lib/Screens/group/groupDetails.dart @@ -284,9 +284,9 @@ class GroupDataState extends State { print("Response: ${response.body}"); // _clearError(); _clearError(); + await apiService.handleTokenRefresh(context, userId!); await widget.fetchGetGroup(); - await apiService.handleTokenRefresh(context, userId!); if (context.mounted) { Navigator.of(context).pop(); // Close modal only if mounted } @@ -295,11 +295,6 @@ class GroupDataState extends State { }); // dispose(); - } else if (response.statusCode == 403) { - print("403-FORB"); - await apiService.logout(context); - return null; - // throw Exception('Failed to load users'); } else if (response.statusCode == 404) { if (context.mounted) { Navigator.of(context).pop(); diff --git a/lib/Screens/organization/orgSetup.dart b/lib/Screens/organization/orgSetup.dart index 8e312c6..a5c0ac2 100644 --- a/lib/Screens/organization/orgSetup.dart +++ b/lib/Screens/organization/orgSetup.dart @@ -384,7 +384,7 @@ class _OrgSetUpState extends State { if (response.statusCode == 200 || response.statusCode == 201) { print("✅ User submitted successfully!"); print("📨 Response Organizt Update: ${response.body}"); - + await apiService.handleTokenRefresh(context, userId!); final data = json.decode(response.body); if (!data.containsKey('data') || data['data'] is! Map) { @@ -400,7 +400,7 @@ class _OrgSetUpState extends State { print(orgList); await updateOrgDataWithNewValues(orgList); - await apiService.handleTokenRefresh(context, userId!); + print("📨 Response Organizt Update:"); // return orgList; context.go('/OrganizationSettings'); diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index 62c8d9f..6f7b51f 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -851,14 +851,12 @@ class CreateNewPlansState extends State { } catch (e) { throw Exception('Error parsing response: $e'); } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else if (response.statusCode == 404) { + } else if (response.statusCode == 404) { showDialog( context: context, builder: (BuildContext context) { @@ -1023,14 +1021,12 @@ class CreateNewPlansState extends State { } catch (e) { throw Exception('Error parsing response: $e'); } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { throw Exception('Failed to load plans'); } } @@ -1102,14 +1098,12 @@ class CreateNewPlansState extends State { } catch (e) { throw Exception('Error parsing response: $e'); } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { throw Exception('Failed to load plans'); } } @@ -1163,14 +1157,12 @@ class CreateNewPlansState extends State { } catch (e) { throw Exception('Error parsing response: $e'); } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { throw Exception('Failed to load plans'); } } @@ -1222,14 +1214,12 @@ class CreateNewPlansState extends State { } catch (e) { throw Exception('Error parsing response: $e'); } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { throw Exception('Failed to load plans'); } } @@ -1384,14 +1374,12 @@ class CreateNewPlansState extends State { // Close loading dialog (ONLY if still mounted) if (mounted) Navigator.of(context, rootNavigator: true).pop(); context.go('/approvallist'); - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { print("$methodName failed. Status: ${response.statusCode}"); print("Error: ${response.body}"); } @@ -1602,14 +1590,12 @@ class CreateNewPlansState extends State { // ? context.go('/approvallist') // : context.go('/listPlan'); // } - } - else if (response.statusCode == 403) { + } else if (response.statusCode == 403) { print("403-FORB"); await apiService.logout(context); return null; // throw Exception('Failed to load users'); - } - else { + } else { print("Failed to submit plan. Status: ${response.statusCode}"); print("Error: ${response.body}"); @@ -3375,9 +3361,11 @@ class CreateNewPlansState extends State { _showInputDialog(selected["title"]!); } else if (_selectedOption == "Option 1") { otherUserName = userName; - await apiService.handleTripWiseToken(selfId!, context); + // await apiService.handleTripWiseToken(selfId!, context); fetchUserDetails(); _selectedTripType = null; + getSelectedPlanFor(); + fetchUsrDtlFromSelectedTripUser(); dynamicItineraryKey.currentState ?.loadOrgSelectedAlServices(); dynamicItineraryKey.currentState @@ -3777,7 +3765,7 @@ class CreateNewPlansState extends State { keyboardType: TextInputType.text, scrollPhysics: BouncingScrollPhysics(), inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9_ ]')), + FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9_-]')), ], ), ), @@ -4290,7 +4278,6 @@ class CreateNewPlansState extends State { selectedIstravelUser = isTraveller; }); print("USer entered : $otherUserName $userId $isTraveller"); - getSelectedPlanFor(); if (isTraveller) { await apiService.handleTripWiseToken( @@ -4303,7 +4290,7 @@ class CreateNewPlansState extends State { context, ); // fallback to selfId } - + getSelectedPlanFor(); fetchUsrDtlFromSelectedTripUser(); dynamicItineraryKey.currentState?.loadOrgSelectedAlServices(); @@ -4311,7 +4298,7 @@ class CreateNewPlansState extends State { }, onClose: () async { print("Choosede Clsoes"); - await apiService.handleTripWiseToken(selfId!, context); + // await apiService.handleTripWiseToken(selfId!, context); fetchUserDetails(); }, layoutColorForUser: widget.layoutColor!, diff --git a/lib/Screens/userManagement/create_user/create_user.dart b/lib/Screens/userManagement/create_user/create_user.dart index 77c4b75..1e5b9e6 100644 --- a/lib/Screens/userManagement/create_user/create_user.dart +++ b/lib/Screens/userManagement/create_user/create_user.dart @@ -1345,6 +1345,8 @@ class _CreateUserFormDetialsState extends State { print("📨 Response: ${response.body}"); + await apiService.handleTokenRefresh(context, userId!); + if (roleId == "4") { context.go('/listPlan'); } else { diff --git a/lib/Screens/userManagement/create_user/traveller_details.dart b/lib/Screens/userManagement/create_user/traveller_details.dart index 0926b9a..01c886b 100644 --- a/lib/Screens/userManagement/create_user/traveller_details.dart +++ b/lib/Screens/userManagement/create_user/traveller_details.dart @@ -2080,7 +2080,7 @@ class TravellerDetailsState extends State { void pickFileWeb() { html.FileUploadInputElement uploadInput = html.FileUploadInputElement(); // Accept PDFs and common image formats - uploadInput.accept = '.pdf,.jpg,.jpeg,.png,.gif'; + uploadInput.accept = '.pdf,.jpg,.jpeg,.png'; uploadInput.click(); uploadInput.onChange.listen((e) { @@ -2140,6 +2140,18 @@ class TravellerDetailsState extends State { ), ), ), + + SizedBox(height: 5), + Center( + child: Text( + " * Allow types pdf, jpg, jpeg, png and max size 3MB ", + style: GoogleFonts.poppins( + fontSize: 10, + fontWeight: FontWeight.w400, + color: Colors.grey, + ), + ), + ), SizedBox(height: 10), if (passportFile != null || passportFileUrlFromApi != null) // Centers the text diff --git a/lib/services/apiService.dart b/lib/services/apiService.dart index 5fe4572..2e55665 100644 --- a/lib/services/apiService.dart +++ b/lib/services/apiService.dart @@ -33,6 +33,8 @@ class ApiService { if (userData != null) { final pref = await SharedPreferences.getInstance(); + // await pref.clear(); + // print("Clearing Token--"); await pref.setString('auth_token', token); await pref.setString('user_data', jsonEncode(userData)); @@ -94,6 +96,7 @@ class ApiService { final parts = token.split('.'); if (parts.length != 3) throw Exception('Invalid token format'); + print('storeTripUserDetails - $token'); final payload = json.decode( utf8.decode(base64Url.decode(base64Url.normalize(parts[1]))), ); @@ -119,7 +122,7 @@ class ApiService { // print("userData12 - $userRole"); } - await getOrganizationData(context); + // await getOrganizationData(context); } catch (e) { print('Error decoding token: $e'); } @@ -695,7 +698,7 @@ class ApiService { final String apiUrldata = '$apiUrl/api/organizations/find/$orgId'; final token = await getToken(); - + print('ORGFindToken - $token'); if (token == null) { throw Exception('Token not found. Please log in.'); } @@ -850,6 +853,8 @@ class ApiService { final token = await getToken(); + print('handleTripWiseToken OLd - $token'); + final response = await http.get( Uri.parse(apiUrldata), headers: { @@ -866,7 +871,7 @@ class ApiService { final token = data['token']; // Assuming the token is in response // final userId = data['user_id'].toString(); - print("Token - $token"); + print('handleTripWiseToken NEW - $token'); await storeTripUserDetails(context, token); } else if (response.statusCode == 403) { print("403-FORB");