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 {
|
Future<void> _selectDate(BuildContext context, formType) async {
|
||||||
print(formType);
|
print(formType);
|
||||||
var ageValidation = formType['age_validation'];
|
var ageValidation = formType['age_validation'];
|
||||||
int min =
|
print(ageValidation);
|
||||||
int.parse(ageValidation['min']); // Parsing the string to an integer
|
// Ensure ageValidation is a Map and contains the expected values
|
||||||
int max =
|
if (ageValidation is Map<String, dynamic>) {
|
||||||
int.parse(ageValidation['max']); // Parsing the string to an integer
|
int min = ageValidation.containsKey('min')
|
||||||
print(min);
|
? int.tryParse(ageValidation['min'].toString()) ?? 0
|
||||||
print(max);
|
: 0;
|
||||||
late DateTime minDate;
|
int max = ageValidation.containsKey('max')
|
||||||
late DateTime maxDate;
|
? 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);
|
final DateTime now = DateTime.now();
|
||||||
print(maxDate);
|
|
||||||
minDate = DateTime(now.year - max, now.month, now.day);
|
|
||||||
print(minDate);
|
|
||||||
|
|
||||||
// if (formType['form_type'] == 'child') {
|
maxDate = DateTime(now.year - min, now.month, now.day);
|
||||||
// // For 'child' form type, allow 0-25 age
|
print(maxDate);
|
||||||
// minDate = DateTime(now.year - 25, now.month, now.day);
|
minDate = DateTime(now.year - max, now.month, now.day);
|
||||||
// maxDate = now;
|
print(minDate);
|
||||||
// } else {
|
|
||||||
// // For other form types, allow 18-100 age
|
|
||||||
// minDate = DateTime(1900);
|
|
||||||
// maxDate = DateTime(now.year - 18, now.month, now.day);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Ensure initialDate is within the range of minDate and maxDate
|
// if (formType['form_type'] == 'child') {
|
||||||
DateTime initialDate =
|
// // For 'child' form type, allow 0-25 age
|
||||||
_selectedDate ?? maxDate; // Use maxDate if _selectedDate is null
|
// minDate = DateTime(now.year - 25, now.month, now.day);
|
||||||
initialDate = initialDate.isBefore(minDate) ? minDate : initialDate;
|
// maxDate = now;
|
||||||
initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate;
|
// } 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(
|
// Ensure initialDate is within the range of minDate and maxDate
|
||||||
context: context,
|
DateTime initialDate =
|
||||||
initialDate: initialDate,
|
_selectedDate ?? maxDate; // Use maxDate if _selectedDate is null
|
||||||
firstDate: minDate,
|
initialDate = initialDate.isBefore(minDate) ? minDate : initialDate;
|
||||||
lastDate: maxDate,
|
initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate;
|
||||||
selectableDayPredicate: (DateTime date) {
|
|
||||||
return date.isAfter(minDate.subtract(const Duration(days: 1))) &&
|
|
||||||
date.isBefore(maxDate.add(const Duration(days: 1)));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (picked != null && picked != _selectedDate) {
|
final DateTime? picked = await showDatePicker(
|
||||||
setState(() {
|
context: context,
|
||||||
_selectedDate = picked;
|
initialDate: initialDate,
|
||||||
_dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate);
|
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();
|
.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(selectedRelationships);
|
||||||
print(gmcMappedFamilyFloaters);
|
print(gmcMappedFamilyFloaters);
|
||||||
if (action == 'Add') {
|
if (action == 'Add') {
|
||||||
@ -1418,9 +1452,10 @@ class _empDetailsState extends State<empDetails> {
|
|||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(
|
||||||
vertical: 5, horizontal: 5),
|
vertical: 5, horizontal: 5),
|
||||||
),
|
),
|
||||||
value: action == 'Edit'
|
value: dropdownValue ??
|
||||||
? _relationShipController.text
|
(action == 'Edit'
|
||||||
: null,
|
? _relationShipController.text
|
||||||
|
: null),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
_relationShipController.text = value!;
|
_relationShipController.text = value!;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -705,12 +705,14 @@ class _empReviewDetailsState extends State<empReviewDetails> {
|
|||||||
isChecked = false;
|
isChecked = false;
|
||||||
});
|
});
|
||||||
print('response.statusCode == 200');
|
print('response.statusCode == 200');
|
||||||
|
_showSuccessDialog();
|
||||||
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
// Handle other status codes
|
// Handle other status codes
|
||||||
|
_showErrorDialog();
|
||||||
ToastHelper.showErrorToast(context, 'Failed to Save');
|
ToastHelper.showErrorToast(context, 'Failed to Save');
|
||||||
print('Request failed with status: ${response['code']}');
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if ((gpaMappedFamilyFloaters == [] && gpaMappedFamilyFloaters == null) &&
|
if ((gpaMappedFamilyFloaters == [] && gpaMappedFamilyFloaters == null) &&
|
||||||
|
|||||||
@ -138,14 +138,16 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getEmployeeAndDependence(clintID, getPolicyNo) async {
|
Future<void> getEmployeeAndDependence(clintID, getPolicyNo) async {
|
||||||
// setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
// });
|
});
|
||||||
try {
|
try {
|
||||||
final response = await apiService.getEmployeeAndDependenceToApi(
|
final response = await apiService.getEmployeeAndDependenceToApi(
|
||||||
clintID!, getPolicyNo!, empRefId!);
|
clintID!, getPolicyNo!, empRefId!);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
isLoading = false;
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
setState(() {
|
setState(() {
|
||||||
getEmpDependenceByClintId =
|
getEmpDependenceByClintId =
|
||||||
List<Map<String, dynamic>>.from(response['data']);
|
List<Map<String, dynamic>>.from(response['data']);
|
||||||
@ -155,13 +157,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
print(filteredData);
|
print(filteredData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
isLoading = false;
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
|
||||||
// ToastHelper.showWarningToast(
|
// ToastHelper.showWarningToast(
|
||||||
// context, 'Request failed with status: ${response.statusCode}');
|
// context, 'Request failed with status: ${response.statusCode}');
|
||||||
print('Request failed with status: ${response['code']}');
|
print('Request failed with status: ${response['code']}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_isLoading = false;
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
print('Exception occurred: $e');
|
print('Exception occurred: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@ -88,6 +88,8 @@ flutter:
|
|||||||
- .env
|
- .env
|
||||||
- .env.development
|
- .env.development
|
||||||
- .env.production
|
- .env.production
|
||||||
|
- .env.uat
|
||||||
|
- .env.test
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user