Broken Access
This commit is contained in:
parent
aaff31e8d4
commit
a838aaeae0
@ -406,8 +406,10 @@ class _LoginWidgetState extends State<LoginWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
void _clearAllFields() {
|
||||
Future<void> _clearAllFields() async {
|
||||
print("CLEAR ALL Fields");
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.clear();
|
||||
|
||||
_emailController.clear();
|
||||
_passwordController.clear();
|
||||
|
||||
@ -78,16 +78,21 @@ class CostCenterListState extends State<CostCenterList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureCostCenter = fetchGetCostCenter();
|
||||
|
||||
futureCostCenter?.then((object) {
|
||||
setState(() {
|
||||
allCostCenter = object;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureCostCenter?.then((object) {
|
||||
setState(() {
|
||||
allCostCenter = object;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -78,16 +78,21 @@ class DepartmentListState extends State<DepartmentList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureDepartment = fetchGetDepartment();
|
||||
|
||||
futureDepartment?.then((object) {
|
||||
setState(() {
|
||||
allDepartment = object;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureDepartment?.then((object) {
|
||||
setState(() {
|
||||
allDepartment = object;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -146,18 +146,23 @@ class _groupState extends State<Group> {
|
||||
|
||||
orgId = await getOrgId();
|
||||
userId = await getUserId();
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
setState(() {
|
||||
apiAllPolicy = result;
|
||||
|
||||
setState(() {
|
||||
apiAllPolicy = result;
|
||||
|
||||
apiForDomestic =
|
||||
result.where((policy) => policy["domestic"] == "1").toList();
|
||||
apiForInternational =
|
||||
result.where((policy) => policy["international"] == "1").toList();
|
||||
});
|
||||
print("Fetched services: $apiAllPolicy");
|
||||
print("Domestic policies: $apiForDomestic");
|
||||
print("International policies: $apiForInternational");
|
||||
apiForDomestic =
|
||||
result.where((policy) => policy["domestic"] == "1").toList();
|
||||
apiForInternational =
|
||||
result.where((policy) => policy["international"] == "1").toList();
|
||||
});
|
||||
print("Fetched services: $apiAllPolicy");
|
||||
print("Domestic policies: $apiForDomestic");
|
||||
print("International policies: $apiForInternational");
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching role list: $e');
|
||||
}
|
||||
|
||||
@ -180,15 +180,20 @@ class GroupDataState extends State<GroupData> {
|
||||
final result = await apiService.fetchAllPolicy(context);
|
||||
|
||||
userId = await getUserId();
|
||||
|
||||
setState(() {
|
||||
apiForDomestic =
|
||||
result.where((policy) => policy["domestic"] == "1").toList();
|
||||
apiForInternational =
|
||||
result.where((policy) => policy["international"] == "1").toList();
|
||||
});
|
||||
print("Domestic policies: $apiForDomestic");
|
||||
print("International policies: $apiForInternational");
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
setState(() {
|
||||
apiForDomestic =
|
||||
result.where((policy) => policy["domestic"] == "1").toList();
|
||||
apiForInternational =
|
||||
result.where((policy) => policy["international"] == "1").toList();
|
||||
});
|
||||
print("Domestic policies: $apiForDomestic");
|
||||
print("International policies: $apiForInternational");
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching role list: $e');
|
||||
}
|
||||
|
||||
@ -124,13 +124,19 @@ class _GroupListState extends State<GroupList> {
|
||||
|
||||
Future<void> loadAllGroups() async {
|
||||
try {
|
||||
final result = await apiService.fetchAllGroup(context);
|
||||
setState(() {
|
||||
allGroups = result;
|
||||
filteredGroups = result;
|
||||
searchController.text = "";
|
||||
});
|
||||
print("Fetched services: $allGroups");
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
final result = await apiService.fetchAllGroup(context);
|
||||
setState(() {
|
||||
allGroups = result;
|
||||
filteredGroups = result;
|
||||
searchController.text = "";
|
||||
});
|
||||
print("Fetched services: $allGroups");
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching role list: $e');
|
||||
}
|
||||
|
||||
@ -82,17 +82,22 @@ class HotelsDataListState extends State<HotelsDataList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureHotels = fetchGetHotels();
|
||||
|
||||
futureHotels?.then((objects) {
|
||||
setState(() {
|
||||
allHotels = objects;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureHotels?.then((objects) {
|
||||
setState(() {
|
||||
allHotels = objects;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -140,13 +140,19 @@ class TemplateState extends State<Template> {
|
||||
}
|
||||
if (!mounted) return;
|
||||
try {
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
updateData();
|
||||
loadinitializeData();
|
||||
loadInitialData();
|
||||
updateData();
|
||||
loadinitializeData();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -151,13 +151,19 @@ class TemplateForexState extends State<TemplateForex> {
|
||||
}
|
||||
if (!mounted) return;
|
||||
try {
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
updateData();
|
||||
loadinitializeData();
|
||||
loadInitialData();
|
||||
updateData();
|
||||
loadinitializeData();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -80,17 +80,22 @@ class TemplatesListState extends State<TemplatesList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureTemplates = fetchGetForex();
|
||||
|
||||
futureTemplates?.then((users) {
|
||||
setState(() {
|
||||
allTemplate = users;
|
||||
print("AlL tEMPLATESNIT - $allTemplate");
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureTemplates?.then((users) {
|
||||
setState(() {
|
||||
allTemplate = users;
|
||||
print("AlL tEMPLATESNIT - $allTemplate");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -78,10 +78,14 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
loadAllServices();
|
||||
getOrganizationData();
|
||||
initializeData();
|
||||
loadInitialData();
|
||||
if (roleUser != null && (roleUser == 'Org Admin')) {
|
||||
loadAllServices();
|
||||
getOrganizationData();
|
||||
initializeData();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
}
|
||||
|
||||
void loadInitialData() async {
|
||||
|
||||
@ -81,17 +81,22 @@ class ForexDataListState extends State<ForexDataList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureForex = fetchGetForex();
|
||||
|
||||
futureForex?.then((users) {
|
||||
setState(() {
|
||||
allForex = users;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureForex?.then((users) {
|
||||
setState(() {
|
||||
allForex = users;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -682,11 +682,19 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
void handleUpdateData() {
|
||||
if (widget.selectedPlanData != null) {
|
||||
setState(() {
|
||||
print("updatedPlanDAta - ${widget.selectedPlanData}");
|
||||
statusValue = widget.selectedPlanData['status_value'] ?? '';
|
||||
|
||||
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'] ?? '';
|
||||
_descriptionController.text =
|
||||
widget.selectedPlanData['description'] ?? '';
|
||||
@ -1168,12 +1176,19 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
||||
}
|
||||
|
||||
Future<void> fetchTrainFlightClass(int tripId) async {
|
||||
// final userId =
|
||||
// (planUsrId?.toString().isNotEmpty == true)
|
||||
// ? planUsrId.toString()
|
||||
// : (planTravlrId?.toString().isNotEmpty == true)
|
||||
// ? planTravlrId.toString()
|
||||
// : '';
|
||||
|
||||
print("TfetchTrainFlightClass");
|
||||
|
||||
final userId =
|
||||
(planUsrId?.toString().isNotEmpty == true)
|
||||
? planUsrId.toString()
|
||||
: (planTravlrId?.toString().isNotEmpty == true)
|
||||
? planTravlrId.toString()
|
||||
: '';
|
||||
(planUsrId?.toString().isNotEmpty == true) ? planUsrId.toString() : '';
|
||||
|
||||
print("TfetchTrainFlightClass - $userId");
|
||||
|
||||
// final String apiUrldata = '$apiUrl/api/getDropdownMaster';
|
||||
final String apiUrldata =
|
||||
|
||||
@ -91,7 +91,18 @@ class _ListPlansState extends State<ListPlans> {
|
||||
if (!msUser) {
|
||||
_popStateListener = html.window.onPopState.listen((event) {
|
||||
if (!_dialogShown && mounted) {
|
||||
_showBackConfirmationDialog();
|
||||
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();
|
||||
}
|
||||
print("locationLPw - 2");
|
||||
}
|
||||
|
||||
// Re-push to prevent leaving
|
||||
@ -109,7 +120,7 @@ class _ListPlansState extends State<ListPlans> {
|
||||
|
||||
void _showBackConfirmationDialog() {
|
||||
print('List planstt');
|
||||
if (!mounted) return;
|
||||
// if (!mounted) return;
|
||||
|
||||
_dialogShown = true;
|
||||
|
||||
|
||||
@ -187,31 +187,38 @@ class _PolicyState extends State<Policy> {
|
||||
}
|
||||
if (!mounted) return;
|
||||
try {
|
||||
loadinitializeData();
|
||||
final roleUser = await getRoleUser();
|
||||
|
||||
await updateSelectedServices();
|
||||
updateData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadinitializeData();
|
||||
|
||||
loadInitialData();
|
||||
await updateSelectedServices();
|
||||
updateData();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.policy != null) {
|
||||
final details = List<Map<String, dynamic>>.from(
|
||||
widget.policy!['policy_details'],
|
||||
);
|
||||
policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
||||
}
|
||||
});
|
||||
loadInitialData();
|
||||
|
||||
// if (widget.policy != null) {
|
||||
// print("185");
|
||||
// final details = List<Map<String, dynamic>>.from(
|
||||
// widget.policy!['policy_details'],
|
||||
// );
|
||||
// policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
||||
//
|
||||
// policyCriteriaKey.currentState?.fetchTrainFlightClass();
|
||||
// }
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.policy != null) {
|
||||
final details = List<Map<String, dynamic>>.from(
|
||||
widget.policy!['policy_details'],
|
||||
);
|
||||
policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
||||
}
|
||||
});
|
||||
|
||||
// if (widget.policy != null) {
|
||||
// print("185");
|
||||
// final details = List<Map<String, dynamic>>.from(
|
||||
// widget.policy!['policy_details'],
|
||||
// );
|
||||
// policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
||||
//
|
||||
// policyCriteriaKey.currentState?.fetchTrainFlightClass();
|
||||
// }
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -74,16 +74,23 @@ class _PolicyListState extends State<PolicyList> {
|
||||
}
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futurePolicy = fetchPolicy();
|
||||
final roleUser = await getRoleUser();
|
||||
|
||||
futurePolicy?.then((object) {
|
||||
setState(() {
|
||||
allPolicy = object;
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futurePolicy = fetchPolicy();
|
||||
|
||||
futurePolicy?.then((object) {
|
||||
setState(() {
|
||||
allPolicy = object;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
loadInitialData();
|
||||
fetchPolicy();
|
||||
loadInitialData();
|
||||
fetchPolicy();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -79,15 +79,21 @@ class PurposeOfTravelListState extends State<PurposeOfTravelList> {
|
||||
try {
|
||||
futurePurposeOfTravel = fetchGetPurposeOfTravel();
|
||||
|
||||
futurePurposeOfTravel?.then((object) {
|
||||
setState(() {
|
||||
allPurposeOfTravel = object;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futurePurposeOfTravel?.then((object) {
|
||||
setState(() {
|
||||
allPurposeOfTravel = object;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class _AdvancePurchaseState extends State<AdvancePurchase>
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -193,10 +193,17 @@ class _AdvancePurchaseState extends State<AdvancePurchase>
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("advance report : $e");
|
||||
|
||||
@ -149,7 +149,7 @@ class _GuestHouseState extends State<GuestHouse>
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -157,10 +157,17 @@ class _GuestHouseState extends State<GuestHouse>
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("guest report : $e");
|
||||
|
||||
@ -150,7 +150,7 @@ class _MISairState extends State<MISair> with SingleTickerProviderStateMixin {
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -158,10 +158,17 @@ class _MISairState extends State<MISair> with SingleTickerProviderStateMixin {
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("Air report : $e");
|
||||
|
||||
@ -120,7 +120,7 @@ class _MISforexState extends State<MISforex>
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -128,10 +128,17 @@ class _MISforexState extends State<MISforex>
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("Forex report : $e");
|
||||
|
||||
@ -134,7 +134,7 @@ class _MIShotelState extends State<MIShotel>
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -142,10 +142,17 @@ class _MIShotelState extends State<MIShotel>
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("hotel report : $e");
|
||||
|
||||
@ -47,7 +47,7 @@ class _ReportListState extends State<ReportList> {
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -55,10 +55,17 @@ class _ReportListState extends State<ReportList> {
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
print('_checkAuthAndLoadDataSS - $roleUser');
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("service report : $e");
|
||||
@ -177,8 +184,8 @@ class _ReportListState extends State<ReportList> {
|
||||
color: Colors.white,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final route = item['value'] as String;
|
||||
context.go(route);
|
||||
final route = item['value'] as String;
|
||||
context.go(route);
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
|
||||
@ -163,7 +163,7 @@ class _ServicesAnalysisState extends State<ServicesAnalysis>
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -171,10 +171,16 @@ class _ServicesAnalysisState extends State<ServicesAnalysis>
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
try {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print("service report : $e");
|
||||
|
||||
@ -78,16 +78,21 @@ class TravellerListState extends State<TravellerList> {
|
||||
if (!mounted) return;
|
||||
try {
|
||||
futureTraveller = fetchGetTraveller();
|
||||
|
||||
futureTraveller?.then((object) {
|
||||
setState(() {
|
||||
allTraveller = object;
|
||||
final roleUser = await getRoleUser();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureTraveller?.then((object) {
|
||||
setState(() {
|
||||
allTraveller = object;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
loadInitialData();
|
||||
});
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
print("group : $e");
|
||||
}
|
||||
|
||||
@ -355,6 +355,7 @@ class _CreateTravelAgentFormDetialsState
|
||||
}
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final roleUser = await getRoleUser();
|
||||
setState(() {
|
||||
isCheckingToken = true;
|
||||
});
|
||||
@ -367,44 +368,50 @@ class _CreateTravelAgentFormDetialsState
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
isCheckingToken = false;
|
||||
});
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
setState(() {
|
||||
isCheckingToken = false;
|
||||
});
|
||||
|
||||
prepareForNewEntry();
|
||||
selectedTab = "personal";
|
||||
prepareForNewEntry();
|
||||
selectedTab = "personal";
|
||||
|
||||
apiCountryData = null;
|
||||
apiUserData = null;
|
||||
apiCostData = null;
|
||||
apiRoleData = null;
|
||||
apiCountryData = null;
|
||||
apiUserData = null;
|
||||
apiCostData = null;
|
||||
apiRoleData = null;
|
||||
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
/// ✅ Now this is safe here
|
||||
try {
|
||||
final extraData = GoRouterState.of(context).extra;
|
||||
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||
setState(() {
|
||||
apiselectedUser = extraData['selectedUser'] as Map<String, dynamic>?;
|
||||
isViewMode = extraData['isViewMode'] ?? false;
|
||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||
});
|
||||
updateData();
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
} catch (e) {
|
||||
print("Router extra error: $e");
|
||||
}
|
||||
|
||||
// Final async data fetches
|
||||
initializeData();
|
||||
fetchCountries();
|
||||
fetchDepartment();
|
||||
fetchUsers();
|
||||
fetchRoles();
|
||||
loadInitialData();
|
||||
/// ✅ Now this is safe here
|
||||
try {
|
||||
final extraData = GoRouterState.of(context).extra;
|
||||
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||
setState(() {
|
||||
apiselectedUser =
|
||||
extraData['selectedUser'] as Map<String, dynamic>?;
|
||||
isViewMode = extraData['isViewMode'] ?? false;
|
||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||
});
|
||||
updateData();
|
||||
}
|
||||
} catch (e) {
|
||||
print("Router extra error: $e");
|
||||
}
|
||||
|
||||
// Final async data fetches
|
||||
initializeData();
|
||||
fetchCountries();
|
||||
fetchDepartment();
|
||||
fetchUsers();
|
||||
fetchRoles();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
}
|
||||
|
||||
void _checkAuthAndLoadData22() async {
|
||||
|
||||
@ -66,7 +66,7 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -75,18 +75,22 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
|
||||
return;
|
||||
} else {
|
||||
futureUsers = fetchUsers();
|
||||
|
||||
futureUsers.then((users) {
|
||||
setState(() {
|
||||
allUsers = users;
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureUsers.then((users) {
|
||||
setState(() {
|
||||
allUsers = users;
|
||||
});
|
||||
});
|
||||
});
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// fetchCountryList();
|
||||
// loadInitialData();
|
||||
// });
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// fetchCountryList();
|
||||
// loadInitialData();
|
||||
// });
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -445,6 +445,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
}
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final roleUser = await getRoleUser();
|
||||
setState(() {
|
||||
isCheckingToken = true;
|
||||
});
|
||||
@ -457,44 +458,50 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
isCheckingToken = false;
|
||||
});
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
setState(() {
|
||||
isCheckingToken = false;
|
||||
});
|
||||
|
||||
prepareForNewEntry();
|
||||
selectedTab = "personal";
|
||||
prepareForNewEntry();
|
||||
selectedTab = "personal";
|
||||
|
||||
apiCountryData = null;
|
||||
apiUserData = null;
|
||||
apiCostData = null;
|
||||
apiRoleData = null;
|
||||
apiCountryData = null;
|
||||
apiUserData = null;
|
||||
apiCostData = null;
|
||||
apiRoleData = null;
|
||||
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
/// ✅ Now this is safe here
|
||||
try {
|
||||
final extraData = GoRouterState.of(context).extra;
|
||||
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||
setState(() {
|
||||
apiselectedUser = extraData['selectedUser'] as Map<String, dynamic>?;
|
||||
isViewMode = extraData['isViewMode'] ?? false;
|
||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||
});
|
||||
updateData();
|
||||
for (var field in dataHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
} catch (e) {
|
||||
print("Router extra error: $e");
|
||||
}
|
||||
|
||||
// Final async data fetches
|
||||
initializeData();
|
||||
fetchCountries();
|
||||
fetchDepartment();
|
||||
fetchUsers();
|
||||
fetchRoles();
|
||||
loadInitialData();
|
||||
/// ✅ Now this is safe here
|
||||
try {
|
||||
final extraData = GoRouterState.of(context).extra;
|
||||
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||
setState(() {
|
||||
apiselectedUser =
|
||||
extraData['selectedUser'] as Map<String, dynamic>?;
|
||||
isViewMode = extraData['isViewMode'] ?? false;
|
||||
isEditProfile = extraData['isEditProfile'] ?? false;
|
||||
});
|
||||
updateData();
|
||||
}
|
||||
} catch (e) {
|
||||
print("Router extra error: $e");
|
||||
}
|
||||
|
||||
// Final async data fetches
|
||||
initializeData();
|
||||
fetchCountries();
|
||||
fetchDepartment();
|
||||
fetchUsers();
|
||||
fetchRoles();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
}
|
||||
|
||||
void _checkAuthAndLoadData22() async {
|
||||
|
||||
@ -1347,7 +1347,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
List<String> nationalityOptions = [
|
||||
"Indian",
|
||||
"International",
|
||||
"other nationality",
|
||||
"Other Nationality",
|
||||
];
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@ -51,7 +51,7 @@ class _UserListScreenState extends State<UserListScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// futureUsers = fetchUsers();
|
||||
futureUsers = fetchUsers();
|
||||
//
|
||||
// futureUsers.then((users) {
|
||||
// setState(() {
|
||||
@ -63,12 +63,13 @@ class _UserListScreenState extends State<UserListScreen> {
|
||||
// fetchCountryList();
|
||||
// loadInitialData();
|
||||
// });
|
||||
|
||||
_checkAuthAndLoadData();
|
||||
}
|
||||
|
||||
void _checkAuthAndLoadData() async {
|
||||
final String? token = await getToken(); // Your async function to get token
|
||||
|
||||
final roleUser = await getRoleUser();
|
||||
if (token == null || token.isEmpty) {
|
||||
// Token doesn't exist → redirect to login
|
||||
context.go(
|
||||
@ -76,15 +77,20 @@ class _UserListScreenState extends State<UserListScreen> {
|
||||
); // or use: router.go("/") if you're using `GoRouter` directly
|
||||
return;
|
||||
} else {
|
||||
futureUsers = fetchUsers();
|
||||
if (roleUser != null &&
|
||||
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||
futureUsers = fetchUsers();
|
||||
|
||||
futureUsers.then((users) {
|
||||
setState(() {
|
||||
allUsers = users;
|
||||
futureUsers.then((users) {
|
||||
setState(() {
|
||||
allUsers = users;
|
||||
});
|
||||
});
|
||||
});
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
fetchCountryList();
|
||||
loadInitialData();
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// fetchCountryList();
|
||||
// loadInitialData();
|
||||
|
||||
@ -35,8 +35,8 @@ class _MyAppState extends State<MyApp> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// SemanticsBinding.instance
|
||||
// .ensureSemantics(); // -only for testing uncomment, Otherwise Email Template wont allow to type
|
||||
SemanticsBinding.instance
|
||||
.ensureSemantics(); // -NOTE:only for testing uncomment, Otherwise Email Template wont allow to type
|
||||
if (kIsWeb) {
|
||||
final uri = Uri.parse(html.window.location.href);
|
||||
print("URI - $uri");
|
||||
|
||||
@ -893,7 +893,7 @@ class ApiService {
|
||||
}) async {
|
||||
try {
|
||||
Map<String, dynamic> planData = await getViewPlanEdit(planId, context);
|
||||
print("ViewAAA - $planData");
|
||||
print("ViewAAA API Service - $planData");
|
||||
|
||||
context.go(
|
||||
isMyTrips ? '/createPlan' : '/allTrips/trips',
|
||||
|
||||
@ -83,15 +83,19 @@ class CommentModalState extends State<CommentModal> {
|
||||
throw Exception('Invalid user ID format.');
|
||||
}
|
||||
|
||||
final data = await getRemarks(userId);
|
||||
if (role != null && (role == 'Org Admin' || role == 'Travel Admin')) {
|
||||
final data = await getRemarks(userId);
|
||||
|
||||
setState(() {
|
||||
remarksData = data;
|
||||
setState(() {
|
||||
remarksData = data;
|
||||
|
||||
isLoading = false;
|
||||
});
|
||||
print("Remarks -");
|
||||
print("Remarks - ${jsonEncode(remarksData)}");
|
||||
isLoading = false;
|
||||
});
|
||||
print("Remarks -");
|
||||
print("Remarks - ${jsonEncode(remarksData)}");
|
||||
} else {
|
||||
apiService.logout(context);
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
errorMessage = e.toString();
|
||||
@ -203,12 +207,12 @@ class CommentModalState extends State<CommentModal> {
|
||||
if (response.statusCode == 200) {
|
||||
print("Plan submitted successfully!");
|
||||
print("Response: ${response.body}");
|
||||
} 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}");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user