Broken Access

This commit is contained in:
venbaittech 2025-10-29 09:28:12 +05:30
parent aaff31e8d4
commit a838aaeae0
33 changed files with 441 additions and 255 deletions

View File

@ -406,8 +406,10 @@ class _LoginWidgetState extends State<LoginWidget> {
} }
} }
void _clearAllFields() { Future<void> _clearAllFields() async {
print("CLEAR ALL Fields"); print("CLEAR ALL Fields");
final prefs = await SharedPreferences.getInstance();
prefs.clear();
_emailController.clear(); _emailController.clear();
_passwordController.clear(); _passwordController.clear();

View File

@ -78,7 +78,9 @@ class CostCenterListState extends State<CostCenterList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureCostCenter = fetchGetCostCenter(); futureCostCenter = fetchGetCostCenter();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureCostCenter?.then((object) { futureCostCenter?.then((object) {
setState(() { setState(() {
allCostCenter = object; allCostCenter = object;
@ -88,6 +90,9 @@ class CostCenterListState extends State<CostCenterList> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -78,7 +78,9 @@ class DepartmentListState extends State<DepartmentList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureDepartment = fetchGetDepartment(); futureDepartment = fetchGetDepartment();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureDepartment?.then((object) { futureDepartment?.then((object) {
setState(() { setState(() {
allDepartment = object; allDepartment = object;
@ -88,6 +90,9 @@ class DepartmentListState extends State<DepartmentList> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -146,7 +146,9 @@ class _groupState extends State<Group> {
orgId = await getOrgId(); orgId = await getOrgId();
userId = await getUserId(); userId = await getUserId();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
setState(() { setState(() {
apiAllPolicy = result; apiAllPolicy = result;
@ -158,6 +160,9 @@ class _groupState extends State<Group> {
print("Fetched services: $apiAllPolicy"); print("Fetched services: $apiAllPolicy");
print("Domestic policies: $apiForDomestic"); print("Domestic policies: $apiForDomestic");
print("International policies: $apiForInternational"); print("International policies: $apiForInternational");
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print('Error fetching role list: $e'); print('Error fetching role list: $e');
} }

View File

@ -180,7 +180,9 @@ class GroupDataState extends State<GroupData> {
final result = await apiService.fetchAllPolicy(context); final result = await apiService.fetchAllPolicy(context);
userId = await getUserId(); userId = await getUserId();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
setState(() { setState(() {
apiForDomestic = apiForDomestic =
result.where((policy) => policy["domestic"] == "1").toList(); result.where((policy) => policy["domestic"] == "1").toList();
@ -189,6 +191,9 @@ class GroupDataState extends State<GroupData> {
}); });
print("Domestic policies: $apiForDomestic"); print("Domestic policies: $apiForDomestic");
print("International policies: $apiForInternational"); print("International policies: $apiForInternational");
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print('Error fetching role list: $e'); print('Error fetching role list: $e');
} }

View File

@ -124,6 +124,9 @@ class _GroupListState extends State<GroupList> {
Future<void> loadAllGroups() async { Future<void> loadAllGroups() async {
try { try {
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
final result = await apiService.fetchAllGroup(context); final result = await apiService.fetchAllGroup(context);
setState(() { setState(() {
allGroups = result; allGroups = result;
@ -131,6 +134,9 @@ class _GroupListState extends State<GroupList> {
searchController.text = ""; searchController.text = "";
}); });
print("Fetched services: $allGroups"); print("Fetched services: $allGroups");
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print('Error fetching role list: $e'); print('Error fetching role list: $e');
} }

View File

@ -82,7 +82,9 @@ class HotelsDataListState extends State<HotelsDataList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureHotels = fetchGetHotels(); futureHotels = fetchGetHotels();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureHotels?.then((objects) { futureHotels?.then((objects) {
setState(() { setState(() {
allHotels = objects; allHotels = objects;
@ -93,6 +95,9 @@ class HotelsDataListState extends State<HotelsDataList> {
fetchCountryList(); fetchCountryList();
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -140,6 +140,9 @@ class TemplateState extends State<Template> {
} }
if (!mounted) return; if (!mounted) return;
try { try {
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
for (var field in dataHeader) { for (var field in dataHeader) {
controllers[field] = TextEditingController(); controllers[field] = TextEditingController();
} }
@ -147,6 +150,9 @@ class TemplateState extends State<Template> {
updateData(); updateData();
loadinitializeData(); loadinitializeData();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -151,6 +151,9 @@ class TemplateForexState extends State<TemplateForex> {
} }
if (!mounted) return; if (!mounted) return;
try { try {
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
for (var field in dataHeader) { for (var field in dataHeader) {
controllers[field] = TextEditingController(); controllers[field] = TextEditingController();
} }
@ -158,6 +161,9 @@ class TemplateForexState extends State<TemplateForex> {
updateData(); updateData();
loadinitializeData(); loadinitializeData();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -80,7 +80,9 @@ class TemplatesListState extends State<TemplatesList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureTemplates = fetchGetForex(); futureTemplates = fetchGetForex();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureTemplates?.then((users) { futureTemplates?.then((users) {
setState(() { setState(() {
allTemplate = users; allTemplate = users;
@ -91,6 +93,9 @@ class TemplatesListState extends State<TemplatesList> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -70,7 +70,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -78,10 +78,14 @@ class _OrgSetUpState extends State<OrgSetUp> {
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
if (roleUser != null && (roleUser == 'Org Admin')) {
loadAllServices(); loadAllServices();
getOrganizationData(); getOrganizationData();
initializeData(); initializeData();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
} }
void loadInitialData() async { void loadInitialData() async {

View File

@ -81,7 +81,9 @@ class ForexDataListState extends State<ForexDataList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureForex = fetchGetForex(); futureForex = fetchGetForex();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureForex?.then((users) { futureForex?.then((users) {
setState(() { setState(() {
allForex = users; allForex = users;
@ -92,6 +94,9 @@ class ForexDataListState extends State<ForexDataList> {
fetchCountryList(); fetchCountryList();
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -682,11 +682,19 @@ class CreateNewPlansState extends State<CreateNewPlan> {
void handleUpdateData() { void handleUpdateData() {
if (widget.selectedPlanData != null) { if (widget.selectedPlanData != null) {
setState(() { setState(() {
print("updatedPlanDAta - ${widget.selectedPlanData}");
statusValue = widget.selectedPlanData['status_value'] ?? ''; statusValue = widget.selectedPlanData['status_value'] ?? '';
print("STATUS____ : $statusValue"); print("STATUS____ : $statusValue");
print("STATUSplanUsrId____ : ${widget.selectedPlanData['user_id']}");
planUsrId =
widget.selectedPlanData['user_id'] != '0'
? widget.selectedPlanData['user_id']
: widget.selectedPlanData['traveller_id'];
print("STATUSplanUsrId____1 : $planUsrId");
planUsrId = widget.selectedPlanData['user_id'] ?? '';
_tripTitleController.text = widget.selectedPlanData['trip_title'] ?? ''; _tripTitleController.text = widget.selectedPlanData['trip_title'] ?? '';
_descriptionController.text = _descriptionController.text =
widget.selectedPlanData['description'] ?? ''; widget.selectedPlanData['description'] ?? '';
@ -1168,12 +1176,19 @@ class CreateNewPlansState extends State<CreateNewPlan> {
} }
Future<void> fetchTrainFlightClass(int tripId) async { Future<void> fetchTrainFlightClass(int tripId) async {
// final userId =
// (planUsrId?.toString().isNotEmpty == true)
// ? planUsrId.toString()
// : (planTravlrId?.toString().isNotEmpty == true)
// ? planTravlrId.toString()
// : '';
print("TfetchTrainFlightClass");
final userId = final userId =
(planUsrId?.toString().isNotEmpty == true) (planUsrId?.toString().isNotEmpty == true) ? planUsrId.toString() : '';
? planUsrId.toString()
: (planTravlrId?.toString().isNotEmpty == true) print("TfetchTrainFlightClass - $userId");
? planTravlrId.toString()
: '';
// final String apiUrldata = '$apiUrl/api/getDropdownMaster'; // final String apiUrldata = '$apiUrl/api/getDropdownMaster';
final String apiUrldata = final String apiUrldata =

View File

@ -91,8 +91,19 @@ class _ListPlansState extends State<ListPlans> {
if (!msUser) { if (!msUser) {
_popStateListener = html.window.onPopState.listen((event) { _popStateListener = html.window.onPopState.listen((event) {
if (!_dialogShown && mounted) { if (!_dialogShown && mounted) {
print("locationLPw - 1");
print("locationLPw - ${html.window.location}");
final fullUrl = html.window.location.href;
final hashPart =
fullUrl.split('#/').last; // "OrganizationSettings"
print("Current route: $hashPart");
if (hashPart.contains('/listPlan')) {
print("locationLPw - 2r");
_showBackConfirmationDialog(); _showBackConfirmationDialog();
} }
print("locationLPw - 2");
}
// Re-push to prevent leaving // Re-push to prevent leaving
html.window.history.pushState(null, '', html.window.location.href); html.window.history.pushState(null, '', html.window.location.href);
@ -109,7 +120,7 @@ class _ListPlansState extends State<ListPlans> {
void _showBackConfirmationDialog() { void _showBackConfirmationDialog() {
print('List planstt'); print('List planstt');
if (!mounted) return; // if (!mounted) return;
_dialogShown = true; _dialogShown = true;

View File

@ -187,6 +187,10 @@ class _PolicyState extends State<Policy> {
} }
if (!mounted) return; if (!mounted) return;
try { try {
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadinitializeData(); loadinitializeData();
await updateSelectedServices(); await updateSelectedServices();
@ -212,6 +216,9 @@ class _PolicyState extends State<Policy> {
// //
// policyCriteriaKey.currentState?.fetchTrainFlightClass(); // policyCriteriaKey.currentState?.fetchTrainFlightClass();
// } // }
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -74,6 +74,10 @@ class _PolicyListState extends State<PolicyList> {
} }
if (!mounted) return; if (!mounted) return;
try { try {
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futurePolicy = fetchPolicy(); futurePolicy = fetchPolicy();
futurePolicy?.then((object) { futurePolicy?.then((object) {
@ -84,6 +88,9 @@ class _PolicyListState extends State<PolicyList> {
loadInitialData(); loadInitialData();
fetchPolicy(); fetchPolicy();
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -79,6 +79,9 @@ class PurposeOfTravelListState extends State<PurposeOfTravelList> {
try { try {
futurePurposeOfTravel = fetchGetPurposeOfTravel(); futurePurposeOfTravel = fetchGetPurposeOfTravel();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futurePurposeOfTravel?.then((object) { futurePurposeOfTravel?.then((object) {
setState(() { setState(() {
allPurposeOfTravel = object; allPurposeOfTravel = object;
@ -88,6 +91,9 @@ class PurposeOfTravelListState extends State<PurposeOfTravelList> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -185,7 +185,7 @@ class _AdvancePurchaseState extends State<AdvancePurchase>
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -193,10 +193,17 @@ class _AdvancePurchaseState extends State<AdvancePurchase>
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("advance report : $e"); print("advance report : $e");

View File

@ -149,7 +149,7 @@ class _GuestHouseState extends State<GuestHouse>
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -157,10 +157,17 @@ class _GuestHouseState extends State<GuestHouse>
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("guest report : $e"); print("guest report : $e");

View File

@ -150,7 +150,7 @@ class _MISairState extends State<MISair> with SingleTickerProviderStateMixin {
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -158,10 +158,17 @@ class _MISairState extends State<MISair> with SingleTickerProviderStateMixin {
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("Air report : $e"); print("Air report : $e");

View File

@ -120,7 +120,7 @@ class _MISforexState extends State<MISforex>
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -128,10 +128,17 @@ class _MISforexState extends State<MISforex>
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("Forex report : $e"); print("Forex report : $e");

View File

@ -134,7 +134,7 @@ class _MIShotelState extends State<MIShotel>
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -142,10 +142,17 @@ class _MIShotelState extends State<MIShotel>
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("hotel report : $e"); print("hotel report : $e");

View File

@ -47,7 +47,7 @@ class _ReportListState extends State<ReportList> {
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -55,10 +55,17 @@ class _ReportListState extends State<ReportList> {
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
print('_checkAuthAndLoadDataSS - $roleUser');
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("service report : $e"); print("service report : $e");

View File

@ -163,7 +163,7 @@ class _ServicesAnalysisState extends State<ServicesAnalysis>
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -171,10 +171,16 @@ class _ServicesAnalysisState extends State<ServicesAnalysis>
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} }
if (!mounted) return; if (!mounted) return;
try { try {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
}); });
} catch (e) { } catch (e) {
print("service report : $e"); print("service report : $e");

View File

@ -78,7 +78,9 @@ class TravellerListState extends State<TravellerList> {
if (!mounted) return; if (!mounted) return;
try { try {
futureTraveller = fetchGetTraveller(); futureTraveller = fetchGetTraveller();
final roleUser = await getRoleUser();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureTraveller?.then((object) { futureTraveller?.then((object) {
setState(() { setState(() {
allTraveller = object; allTraveller = object;
@ -88,6 +90,9 @@ class TravellerListState extends State<TravellerList> {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
loadInitialData(); loadInitialData();
}); });
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
print("group : $e"); print("group : $e");
} }

View File

@ -355,6 +355,7 @@ class _CreateTravelAgentFormDetialsState
} }
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final roleUser = await getRoleUser();
setState(() { setState(() {
isCheckingToken = true; isCheckingToken = true;
}); });
@ -367,6 +368,8 @@ class _CreateTravelAgentFormDetialsState
return; return;
} }
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
setState(() { setState(() {
isCheckingToken = false; isCheckingToken = false;
}); });
@ -388,7 +391,8 @@ class _CreateTravelAgentFormDetialsState
final extraData = GoRouterState.of(context).extra; final extraData = GoRouterState.of(context).extra;
if (extraData != null && extraData is Map<String, dynamic>) { if (extraData != null && extraData is Map<String, dynamic>) {
setState(() { setState(() {
apiselectedUser = extraData['selectedUser'] as Map<String, dynamic>?; apiselectedUser =
extraData['selectedUser'] as Map<String, dynamic>?;
isViewMode = extraData['isViewMode'] ?? false; isViewMode = extraData['isViewMode'] ?? false;
isEditProfile = extraData['isEditProfile'] ?? false; isEditProfile = extraData['isEditProfile'] ?? false;
}); });
@ -405,6 +409,9 @@ class _CreateTravelAgentFormDetialsState
fetchUsers(); fetchUsers();
fetchRoles(); fetchRoles();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
} }
void _checkAuthAndLoadData22() async { void _checkAuthAndLoadData22() async {

View File

@ -66,7 +66,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -75,7 +75,8 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
return; return;
} else { } else {
futureUsers = fetchUsers(); futureUsers = fetchUsers();
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureUsers.then((users) { futureUsers.then((users) {
setState(() { setState(() {
allUsers = users; allUsers = users;
@ -87,6 +88,9 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
// fetchCountryList(); // fetchCountryList();
// loadInitialData(); // loadInitialData();
// }); // });
} else {
apiService.logout(context);
}
} }
} }

View File

@ -445,6 +445,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
} }
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final roleUser = await getRoleUser();
setState(() { setState(() {
isCheckingToken = true; isCheckingToken = true;
}); });
@ -457,6 +458,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
return; return;
} }
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
setState(() { setState(() {
isCheckingToken = false; isCheckingToken = false;
}); });
@ -478,7 +481,8 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
final extraData = GoRouterState.of(context).extra; final extraData = GoRouterState.of(context).extra;
if (extraData != null && extraData is Map<String, dynamic>) { if (extraData != null && extraData is Map<String, dynamic>) {
setState(() { setState(() {
apiselectedUser = extraData['selectedUser'] as Map<String, dynamic>?; apiselectedUser =
extraData['selectedUser'] as Map<String, dynamic>?;
isViewMode = extraData['isViewMode'] ?? false; isViewMode = extraData['isViewMode'] ?? false;
isEditProfile = extraData['isEditProfile'] ?? false; isEditProfile = extraData['isEditProfile'] ?? false;
}); });
@ -495,6 +499,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
fetchUsers(); fetchUsers();
fetchRoles(); fetchRoles();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
} }
void _checkAuthAndLoadData22() async { void _checkAuthAndLoadData22() async {

View File

@ -1347,7 +1347,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
List<String> nationalityOptions = [ List<String> nationalityOptions = [
"Indian", "Indian",
"International", "International",
"other nationality", "Other Nationality",
]; ];
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -51,7 +51,7 @@ class _UserListScreenState extends State<UserListScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// futureUsers = fetchUsers(); futureUsers = fetchUsers();
// //
// futureUsers.then((users) { // futureUsers.then((users) {
// setState(() { // setState(() {
@ -63,12 +63,13 @@ class _UserListScreenState extends State<UserListScreen> {
// fetchCountryList(); // fetchCountryList();
// loadInitialData(); // loadInitialData();
// }); // });
_checkAuthAndLoadData(); _checkAuthAndLoadData();
} }
void _checkAuthAndLoadData() async { void _checkAuthAndLoadData() async {
final String? token = await getToken(); // Your async function to get token final String? token = await getToken(); // Your async function to get token
final roleUser = await getRoleUser();
if (token == null || token.isEmpty) { if (token == null || token.isEmpty) {
// Token doesn't exist → redirect to login // Token doesn't exist → redirect to login
context.go( context.go(
@ -76,6 +77,8 @@ class _UserListScreenState extends State<UserListScreen> {
); // or use: router.go("/") if you're using `GoRouter` directly ); // or use: router.go("/") if you're using `GoRouter` directly
return; return;
} else { } else {
if (roleUser != null &&
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
futureUsers = fetchUsers(); futureUsers = fetchUsers();
futureUsers.then((users) { futureUsers.then((users) {
@ -85,6 +88,9 @@ class _UserListScreenState extends State<UserListScreen> {
}); });
fetchCountryList(); fetchCountryList();
loadInitialData(); loadInitialData();
} else {
apiService.logout(context);
}
// WidgetsBinding.instance.addPostFrameCallback((_) { // WidgetsBinding.instance.addPostFrameCallback((_) {
// fetchCountryList(); // fetchCountryList();
// loadInitialData(); // loadInitialData();

View File

@ -35,8 +35,8 @@ class _MyAppState extends State<MyApp> {
void initState() { void initState() {
super.initState(); super.initState();
// SemanticsBinding.instance SemanticsBinding.instance
// .ensureSemantics(); // -only for testing uncomment, Otherwise Email Template wont allow to type .ensureSemantics(); // -NOTE:only for testing uncomment, Otherwise Email Template wont allow to type
if (kIsWeb) { if (kIsWeb) {
final uri = Uri.parse(html.window.location.href); final uri = Uri.parse(html.window.location.href);
print("URI - $uri"); print("URI - $uri");

View File

@ -893,7 +893,7 @@ class ApiService {
}) async { }) async {
try { try {
Map<String, dynamic> planData = await getViewPlanEdit(planId, context); Map<String, dynamic> planData = await getViewPlanEdit(planId, context);
print("ViewAAA - $planData"); print("ViewAAA API Service - $planData");
context.go( context.go(
isMyTrips ? '/createPlan' : '/allTrips/trips', isMyTrips ? '/createPlan' : '/allTrips/trips',

View File

@ -83,6 +83,7 @@ class CommentModalState extends State<CommentModal> {
throw Exception('Invalid user ID format.'); throw Exception('Invalid user ID format.');
} }
if (role != null && (role == 'Org Admin' || role == 'Travel Admin')) {
final data = await getRemarks(userId); final data = await getRemarks(userId);
setState(() { setState(() {
@ -92,6 +93,9 @@ class CommentModalState extends State<CommentModal> {
}); });
print("Remarks -"); print("Remarks -");
print("Remarks - ${jsonEncode(remarksData)}"); print("Remarks - ${jsonEncode(remarksData)}");
} else {
apiService.logout(context);
}
} catch (e) { } catch (e) {
setState(() { setState(() {
errorMessage = e.toString(); errorMessage = e.toString();
@ -208,7 +212,7 @@ class CommentModalState extends State<CommentModal> {
await apiService.logout(context); await apiService.logout(context);
return null; return null;
// throw Exception('Failed to load users'); // throw Exception('Failed to load users');
}else { } else {
print("Failed to submit plan. Status: ${response.statusCode}"); print("Failed to submit plan. Status: ${response.statusCode}");
print("Error: ${response.body}"); print("Error: ${response.body}");
} }