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");
|
print("CLEAR ALL Fields");
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
prefs.clear();
|
||||||
|
|
||||||
_emailController.clear();
|
_emailController.clear();
|
||||||
_passwordController.clear();
|
_passwordController.clear();
|
||||||
|
|||||||
@ -78,16 +78,21 @@ class CostCenterListState extends State<CostCenterList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureCostCenter = fetchGetCostCenter();
|
futureCostCenter = fetchGetCostCenter();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureCostCenter?.then((object) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allCostCenter = object;
|
futureCostCenter?.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allCostCenter = object;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,16 +78,21 @@ class DepartmentListState extends State<DepartmentList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureDepartment = fetchGetDepartment();
|
futureDepartment = fetchGetDepartment();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureDepartment?.then((object) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allDepartment = object;
|
futureDepartment?.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allDepartment = object;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,18 +146,23 @@ 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(() {
|
||||||
|
apiAllPolicy = result;
|
||||||
|
|
||||||
setState(() {
|
apiForDomestic =
|
||||||
apiAllPolicy = result;
|
result.where((policy) => policy["domestic"] == "1").toList();
|
||||||
|
apiForInternational =
|
||||||
apiForDomestic =
|
result.where((policy) => policy["international"] == "1").toList();
|
||||||
result.where((policy) => policy["domestic"] == "1").toList();
|
});
|
||||||
apiForInternational =
|
print("Fetched services: $apiAllPolicy");
|
||||||
result.where((policy) => policy["international"] == "1").toList();
|
print("Domestic policies: $apiForDomestic");
|
||||||
});
|
print("International policies: $apiForInternational");
|
||||||
print("Fetched services: $apiAllPolicy");
|
} else {
|
||||||
print("Domestic policies: $apiForDomestic");
|
apiService.logout(context);
|
||||||
print("International policies: $apiForInternational");
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error fetching role list: $e');
|
print('Error fetching role list: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -180,15 +180,20 @@ 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();
|
||||||
setState(() {
|
if (roleUser != null &&
|
||||||
apiForDomestic =
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
result.where((policy) => policy["domestic"] == "1").toList();
|
setState(() {
|
||||||
apiForInternational =
|
apiForDomestic =
|
||||||
result.where((policy) => policy["international"] == "1").toList();
|
result.where((policy) => policy["domestic"] == "1").toList();
|
||||||
});
|
apiForInternational =
|
||||||
print("Domestic policies: $apiForDomestic");
|
result.where((policy) => policy["international"] == "1").toList();
|
||||||
print("International policies: $apiForInternational");
|
});
|
||||||
|
print("Domestic policies: $apiForDomestic");
|
||||||
|
print("International policies: $apiForInternational");
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error fetching role list: $e');
|
print('Error fetching role list: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,13 +124,19 @@ class _GroupListState extends State<GroupList> {
|
|||||||
|
|
||||||
Future<void> loadAllGroups() async {
|
Future<void> loadAllGroups() async {
|
||||||
try {
|
try {
|
||||||
final result = await apiService.fetchAllGroup(context);
|
final roleUser = await getRoleUser();
|
||||||
setState(() {
|
if (roleUser != null &&
|
||||||
allGroups = result;
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
filteredGroups = result;
|
final result = await apiService.fetchAllGroup(context);
|
||||||
searchController.text = "";
|
setState(() {
|
||||||
});
|
allGroups = result;
|
||||||
print("Fetched services: $allGroups");
|
filteredGroups = result;
|
||||||
|
searchController.text = "";
|
||||||
|
});
|
||||||
|
print("Fetched services: $allGroups");
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error fetching role list: $e');
|
print('Error fetching role list: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,17 +82,22 @@ class HotelsDataListState extends State<HotelsDataList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureHotels = fetchGetHotels();
|
futureHotels = fetchGetHotels();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureHotels?.then((objects) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allHotels = objects;
|
futureHotels?.then((objects) {
|
||||||
|
setState(() {
|
||||||
|
allHotels = objects;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
fetchCountryList();
|
fetchCountryList();
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,13 +140,19 @@ class TemplateState extends State<Template> {
|
|||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
for (var field in dataHeader) {
|
final roleUser = await getRoleUser();
|
||||||
controllers[field] = TextEditingController();
|
if (roleUser != null &&
|
||||||
}
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
for (var field in dataHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
loadinitializeData();
|
loadinitializeData();
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,13 +151,19 @@ class TemplateForexState extends State<TemplateForex> {
|
|||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
for (var field in dataHeader) {
|
final roleUser = await getRoleUser();
|
||||||
controllers[field] = TextEditingController();
|
if (roleUser != null &&
|
||||||
}
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
for (var field in dataHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
loadinitializeData();
|
loadinitializeData();
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,17 +80,22 @@ class TemplatesListState extends State<TemplatesList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureTemplates = fetchGetForex();
|
futureTemplates = fetchGetForex();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureTemplates?.then((users) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allTemplate = users;
|
futureTemplates?.then((users) {
|
||||||
print("AlL tEMPLATESNIT - $allTemplate");
|
setState(() {
|
||||||
|
allTemplate = users;
|
||||||
|
print("AlL tEMPLATESNIT - $allTemplate");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
loadAllServices();
|
if (roleUser != null && (roleUser == 'Org Admin')) {
|
||||||
getOrganizationData();
|
loadAllServices();
|
||||||
initializeData();
|
getOrganizationData();
|
||||||
loadInitialData();
|
initializeData();
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadInitialData() async {
|
void loadInitialData() async {
|
||||||
|
|||||||
@ -81,17 +81,22 @@ class ForexDataListState extends State<ForexDataList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureForex = fetchGetForex();
|
futureForex = fetchGetForex();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureForex?.then((users) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allForex = users;
|
futureForex?.then((users) {
|
||||||
|
setState(() {
|
||||||
|
allForex = users;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
fetchCountryList();
|
fetchCountryList();
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 =
|
||||||
|
|||||||
@ -91,7 +91,18 @@ 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) {
|
||||||
_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
|
// Re-push to prevent leaving
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -187,31 +187,38 @@ class _PolicyState extends State<Policy> {
|
|||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
loadinitializeData();
|
final roleUser = await getRoleUser();
|
||||||
|
|
||||||
await updateSelectedServices();
|
if (roleUser != null &&
|
||||||
updateData();
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadinitializeData();
|
||||||
|
|
||||||
loadInitialData();
|
await updateSelectedServices();
|
||||||
|
updateData();
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
loadInitialData();
|
||||||
if (widget.policy != null) {
|
|
||||||
final details = List<Map<String, dynamic>>.from(
|
|
||||||
widget.policy!['policy_details'],
|
|
||||||
);
|
|
||||||
policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// if (widget.policy != null) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
// print("185");
|
if (widget.policy != null) {
|
||||||
// final details = List<Map<String, dynamic>>.from(
|
final details = List<Map<String, dynamic>>.from(
|
||||||
// widget.policy!['policy_details'],
|
widget.policy!['policy_details'],
|
||||||
// );
|
);
|
||||||
// policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
policyCriteriaKey.currentState?.loadPolicyDetails(details);
|
||||||
//
|
}
|
||||||
// policyCriteriaKey.currentState?.fetchTrainFlightClass();
|
});
|
||||||
// }
|
|
||||||
|
// 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) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,16 +74,23 @@ class _PolicyListState extends State<PolicyList> {
|
|||||||
}
|
}
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futurePolicy = fetchPolicy();
|
final roleUser = await getRoleUser();
|
||||||
|
|
||||||
futurePolicy?.then((object) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allPolicy = object;
|
futurePolicy = fetchPolicy();
|
||||||
|
|
||||||
|
futurePolicy?.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allPolicy = object;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
fetchPolicy();
|
fetchPolicy();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,15 +79,21 @@ class PurposeOfTravelListState extends State<PurposeOfTravelList> {
|
|||||||
try {
|
try {
|
||||||
futurePurposeOfTravel = fetchGetPurposeOfTravel();
|
futurePurposeOfTravel = fetchGetPurposeOfTravel();
|
||||||
|
|
||||||
futurePurposeOfTravel?.then((object) {
|
final roleUser = await getRoleUser();
|
||||||
setState(() {
|
if (roleUser != null &&
|
||||||
allPurposeOfTravel = object;
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
futurePurposeOfTravel?.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allPurposeOfTravel = object;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("advance report : $e");
|
print("advance report : $e");
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("guest report : $e");
|
print("guest report : $e");
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Air report : $e");
|
print("Air report : $e");
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Forex report : $e");
|
print("Forex report : $e");
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("hotel report : $e");
|
print("hotel report : $e");
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("service report : $e");
|
print("service report : $e");
|
||||||
@ -177,8 +184,8 @@ class _ReportListState extends State<ReportList> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final route = item['value'] as String;
|
final route = item['value'] as String;
|
||||||
context.go(route);
|
context.go(route);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
|
|||||||
@ -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((_) {
|
||||||
loadInitialData();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
loadInitialData();
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("service report : $e");
|
print("service report : $e");
|
||||||
|
|||||||
@ -78,16 +78,21 @@ class TravellerListState extends State<TravellerList> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
try {
|
try {
|
||||||
futureTraveller = fetchGetTraveller();
|
futureTraveller = fetchGetTraveller();
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
futureTraveller?.then((object) {
|
if (roleUser != null &&
|
||||||
setState(() {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
allTraveller = object;
|
futureTraveller?.then((object) {
|
||||||
|
setState(() {
|
||||||
|
allTraveller = object;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("group : $e");
|
print("group : $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -355,6 +355,7 @@ class _CreateTravelAgentFormDetialsState
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _checkAuthAndLoadData() async {
|
void _checkAuthAndLoadData() async {
|
||||||
|
final roleUser = await getRoleUser();
|
||||||
setState(() {
|
setState(() {
|
||||||
isCheckingToken = true;
|
isCheckingToken = true;
|
||||||
});
|
});
|
||||||
@ -367,44 +368,50 @@ class _CreateTravelAgentFormDetialsState
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
if (roleUser != null &&
|
||||||
isCheckingToken = false;
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
});
|
setState(() {
|
||||||
|
isCheckingToken = false;
|
||||||
|
});
|
||||||
|
|
||||||
prepareForNewEntry();
|
prepareForNewEntry();
|
||||||
selectedTab = "personal";
|
selectedTab = "personal";
|
||||||
|
|
||||||
apiCountryData = null;
|
apiCountryData = null;
|
||||||
apiUserData = null;
|
apiUserData = null;
|
||||||
apiCostData = null;
|
apiCostData = null;
|
||||||
apiRoleData = null;
|
apiRoleData = null;
|
||||||
|
|
||||||
for (var field in dataHeader) {
|
for (var field in dataHeader) {
|
||||||
controllers[field] = TextEditingController();
|
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();
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
print("Router extra error: $e");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final async data fetches
|
/// ✅ Now this is safe here
|
||||||
initializeData();
|
try {
|
||||||
fetchCountries();
|
final extraData = GoRouterState.of(context).extra;
|
||||||
fetchDepartment();
|
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||||
fetchUsers();
|
setState(() {
|
||||||
fetchRoles();
|
apiselectedUser =
|
||||||
loadInitialData();
|
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 {
|
void _checkAuthAndLoadData22() async {
|
||||||
|
|||||||
@ -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,18 +75,22 @@ class _TravelAgentListScreenState extends State<TravelAgentListScreen> {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
futureUsers = fetchUsers();
|
futureUsers = fetchUsers();
|
||||||
|
if (roleUser != null &&
|
||||||
futureUsers.then((users) {
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
setState(() {
|
futureUsers.then((users) {
|
||||||
allUsers = users;
|
setState(() {
|
||||||
|
allUsers = users;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
fetchCountryList();
|
||||||
fetchCountryList();
|
loadInitialData();
|
||||||
loadInitialData();
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
// fetchCountryList();
|
||||||
// fetchCountryList();
|
// loadInitialData();
|
||||||
// loadInitialData();
|
// });
|
||||||
// });
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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,44 +458,50 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
if (roleUser != null &&
|
||||||
isCheckingToken = false;
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
});
|
setState(() {
|
||||||
|
isCheckingToken = false;
|
||||||
|
});
|
||||||
|
|
||||||
prepareForNewEntry();
|
prepareForNewEntry();
|
||||||
selectedTab = "personal";
|
selectedTab = "personal";
|
||||||
|
|
||||||
apiCountryData = null;
|
apiCountryData = null;
|
||||||
apiUserData = null;
|
apiUserData = null;
|
||||||
apiCostData = null;
|
apiCostData = null;
|
||||||
apiRoleData = null;
|
apiRoleData = null;
|
||||||
|
|
||||||
for (var field in dataHeader) {
|
for (var field in dataHeader) {
|
||||||
controllers[field] = TextEditingController();
|
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();
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
print("Router extra error: $e");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Final async data fetches
|
/// ✅ Now this is safe here
|
||||||
initializeData();
|
try {
|
||||||
fetchCountries();
|
final extraData = GoRouterState.of(context).extra;
|
||||||
fetchDepartment();
|
if (extraData != null && extraData is Map<String, dynamic>) {
|
||||||
fetchUsers();
|
setState(() {
|
||||||
fetchRoles();
|
apiselectedUser =
|
||||||
loadInitialData();
|
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 {
|
void _checkAuthAndLoadData22() async {
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,15 +77,20 @@ 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 {
|
||||||
futureUsers = fetchUsers();
|
if (roleUser != null &&
|
||||||
|
(roleUser == 'Org Admin' || roleUser == 'Travel Admin')) {
|
||||||
|
futureUsers = fetchUsers();
|
||||||
|
|
||||||
futureUsers.then((users) {
|
futureUsers.then((users) {
|
||||||
setState(() {
|
setState(() {
|
||||||
allUsers = users;
|
allUsers = users;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
fetchCountryList();
|
||||||
fetchCountryList();
|
loadInitialData();
|
||||||
loadInitialData();
|
} else {
|
||||||
|
apiService.logout(context);
|
||||||
|
}
|
||||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
// fetchCountryList();
|
// fetchCountryList();
|
||||||
// loadInitialData();
|
// loadInitialData();
|
||||||
|
|||||||
@ -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");
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
@ -83,15 +83,19 @@ class CommentModalState extends State<CommentModal> {
|
|||||||
throw Exception('Invalid user ID format.');
|
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(() {
|
setState(() {
|
||||||
remarksData = data;
|
remarksData = data;
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
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();
|
||||||
@ -203,12 +207,12 @@ class CommentModalState extends State<CommentModal> {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print("Plan submitted successfully!");
|
print("Plan submitted successfully!");
|
||||||
print("Response: ${response.body}");
|
print("Response: ${response.body}");
|
||||||
} else if (response.statusCode == 403) {
|
} else if (response.statusCode == 403) {
|
||||||
print("403-FORB");
|
print("403-FORB");
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user