CHANGE_ : GPA changed as dynamic

This commit is contained in:
venbaittech 2024-08-05 12:13:18 +05:30
parent b5d77d2426
commit 62cff8343a
5 changed files with 727 additions and 884 deletions

View File

@ -99,7 +99,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
),
),
// AdaptiveNavBar Column
if (!Responsive.isDesktop(context) && empStatus != 'enrolled')
if (empStatus != 'enrolled')
Expanded(
flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar(
@ -111,9 +111,9 @@ class _CustomAppBarState extends State<CustomAppBar> {
navBarItems: [
if (Responsive.isDesktop(context))
NavBarItem(
text: "Inactive Policy",
text: "",
onTap: () {
Navigator.pushNamed(context, 'oldPolicy');
// Navigator.pushNamed(context, 'oldPolicy');
},
),
NavBarItem(

View File

@ -245,52 +245,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
}
final response = await apiService.getGpaEmpPolicyDetailsToApi(
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
gpaPolicies = response['data'];
print(gpaPolicies);
// Assuming data is a List
print(gpaPolicies);
if (gpaPolicies.isNotEmpty) {
setState(() {
// You can use gpaPolicies as needed
print('GPA Policies found: $gpaPolicies');
gpaPolicyName = gpaPolicies['Policy_Name'].toString();
print(gpaPolicyName);
gpaClintPolicyId = gpaPolicies['ClientPolicyId'].toString();
print(gpaClintPolicyId);
gpasumInsured = gpaPolicies['mapped_family_floaters']['data']
['basic_cover_si'];
print(gpasumInsured);
gpaMappedFamilyFloaters =
gpaPolicies['mapped_family_floaters']['data'];
print(gpaMappedFamilyFloaters);
gpaSelfName = gpaMappedFamilyFloaters['name'].toString() ?? '';
// gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile'];
gpaSelfDob = gpaMappedFamilyFloaters['dob'].toString() ?? '';
gpaSelfRelationship =
gpaMappedFamilyFloaters['relationship'].toString() ?? '';
gpaSelfDetails = gpaSelfName +
' ~ ' +
gpaSelfRelationship +
' ~ ' +
' DOB : ' +
formatDate(gpaSelfDob);
gpaECardDownload = gpaPolicies['eCardDownload'];
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// ToastHelper.showWarningToast(context, 'Something went wrong');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
// ToastHelper.showWarningToast(context, 'Something went wrong');
print('API request failed with status: ${response['status']}');
}
if (response['status'] == 'success') {
setState(() {
gpaPolicies = response['data'];
print('gpaPolicies');
});
} else {
setState(() {
gpaDataIsEmpty = 0;
@ -1797,188 +1757,12 @@ class _addOnsDetailsState extends State<addOnsDetails> {
),
SizedBox(height: 16),
if (gpaPolicies != null && gpaPolicies.length > 0)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gpaPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Row(
children: [
Text(
'Group Personal Accident Coverage',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
),
if (gpaECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
gpaECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${gpasumInsured != null ? gpasumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
gpaSelfDetails ?? '',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
),
],
),
),
],
),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...generateGpaCards(gpaPolicies),
],
),
SizedBox(height: 16),
if (gmcPolicies != null && gmcPolicies.length > 0)
Column(
@ -2087,12 +1871,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
fontSize: Responsive
.isDesktop(
context)
? 18
: 14,
? 20
: 16,
fontWeight:
FontWeight.w600,
),
),
Text(
topUpTypeName ?? '',
'',
textAlign:
TextAlign.left,
style:
@ -2721,13 +2507,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
fontSize: Responsive
.isDesktop(
context)
? 18
: 14,
? 20
: 16,
fontWeight:
FontWeight.w600,
),
),
Text(
topUpParentTypeName ??
'',
'',
textAlign:
TextAlign.left,
style:
@ -2735,10 +2522,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
fontSize: Responsive
.isDesktop(
context)
? 20
: 16,
fontWeight:
FontWeight.w600,
? 18
: 14,
),
),
],
@ -3357,12 +3142,14 @@ class _addOnsDetailsState extends State<addOnsDetails> {
fontSize: Responsive
.isDesktop(
context)
? 18
: 14,
? 20
: 16,
fontWeight:
FontWeight.w600,
),
),
Text(
'Group Medical Coverage - Dependent AddOns',
'',
textAlign:
TextAlign.left,
style: GoogleFonts
@ -3370,10 +3157,8 @@ class _addOnsDetailsState extends State<addOnsDetails> {
fontSize: Responsive
.isDesktop(
context)
? 20
: 16,
fontWeight:
FontWeight.w600,
? 18
: 14,
),
),
],
@ -4590,7 +4375,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
CrossAxisAlignment.start,
children: [
Text(
gmcPolicyName ?? '',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -4602,7 +4387,7 @@ class _addOnsDetailsState extends State<addOnsDetails> {
Row(
children: [
Text(
gmcTypeName ?? '',
gmcPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -4724,4 +4509,198 @@ class _addOnsDetailsState extends State<addOnsDetails> {
return cards;
}
List<Widget> generateGpaCards(List<dynamic> data) {
List<Widget> cards = [];
for (var item in data) {
print('item');
print(item);
String? gpaPolicyName = item['Policy_Name'];
String? gpaECardDownload = item['eCardDownload'];
String? gpaSumInsured;
List<dynamic> gpaMappedFamilyFloaters = [];
if (item['mapped_family_floaters'] != null) {
gpaMappedFamilyFloaters = [item['mapped_family_floaters']];
}
dynamic getTrueObjects = gpaMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true)
.toList();
if (getTrueObjects.length > 0) {
gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"];
} else {
gpaSumInsured = item['Policy_Terms']['sumInsured2'];
}
int gpaOpenForEnrollment = int.parse(item['OpenForEnrollment']);
List<Widget> familyFloaterContainers = [];
for (var floater in gpaMappedFamilyFloaters) {
bool isValueExist = floater['is_value_exist'];
Map<String, dynamic> floaterData = floater['data'];
gpaSelfDetails = floaterData['name'] +
' ~ ' +
floaterData['relationship'] +
' ~ ' +
' DOB : ' +
formatDate(floaterData['dob']);
if (isValueExist) {
familyFloaterContainers.add(
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
gpaSelfDetails ?? '',
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
color: Color(0xFF232526),
),
),
),
],
),
],
),
),
);
}
familyFloaterContainers.add(SizedBox(height: 15));
}
Widget card = Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(0xFFFFF1DD),
borderRadius: BorderRadius.circular(5),
),
padding: EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 13,
),
),
Row(
children: [
Text(
gpaPolicyName ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
if (gpaECardDownload != null)
GestureDetector(
onTap: () async {
Uri uri = Uri.parse(gpaECardDownload);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Icon(
Icons.file_download,
color: Color(0xFFE26728),
size: 25,
),
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 13,
),
),
Text(
'${gpaSumInsured != null ? gpaSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
],
),
),
SizedBox(height: 10),
Column(
children: familyFloaterContainers,
),
],
),
),
);
cards.add(card);
}
return cards;
}
}

View File

@ -48,6 +48,7 @@ class _empDetailsState extends State<empDetails> {
dynamic gpaSelfDetails;
dynamic gpaOpenForEnrollment;
dynamic gpaECardDownload;
dynamic gpaSumInsured;
dynamic gmcECardDownload;
int gmcOpenForEnrollment = 0;
dynamic gmcPolicies;
@ -274,48 +275,14 @@ class _empDetailsState extends State<empDetails> {
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
setState(() {
gpaPolicies = response['data'];
print('gpaPolicies');
// Assuming data is a List
print(gpaPolicies);
if (gpaPolicies.isNotEmpty) {
setState(() {
// You can use gpaPolicies as needed
print('GPA Policies found: $gpaPolicies');
gpaPolicyName = gpaPolicies['Policy_Name'].toString();
print(gpaPolicyName);
gpasumInsured = gpaPolicies['mapped_family_floaters']['data']
['basic_cover_si'];
print(gpasumInsured);
gpaMappedFamilyFloaters =
gpaPolicies['mapped_family_floaters']['data'];
print(gpaMappedFamilyFloaters);
gpaSelfName = gpaMappedFamilyFloaters['name'].toString();
// gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile'];
gpaSelfDob = gpaMappedFamilyFloaters['dob'].toString();
gpaSelfRelationship =
gpaMappedFamilyFloaters['relationship'].toString();
gpaSelfDetails = gpaSelfRelationship + ' . ' + gpaSelfDob;
gpaOpenForEnrollment = gpaPolicies['OpenForEnrollment'];
gpaECardDownload = gpaPolicies['eCardDownload'];
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// ToastHelper.showErrorToast(context, 'Something went wrong');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
// ToastHelper.showErrorToast(context, 'Something went wrong');
print('API request failed with status: ${response['status']}');
}
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// Handle other status codes
ToastHelper.showWarningToast(context, 'Something went wrong');
print('Request failed with status: ${response['code']}');
@ -781,340 +748,12 @@ class _empDetailsState extends State<empDetails> {
),
SizedBox(height: 16),
if (gpaPolicies != null && gpaPolicies.length > 0)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gpaPolicyName ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Row(
children: [
Text(
'Group Personal Accident Coverage',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
),
if (gpaECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
gpaECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${gpasumInsured != null ? gpasumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 10),
// Container(
// padding: EdgeInsets.only(
// top: 0, bottom: 0, left: 10, right: 10),
// child: Text(
// 'This is a floater sum insured. A floater is a type ot sum insured that provides coverage to more than one member ot a tamily at the same time. Simply put, its a single insurance cover tor the entire family.',
// style: TextStyle(
// fontSize:
// Responsive.isDesktop(context) ? 14 : 11,
// color: Color(0xFF727272),
// )),
// ),
SizedBox(
height:
Responsive.isDesktop(context) ? 15 : 15),
// Container(
// decoration: BoxDecoration(
// color: Color(
// 0xFFF9F9FB), // Set background color for the container
// borderRadius: BorderRadius.circular(
// 5), // Set border radius for the container
// ),
// padding: EdgeInsets.only(
// top: 15, bottom: 15, left: 25, right: 25),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Expanded(
// flex: 12,
// child: Container(
// alignment: Alignment.centerLeft,
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.start,
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// Text(
// 'Please Note',
// textAlign: TextAlign.left,
// style: TextStyle(
// fontSize: 18,
// fontWeight: FontWeight.w600,
// ),
// ),
// Text(
// 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
// textAlign: TextAlign.left,
// style: TextStyle(
// fontSize: 18,
// ),
// ),
// ],
// ))),
// ],
// ),
// ),
Container(
decoration: BoxDecoration(
border: Border.all(
color:
Color(0xFF000000), // Set border color
width: 1, // Set border width
),
// Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 8, bottom: 8, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: Responsive.isDesktop(context)
? 1
: 2,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
padding: Responsive.isDesktop(
context)
? EdgeInsets.all(10)
: EdgeInsets.all(
5), // Padding around the icon
decoration: BoxDecoration(
color: Color(
0xFF00989E), // Background color of the icon container
borderRadius:
BorderRadius.circular(
5), // Radius of the container
),
child: Icon(
Icons
.account_circle, // Icon data
color: Colors.white,
size:
32, // Color of the icon
),
),
],
))),
Expanded(
flex: Responsive.isDesktop(context)
? 9
: 8,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gpaSelfName ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
fontWeight: FontWeight.w600,
),
),
Text(
gpaSelfDetails ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 16,
),
),
],
))),
Expanded(
flex: 2,
child: Container(
alignment: Alignment.topRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
MouseRegion(
cursor:
SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
openSelfForm('View');
},
child: Text(
'View',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 16
: 15,
color: Color(
0xFFE26728), // Add underline decoration
),
),
),
)
],
))),
],
),
),
],
),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...generateGpaCards(gpaPolicies),
],
),
SizedBox(height: 16),
if (gmcPolicies != null && gmcPolicies.length > 0)
Column(
@ -1917,6 +1556,262 @@ class _empDetailsState extends State<empDetails> {
);
}
List<Widget> generateGpaCards(List<dynamic> data) {
List<Widget> cards = [];
for (var item in data) {
print('item');
print(item);
String? gpaPolicyName = item['Policy_Name'];
String? gpaECardDownload = item['eCardDownload'];
String? gpaSumInsured;
List<dynamic> gpaMappedFamilyFloaters = [];
if (item['mapped_family_floaters'] != null) {
gpaMappedFamilyFloaters = [item['mapped_family_floaters']];
}
dynamic getTrueObjects = gpaMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true)
.toList();
if (getTrueObjects.length > 0) {
gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"];
} else {
gpaSumInsured = item['Policy_Terms']['sumInsured2'];
}
int gpaOpenForEnrollment = int.parse(item['OpenForEnrollment']);
List<Widget> familyFloaterContainers = [];
for (var floater in gpaMappedFamilyFloaters) {
bool isValueExist = floater['is_value_exist'];
Map<String, dynamic> floaterData = floater['data'];
if (isValueExist) {
familyFloaterContainers.add(Container(
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFF000000),
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
padding: Responsive.isDesktop(context)
? EdgeInsets.all(15)
: EdgeInsets.only(top: 8, bottom: 8, left: 10, right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: Responsive.isDesktop(context) ? 1 : 2,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(10)
: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Color(0xFF00989E),
borderRadius: BorderRadius.circular(5),
),
child: Icon(
Icons.account_circle,
color: Colors.white,
size: 32,
),
),
],
),
),
),
Expanded(
flex: 8,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
floaterData['name'] ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
fontWeight: FontWeight.w600,
),
),
Text(
'${floaterData['relationship']} - ${floaterData['dob']}' ??
'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
),
),
],
),
),
),
Expanded(
flex: 2,
child: Container(
alignment: Alignment.topRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
openSelfForm('View');
},
child: Text(
'View',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 16 : 15,
color: Color(0xFFE26728),
),
),
),
)
],
),
),
),
],
),
));
}
familyFloaterContainers.add(SizedBox(height: 15));
}
Widget card = Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(0xFFFFF1DD),
borderRadius: BorderRadius.circular(5),
),
padding: EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 13,
),
),
Row(
children: [
Text(
gpaPolicyName ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
if (gpaECardDownload != null)
GestureDetector(
onTap: () async {
Uri uri = Uri.parse(gpaECardDownload);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Icon(
Icons.file_download,
color: Color(0xFFE26728),
size: 25,
),
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 13,
),
),
Text(
'${gpaSumInsured != null ? gpaSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
],
),
),
SizedBox(height: 10),
Column(
children: familyFloaterContainers,
),
],
),
),
);
cards.add(card);
}
return cards;
}
List<Widget> generateCards(List<dynamic> data) {
List<Widget> cards = [];
@ -2221,7 +2116,7 @@ class _empDetailsState extends State<empDetails> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
gmcPolicyName ?? 'NA',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context)
@ -2232,7 +2127,7 @@ class _empDetailsState extends State<empDetails> {
Row(
children: [
Text(
gmcTypeName ?? '',
gmcPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:

View File

@ -300,63 +300,18 @@ class _empReviewDetailsState extends State<empReviewDetails> {
}
final response = await apiService.getGpaEmpPolicyDetailsToApi(
empPrimaryId, empCodeString!, client_id!, 'GPA', empClientBranchId!);
if (response['status'] == 'success') {
if (response.containsKey('data')) {
setState(() {
gpaPolicies = response['data'];
print(gpaPolicies);
// Assuming data is a List
print(gpaPolicies);
if (gpaPolicies.isNotEmpty) {
setState(() {
// You can use gpaPolicies as needed
print('GPA Policies found: $gpaPolicies');
gpaPolicyName = gpaPolicies['Policy_Name'];
print(gpaPolicyName);
gpasumInsured = gpaPolicies['mapped_family_floaters']['data']
['basic_cover_si'];
print(gpasumInsured);
gpaMappedFamilyFloaters =
gpaPolicies['mapped_family_floaters']['data'];
print(gpaMappedFamilyFloaters);
gpaSelfName = gpaMappedFamilyFloaters['name'];
// gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile'];
gpaSelfDob = gpaMappedFamilyFloaters['dob'];
gpaSelfRelationship = gpaMappedFamilyFloaters['relationship'];
gpaSelfDetails = gpaSelfName +
' ~ ' +
gpaSelfRelationship +
' ~ ' +
' DOB : ' +
formatDate(gpaSelfDob);
// gpaGridMaster = await gpaPolicies[0]['GridMaster'];
// gpaSlabRates = await gpaPolicies[0]['SlabRates'];
gpaClintPolicyId = gpaPolicies['ClientPolicyId'];
gpaECardDownload = gpaPolicies['eCardDownload'];
// gpaSelectedSI =
// gpaMappedFamilyFloaters['basic_cover_si'].toString();
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// ToastHelper.showWarningToast(context, 'No data found');
print('No data found in the response');
}
} else {
// Handle other status messages if needed
ToastHelper.showWarningToast(context, 'Something went wrong');
print('API request failed with status: ${response['status']}');
}
print('gpaPolicies');
});
} else {
setState(() {
gpaDataIsEmpty = 0;
});
// Handle other status codes
ToastHelper.showErrorToast(context, 'Something went wrong');
ToastHelper.showWarningToast(context, 'Something went wrong');
print('Request failed with status: ${response['code']}');
}
} catch (e) {
@ -992,188 +947,12 @@ class _empReviewDetailsState extends State<empReviewDetails> {
),
SizedBox(height: 16),
if (gpaPolicies != null && gpaPolicies.length > 0)
Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(
0xFFFFF1DD), // Set background color for the container
borderRadius: BorderRadius.circular(
5), // Set border radius for the container
),
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 15,
bottom: 15,
left: 25,
right: 25)
: EdgeInsets.only(
top: 10,
bottom: 10,
left: 10,
right: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
gpaPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Row(
children: [
Text(
'Group Personal Accident Coverage',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
fontSize: Responsive
.isDesktop(
context)
? 20
: 14,
fontWeight:
FontWeight.w600,
),
),
if (gpaECardDownload !=
null)
GestureDetector(
onTap: () async {
// Convert the URL string to a Uri object
Uri uri = Uri.parse(
gpaECardDownload);
// Check if the URL is valid
if (await canLaunchUrl(
uri)) {
// Open the URL in the default browser
await launchUrl(
uri);
} else {
// Handle the case where the URL cannot be launched
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor:
SystemMouseCursors
.click,
child: Icon(
Icons.file_download,
color: Color(
0xFFE26728),
size: 25,
),
),
),
],
),
],
))),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 18
: 13,
),
),
Text(
'${gpasumInsured != null ? gpasumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(
context)
? 20
: 14,
fontWeight: FontWeight.w600,
),
),
],
))),
],
),
),
SizedBox(height: 15),
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(
top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(
0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
gpaSelfDetails ?? '',
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context)
? 18
: 16,
color: Color(0xFF232526),
),
),
),
],
),
],
),
),
],
),
)),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...generateGpaCards(gpaPolicies),
],
),
SizedBox(height: 16),
if (gmcPolicies != null && gmcPolicies.length > 0)
Column(
@ -1258,7 +1037,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
CrossAxisAlignment.start,
children: [
Text(
topUpPolicyName ?? '',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -1271,7 +1050,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
Row(
children: [
Text(
'Group Medical Coverage - Top Up',
topUpPolicyName ?? '',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
@ -1481,7 +1260,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
CrossAxisAlignment.start,
children: [
Text(
topUpParentPolicyName ?? '',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -1497,7 +1276,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
children: [
Flexible(
child: Text(
topUpParentTypeName ??
topUpParentPolicyName ??
'',
textAlign:
TextAlign.left,
@ -1718,8 +1497,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
CrossAxisAlignment.start,
children: [
Text(
addOnsDependentPolicyName ??
'',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -1732,7 +1510,8 @@ class _empReviewDetailsState extends State<empReviewDetails> {
Row(
children: [
Text(
'Group Medical Coverage - Dependent AddOns',
addOnsDependentPolicyName ??
'',
textAlign: TextAlign.left,
style:
GoogleFonts.poppins(
@ -2018,10 +1797,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
padding:
EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(
(Responsive.isDesktop(
context)
? topUpTypeName
: 'GMC - Top Up',
? (topUpPolicyName ??
'Default Top Up Name')
: 'GMC - Top Up'),
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
@ -2103,10 +1883,11 @@ class _empReviewDetailsState extends State<empReviewDetails> {
padding:
EdgeInsets.all(8.0),
child: Text(
Responsive.isDesktop(
(Responsive.isDesktop(
context)
? topUpParentTypeName
: 'GMC - Parents Top Up',
? (topUpParentPolicyName ??
'Default Parent Top Up Name')
: 'GMC - Parents Top Up'),
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
@ -2190,8 +1971,9 @@ class _empReviewDetailsState extends State<empReviewDetails> {
child: Text(
Responsive.isDesktop(
context)
? 'Group Medical Coverage - Add Dependent'
: 'GMC - Dependent ',
? (addOnsDependentPolicyName ??
'Default Add Dependent Up Name')
: 'GMC - Dependent',
textAlign:
TextAlign.start,
style: GoogleFonts.poppins(
@ -2534,6 +2316,199 @@ class _empReviewDetailsState extends State<empReviewDetails> {
}
}
List<Widget> generateGpaCards(List<dynamic> data) {
List<Widget> cards = [];
for (var item in data) {
print('item');
print(item);
String? gpaPolicyName = item['Policy_Name'];
String? gpaECardDownload = item['eCardDownload'];
String? gpaSumInsured;
List<dynamic> gpaMappedFamilyFloaters = [];
if (item['mapped_family_floaters'] != null) {
gpaMappedFamilyFloaters = [item['mapped_family_floaters']];
}
dynamic getTrueObjects = gpaMappedFamilyFloaters
.where((element) => element['is_value_exist'] == true)
.toList();
if (getTrueObjects.length > 0) {
gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"];
} else {
gpaSumInsured = item['Policy_Terms']['sumInsured2'];
}
int gpaOpenForEnrollment = int.parse(item['OpenForEnrollment']);
List<Widget> familyFloaterContainers = [];
for (var floater in gpaMappedFamilyFloaters) {
bool isValueExist = floater['is_value_exist'];
Map<String, dynamic> floaterData = floater['data'];
gpaSelfDetails = floaterData['name'] +
' ~ ' +
floaterData['relationship'] +
' ~ ' +
' DOB : ' +
formatDate(floaterData['dob']);
if (isValueExist) {
familyFloaterContainers.add(
Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15)
: EdgeInsets.only(top: 0, bottom: 0, left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.arrow_right,
color: Color(0xFFE26728)), // Arrow icon
SizedBox(
width: Responsive.isDesktop(context)
? 10
: 5), // Space between icon and text
Expanded(
child: Text(
gpaSelfDetails ?? '',
style: GoogleFonts.poppins(
fontSize: Responsive.isDesktop(context) ? 18 : 16,
color: Color(0xFF232526),
),
),
),
],
),
],
),
),
);
}
familyFloaterContainers.add(SizedBox(height: 15));
}
Widget card = Card(
elevation: 0,
color: Colors.white,
child: Padding(
padding: Responsive.isDesktop(context)
? EdgeInsets.all(30)
: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Color(0xFFFFF1DD),
borderRadius: BorderRadius.circular(5),
),
padding: EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 9,
child: Container(
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize: 13,
),
),
Row(
children: [
Text(
gpaPolicyName ?? 'NA',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
if (gpaECardDownload != null)
GestureDetector(
onTap: () async {
Uri uri = Uri.parse(gpaECardDownload);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
print(
'Could not launch $gpaECardDownload');
}
},
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Icon(
Icons.file_download,
color: Color(0xFFE26728),
size: 25,
),
),
),
],
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'Sum Insured',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 18 : 13,
),
),
Text(
'${gpaSumInsured != null ? gpaSumInsured : 'NA'}',
textAlign: TextAlign.right,
style: GoogleFonts.poppins(
fontSize:
Responsive.isDesktop(context) ? 20 : 14,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
],
),
),
SizedBox(height: 10),
Column(
children: familyFloaterContainers,
),
],
),
),
);
cards.add(card);
}
return cards;
}
List<Widget> generateGmcCards(List<dynamic> data) {
List<Widget> cards = [];
@ -2603,7 +2578,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
CrossAxisAlignment.start,
children: [
Text(
gmcPolicyName ?? '',
'',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:
@ -2615,7 +2590,7 @@ class _empReviewDetailsState extends State<empReviewDetails> {
Row(
children: [
Text(
gmcTypeName ?? '',
gmcPolicyName ?? '',
textAlign: TextAlign.left,
style: GoogleFonts.poppins(
fontSize:

View File

@ -109,18 +109,12 @@ class _loginState extends State<login> {
var countryCode = countryController.text;
prefs.setString('empMobileNo', enteredMobileNumber);
// await FirebaseAuth.instance.verifyPhoneNumber(
// phoneNumber: '${countryCode + enteredMobileNumber}',
// verificationCompleted: (PhoneAuthCredential credential) {},
// verificationFailed: (FirebaseAuthException e) {},
// codeSent: (String verificationId, int? resendToken) {},
// codeAutoRetrievalTimeout: (String verificationId) {},
//
_verifyPhoneNumber();
// ToastHelper.showSuccessToast(context, message);
// Navigator.pushNamed(context, 'verify',
// arguments: enteredMobileNumber);
ToastHelper.showSuccessToast(context, message);
setState(() {
_isLoading = false;
});
} else {
setState(() {
_isLoading = false;