CHANGE_
This commit is contained in:
parent
4565440151
commit
ecc4dc9371
@ -497,54 +497,81 @@ class _empDetailsState extends State<empDetails> {
|
||||
Future<void> _selectDate(BuildContext context, formType) async {
|
||||
print(formType);
|
||||
var ageValidation = formType['age_validation'];
|
||||
int min =
|
||||
int.parse(ageValidation['min']); // Parsing the string to an integer
|
||||
int max =
|
||||
int.parse(ageValidation['max']); // Parsing the string to an integer
|
||||
print(min);
|
||||
print(max);
|
||||
late DateTime minDate;
|
||||
late DateTime maxDate;
|
||||
print(ageValidation);
|
||||
// Ensure ageValidation is a Map and contains the expected values
|
||||
if (ageValidation is Map<String, dynamic>) {
|
||||
int min = ageValidation.containsKey('min')
|
||||
? int.tryParse(ageValidation['min'].toString()) ?? 0
|
||||
: 0;
|
||||
int max = ageValidation.containsKey('max')
|
||||
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
||||
: 100;
|
||||
|
||||
final DateTime now = DateTime.now();
|
||||
print('Min age: $min');
|
||||
print('Max age: $max');
|
||||
late DateTime minDate;
|
||||
late DateTime maxDate;
|
||||
|
||||
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||
print(maxDate);
|
||||
minDate = DateTime(now.year - max, now.month, now.day);
|
||||
print(minDate);
|
||||
final DateTime now = DateTime.now();
|
||||
|
||||
// if (formType['form_type'] == 'child') {
|
||||
// // For 'child' form type, allow 0-25 age
|
||||
// minDate = DateTime(now.year - 25, now.month, now.day);
|
||||
// maxDate = now;
|
||||
// } else {
|
||||
// // For other form types, allow 18-100 age
|
||||
// minDate = DateTime(1900);
|
||||
// maxDate = DateTime(now.year - 18, now.month, now.day);
|
||||
// }
|
||||
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||
print(maxDate);
|
||||
minDate = DateTime(now.year - max, now.month, now.day);
|
||||
print(minDate);
|
||||
|
||||
// Ensure initialDate is within the range of minDate and maxDate
|
||||
DateTime initialDate =
|
||||
_selectedDate ?? maxDate; // Use maxDate if _selectedDate is null
|
||||
initialDate = initialDate.isBefore(minDate) ? minDate : initialDate;
|
||||
initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate;
|
||||
// if (formType['form_type'] == 'child') {
|
||||
// // For 'child' form type, allow 0-25 age
|
||||
// minDate = DateTime(now.year - 25, now.month, now.day);
|
||||
// maxDate = now;
|
||||
// } else {
|
||||
// // For other form types, allow 18-100 age
|
||||
// minDate = DateTime(1900);
|
||||
// maxDate = DateTime(now.year - 18, now.month, now.day);
|
||||
// }
|
||||
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initialDate,
|
||||
firstDate: minDate,
|
||||
lastDate: maxDate,
|
||||
selectableDayPredicate: (DateTime date) {
|
||||
return date.isAfter(minDate.subtract(const Duration(days: 1))) &&
|
||||
date.isBefore(maxDate.add(const Duration(days: 1)));
|
||||
},
|
||||
);
|
||||
// Ensure initialDate is within the range of minDate and maxDate
|
||||
DateTime initialDate =
|
||||
_selectedDate ?? maxDate; // Use maxDate if _selectedDate is null
|
||||
initialDate = initialDate.isBefore(minDate) ? minDate : initialDate;
|
||||
initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate;
|
||||
|
||||
if (picked != null && picked != _selectedDate) {
|
||||
setState(() {
|
||||
_selectedDate = picked;
|
||||
_dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate);
|
||||
});
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initialDate,
|
||||
firstDate: minDate,
|
||||
lastDate: maxDate,
|
||||
selectableDayPredicate: (DateTime date) {
|
||||
return date.isAfter(minDate.subtract(const Duration(days: 1))) &&
|
||||
date.isBefore(maxDate.add(const Duration(days: 1)));
|
||||
},
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Theme(
|
||||
data: ThemeData.light().copyWith(
|
||||
primaryColor: Color(0xFFE26728), // Header background color
|
||||
colorScheme: ColorScheme.light(
|
||||
primary: Color(0xFFE26728), secondary: Color(0xFFE26728)),
|
||||
buttonTheme: ButtonThemeData(textTheme: ButtonTextTheme.primary),
|
||||
// dialogBackgroundColor:
|
||||
// Colors.white, // Background color of the dialog
|
||||
iconTheme: IconThemeData(color: Color(0xFFE26728)),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Color(0xFFE26728)), // Button color
|
||||
),
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (picked != null && picked != _selectedDate) {
|
||||
setState(() {
|
||||
_selectedDate = picked;
|
||||
_dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
print('Invalid age validation data');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1314,6 +1341,13 @@ class _empDetailsState extends State<empDetails> {
|
||||
)
|
||||
.toList();
|
||||
|
||||
// Set the dropdown value based on the form_type
|
||||
String? dropdownValue;
|
||||
if (floaterData['form_type'] == 'spouse') {
|
||||
dropdownValue = 'Spouse';
|
||||
_relationShipController.text = 'Spouse';
|
||||
}
|
||||
|
||||
print(selectedRelationships);
|
||||
print(gmcMappedFamilyFloaters);
|
||||
if (action == 'Add') {
|
||||
@ -1418,9 +1452,10 @@ class _empDetailsState extends State<empDetails> {
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 5, horizontal: 5),
|
||||
),
|
||||
value: action == 'Edit'
|
||||
? _relationShipController.text
|
||||
: null,
|
||||
value: dropdownValue ??
|
||||
(action == 'Edit'
|
||||
? _relationShipController.text
|
||||
: null),
|
||||
onChanged: (value) {
|
||||
_relationShipController.text = value!;
|
||||
},
|
||||
|
||||
@ -705,12 +705,14 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
isChecked = false;
|
||||
});
|
||||
print('response.statusCode == 200');
|
||||
_showSuccessDialog();
|
||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
// Handle other status codes
|
||||
_showErrorDialog();
|
||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||
print('Request failed with status: ${response['code']}');
|
||||
}
|
||||
@ -723,6 +725,67 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
||||
}
|
||||
}
|
||||
|
||||
void _showSuccessDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
title: Text(
|
||||
'Success',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
content: Text('Enrollment Completed'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
'OK',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFFE26728),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.popAndPushNamed(context, 'empDetails');
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showErrorDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Error',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
content: Text('Something went wrong. Enrollemnt not completed'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
'OK',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFFE26728),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if ((gpaMappedFamilyFloaters == [] && gpaMappedFamilyFloaters == null) &&
|
||||
|
||||
@ -138,14 +138,16 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
}
|
||||
|
||||
Future<void> getEmployeeAndDependence(clintID, getPolicyNo) async {
|
||||
// setState(() {
|
||||
isLoading = true;
|
||||
// });
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
try {
|
||||
final response = await apiService.getEmployeeAndDependenceToApi(
|
||||
clintID!, getPolicyNo!, empRefId!);
|
||||
if (response['status'] == 'success') {
|
||||
isLoading = false;
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
setState(() {
|
||||
getEmpDependenceByClintId =
|
||||
List<Map<String, dynamic>>.from(response['data']);
|
||||
@ -155,13 +157,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
print(filteredData);
|
||||
});
|
||||
} else {
|
||||
isLoading = false;
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
|
||||
// ToastHelper.showWarningToast(
|
||||
// context, 'Request failed with status: ${response.statusCode}');
|
||||
print('Request failed with status: ${response['code']}');
|
||||
}
|
||||
} catch (e) {
|
||||
_isLoading = false;
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
print('Exception occurred: $e');
|
||||
} finally {
|
||||
setState(() {
|
||||
|
||||
@ -88,6 +88,8 @@ flutter:
|
||||
- .env
|
||||
- .env.development
|
||||
- .env.production
|
||||
- .env.uat
|
||||
- .env.test
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
|
||||
Loading…
Reference in New Issue
Block a user