Skip to content

Commit

Permalink
updated some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakibul73 committed Oct 13, 2024
1 parent 5ea3979 commit 27a0ecb
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ class _EditProjectScreenAdminState extends State<EditProjectScreenAdmin> {
_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
Expand Down Expand Up @@ -2468,7 +2468,7 @@ class FormData {
// String studentId = '';
// String studentRegNo = '';
// String studentName = '';
int studentUserID = 0;
int? studentUserID;
// String coPiReferencesOfLatestPublications = '';
// String coPiExperienceInTeaching = '';
// String coPiExperienceInResearch = '';
Expand All @@ -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;
Expand Down Expand Up @@ -2578,10 +2578,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<User>(
name: 'co_pi_name',
initialValue: selectedUser,
Expand All @@ -2591,8 +2592,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<User>(
value: user,
Expand All @@ -2602,7 +2603,7 @@ class _CoPiState extends State<CoPi> {
onChanged: (User? user) {
if (user != null) {
setState(() {
widget.formData.coPiUserID = user.userId;
widget.formData.coPiUserID = user?.userId;
});
}
},
Expand Down Expand Up @@ -2655,10 +2656,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<User>(
name: 'student_name',
initialValue: selectedUser,
Expand All @@ -2668,8 +2670,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<User>(
value: user,
Expand All @@ -2679,7 +2681,7 @@ class _StudentState extends State<Student> {
onChanged: (User? user) {
if (user != null) {
setState(() {
widget.formData.studentUserID = user.userId;
widget.formData.studentUserID = user?.userId;
});
}
},
Expand Down
141 changes: 88 additions & 53 deletions lib/views/screens/admin/project_overview/ViewProjectScreenAdmin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class _ViewProjectScreenAdminState extends State<ViewProjectScreenAdmin> {
_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
Expand Down Expand Up @@ -216,26 +216,36 @@ class _ViewProjectScreenAdminState extends State<ViewProjectScreenAdmin> {
}

// 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(
Expand Down Expand Up @@ -275,41 +285,66 @@ class _ViewProjectScreenAdminState extends State<ViewProjectScreenAdmin> {
_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) {
Expand Down
16 changes: 8 additions & 8 deletions lib/views/screens/user/project_panel/CreateProject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@ class FormData {
// String studentId = '';
// String studentRegNo = '';
// String studentName = '';
int studentUserID = 0;
int? studentUserID;
// String coPiReferencesOfLatestPublications = '';
// String coPiExperienceInTeaching = '';
// String coPiExperienceInResearch = '';
Expand All @@ -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;
Expand Down Expand Up @@ -3027,8 +3027,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<User>(
value: user,
Expand All @@ -3038,7 +3038,7 @@ class _CoPiState extends State<CoPi> {
onChanged: (User? user) {
if (user != null) {
setState(() {
widget.formData.coPiUserID = user.userId;
widget.formData.coPiUserID = user?.userId;
});
}
},
Expand Down Expand Up @@ -3099,8 +3099,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<User>(
value: user,
Expand All @@ -3110,7 +3110,7 @@ class _StudentState extends State<Student> {
onChanged: (User? user) {
if (user != null) {
setState(() {
widget.formData.studentUserID = user.userId;
widget.formData.studentUserID = user?.userId;
});
}
},
Expand Down
Loading

0 comments on commit 27a0ecb

Please sign in to comment.