diff --git a/lib/views/screens/admin/project_overview/EditProjectScreenAdmin.dart b/lib/views/screens/admin/project_overview/EditProjectScreenAdmin.dart index 0cc2369..2187e80 100644 --- a/lib/views/screens/admin/project_overview/EditProjectScreenAdmin.dart +++ b/lib/views/screens/admin/project_overview/EditProjectScreenAdmin.dart @@ -223,8 +223,8 @@ class _EditProjectScreenAdminState extends State { _formData.othersRequired = userDetails['project']['OtherRequired']; // // Signature _formData.piUserID = userDetails['project']['CreatorUserID']; - _formData.coPiUserID = userDetails['project']['CoPiUserID']; - _formData.studentUserID = userDetails['project']['StudentUserID']; + _formData.coPiUserID = userDetails['project']['CoPiUserID'] ?? 0; + _formData.studentUserID = userDetails['project']['StudentUserID'] ?? 0; _formData.piSealLocation = userDetails['project']['CreatorUserSealLocation']; String piSealfilePath = _formData.piSealLocation.isNotEmpty @@ -2468,7 +2468,7 @@ class FormData { // String studentId = ''; // String studentRegNo = ''; // String studentName = ''; - int studentUserID = 0; + int? studentUserID; // String coPiReferencesOfLatestPublications = ''; // String coPiExperienceInTeaching = ''; // String coPiExperienceInResearch = ''; @@ -2483,7 +2483,7 @@ class FormData { // String coPiAddress = ''; // String coPiPhone = ''; // String coPiName = ''; - int coPiUserID = 0; + int? coPiUserID; // String piReferencesOfLatestPublications = ''; // int piExperienceInTeaching = 0; // int piExperienceInResearch = 0; @@ -2578,10 +2578,11 @@ class _CoPiState extends State { } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { - User? selectedUser = snapshot.data?.firstWhere( - (user) => user.userId == widget.formData.coPiUserID, - orElse: () => snapshot.data!.first, - ); + User? selectedUser = widget.formData.coPiUserID != 0 + ? snapshot.data?.firstWhere( + (user) => user.userId == widget.formData.coPiUserID, + ) + : null; return FormBuilderDropdown( name: 'co_pi_name', initialValue: selectedUser, @@ -2591,8 +2592,8 @@ class _CoPiState extends State { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -2602,7 +2603,7 @@ class _CoPiState extends State { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.coPiUserID = user.userId; + widget.formData.coPiUserID = user?.userId; }); } }, @@ -2655,10 +2656,11 @@ class _StudentState extends State { } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { - User? selectedUser = snapshot.data?.firstWhere( - (user) => user.userId == widget.formData.studentUserID, - orElse: () => snapshot.data!.first, - ); + User? selectedUser = widget.formData.studentUserID != 0 + ? snapshot.data?.firstWhere( + (user) => user.userId == widget.formData.studentUserID, + ) + : null; return FormBuilderDropdown( name: 'student_name', initialValue: selectedUser, @@ -2668,8 +2670,8 @@ class _StudentState extends State { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -2679,7 +2681,7 @@ class _StudentState extends State { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.studentUserID = user.userId; + widget.formData.studentUserID = user?.userId; }); } }, diff --git a/lib/views/screens/admin/project_overview/ViewProjectScreenAdmin.dart b/lib/views/screens/admin/project_overview/ViewProjectScreenAdmin.dart index b8558c7..2ca5dc5 100644 --- a/lib/views/screens/admin/project_overview/ViewProjectScreenAdmin.dart +++ b/lib/views/screens/admin/project_overview/ViewProjectScreenAdmin.dart @@ -152,8 +152,8 @@ class _ViewProjectScreenAdminState extends State { _formData.othersRequired = userDetails['project']['OtherRequired']; // // Signature _formData.piUserID = userDetails['project']['CreatorUserID']; - _formData.coPiUserID = userDetails['project']['CoPiUserID']; - _formData.studentUserID = userDetails['project']['StudentUserID']; + _formData.coPiUserID = userDetails['project']['CoPiUserID'] ?? 0; + _formData.studentUserID = userDetails['project']['StudentUserID'] ?? 0; _formData.piSealLocation = userDetails['project']['CreatorUserSealLocation']; String piSealfilePath = _formData.piSealLocation.isNotEmpty @@ -216,26 +216,36 @@ class _ViewProjectScreenAdminState extends State { } // get student user details - final studentUserDetails = await ApiService.getSpecificUser( - _formData.studentUserID, - ); - if (studentUserDetails['statuscode'] == 401) { - // Handle token expiration - final dialog = AwesomeDialog( - context: context, - dialogType: DialogType.error, - desc: "Token expired. Please login again.", - width: kDialogWidth, - btnOkText: 'OK', - btnOkOnPress: () {}, + if (_formData.studentUserID != null && _formData.studentUserID != 0) { + final studentUserDetails = await ApiService.getSpecificUser( + _formData.studentUserID, ); - dialog.show(); + if (studentUserDetails['statuscode'] == 401) { + // Handle token expiration + final dialog = AwesomeDialog( + context: context, + dialogType: DialogType.error, + desc: "Token expired. Please login again.", + width: kDialogWidth, + btnOkText: 'OK', + btnOkOnPress: () {}, + ); + dialog.show(); + } else { + _formData.studentName = studentUserDetails['user']['FirstName'] + ' ' + studentUserDetails['user']['LastName']; + _formData.studentId = studentUserDetails['user']['StudentID'].toString(); + _formData.studentRegNo = studentUserDetails['user']['StudentRegNo'] ?? ''; + _formData.firstEnrollmentSemester = studentUserDetails['user']['FirstEnrollmentSemester'] ?? ''; + _formData.cgpaUndergraduateLevel = studentUserDetails['user']['UndergraduateCGPALevel'] ?? ''; + } + } else { + // Reset student related fields if studentUserID is null or 0 + _formData.studentName = ''; + _formData.studentId = ''; + _formData.studentRegNo = ''; + _formData.firstEnrollmentSemester = ''; + _formData.cgpaUndergraduateLevel = ''; } - _formData.studentName = studentUserDetails['user']['FirstName'] + ' ' + studentUserDetails['user']['LastName']; - _formData.studentId = studentUserDetails['user']['StudentID'].toString(); - _formData.studentRegNo = studentUserDetails['user']['StudentRegNo'] ?? ''; - _formData.firstEnrollmentSemester = studentUserDetails['user']['FirstEnrollmentSemester'] ?? ''; - _formData.cgpaUndergraduateLevel = studentUserDetails['user']['UndergraduateCGPALevel'] ?? ''; // get PI user details final piUserDetails = await ApiService.getSpecificUser( @@ -275,41 +285,66 @@ class _ViewProjectScreenAdminState extends State { _formData.piReferencesOfLatestPublications = piUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; // get CO-PI user details - final coPiUserDetails = await ApiService.getSpecificUser( - _formData.coPiUserID, - ); - if (coPiUserDetails['statuscode'] == 401) { - // Handle token expiration - final dialog = AwesomeDialog( - context: context, - dialogType: DialogType.error, - desc: "Token expired. Please login again.", - width: kDialogWidth, - btnOkText: 'OK', - btnOkOnPress: () {}, + if (_formData.coPiUserID != null && _formData.coPiUserID != 0) { + final coPiUserDetails = await ApiService.getSpecificUser( + _formData.coPiUserID, ); - dialog.show(); + if (coPiUserDetails['statuscode'] == 401) { + // Handle token expiration + final dialog = AwesomeDialog( + context: context, + dialogType: DialogType.error, + desc: "Token expired. Please login again.", + width: kDialogWidth, + btnOkText: 'OK', + btnOkOnPress: () {}, + ); + dialog.show(); + } else { + _formData.coPiName = coPiUserDetails['user']['FirstName'] + ' ' + coPiUserDetails['user']['LastName']; + _formData.coPiPresentAddress = coPiUserDetails['user']['PresentAddress'] ?? ''; + _formData.coPiPermanentAddress = coPiUserDetails['user']['PermanentAddress'] ?? ''; + _formData.coPiPositionEnglish = coPiUserDetails['user']['PositionEnglish'] ?? ''; + _formData.coPiDepartmentName = coPiUserDetails['user']['DepartmentName'] ?? ''; + _formData.coPiFacultyName = coPiUserDetails['user']['FacultyName'] ?? ''; + _formData.coPiBasicPay = coPiUserDetails['user']['BasicPay'].toString(); + _formData.coPiInstituteLocation = coPiUserDetails['user']['InstituteLocation'] ?? ''; + _formData.coPiInstituteName = coPiUserDetails['user']['InstituteName'] ?? ''; + _formData.coPiEmail = coPiUserDetails['user']['Email'] ?? ''; + _formData.coPiPhone = coPiUserDetails['user']['Phone'] ?? ''; + _formData.coPiSalaryScale = coPiUserDetails['user']['SalaryScale'] ?? ''; + _formData.coPiHighestAcademicQualification = coPiUserDetails['user']['HighestAcademicQualification'] ?? ''; + _formData.coPiHighestAcademicQualificationUniversity = coPiUserDetails['user']['HighestAcademicQualificationUniversity'] ?? ''; + _formData.coPiHighestAcademicQualificationCountry = coPiUserDetails['user']['HighestAcademicQualificationCountry'] ?? ''; + _formData.coPiHighestAcademicQualificationYear = coPiUserDetails['user']['HighestAcademicQualificationYear'].toString(); + _formData.coPiAreaOfExpertise = coPiUserDetails['user']['AreaOfExpertise'] ?? ''; + _formData.coPiExperienceInResearch = coPiUserDetails['user']['ExperienceInResearch'].toString(); + _formData.coPiExperienceInTeaching = coPiUserDetails['user']['Teaching'].toString(); + _formData.coPiReferencesOfLatestPublications = coPiUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; + } + } else { + // Reset CO-PI related fields if coPiUserID is null or 0 + _formData.coPiName = ''; + _formData.coPiPresentAddress = ''; + _formData.coPiPermanentAddress = ''; + _formData.coPiPositionEnglish = ''; + _formData.coPiDepartmentName = ''; + _formData.coPiFacultyName = ''; + _formData.coPiBasicPay = ''; + _formData.coPiInstituteLocation = ''; + _formData.coPiInstituteName = ''; + _formData.coPiEmail = ''; + _formData.coPiPhone = ''; + _formData.coPiSalaryScale = ''; + _formData.coPiHighestAcademicQualification = ''; + _formData.coPiHighestAcademicQualificationUniversity = ''; + _formData.coPiHighestAcademicQualificationCountry = ''; + _formData.coPiHighestAcademicQualificationYear = ''; + _formData.coPiAreaOfExpertise = ''; + _formData.coPiExperienceInResearch = ''; + _formData.coPiExperienceInTeaching = ''; + _formData.coPiReferencesOfLatestPublications = ''; } - _formData.coPiName = coPiUserDetails['user']['FirstName'] + ' ' + coPiUserDetails['user']['LastName']; - _formData.coPiPresentAddress = coPiUserDetails['user']['PresentAddress'] ?? ''; - _formData.coPiPermanentAddress = coPiUserDetails['user']['PermanentAddress'] ?? ''; - _formData.coPiPositionEnglish = coPiUserDetails['user']['PositionEnglish'] ?? ''; - _formData.coPiDepartmentName = coPiUserDetails['user']['DepartmentName'] ?? ''; - _formData.coPiFacultyName = coPiUserDetails['user']['FacultyName'] ?? ''; - _formData.coPiBasicPay = coPiUserDetails['user']['BasicPay'].toString(); - _formData.coPiInstituteLocation = coPiUserDetails['user']['InstituteLocation'] ?? ''; - _formData.coPiInstituteName = coPiUserDetails['user']['InstituteName'] ?? ''; - _formData.coPiEmail = coPiUserDetails['user']['Email'] ?? ''; - _formData.coPiPhone = coPiUserDetails['user']['Phone'] ?? ''; - _formData.coPiSalaryScale = coPiUserDetails['user']['SalaryScale'] ?? ''; - _formData.coPiHighestAcademicQualification = coPiUserDetails['user']['HighestAcademicQualification'] ?? ''; - _formData.coPiHighestAcademicQualificationUniversity = coPiUserDetails['user']['HighestAcademicQualificationUniversity'] ?? ''; - _formData.coPiHighestAcademicQualificationCountry = coPiUserDetails['user']['HighestAcademicQualificationCountry'] ?? ''; - _formData.coPiHighestAcademicQualificationYear = coPiUserDetails['user']['HighestAcademicQualificationYear'].toString(); - _formData.coPiAreaOfExpertise = coPiUserDetails['user']['AreaOfExpertise'] ?? ''; - _formData.coPiExperienceInResearch = coPiUserDetails['user']['ExperienceInResearch'].toString(); - _formData.coPiExperienceInTeaching = coPiUserDetails['user']['Teaching'].toString(); - _formData.coPiReferencesOfLatestPublications = coPiUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; final reviewerUserId = await ApiService.getReviewerUserId(projectId); if (reviewerUserId['statuscode'] == 401) { diff --git a/lib/views/screens/user/project_panel/CreateProject.dart b/lib/views/screens/user/project_panel/CreateProject.dart index 59f3119..fc9e357 100644 --- a/lib/views/screens/user/project_panel/CreateProject.dart +++ b/lib/views/screens/user/project_panel/CreateProject.dart @@ -2906,7 +2906,7 @@ class FormData { // String studentId = ''; // String studentRegNo = ''; // String studentName = ''; - int studentUserID = 0; + int? studentUserID; // String coPiReferencesOfLatestPublications = ''; // String coPiExperienceInTeaching = ''; // String coPiExperienceInResearch = ''; @@ -2921,7 +2921,7 @@ class FormData { // String coPiAddress = ''; // String coPiPhone = ''; // String coPiName = ''; - int coPiUserID = 0; + int? coPiUserID; // String piReferencesOfLatestPublications = ''; // int piExperienceInTeaching = 0; // int piExperienceInResearch = 0; @@ -3027,8 +3027,8 @@ class _CoPiState extends State { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -3038,7 +3038,7 @@ class _CoPiState extends State { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.coPiUserID = user.userId; + widget.formData.coPiUserID = user?.userId; }); } }, @@ -3099,8 +3099,8 @@ class _StudentState extends State { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -3110,7 +3110,7 @@ class _StudentState extends State { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.studentUserID = user.userId; + widget.formData.studentUserID = user?.userId; }); } }, diff --git a/lib/views/screens/user/project_panel/EditProjectScreen.dart b/lib/views/screens/user/project_panel/EditProjectScreen.dart index 3905862..10cf44b 100644 --- a/lib/views/screens/user/project_panel/EditProjectScreen.dart +++ b/lib/views/screens/user/project_panel/EditProjectScreen.dart @@ -232,8 +232,8 @@ class _EditProjectScreenState extends State { final firstName = sharedPref.getString(StorageKeys.firstname)!; final lastName = sharedPref.getString(StorageKeys.lastname)!; _formData.piName = "$firstName $lastName"; - _formData.coPiUserID = userDetails['project']['CoPiUserID']; - _formData.studentUserID = userDetails['project']['StudentUserID']; + _formData.coPiUserID = userDetails['project']['CoPiUserID'] ?? 0; + _formData.studentUserID = userDetails['project']['StudentUserID'] ?? 0; _formData.piSealLocation = userDetails['project']['CreatorUserSealLocation']; String piSealfilePath = _formData.piSealLocation.isNotEmpty @@ -2511,7 +2511,7 @@ class FormData { // String studentId = ''; // String studentRegNo = ''; // String studentName = ''; - int studentUserID = 0; + int? studentUserID; // String coPiReferencesOfLatestPublications = ''; // String coPiExperienceInTeaching = ''; // String coPiExperienceInResearch = ''; @@ -2526,7 +2526,7 @@ class FormData { // String coPiAddress = ''; // String coPiPhone = ''; // String coPiName = ''; - int coPiUserID = 0; + int? coPiUserID; // String piReferencesOfLatestPublications = ''; // int piExperienceInTeaching = 0; // int piExperienceInResearch = 0; @@ -2621,10 +2621,11 @@ class _CoPiState extends State<_CoPi> { } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { - User? selectedUser = snapshot.data?.firstWhere( - (user) => user.userId == widget.formData.coPiUserID, - orElse: () => snapshot.data!.first, - ); + User? selectedUser = widget.formData.coPiUserID != 0 + ? snapshot.data?.firstWhere( + (user) => user.userId == widget.formData.coPiUserID, + ) + : null; return FormBuilderDropdown( name: 'co_pi_name', initialValue: selectedUser, @@ -2634,8 +2635,8 @@ class _CoPiState extends State<_CoPi> { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -2645,7 +2646,7 @@ class _CoPiState extends State<_CoPi> { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.coPiUserID = user.userId; + widget.formData.coPiUserID = user?.userId; }); } }, @@ -2698,10 +2699,11 @@ class _StudentState extends State<_Student> { } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { - User? selectedUser = snapshot.data?.firstWhere( - (user) => user.userId == widget.formData.studentUserID, - orElse: () => snapshot.data!.first, - ); + User? selectedUser = widget.formData.studentUserID != 0 + ? snapshot.data?.firstWhere( + (user) => user.userId == widget.formData.studentUserID, + ) + : null; return FormBuilderDropdown( name: 'student_name', initialValue: selectedUser, @@ -2711,8 +2713,8 @@ class _StudentState extends State<_Student> { border: OutlineInputBorder(), floatingLabelBehavior: FloatingLabelBehavior.always, ), - validator: FormBuilderValidators.required(), - autovalidateMode: AutovalidateMode.onUserInteraction, + // validator: FormBuilderValidators.required(), + autovalidateMode: AutovalidateMode.disabled, items: snapshot.data! .map((user) => DropdownMenuItem( value: user, @@ -2722,7 +2724,7 @@ class _StudentState extends State<_Student> { onChanged: (User? user) { if (user != null) { setState(() { - widget.formData.studentUserID = user.userId; + widget.formData.studentUserID = user?.userId; }); } }, diff --git a/lib/views/screens/user/project_panel/ViewProjectScreen.dart b/lib/views/screens/user/project_panel/ViewProjectScreen.dart index 32df09f..0c4ef3d 100644 --- a/lib/views/screens/user/project_panel/ViewProjectScreen.dart +++ b/lib/views/screens/user/project_panel/ViewProjectScreen.dart @@ -152,8 +152,8 @@ class _ViewProjectScreenState extends State { _formData.othersRequired = userDetails['project']['OtherRequired']; // // Signature _formData.piUserID = userDetails['project']['CreatorUserID']; - _formData.coPiUserID = userDetails['project']['CoPiUserID']; - _formData.studentUserID = userDetails['project']['StudentUserID']; + _formData.coPiUserID = userDetails['project']['CoPiUserID'] ?? 0; + _formData.studentUserID = userDetails['project']['StudentUserID'] ?? 0; _formData.piSealLocation = userDetails['project']['CreatorUserSealLocation']; String piSealfilePath = _formData.piSealLocation.isNotEmpty @@ -216,26 +216,36 @@ class _ViewProjectScreenState extends State { } // get student user details - final studentUserDetails = await ApiService.getSpecificUser( - _formData.studentUserID, - ); - if (studentUserDetails['statuscode'] == 401) { - // Handle token expiration - final dialog = AwesomeDialog( - context: context, - dialogType: DialogType.error, - desc: "Token expired. Please login again.", - width: kDialogWidth, - btnOkText: 'OK', - btnOkOnPress: () {}, + if (_formData.studentUserID != null && _formData.studentUserID != 0) { + final studentUserDetails = await ApiService.getSpecificUser( + _formData.studentUserID, ); - dialog.show(); + if (studentUserDetails['statuscode'] == 401) { + // Handle token expiration + final dialog = AwesomeDialog( + context: context, + dialogType: DialogType.error, + desc: "Token expired. Please login again.", + width: kDialogWidth, + btnOkText: 'OK', + btnOkOnPress: () {}, + ); + dialog.show(); + } else { + _formData.studentName = studentUserDetails['user']['FirstName'] + ' ' + studentUserDetails['user']['LastName']; + _formData.studentId = studentUserDetails['user']['StudentID'].toString(); + _formData.studentRegNo = studentUserDetails['user']['StudentRegNo'] ?? ''; + _formData.firstEnrollmentSemester = studentUserDetails['user']['FirstEnrollmentSemester'] ?? ''; + _formData.cgpaUndergraduateLevel = studentUserDetails['user']['UndergraduateCGPALevel'] ?? ''; + } + } else { + // Reset student related fields if studentUserID is null or 0 + _formData.studentName = ''; + _formData.studentId = ''; + _formData.studentRegNo = ''; + _formData.firstEnrollmentSemester = ''; + _formData.cgpaUndergraduateLevel = ''; } - _formData.studentName = studentUserDetails['user']['FirstName'] + ' ' + studentUserDetails['user']['LastName']; - _formData.studentId = studentUserDetails['user']['StudentID'].toString(); - _formData.studentRegNo = studentUserDetails['user']['StudentRegNo'] ?? ''; - _formData.firstEnrollmentSemester = studentUserDetails['user']['FirstEnrollmentSemester'] ?? ''; - _formData.cgpaUndergraduateLevel = studentUserDetails['user']['UndergraduateCGPALevel'] ?? ''; // get PI user details final piUserDetails = await ApiService.getSpecificUser( @@ -275,41 +285,66 @@ class _ViewProjectScreenState extends State { _formData.piReferencesOfLatestPublications = piUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; // get CO-PI user details - final coPiUserDetails = await ApiService.getSpecificUser( - _formData.coPiUserID, - ); - if (coPiUserDetails['statuscode'] == 401) { - // Handle token expiration - final dialog = AwesomeDialog( - context: context, - dialogType: DialogType.error, - desc: "Token expired. Please login again.", - width: kDialogWidth, - btnOkText: 'OK', - btnOkOnPress: () {}, + if (_formData.coPiUserID != null && _formData.coPiUserID != 0) { + final coPiUserDetails = await ApiService.getSpecificUser( + _formData.coPiUserID, ); - dialog.show(); + if (coPiUserDetails['statuscode'] == 401) { + // Handle token expiration + final dialog = AwesomeDialog( + context: context, + dialogType: DialogType.error, + desc: "Token expired. Please login again.", + width: kDialogWidth, + btnOkText: 'OK', + btnOkOnPress: () {}, + ); + dialog.show(); + } else { + _formData.coPiName = coPiUserDetails['user']['FirstName'] + ' ' + coPiUserDetails['user']['LastName']; + _formData.coPiPresentAddress = coPiUserDetails['user']['PresentAddress'] ?? ''; + _formData.coPiPermanentAddress = coPiUserDetails['user']['PermanentAddress'] ?? ''; + _formData.coPiPositionEnglish = coPiUserDetails['user']['PositionEnglish'] ?? ''; + _formData.coPiDepartmentName = coPiUserDetails['user']['DepartmentName'] ?? ''; + _formData.coPiFacultyName = coPiUserDetails['user']['FacultyName'] ?? ''; + _formData.coPiBasicPay = coPiUserDetails['user']['BasicPay'].toString(); + _formData.coPiInstituteLocation = coPiUserDetails['user']['InstituteLocation'] ?? ''; + _formData.coPiInstituteName = coPiUserDetails['user']['InstituteName'] ?? ''; + _formData.coPiEmail = coPiUserDetails['user']['Email'] ?? ''; + _formData.coPiPhone = coPiUserDetails['user']['Phone'] ?? ''; + _formData.coPiSalaryScale = coPiUserDetails['user']['SalaryScale'] ?? ''; + _formData.coPiHighestAcademicQualification = coPiUserDetails['user']['HighestAcademicQualification'] ?? ''; + _formData.coPiHighestAcademicQualificationUniversity = coPiUserDetails['user']['HighestAcademicQualificationUniversity'] ?? ''; + _formData.coPiHighestAcademicQualificationCountry = coPiUserDetails['user']['HighestAcademicQualificationCountry'] ?? ''; + _formData.coPiHighestAcademicQualificationYear = coPiUserDetails['user']['HighestAcademicQualificationYear'].toString(); + _formData.coPiAreaOfExpertise = coPiUserDetails['user']['AreaOfExpertise'] ?? ''; + _formData.coPiExperienceInResearch = coPiUserDetails['user']['ExperienceInResearch'].toString(); + _formData.coPiExperienceInTeaching = coPiUserDetails['user']['Teaching'].toString(); + _formData.coPiReferencesOfLatestPublications = coPiUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; + } + } else { + // Reset CO-PI related fields if coPiUserID is null or 0 + _formData.coPiName = ''; + _formData.coPiPresentAddress = ''; + _formData.coPiPermanentAddress = ''; + _formData.coPiPositionEnglish = ''; + _formData.coPiDepartmentName = ''; + _formData.coPiFacultyName = ''; + _formData.coPiBasicPay = ''; + _formData.coPiInstituteLocation = ''; + _formData.coPiInstituteName = ''; + _formData.coPiEmail = ''; + _formData.coPiPhone = ''; + _formData.coPiSalaryScale = ''; + _formData.coPiHighestAcademicQualification = ''; + _formData.coPiHighestAcademicQualificationUniversity = ''; + _formData.coPiHighestAcademicQualificationCountry = ''; + _formData.coPiHighestAcademicQualificationYear = ''; + _formData.coPiAreaOfExpertise = ''; + _formData.coPiExperienceInResearch = ''; + _formData.coPiExperienceInTeaching = ''; + _formData.coPiReferencesOfLatestPublications = ''; } - _formData.coPiName = coPiUserDetails['user']['FirstName'] + ' ' + coPiUserDetails['user']['LastName']; - _formData.coPiPresentAddress = coPiUserDetails['user']['PresentAddress'] ?? ''; - _formData.coPiPermanentAddress = coPiUserDetails['user']['PermanentAddress'] ?? ''; - _formData.coPiPositionEnglish = coPiUserDetails['user']['PositionEnglish'] ?? ''; - _formData.coPiDepartmentName = coPiUserDetails['user']['DepartmentName'] ?? ''; - _formData.coPiFacultyName = coPiUserDetails['user']['FacultyName'] ?? ''; - _formData.coPiBasicPay = coPiUserDetails['user']['BasicPay'].toString(); - _formData.coPiInstituteLocation = coPiUserDetails['user']['InstituteLocation'] ?? ''; - _formData.coPiInstituteName = coPiUserDetails['user']['InstituteName'] ?? ''; - _formData.coPiEmail = coPiUserDetails['user']['Email'] ?? ''; - _formData.coPiPhone = coPiUserDetails['user']['Phone'] ?? ''; - _formData.coPiSalaryScale = coPiUserDetails['user']['SalaryScale'] ?? ''; - _formData.coPiHighestAcademicQualification = coPiUserDetails['user']['HighestAcademicQualification'] ?? ''; - _formData.coPiHighestAcademicQualificationUniversity = coPiUserDetails['user']['HighestAcademicQualificationUniversity'] ?? ''; - _formData.coPiHighestAcademicQualificationCountry = coPiUserDetails['user']['HighestAcademicQualificationCountry'] ?? ''; - _formData.coPiHighestAcademicQualificationYear = coPiUserDetails['user']['HighestAcademicQualificationYear'].toString(); - _formData.coPiAreaOfExpertise = coPiUserDetails['user']['AreaOfExpertise'] ?? ''; - _formData.coPiExperienceInResearch = coPiUserDetails['user']['ExperienceInResearch'].toString(); - _formData.coPiExperienceInTeaching = coPiUserDetails['user']['Teaching'].toString(); - _formData.coPiReferencesOfLatestPublications = coPiUserDetails['user']['ReferencesOfLatestPublications'] ?? ''; }); }