diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 67e589f..957b86b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,9 @@ + + + + + { - bool _gmcDependentSwitcher = false; // Declare the _isSwitched variable here - bool _gmcSiSwitcher = false; + bool isChecked = false; + bool _addOnsDependentSwitcher = + false; // Declare the _isSwitched variable here + bool _topUpSiSwitcher = false; + bool _topUpParentSiSwitcher = false; dynamic _token; dynamic empCodeString; dynamic empPrimaryId; dynamic gpaEmpName; dynamic client_id; - List> gpaPolicies = []; + dynamic gpaPolicies; + dynamic gmcPolicies; dynamic gpaPolicyName; dynamic gpaGridMaster; dynamic gpasumInsured; @@ -37,6 +43,9 @@ class _addOnsDetailsState extends State { dynamic gpaSelfDob; dynamic gpaSelfRelationship; dynamic gpaSelfDetails; + dynamic gpaECardDownload; + dynamic gmcECardDownload; + dynamic gmcClintPolicyId; dynamic gmcMappedFamilyFloaters; dynamic gmcSelfName; dynamic gmcSelfDob; @@ -45,24 +54,55 @@ class _addOnsDetailsState extends State { dynamic gmcPolicyName; dynamic gmcNotes; dynamic gmcSumInsured; + dynamic gmcFloaterTextDescription; + dynamic gmcFloaterTextHeading; + dynamic gmcTypeName; dynamic clientName; dynamic clientLogo; - dynamic addOnsMappedFamilyFloatersSi; - dynamic addOnsMappedFamilyFloatersDependent; - dynamic addOnsClientPolicyId; - dynamic addOnsSlabRates; - dynamic gmcAddOnsselectedSI; - dynamic gmcAddOnsselectedDependent; - dynamic dependentValue; + dynamic topUpECardDownload; + dynamic topUpMappedFamilyFloatersSi; + dynamic topUpMappedFamilyFloatersDependent; + dynamic topUpClientPolicyId; + dynamic topUpSlabRates; + dynamic topUpFamilyFloater; + dynamic topUpPolicyName; + dynamic topUpSiPremiumValue; + dynamic topUpSiValue; + dynamic topUpSiSelectedSI; + dynamic topUpSiPolicies = []; + dynamic topUpTypeName; + int topUpOpenForEnrollment = 0; + dynamic topUpSiParentPolicies = []; + dynamic topUpParentClientPolicyId; + dynamic topUpParentSlabRates; + dynamic topUpParentPolicyName; + dynamic topUpParentFamilyFloater; + dynamic topUpParentMappedFamilyFloatersSi; + dynamic topUpParentECardDownload; + dynamic topUpParentSiValue; + dynamic topUpParentSiSelectedSI; + dynamic topUpParentSiPremiumValue; + dynamic topUpParentSiPremiumGst; + dynamic topUpParentSiTotalAmt; + dynamic topUpParentTypeName; + int topUpParentOpenForEnrollment = 0; + dynamic addOnsDependentPolicies = []; + dynamic addOnsDependentMappedFamilyFloatersDependent; + dynamic addOnsDependentClientPolicyId; + dynamic addOnsDependentSlabRates; + dynamic addOnsSelectedDependent; + dynamic addOnsdependentValue; + dynamic addOnsDependentPolicyName; + dynamic addOnsDependentECardDownload; + int addOnsDependentOpenForEnrollment = 0; dynamic siValue; - dynamic gmcAddOnDependentPremiumValue; + dynamic addOnDependentPremiumValue; + dynamic addOnsDependentFamilyFloater; dynamic gmcAddOnSiPremiumValue; - dynamic dependentPremiumGst; - dynamic siPremiumGst; - dynamic addOnsPolicyName; - dynamic dependentTotalAmt; - dynamic siTotalAmt; - dynamic addOnsFamilyFloater; + dynamic addOnsDependentPremiumGst; + dynamic topUpSiPremiumGst; + dynamic addOnsDependentTotalAmt; + dynamic topUpSiTotalAmt; late TextEditingController _relationShipController; late TextEditingController _dobController; late TextEditingController _memberNameController; @@ -72,6 +112,11 @@ class _addOnsDetailsState extends State { List> formDataList = []; late DateTime _selectedDate = DateTime.now(); // Define _selectedDate here + dynamic iAgreeForAddOn = []; + + dynamic gmcDataIsEmpty = 1; + dynamic gpaDataIsEmpty = 1; + @override void initState() { super.initState(); @@ -89,6 +134,16 @@ class _addOnsDetailsState extends State { super.dispose(); } + String formatDate(String inputDate) { + // Parse the input date string + DateTime dateTime = DateFormat('dd-MM-yyyy').parse(inputDate); + + // Format the date to the desired format + String formattedDate = DateFormat('dd MMM yyyy').format(dateTime); + + return formattedDate; + } + Future _loadToken() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); final String? token = prefs.getString('token'); @@ -108,8 +163,15 @@ class _addOnsDetailsState extends State { // print(empPrimaryId); // Call the API when the page enters - getClientLogoAndDetails(); - getAddOnsEmpPolicyDetails(); + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(); + } + getGmcSiTopUp(); + getGmcSiParentTopUp(); + getGmcDependentAddOns(); fetchRelationshipList(); getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); @@ -146,14 +208,14 @@ class _addOnsDetailsState extends State { print(clientLogo); } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -164,7 +226,7 @@ class _addOnsDetailsState extends State { Future getGpaEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA'); try { var response = await http.get( url, @@ -179,7 +241,7 @@ class _addOnsDetailsState extends State { print(data); if (data.containsKey('data')) { - dynamic gpaPolicies = data['data']; + gpaPolicies = data['data']; print(gpaPolicies); // Assuming data is a List print(gpaPolicies); @@ -189,7 +251,10 @@ class _addOnsDetailsState extends State { print('GPA Policies found: $gpaPolicies'); gpaPolicyName = gpaPolicies['Policy_Name'].toString(); print(gpaPolicyName); - gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + gpaClintPolicyId = gpaPolicies['ClientPolicyId'].toString(); + print(gpaClintPolicyId); + gpasumInsured = gpaPolicies['mapped_family_floaters']['data'] + ['basic_cover_si']; print(gpasumInsured); gpaMappedFamilyFloaters = gpaPolicies['mapped_family_floaters']['data']; @@ -200,26 +265,32 @@ class _addOnsDetailsState extends State { gpaSelfRelationship = gpaMappedFamilyFloaters['relationship'].toString() ?? ''; gpaSelfDetails = gpaSelfName + - ' - ' + + ' ~ ' + gpaSelfRelationship + - ' - ' + - gpaSelfDob; + ' ~ ' + + ' DOB : ' + + formatDate(gpaSelfDob); + + gpaECardDownload = gpaPolicies['eCardDownload']; }); } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); + setState(() { + gpaDataIsEmpty = 0; + }); + // ToastHelper.showWarningToast(context, 'Something went wrong'); print('No data found in the response'); } } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showWarningToast(context, 'Something went wrong'); print('API request failed with status: ${data['status']}'); } } else { + setState(() { + gpaDataIsEmpty = 0; + }); // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + ToastHelper.showWarningToast(context, 'Something went wrong'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -230,7 +301,7 @@ class _addOnsDetailsState extends State { Future getGmcEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC'); try { var response = await http.get( url, @@ -240,49 +311,33 @@ class _addOnsDetailsState extends State { }, ); if (response.statusCode == 200) { - print('response.statusCode == 200'); + print('GMC response.statusCode == 200'); Map data = json.decode(response.body); print(data); - if (data.containsKey('data')) { - dynamic gmcPolicies = data['data']; - print(gmcPolicies); + if (data['status'] == 'success') { + // setState(() { + gmcPolicies = data['data']; + print('gmcPolicies'); + // }); // Assuming data is a List print(gmcPolicies); - if (gmcPolicies.isNotEmpty) { - setState(() { - print('GPM Policies found: $gmcPolicies'); - gmcPolicyName = gmcPolicies['Policy_Name'].toString(); - print(gmcPolicyName); - gmcNotes = gmcPolicies['notes'].toString(); - gmcSumInsured = - gmcPolicies['Policy_Terms']['sum_insured'].toString(); - print(gmcSumInsured); - - gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; - print(gmcMappedFamilyFloaters); - // gmcSelfName = gpaMappedFamilyFloaters['name'].toString(); - // // selfMobileNo = gpaMappedFamilyFloaters['mobile']; - // gmcSelfDob = gpaMappedFamilyFloaters['dob'].toString(); - // gmcSelfRelationship = - // gpaMappedFamilyFloaters['relationship'].toString(); - // gmcSelfDetails = gmcSelfRelationship + ' . ' + gmcSelfDob; - }); - } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); - print('No data found in the response'); - } } else { - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + setState(() { + gmcDataIsEmpty = 0; + }); // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + setState(() { + gmcDataIsEmpty = 0; + }); // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -291,9 +346,9 @@ class _addOnsDetailsState extends State { } } - Future getAddOnsEmpPolicyDetails() async { + Future getGmcSiTopUp() async { var url = Uri.parse(Environment.apiUrl + - 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString'); + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-TOPUP'); try { var response = await http.get( url, @@ -309,81 +364,78 @@ class _addOnsDetailsState extends State { print(data); if (data.containsKey('data')) { - dynamic addOnsPolicies = data['data']; - print(addOnsPolicies); - if (addOnsPolicies.isNotEmpty) { + setState(() { + topUpSiPolicies = data['data']; + print('topUpSiPolicies'); + print(topUpSiPolicies); + }); + if (topUpSiPolicies.isNotEmpty) { // setState(() { - addOnsClientPolicyId = - addOnsPolicies['addon_policy']['client_policy_id']; + topUpClientPolicyId = + await topUpSiPolicies['gmc_si_topup']['client_policy_id']; - addOnsSlabRates = await addOnsPolicies['addon_policy']['SlabRates']; - print(addOnsSlabRates); + topUpSlabRates = await topUpSiPolicies['gmc_si_topup']['SlabRates']; + print('topUpSlabRates'); + print(topUpSlabRates); - addOnsPolicyName = - await addOnsPolicies['addon_policy']['policy_name']; + topUpPolicyName = + await topUpSiPolicies['gmc_si_topup']['policy_name']; - addOnsFamilyFloater = await addOnsPolicies['addon_policy'] + topUpFamilyFloater = await topUpSiPolicies['gmc_si_topup'] ['policy_terms']['family_floater']; - print('addOnsFamilyFloater'); - print(addOnsFamilyFloater); - setState(() { - addOnsMappedFamilyFloatersDependent = - addOnsPolicies['addon_policy'] - ['family_floaters_of_dependent_and_si_array']; - print('addOnsMappedFamilyFloatersDependent'); - print(addOnsMappedFamilyFloatersDependent); - }); + print('topUpFamilyFloater'); + print(topUpFamilyFloater); - addOnsMappedFamilyFloatersSi = await addOnsPolicies['addon_policy'] + topUpMappedFamilyFloatersSi = await topUpSiPolicies['gmc_si_topup'] ['family_floaters_of_only_si_array']; - print('addOnsMappedFamilyFloatersSi'); - print(addOnsMappedFamilyFloatersSi); + print('topUpMappedFamilyFloatersSi'); + print(topUpMappedFamilyFloatersSi); - gmcAddOnDependentPremiumValue = await addOnsPolicies['addon_policy'] - ['family_floaters_of_dependent_and_si_premium_value']; + print('topUpECardDownload'); + topUpECardDownload = + topUpSiPolicies['gmc_si_topup']['eCardDownload']; + print(topUpECardDownload); + String intOpenForEnrollment = + topUpSiPolicies['gmc_si_topup']['OpenForEnrollment']; + topUpOpenForEnrollment = int.parse(intOpenForEnrollment); + print(topUpOpenForEnrollment); - dependentValue = await addOnsPolicies['addon_policy'] - ['family_floaters_of_dependent_and_si_value']; - gmcAddOnsselectedDependent = - dependentValue != null ? dependentValue.toString() : null; - if (gmcAddOnsselectedDependent != null) { - _gmcDependentSwitcher = true; - if (gmcAddOnDependentPremiumValue != null) { - calculationForDependentSumValue('Add'); - } - } + topUpTypeName = topUpSiPolicies['gmc_si_topup']['type']; - gmcAddOnSiPremiumValue = await addOnsPolicies['addon_policy'] - ['family_floaters_of_only_si_premium_value']; - - siValue = await addOnsPolicies['addon_policy'] + topUpSiValue = await topUpSiPolicies['gmc_si_topup'] ['family_floaters_of_only_si_value']; - gmcAddOnsselectedSI = siValue != null ? siValue.toString() : null; - if (gmcAddOnsselectedSI != null) { - print('gmcAddOnsselectedSI'); - _gmcSiSwitcher = true; - if (gmcAddOnSiPremiumValue != null) { - print('gmcAddOnSiPremiumValue'); - calculationForSiSumValue('Add'); - } - } + topUpSiSelectedSI = + topUpSiValue != 0 ? topUpSiValue.toString() : null; + if (topUpSiSelectedSI != null) { + print('topUpSiSelectedSI'); + _topUpSiSwitcher = true; + setState(() { + topUpSiPremiumValue = topUpSiPolicies['gmc_si_topup'] + ['family_floaters_of_only_si_premium_value']; + + topUpSiPremiumGst = topUpSiPolicies['gmc_si_topup'] + ['family_floaters_of_only_si_gst_value']; + + topUpSiTotalAmt = topUpSiPremiumValue + topUpSiPremiumGst; + }); + } // }); } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); print('No data found in the response'); } } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -392,86 +444,227 @@ class _addOnsDetailsState extends State { } } - Future calculationForDependentSumValue(String action) async { - double premiumValue; - if (action == 'Add') { - premiumValue = double.parse(gmcAddOnDependentPremiumValue.toString()); - } else { - Map? findedSiObject = addOnsSlabRates.firstWhere( - (element) => element['si'] == gmcAddOnsselectedDependent.toString(), - orElse: () => null, + Future getGmcSiParentTopUp() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-PARENT-TOPUP'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print('parent'); + print(data); - print('findedSiObject'); - print(findedSiObject); + if (data.containsKey('data')) { + setState(() { + topUpSiParentPolicies = data['data']; + print('topUpSiParentPolicies'); + print(topUpSiParentPolicies); + }); + if (topUpSiParentPolicies.isNotEmpty) { + // setState(() { + topUpParentClientPolicyId = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['client_policy_id']; - if (findedSiObject != null) { - gmcAddOnDependentPremiumValue = findedSiObject['premium']; - premiumValue = double.parse(findedSiObject['premium'].toString()); - } else { - // Handle the case when no matching object is found - print( - 'No matching object found for gmcAddOnsselectedDependent: $gmcAddOnsselectedDependent'); - return; // Exit the function early - } - } - const gstRate = 18.0; - dependentPremiumGst = premiumValue * (gstRate / 100); - print(dependentPremiumGst); + topUpParentSlabRates = + await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates']; + print('topUpParentSlabRates'); + print(topUpParentSlabRates); - dependentTotalAmt = premiumValue + dependentPremiumGst; - } + topUpParentPolicyName = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['policy_name']; - Future calculationForSiSumValue(action) async { - double premiumValue; - if (action == 'Add') { - print('Add'); - print(addOnsFamilyFloater); - if (addOnsFamilyFloater == '0') { - print('calculationForSiSumValue'); - int lengthArray = addOnsMappedFamilyFloatersSi.length; + topUpParentFamilyFloater = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['policy_terms']['family_floater']; + print('topUpParentFamilyFloater'); + print(topUpParentFamilyFloater); - premiumValue = - double.parse(gmcAddOnSiPremiumValue.toString()) * lengthArray; - gmcAddOnSiPremiumValue = premiumValue; - } else { - premiumValue = double.parse(gmcAddOnSiPremiumValue.toString()); - } - } else { - Map? findedSiObject = addOnsSlabRates.firstWhere( - (element) => element['si'] == gmcAddOnsselectedSI.toString(), - orElse: () => null, - ); + topUpParentMappedFamilyFloatersSi = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_array']; + print('topUpParentMappedFamilyFloatersSi'); + print(topUpParentMappedFamilyFloatersSi); - print('findedSiObject'); - print(findedSiObject); + print('topUpECardDownload'); + topUpParentECardDownload = + topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload']; + print(topUpParentECardDownload); + String intOpenForEnrollment = + topUpSiParentPolicies['gmc_si_parent_topup'] + ['OpenForEnrollment']; + topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment); + print(topUpParentOpenForEnrollment); - if (findedSiObject != null) { - if (addOnsFamilyFloater == '0') { - print('calculationForSiSumValue'); - int lengthArray = addOnsMappedFamilyFloatersSi.length; + topUpParentTypeName = + topUpSiParentPolicies['gmc_si_parent_topup']['type']; - premiumValue = - double.parse(findedSiObject['premium'].toString()) * lengthArray; - gmcAddOnSiPremiumValue = premiumValue; + topUpParentSiValue = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_value']; + topUpParentSiSelectedSI = + topUpParentSiValue != 0 ? topUpParentSiValue.toString() : null; + if (topUpParentSiSelectedSI != null) { + print('topUpParentSiSelectedSI'); + + _topUpParentSiSwitcher = true; + setState(() { + topUpParentSiPremiumValue = + topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_premium_value']; + + topUpParentSiPremiumGst = + topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_gst_value']; + + topUpParentSiTotalAmt = + topUpParentSiPremiumValue + topUpParentSiPremiumGst; + }); + } + // }); + } else { + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); + print('No data found in the response'); + } } else { - premiumValue = double.parse(findedSiObject['premium'].toString()); - gmcAddOnSiPremiumValue = premiumValue; + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); } } else { - // Handle the case when no matching object is found - print( - 'No matching object found for gmcAddOnsselectedDependent: $gmcAddOnsselectedDependent'); - return; // Exit the function early + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); } - print('premium'); - print(premiumValue); - const gstRate = 18.0; - siPremiumGst = premiumValue * (gstRate / 100); - print(siPremiumGst); + } - siTotalAmt = premiumValue + siPremiumGst; + Future getGmcDependentAddOns() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-DEPENDENT-ADDON'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print('222222222'); + print(data); + + if (data.containsKey('data')) { + setState(() { + addOnsDependentPolicies = data['data']; + print('addOnsDependentPolicies'); + print(addOnsDependentPolicies); + }); + if (addOnsDependentPolicies.isNotEmpty) { + // setState(() { + addOnsDependentClientPolicyId = + addOnsDependentPolicies['gmc_dependent_addon'] + ['client_policy_id']; + + addOnsDependentSlabRates = + await addOnsDependentPolicies['gmc_dependent_addon'] + ['SlabRates']; + print(addOnsDependentSlabRates); + + addOnsDependentPolicyName = + await addOnsDependentPolicies['gmc_dependent_addon'] + ['policy_name']; + + addOnsDependentFamilyFloater = + await addOnsDependentPolicies['gmc_dependent_addon'] + ['policy_terms']['family_floater']; + print('addOnsDependentFamilyFloater'); + print(addOnsDependentFamilyFloater); + + setState(() { + addOnsDependentMappedFamilyFloatersDependent = + addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_si_array']; + print('addOnsDependentMappedFamilyFloatersDependent'); + print(addOnsDependentMappedFamilyFloatersDependent); + }); + + addOnsdependentValue = + await addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_si_value']; + + addOnsSelectedDependent = await addOnsdependentValue != 0 + ? addOnsdependentValue.toString() + : null; + if (addOnsSelectedDependent != null) { + _addOnsDependentSwitcher = true; + setState(() { + addOnDependentPremiumValue = + addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_si_premium_value']; + + addOnsDependentPremiumGst = + addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_gst_value']; + + addOnsDependentTotalAmt = + addOnDependentPremiumValue + addOnsDependentPremiumGst; + }); + + addOnsDependentECardDownload = + addOnsDependentPolicies['gmc_dependent_addon'] + ['eCardDownload']; + print('addOnsDependentECardDownload'); + print(addOnsDependentECardDownload); + + String intOpenForEnrollment = + addOnsDependentPolicies['gmc_dependent_addon'] + ['OpenForEnrollment']; + addOnsDependentOpenForEnrollment = + int.parse(intOpenForEnrollment); + // if (addOnDependentPremiumValue != null) { + // calculationForDependentSumValue('Add'); + // } + } + + // }); + } else { + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } } Future fetchRelationshipList() async { @@ -502,33 +695,46 @@ class _addOnsDetailsState extends State { // relationshipOptions = relationships; // }); } else { - ToastHelper.showErrorToast( - context, 'Failed to fetch relationship list'); + // ToastHelper.showErrorToast( + // context, 'Failed to fetch relationship list'); throw Exception('Failed to fetch relationship list'); } } catch (error) { - ToastHelper.showErrorToast( - context, 'Error fetching relationship list: $error'); + // ToastHelper.showErrorToast( + // context, 'Error fetching relationship list: $error'); print('Error fetching relationship list: $error'); // Handle error accordingly, e.g., show a snackbar with an error message } } - Future _selectDate(BuildContext context, [String? formType]) async { + Future _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; final DateTime now = DateTime.now(); - if (formType == '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); + + // if (formType == '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); + // } // Ensure initialDate is within the range of minDate and maxDate DateTime initialDate = @@ -582,13 +788,14 @@ class _addOnsDetailsState extends State { getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); fetchRelationshipList(); - getAddOnsEmpPolicyDetails(); + getGmcSiTopUp(); + getGmcSiParentTopUp(); + getGmcDependentAddOns(); ToastHelper.showSuccessToast(context, 'Item deleted successfully'); print('Item deleted successfully'); } else { // Handle errors - ToastHelper.showSuccessToast(context, - 'Failed to delete item. Status code: ${response.statusCode}'); + ToastHelper.showErrorToast(context, 'Failed to delete item'); print('Failed to delete item. Status code: ${response.statusCode}'); print('Response body: ${response.body}'); } @@ -612,6 +819,8 @@ class _addOnsDetailsState extends State { 'client_id': client_id, 'client_policy_id': floatedData['client_policy_id'], 'is_addon_value': 1, + 'basic_cover_si': addOnsSelectedDependent, + 'created_by': empPrimaryId, // Add the 'id' field only if action is 'Edit' if (action == 'Edit') 'id': floatedData['employee_id'], }); @@ -642,13 +851,14 @@ class _addOnsDetailsState extends State { getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); fetchRelationshipList(); - getAddOnsEmpPolicyDetails(); + getGmcSiTopUp(); + getGmcSiParentTopUp(); + getGmcDependentAddOns(); ToastHelper.showSuccessToast(context, 'Saved Successfully...'); print('Form data sent successfully.'); } else { // Request failed, handle error - ToastHelper.showErrorToast( - context, 'Failed to send form data. Error: ${response.reasonPhrase}'); + ToastHelper.showErrorToast(context, 'Failed'); print('Failed to send form data. Error: ${response.reasonPhrase}'); } } @@ -662,17 +872,16 @@ class _addOnsDetailsState extends State { } void sendAddonsGmcDependentToAPI() async { - print(_gmcDependentSwitcher); + print(_addOnsDependentSwitcher); print('continue'); - print(gmcAddOnsselectedDependent); - if (_gmcDependentSwitcher == true) { - if (gmcAddOnsselectedDependent == null || - gmcAddOnsselectedDependent.isEmpty) { - return; // Return if gmcAddOnsselectedDependent is null or empty + print(addOnsSelectedDependent); + if (_addOnsDependentSwitcher == true) { + if (addOnsSelectedDependent == null || addOnsSelectedDependent.isEmpty) { + return; // Return if addOnsSelectedDependent is null or empty } else { print('createOrUpdateEmployeePolicySiAmount'); try { - dynamic getTrueObjects = addOnsMappedFamilyFloatersDependent + dynamic getTrueObjects = addOnsDependentMappedFamilyFloatersDependent .where((element) => element['is_value_exist'] == true) .toList(); @@ -695,10 +904,11 @@ class _addOnsDetailsState extends State { // Create a map containing the floater details and its selected values Map floaterData = { - 'basic_cover_si': gmcAddOnsselectedDependent, + 'basic_cover_si': addOnsSelectedDependent, 'client_policy_id': client_policy_id, 'employee_id': employee_id, 'client_id': client_id, + 'emp_code': empCodeString, }; // Add the map to the list @@ -729,7 +939,7 @@ class _addOnsDetailsState extends State { _memberNameController.clear(); _dobController.clear(); // Navigator.pushNamed(context, 'empReviewDetails'); - ToastHelper.showSuccessToast(context, 'Saved successfully!'); + // ToastHelper.showSuccessToast(context, 'Saved successfully!'); print('Saved successfully!'); } } else { @@ -749,16 +959,17 @@ class _addOnsDetailsState extends State { } void sendAddonsGmcSiToAPI() async { - print(_gmcSiSwitcher); + print(_topUpSiSwitcher); print('continue'); - print(gmcAddOnsselectedSI); - if (_gmcSiSwitcher == true) { - if (gmcAddOnsselectedSI == null || gmcAddOnsselectedSI.isEmpty) { - return; // Return if gmcAddOnsselectedDependent is null or empty + print(topUpSiSelectedSI); + if (_topUpSiSwitcher == true) { + if (topUpSiSelectedSI == null || topUpSiSelectedSI.isEmpty) { + print('topUpSiSelectedSI'); + return; // Return if addOnsSelectedDependent is null or empty } else { print('createOrUpdateEmployeePolicySiAmount'); try { - dynamic getTrueObjects = addOnsMappedFamilyFloatersSi + dynamic getTrueObjects = topUpMappedFamilyFloatersSi .where((element) => element['is_value_exist'] == true) .toList(); @@ -781,10 +992,11 @@ class _addOnsDetailsState extends State { // Create a map containing the floater details and its selected values Map floaterData = { - 'basic_cover_si': gmcAddOnsselectedSI, + 'basic_cover_si': topUpSiSelectedSI, 'client_policy_id': client_policy_id, 'employee_id': employee_id, 'client_id': client_id, + 'emp_code': empCodeString, }; // Add the map to the list @@ -816,14 +1028,14 @@ class _addOnsDetailsState extends State { _memberNameController.clear(); _dobController.clear(); // Navigator.pushNamed(context, 'empReviewDetails'); - ToastHelper.showSuccessToast(context, 'Saved successfully!'); + // ToastHelper.showSuccessToast(context, 'Saved successfully!'); print('Saved successfully!'); } } else { // Failed to save member // ToastHelper.showErrorToast(context, "Operation Failed!"); - ToastHelper.showSuccessToast(context, 'Failed to Save...'); - print('Operation Failed!'); + // ToastHelper.showSuccessToast(context, 'Failed to Save...'); + print('Failed to Save...'); } } catch (error) { print('Error saving family members'); @@ -835,179 +1047,566 @@ class _addOnsDetailsState extends State { } } + void sendAddonsGmcParentSiToAPI() async { + print(_topUpParentSiSwitcher); + print('continue'); + print(topUpParentSiSelectedSI); + if (_topUpParentSiSwitcher == true) { + if (topUpParentSiSelectedSI == null || topUpParentSiSelectedSI.isEmpty) { + print('topUpSiSelectedSI'); + return; // Return if addOnsSelectedDependent is null or empty + } else { + print('createOrUpdateEmployeePolicySiAmount'); + try { + dynamic getTrueObjects = topUpParentMappedFamilyFloatersSi + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); + + print(getTrueDataObjects); + + List> selectedValues = []; + // try { + print('fff'); + if (getTrueDataObjects != null || getTrueDataObjects.isNotEmpty) { + for (var floater in getTrueDataObjects) { + String employee_id = floater['employee_id']; + String client_policy_id = floater['client_policy_id'].toString(); + + // Create a map containing the floater details and its selected values + Map floaterData = { + 'basic_cover_si': topUpParentSiSelectedSI, + 'client_policy_id': client_policy_id, + 'employee_id': employee_id, + 'client_id': client_id, + 'emp_code': empCodeString, + }; + + // Add the map to the list + selectedValues.add(floaterData); + } + print(selectedValues); + } + + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse( + Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount'); + final response = await http.post( + url, + body: jsonEncode(selectedValues), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + // Member saved successfully + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + // Navigator.pushNamed(context, 'empReviewDetails'); + // ToastHelper.showSuccessToast(context, 'Saved successfully!'); + print('Saved successfully!'); + } + } else { + // Failed to save member + // ToastHelper.showErrorToast(context, "Operation Failed!"); + // ToastHelper.showSuccessToast(context, 'Failed to Save...'); + print('Failed to Save...'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + } else { + // Navigator.pushNamed(context, 'empReviewDetails'); + } + } + + Future removeAddonsGmcDependentToAPI() async { + var url = Uri.parse(Environment.apiUrl + + 'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$addOnsDependentClientPolicyId'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + print(data); + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future removeAddonsGmcSiToAPI() async { + var url = Uri.parse(Environment.apiUrl + + 'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpClientPolicyId'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + print(data); + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future removeAddonsGmcParentSiToAPI() async { + var url = Uri.parse(Environment.apiUrl + + 'removeEmpAndEmpPolicyData?emp_code=$empCodeString&client_policy_id=$topUpParentClientPolicyId'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + print(data); + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + void checkToCallRemoveEmpOrNot() { + if (_topUpSiSwitcher == false && + _addOnsDependentSwitcher == false && + _topUpParentSiSwitcher == false) { + removeAddonsGmcDependentToAPI(); + removeAddonsGmcSiToAPI(); + removeAddonsGmcParentSiToAPI(); + Navigator.pushNamed(context, 'empReviewDetails', + arguments: {'siData': [], 'siParentData': [], 'dependentData': []}); + } else if (_topUpSiSwitcher == false) { + removeAddonsGmcSiToAPI(); + Navigator.pushNamed(context, 'empReviewDetails', + arguments: {'siData': [], 'siParentData': [], 'dependentData': []}); + } else if (_topUpParentSiSwitcher == false) { + removeAddonsGmcParentSiToAPI(); + Navigator.pushNamed(context, 'empReviewDetails', + arguments: {'siData': [], 'siParentData': [], 'dependentData': []}); + } else if (_addOnsDependentSwitcher == false) { + removeAddonsGmcDependentToAPI(); + Navigator.pushNamed(context, 'empReviewDetails', + arguments: {'siData': [], 'siParentData': [], 'dependentData': []}); + } + } + + void topUpSiCalculation(choosedSiValue) async { + try { + print(choosedSiValue); + + var calculation = { + 'client_policy_id': topUpClientPolicyId, + 'emp_code': empCodeString, + 'si': choosedSiValue + }; + + print(calculation); + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse(Environment.apiUrl + 'calculatePremium'); + final response = await http.post( + url, + body: jsonEncode(calculation), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + print(data); + List? topUpEmpArray; + for (var item in data['data']) { + if (item.containsKey(empCodeString)) { + topUpEmpArray = item[empCodeString]; + break; + } + } + + if (topUpEmpArray != null) { + print('Array for emp_code $empCodeString:'); + print(topUpEmpArray); + double topUpRataPremimumSum = 0; + for (var item in topUpEmpArray) { + var topUpRataPremimum = item['policy_details']['rata_premimum']; + if (topUpRataPremimum != null) { + topUpRataPremimumSum += topUpRataPremimum; + } + } + print('Sum of rata_premimum: $topUpRataPremimumSum'); + + double topUpGstSum = 0; + for (var item in topUpEmpArray) { + var topUpGst = item['policy_details']['gst']; + if (topUpGst != null) { + topUpGstSum += topUpGst; + } + } + print('Sum of gst: $topUpGstSum'); + setState(() { + topUpSiPremiumValue = topUpRataPremimumSum; + print(topUpSiPremiumValue); + topUpSiPremiumGst = topUpGstSum; + print(topUpSiPremiumGst); + topUpSiTotalAmt = topUpSiPremiumValue + topUpSiPremiumGst; + print(topUpSiTotalAmt); + }); + sendAddonsGmcSiToAPI(); + } else { + print('Array not found for emp_code $empCodeString'); + } + } + } else { + print('Operation Failed!'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + + void topUpParentSiCalculation(choosedSiValue) async { + try { + print(choosedSiValue); + + var calculation = { + 'client_policy_id': topUpParentClientPolicyId, + 'emp_code': empCodeString, + 'si': choosedSiValue + }; + + print(calculation); + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse(Environment.apiUrl + 'calculatePremium'); + final response = await http.post( + url, + body: jsonEncode(calculation), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + print(data); + List? topUpEmpArray; + for (var item in data['data']) { + if (item.containsKey(empCodeString)) { + topUpEmpArray = item[empCodeString]; + break; + } + } + + if (topUpEmpArray != null) { + print('Array for emp_code $empCodeString:'); + print(topUpEmpArray); + double topUpRataPremimumSum = 0; + for (var item in topUpEmpArray) { + var topUpRataPremimum = item['policy_details']['rata_premimum']; + if (topUpRataPremimum != null) { + topUpRataPremimumSum += topUpRataPremimum; + } + } + print('Sum of rata_premimum: $topUpRataPremimumSum'); + + double topUpGstSum = 0; + for (var item in topUpEmpArray) { + var topUpGst = item['policy_details']['gst']; + if (topUpGst != null) { + topUpGstSum += topUpGst; + } + } + print('Sum of gst: $topUpGstSum'); + setState(() { + topUpParentSiPremiumValue = topUpRataPremimumSum; + print(topUpParentSiPremiumValue); + topUpParentSiPremiumGst = topUpGstSum; + print(topUpSiPremiumGst); + topUpParentSiTotalAmt = + topUpParentSiPremiumValue + topUpParentSiPremiumGst; + print(topUpParentSiTotalAmt); + }); + sendAddonsGmcParentSiToAPI(); + } else { + print('Array not found for emp_code $empCodeString'); + } + } + } else { + print('Operation Failed!'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + + void addOnsDependentCalculation(choosedDependentValue) async { + try { + print(choosedDependentValue); + + var calculation = { + 'client_policy_id': addOnsDependentClientPolicyId, + 'emp_code': empCodeString, + 'si': choosedDependentValue + }; + + print(calculation); + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse(Environment.apiUrl + 'calculatePremium'); + final response = await http.post( + url, + body: jsonEncode(calculation), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + print(data); + List? addOnsEmpArray; + for (var item in data['data']) { + if (item.containsKey(empCodeString)) { + addOnsEmpArray = item[empCodeString]; + break; + } + } + + if (addOnsEmpArray != null) { + print('Array for emp_code $empCodeString:'); + print(addOnsEmpArray); + double addOnsRataPremimumSum = 0; + for (var item in addOnsEmpArray) { + var addOnsRataPremimum = item['policy_details']['rata_premimum']; + if (addOnsRataPremimum != null) { + addOnsRataPremimumSum += addOnsRataPremimum; + } + } + print('Sum of rata_premimum: $addOnsRataPremimumSum'); + + double addOnsGstSum = 0; + for (var item in addOnsEmpArray) { + var addOnsGst = item['policy_details']['gst']; + if (addOnsGst != null) { + addOnsGstSum += addOnsGst; + } + } + print('Sum of gst: $addOnsGstSum'); + setState(() { + addOnDependentPremiumValue = addOnsRataPremimumSum; + print(addOnDependentPremiumValue); + addOnsDependentPremiumGst = addOnsGstSum; + print(addOnsDependentPremiumGst); + addOnsDependentTotalAmt = + addOnDependentPremiumValue + addOnsDependentPremiumGst; + print(topUpSiTotalAmt); + }); + } else { + print('Array not found for emp_code $empCodeString'); + } + } + } else { + print('Operation Failed!'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + + Future sendAddOnAPI() async { + print('sendAddOnAPI'); + if (gpaDataIsEmpty != 0) { + iAgreeForAddOn.add(int.parse(gpaClintPolicyId)); + } + + if (gmcDataIsEmpty != 0) { + for (var item in gmcPolicies) { + // Extract ClientPolicyId value from each object + String clientPolicyId = item['ClientPolicyId']; + // Convert to integer and add to iAgreeForAddOn list + iAgreeForAddOn.add(int.parse(clientPolicyId)); + } + } + + print('iAgreeForAddOn'); + iAgreeForAddOn = iAgreeForAddOn.toSet().toList(); + print(iAgreeForAddOn); // Output: [90, 92, 88, 89] + + Map apiParams = { + 'emp_code': empCodeString, + 'client_policy_id': iAgreeForAddOn, + 'client_id': client_id, + }; + + // Convert the list of objects to JSON + String formDataJson = jsonEncode(apiParams); + + var url = Uri.parse(Environment.apiUrl + 'iAgreeForAddOn'); + try { + var response = await http.post( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + body: formDataJson, + ); + + if (response.statusCode == 200) { + print('response.statusCode == 200'); + ToastHelper.showSuccessToast(context, 'Saved Successfully...'); + } else { + // Handle other status codes + ToastHelper.showErrorToast(context, 'failed to save'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future backFunction() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + if (prefs.containsKey('hrtoken')) { + String? mobileNo = prefs.getString('fromHrLoginMobileNo'); + print('mobileNo'); + print(mobileNo); + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': mobileNo}); + } else { + Navigator.pushNamed(context, 'empDetails'); + } + } + + void checkSiTopUp() async { + print('checkSiTopUp'); + List> siData = [ + { + 'topUpSiPremiumValue': topUpSiPremiumValue, + 'topUpSiPremiumGst': topUpSiPremiumGst, + 'topUpSiTotalAmt': topUpSiTotalAmt, + } + ]; + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('siData', jsonEncode(siData)); + } + + void checkSiParentTopUp() async { + print('checkSiParentTopUp'); + List> siParentData = [ + { + 'topUpParentSiPremiumValue': topUpParentSiPremiumValue, + 'topUpParentSiPremiumGst': topUpParentSiPremiumGst, + 'topUpParentSiTotalAmt': topUpParentSiTotalAmt, + } + ]; + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('siParentData', jsonEncode(siParentData)); + } + + void checkDependentTopUp() async { + print('checkDependentTopUp'); + List> dependentData = [ + { + 'addOnDependentPremiumValue': addOnDependentPremiumValue, + 'addOnsDependentPremiumGst': addOnsDependentPremiumGst, + 'addOnsDependentTotalAmt': addOnsDependentTotalAmt, + } + ]; + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('dependentData', jsonEncode(dependentData)); + } + @override Widget build(BuildContext context) { - if (addOnsMappedFamilyFloatersDependent == null) { + print('CVC'); + print('Check1: $topUpSiPolicies'); + print('CVC'); + print('Check2: $addOnsDependentPolicies'); + if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) { return Scaffold( appBar: CustomAppBar(), body: Center( child: Container( color: Color(0xFFEFF3F6), child: Center( - child: Text('No Data Available'), + child: Text('No Data Available', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + )), ), ), ), ); } else { List familyFloaterContainers = []; - for (var floater in addOnsMappedFamilyFloatersDependent) { - bool isValueExist = floater['is_value_exist']; - Map floaterData = floater['data']; + if (addOnsDependentMappedFamilyFloatersDependent != null) { + for (var floater in addOnsDependentMappedFamilyFloatersDependent) { + bool isValueExist = floater['is_value_exist']; + Map 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, - ), - ), - ], - ), - ), - ), - SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), - Expanded( - flex: Responsive.isDesktop(context) ? 9 : 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - floaterData['name'] ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop(context) ? 18 : 16, - fontWeight: FontWeight.w600, - ), - ), - Text( - '${floaterData['relationship']} - ${floaterData['dob']}', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop(context) ? 18 : 16, - ), - ), - ], - ), - ), - ), - if (isValueExist && floaterData['relationship'] != 'Self') - Expanded( - flex: Responsive.isDesktop(context) ? 1 : 2, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - deleteItem(floaterData); - }, - child: Text( - 'Delete', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop(context) ? 16 : 15, - color: Color( - 0xFFE26728), // Add underline decoration - ), - ), - ), - ) - ], - ), - ), - ), - Expanded( - flex: - (isValueExist && floaterData['relationship'] != 'Self') - ? Responsive.isDesktop(context) - ? 1 - : 2 - : Responsive.isDesktop(context) - ? 2 - : 4, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - openForm(floaterData, 'Edit'); - }, - child: Text( - floaterData['relationship'] == 'Self' - ? 'View' - : 'Edit', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop(context) ? 16 : 15, - color: Color( - 0xFFE26728), // Add underline decoration - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - ), - ); - } else { - familyFloaterContainers.add(MouseRegion( - cursor: SystemMouseCursors.click, // Set cursor to pointer - child: GestureDetector( - onTap: () { - // Handle the click event to open the form - openForm(floaterData, 'Add'); - }, - child: Container( + if (isValueExist) { + familyFloaterContainers.add( + Container( decoration: BoxDecoration( border: Border.all( color: Color(0xFF000000), @@ -1016,38 +1615,40 @@ class _addOnsDetailsState extends State { borderRadius: BorderRadius.circular(5), ), padding: Responsive.isDesktop(context) - ? EdgeInsets.all(12) - : EdgeInsets.all(10), + ? 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 : 4, + flex: Responsive.isDesktop(context) ? 1 : 2, child: Container( - alignment: Alignment.centerRight, + alignment: Alignment.centerLeft, child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: EdgeInsets.all(5), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(10) + : EdgeInsets.all(5), decoration: BoxDecoration( - color: Color(0xFF6A6A6A), + color: Color(0xFF00989E), borderRadius: BorderRadius.circular(5), ), child: Icon( - Icons.person_add, + Icons.account_circle, color: Colors.white, - size: 20, + size: 32, ), ), ], ), ), ), - SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), Expanded( - flex: Responsive.isDesktop(context) ? 11 : 8, + flex: Responsive.isDesktop(context) ? 9 : 6, child: Container( alignment: Alignment.centerLeft, child: Column( @@ -1055,26 +1656,195 @@ class _addOnsDetailsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - floaterData['button_name'] ?? '', + floaterData['name'] ?? '', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop(context) ? 22 : 18, - fontWeight: FontWeight.w500, + Responsive.isDesktop(context) ? 18 : 16, + fontWeight: FontWeight.w600, + ), + ), + Text( + '${floaterData['relationship']} - ${floaterData['dob']}', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 18 : 16, ), ), ], ), ), ), + if (addOnsDependentOpenForEnrollment != 0) + if (addOnsDependentECardDownload == null) + if (isValueExist && + floaterData['relationship'] != 'Self') + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + deleteItem(floaterData); + }, + child: Text( + 'Delete', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 16 + : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), + if (addOnsDependentOpenForEnrollment != 0) + if (addOnsDependentECardDownload == null) + Expanded( + flex: (isValueExist && + floaterData['relationship'] != 'Self') + ? Responsive.isDesktop(context) + ? 1 + : 2 + : Responsive.isDesktop(context) + ? 2 + : 4, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + openForm(floaterData, 'Edit'); + }, + child: Text( + floaterData['relationship'] == 'Self' + ? 'View' + : 'Edit', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 16 + : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), ], ), - ), // Replace YourChildWidget with the widget you want to wrap - ), - )); + ), + ); + } else { + familyFloaterContainers.add(MouseRegion( + cursor: SystemMouseCursors.click, // Set cursor to pointer + child: GestureDetector( + onTap: () { + // Handle the click event to open the form + if (addOnsSelectedDependent != null) { + if (addOnsDependentOpenForEnrollment != 0) { + if (addOnsDependentECardDownload == null) { + openForm(floaterData, 'Add'); + } + } + } else { + ToastHelper.showWarningToast( + context, 'Please Select Sum Insured Amount'); + } + }, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(12) + : EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF6A6A6A), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.person_add, + color: Colors.white, + size: 20, + ), + ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), + Expanded( + flex: Responsive.isDesktop(context) ? 11 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['button_name'] ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 22 : 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ], + ), + ), // Replace YourChildWidget with the widget you want to wrap + ), + )); + } + familyFloaterContainers.add(SizedBox(height: 15)); } - familyFloaterContainers.add(SizedBox(height: 15)); } + return Scaffold( appBar: CustomAppBar(), body: SingleChildScrollView( @@ -1106,44 +1876,48 @@ class _addOnsDetailsState extends State { child: Row( children: [ Expanded( - flex: 3, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.network( - clientLogo, - width: Responsive.isDesktop(context) - ? 80 - : 50, // Set the width here - height: Responsive.isDesktop(context) - ? 80 - : 80, // Set the height here - loadingBuilder: (BuildContext context, - Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: CircularProgressIndicator( - value: - loadingProgress.expectedTotalBytes != - null - ? loadingProgress - .cumulativeBytesLoaded / - loadingProgress - .expectedTotalBytes! - : null, - ), - ); - }, - ), - )), + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, Object error, + StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, + ), + ), + ), Expanded( flex: 9, child: Text( clientName ?? '', textAlign: TextAlign.right, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop(context) ? 20 : 18, fontWeight: FontWeight.w600, ), @@ -1154,695 +1928,1749 @@ class _addOnsDetailsState extends State { ), ), SizedBox(height: 16), - Card( - elevation: 0, - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gpaPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, + if (gpaPolicies != null && gpaPolicies.length > 0) + Card( + elevation: 0, + 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: 8, + 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 + : 14, + ), ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, + Row( + children: [ + Text( + 'Group Personal Accident Coverage', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, + ], + ))), + Expanded( + flex: 4, + 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 + : 14, + ), ), - ), - Text( - '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gmcPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: gmcMappedFamilyFloaters - .where( - (item) => item['is_value_exist'] == true) - .map((item) { - Map data = item['data']; - return 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( - '${data['name']} - ${data['relationship']} - ${data['dob']}', - style: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), - ), - ), - ), - ], - ); - }).toList(), - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(30) - : EdgeInsets.all(10), - child: Column( - children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add Ons', - textAlign: TextAlign.left, - style: TextStyle( + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop( context) ? 20 - : 18, + : 16, fontWeight: FontWeight.w600, - color: Color(0xFF181818)), - ), - Text( - 'Increase your medical cover for your family or add parents or parent in laws by paying additional premium', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 15, - color: Color(0xFF181818), - ), - ), - ], - ))), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(30) - : EdgeInsets.all(10), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: Color( - 0xFFDDF3FF), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(25) - : EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: Responsive.isDesktop(context) - ? 6 - : 10, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - addOnsPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 14, - ), ), - Text( - 'Group Medical Coverage - Top Up ', - textAlign: TextAlign.left, - style: TextStyle( + ), + ], + ))), + ], + ), + ), + 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), + ), + ), + ), + ], + ), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + if (gmcPolicies != null && gmcPolicies.length > 0) + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ...generateGmcCards(gmcPolicies), + ], + ), + SizedBox(height: 16), + if (addOnsDependentMappedFamilyFloatersDependent != null || + topUpMappedFamilyFloatersSi != null) + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop( context) ? 20 - : 16, + : 18, fontWeight: FontWeight.w600, - ), + color: Color(0xFF181818)), + ), + Text( + 'Increase your medical cover for your family or add parents or parent in laws by paying additional premium', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 15, + color: Color(0xFF181818), ), - ], - ))), - if (Responsive.isDesktop(context) && - _gmcSiSwitcher == true) - Expanded( - flex: 3, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField< - String>( - onChanged: (value) { - setState(() { - gmcAddOnsselectedSI = - value; - }); - calculationForSiSumValue( - 'Edit'); - }, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Sum Insured', - labelText: 'Sum Insured', - contentPadding: - EdgeInsets.symmetric( - vertical: 5, - horizontal: 5), - ), - value: gmcAddOnsselectedSI, - items: (addOnsSlabRates ?? - []) - .map< - DropdownMenuItem< - String>>( - (addOn) { - return DropdownMenuItem< - String>( - value: addOn['si'] - .toString(), - child: Text( - '₹ ${addOn['si']}'), - ); - }).toList(), - ), - ], - ))), - Expanded( - flex: Responsive.isDesktop(context) - ? 3 - : 2, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Switch( - value: _gmcSiSwitcher, - onChanged: (value) { - setState(() { - _gmcSiSwitcher = value; - // Add your logic here based on the toggle state - }); - }, - activeColor: Color( - 0xFFE26728), // Color when the switch is ON - inactiveTrackColor: Colors - .grey, // Color of the switch track when OFF - ), - ], - ))), - ], + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + if (topUpMappedFamilyFloatersSi != null) + Container( + decoration: BoxDecoration( + color: Color( + 0xFFDDF3FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container ), - if (_gmcSiSwitcher == true) - SizedBox(height: 10), - if (!Responsive.isDesktop(context) && - _gmcSiSwitcher == true) - Row( - children: [ - Expanded( - flex: 12, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField< - String>( - onChanged: (value) { - setState(() { - gmcAddOnsselectedSI = - value; - }); - calculationForSiSumValue( - 'Edit'); - }, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Sum Insured', - labelText: 'Sum Insured', - contentPadding: - EdgeInsets.symmetric( - vertical: 5, - horizontal: 5), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(25) + : EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) + ? 6 + : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + topUpPolicyName ?? '', + textAlign: TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 14, + ), ), - value: gmcAddOnsselectedSI, - items: (addOnsSlabRates ?? - []) - .map< - DropdownMenuItem< - String>>( - (addOn) { - return DropdownMenuItem< - String>( - value: addOn['si'] - .toString(), - child: Text( - '₹ ${addOn['si']}'), - ); - }).toList(), - ), - ], - ))), - ], - ), - if (_gmcSiSwitcher == true) - SizedBox(height: 10), - if (_gmcSiSwitcher == - true) // Add space between rows - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: addOnsMappedFamilyFloatersSi - .where((item) => - item['is_value_exist'] == - true) - .map((item) { - Map data = - item['data']; - return Row( + Text( + topUpTypeName ?? '', + textAlign: TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + ], + ))), + if (Responsive.isDesktop(context) && + _topUpSiSwitcher == true) + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (topUpOpenForEnrollment == + 0 || + (topUpOpenForEnrollment != + 0 && + topUpECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + topUpSiSelectedSI = + value; + }); + topUpSiCalculation( + value); + // calculationForTopUpSiSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + topUpSiSelectedSI, + items: (topUpSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + Expanded( + flex: 3, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Switch( + value: _topUpSiSwitcher, + onChanged: (topUpOpenForEnrollment == + 0 || + (topUpOpenForEnrollment != + 0 && + topUpECardDownload != + null)) + ? null + : (value) { + setState(() { + _topUpSiSwitcher = + value; + // Add your logic here based on the toggle state + }); + }, + activeColor: Color( + 0xFFE26728), // Color when the switch is ON + inactiveTrackColor: Colors + .grey, // Color of the switch track when OFF + ), + ], + ))), + ], + ), + if (_topUpSiSwitcher == true) + SizedBox(height: 10), + if (!Responsive.isDesktop(context) && + _topUpSiSwitcher == true) + Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (topUpOpenForEnrollment == + 0 || + (topUpOpenForEnrollment != + 0 && + topUpECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + topUpSiSelectedSI = + value; + }); + topUpSiCalculation( + value); + // calculationForTopUpSiSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + topUpSiSelectedSI, + items: (topUpSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + ], + ), + if (_topUpSiSwitcher == true) + SizedBox(height: 10), + if (_topUpSiSwitcher == + true) // Add space between rows + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: + topUpMappedFamilyFloatersSi + .where((item) => + item[ + 'is_value_exist'] == + true) + .map((item) { + Map data = + item['data']; + String formattedDate = + formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 16, + color: + Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ) + ], + ), + if (_topUpSiSwitcher == true) + SizedBox(height: 20), + if (Responsive.isDesktop(context) && + _topUpSiSwitcher == true) + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpSiPremiumValue != + null + ? '₹ $topUpSiPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'GST', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpSiPremiumGst != + null + ? '₹ $topUpSiPremiumGst/-' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpSiTotalAmt != null + ? '₹ $topUpSiTotalAmt/-' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && + _topUpSiSwitcher == true) + Container( + 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( - '${data['name']} - ${data['relationship']} - ${data['dob']}', - style: TextStyle( - fontSize: - Responsive.isDesktop( - context) + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpSiPremiumValue != + null + ? '₹ $topUpSiPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'GST', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpSiPremiumGst != + null + ? '₹ $topUpSiPremiumGst/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpSiTotalAmt != + null + ? '₹ $topUpSiTotalAmt/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) + ], + ), + ), + SizedBox(height: 15), + if (topUpParentMappedFamilyFloatersSi != null) + Container( + decoration: BoxDecoration( + color: Color( + 0xFFDDF3FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(25) + : EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) + ? 6 + : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + topUpParentPolicyName ?? + '', + textAlign: TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + topUpParentTypeName ?? '', + textAlign: TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + ], + ))), + if (Responsive.isDesktop(context) && + _topUpParentSiSwitcher == true) + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (topUpParentOpenForEnrollment == + 0 || + (topUpParentOpenForEnrollment != + 0 && + topUpParentECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + topUpParentSiSelectedSI = + value; + }); + topUpParentSiCalculation( + value); + // calculationForTopUpSiSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + topUpParentSiSelectedSI, + items: (topUpParentSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + Expanded( + flex: 3, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Switch( + value: + _topUpParentSiSwitcher, + onChanged: (topUpParentOpenForEnrollment == + 0 || + (topUpParentOpenForEnrollment != + 0 && + topUpParentECardDownload != + null)) + ? null + : (value) { + setState(() { + _topUpParentSiSwitcher = + value; + // Add your logic here based on the toggle state + }); + }, + activeColor: Color( + 0xFFE26728), // Color when the switch is ON + inactiveTrackColor: Colors + .grey, // Color of the switch track when OFF + ), + ], + ))), + ], + ), + if (_topUpParentSiSwitcher == true) + SizedBox(height: 10), + if (!Responsive.isDesktop(context) && + _topUpParentSiSwitcher == true) + Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (topUpParentOpenForEnrollment == + 0 || + (topUpParentOpenForEnrollment != + 0 && + topUpParentECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + topUpParentSiSelectedSI = + value; + }); + topUpParentSiCalculation( + value); + // calculationForTopUpSiSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + topUpParentSiSelectedSI, + items: (topUpParentSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + ], + ), + if (_topUpParentSiSwitcher == true) + SizedBox(height: 10), + if (_topUpParentSiSwitcher == + true) // Add space between rows + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: + topUpParentMappedFamilyFloatersSi + .where((item) => + item[ + 'is_value_exist'] == + true) + .map((item) { + Map data = + item['data']; + String formattedDate = + formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) ? 18 : 16, - color: Color(0xFF232526), + color: + Color(0xFF232526), + ), + ), ), - ), - ), + ], + ); + }).toList(), + ), + ) + ], + ), + if (_topUpParentSiSwitcher == true) + SizedBox(height: 20), + if (Responsive.isDesktop(context) && + _topUpParentSiSwitcher == true) + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpParentSiPremiumValue != + null + ? '₹ $topUpParentSiPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'GST', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpParentSiPremiumGst != + null + ? '₹ $topUpParentSiPremiumGst/-' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + topUpParentSiTotalAmt != + null + ? '₹ $topUpParentSiTotalAmt/-' + : 'N/A', + textAlign: + TextAlign.start, + style: + GoogleFonts.poppins( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && + _topUpParentSiSwitcher == true) + Container( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpParentSiPremiumValue != + null + ? '₹ $topUpParentSiPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), ], - ); - }).toList(), - ), - ) - ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'GST', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpParentSiPremiumGst != + null + ? '₹ $topUpParentSiPremiumGst/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + topUpParentSiTotalAmt != + null + ? '₹ $topUpParentSiTotalAmt/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) + ], + ), + ), + SizedBox(height: 15), + if (addOnsDependentMappedFamilyFloatersDependent != + null) + Container( + decoration: BoxDecoration( + color: Color( + 0xFFDDF3FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container ), - if (_gmcSiSwitcher == true) - SizedBox(height: 20), - if (Responsive.isDesktop(context) && - _gmcSiSwitcher == true) - Row( - crossAxisAlignment: - CrossAxisAlignment.start, + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(25) + : EdgeInsets.all(10), + child: Column( children: [ - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Additional Premium', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - gmcAddOnSiPremiumValue != - null - ? '₹ $gmcAddOnSiPremiumValue/Year' - : 'N/A', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'GST', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - siPremiumGst != null - ? '₹ $siPremiumGst/-' - : 'N/A', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Total Payable', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - siTotalAmt != null - ? '₹ $siTotalAmt/-' - : 'N/A', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - ], - ), - if (!Responsive.isDesktop(context) && - _gmcSiSwitcher == true) - Container( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: + Responsive.isDesktop(context) + ? 6 + : 8, + child: Container( + alignment: + Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + addOnsDependentPolicyName ?? + '', + textAlign: + TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage - Dependent AddOns', + textAlign: + TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + ], + ))), + if (Responsive.isDesktop(context) && + _addOnsDependentSwitcher) + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (addOnsDependentOpenForEnrollment == + 0 || + (addOnsDependentOpenForEnrollment != + 0 && + addOnsDependentECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + addOnsSelectedDependent = + value; + }); + addOnsDependentCalculation( + value); + // calculationForDependentSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets.symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + addOnsSelectedDependent, + items: (addOnsDependentSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn[ + 'si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + Expanded( + flex: 3, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Switch( + value: + _addOnsDependentSwitcher, + onChanged: (addOnsDependentOpenForEnrollment == + 0 || + (addOnsDependentOpenForEnrollment != + 0 && + addOnsDependentECardDownload != + null)) + ? null + : (value) { + setState(() { + _addOnsDependentSwitcher = + value; + // Add your logic here based on the toggle state + }); + }, + activeColor: Color( + 0xFFE26728), // Color when the switch is ON + inactiveTrackColor: Colors + .grey, // Color of the switch track when OFF + ), + ], + ))), + ], + ), + if (_addOnsDependentSwitcher == true) + SizedBox(height: 10), + if (!Responsive.isDesktop(context) && + _addOnsDependentSwitcher == true) + Row( children: [ + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + IgnorePointer( + ignoring: (addOnsDependentOpenForEnrollment == + 0 || + (addOnsDependentOpenForEnrollment != + 0 && + addOnsDependentECardDownload != + null)), + child: + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + addOnsSelectedDependent = + value; + }); + addOnsDependentCalculation( + value); + // calculationForDependentSumValue( + // 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: + 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets.symmetric( + vertical: + 5, + horizontal: + 5), + ), + value: + addOnsSelectedDependent, + items: (addOnsDependentSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn[ + 'si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ) + ], + ))), + ], + ), + SizedBox(height: 20), + if (_addOnsDependentSwitcher == true) + Column( + children: familyFloaterContainers, + ), + if (_addOnsDependentSwitcher) + SizedBox(height: 20), + if (Responsive.isDesktop(context) && + _addOnsDependentSwitcher) Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - flex: 6, + flex: 5, child: Container( - alignment: - Alignment.centerLeft, + alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment @@ -1855,51 +3683,31 @@ class _addOnsDetailsState extends State { 'Additional Premium', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, + style: GoogleFonts + .poppins( + fontSize: 20, fontWeight: FontWeight.w500, ), ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ Text( - gmcAddOnSiPremiumValue != + addOnDependentPremiumValue != null - ? '₹ $gmcAddOnSiPremiumValue/Year' + ? '₹ $addOnDependentPremiumValue/Year' : 'N/A', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 16, + style: GoogleFonts + .poppins( + fontSize: 18, ), ), ], ))), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ Expanded( - flex: 6, + flex: 2, child: Container( - alignment: - Alignment.centerLeft, + alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment @@ -1912,50 +3720,31 @@ class _addOnsDetailsState extends State { 'GST', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, + style: GoogleFonts + .poppins( + fontSize: 20, fontWeight: FontWeight.w500, ), ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ Text( - siPremiumGst != null - ? '₹ $siPremiumGst/-' + addOnsDependentPremiumGst != + null + ? '₹ $addOnsDependentPremiumGst/-' : 'N/A', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 16, + style: GoogleFonts + .poppins( + fontSize: 18, ), ), ], ))), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ Expanded( - flex: 6, + flex: 5, child: Container( - alignment: - Alignment.centerLeft, + alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment @@ -1968,675 +3757,464 @@ class _addOnsDetailsState extends State { 'Total Payable', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, + style: GoogleFonts + .poppins( + fontSize: 20, fontWeight: FontWeight.w500, ), ), - ], - ))), - Expanded( - flex: 5, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ Text( - siTotalAmt != null - ? '₹ $siTotalAmt/-' + addOnsDependentTotalAmt != + null + ? '₹ $addOnsDependentTotalAmt/-' : 'N/A', textAlign: TextAlign.start, - style: TextStyle( - fontSize: 16, + style: GoogleFonts + .poppins( + fontSize: 18, ), ), ], ))), ], ), - ])) - ], - ), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - color: Color( - 0xFFDDF3FF), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(25) - : EdgeInsets.all(10), - child: Column( - children: [ - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, + if (!Responsive.isDesktop(context) && + _addOnsDependentSwitcher == true) + Container( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - addOnsPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Medical Coverage - Add Dependent', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: - FontWeight.w600, - ), - ), - ], - ))), - if (Responsive.isDesktop(context) && - _gmcDependentSwitcher) - Expanded( - flex: 3, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField< - String>( - onChanged: (value) { - setState(() { - gmcAddOnsselectedDependent = - value; - }); - calculationForDependentSumValue( - 'Edit'); - }, - decoration: - InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Sum Insured', - labelText: - 'Sum Insured', - contentPadding: - EdgeInsets - .symmetric( - vertical: 5, - horizontal: - 5), - ), - value: - gmcAddOnsselectedDependent, - items: (addOnsSlabRates ?? - []) - .map< - DropdownMenuItem< - String>>( - (addOn) { - return DropdownMenuItem< - String>( - value: addOn['si'] - .toString(), - child: Text( - '₹ ${addOn['si']}'), - ); - }).toList(), - ), - ], - ))), - Expanded( - flex: 3, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, + Row( crossAxisAlignment: - CrossAxisAlignment.end, + CrossAxisAlignment.start, children: [ - Switch( - value: - _gmcDependentSwitcher, - onChanged: (value) { - setState(() { - _gmcDependentSwitcher = - value; - // Add your logic here based on the toggle state - }); - }, - activeColor: Color( - 0xFFE26728), // Color when the switch is ON - inactiveTrackColor: Colors - .grey, // Color of the switch track when OFF - ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + addOnDependentPremiumValue != + null + ? '₹ $addOnDependentPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), ], - ))), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'GST', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + addOnsDependentPremiumGst != + null + ? '₹ $addOnsDependentPremiumGst/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment + .centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + addOnsDependentTotalAmt != + null + ? '₹ $addOnsDependentTotalAmt/-' + : 'N/A', + textAlign: + TextAlign + .start, + style: + GoogleFonts + .poppins( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) ], - ), - if (_gmcDependentSwitcher == true) - SizedBox(height: 10), - if (!Responsive.isDesktop(context) && - _gmcDependentSwitcher == true) - Row( - children: [ - Expanded( - flex: 3, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField< - String>( - onChanged: (value) { - setState(() { - gmcAddOnsselectedDependent = - value; - }); - calculationForDependentSumValue( - 'Edit'); - }, - decoration: - InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Sum Insured', - labelText: - 'Sum Insured', - contentPadding: - EdgeInsets - .symmetric( - vertical: 5, - horizontal: - 5), - ), - value: - gmcAddOnsselectedDependent, - items: (addOnsSlabRates ?? - []) - .map< - DropdownMenuItem< - String>>( - (addOn) { - return DropdownMenuItem< - String>( - value: addOn['si'] - .toString(), - child: Text( - '₹ ${addOn['si']}'), - ); - }).toList(), - ), - ], - ))), - ], - ), - SizedBox(height: 20), - if (_gmcDependentSwitcher == true) - Column( - children: familyFloaterContainers, - ), - if (_gmcDependentSwitcher) - SizedBox(height: 20), - if (Responsive.isDesktop(context) && - _gmcDependentSwitcher) - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Additional Premium', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - gmcAddOnDependentPremiumValue != - null - ? '₹ $gmcAddOnDependentPremiumValue/Year' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'GST', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - dependentPremiumGst != - null - ? '₹ $dependentPremiumGst/-' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Total Payable', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w500, - ), - ), - Text( - dependentTotalAmt != null - ? '₹ $dependentTotalAmt/-' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - ], - ), - if (!Responsive.isDesktop(context) && - _gmcDependentSwitcher == true) - Container( - child: Column( + )), + ], + ), + )), + SizedBox(height: 16), + if (addOnsDependentMappedFamilyFloatersDependent == null && + topUpMappedFamilyFloatersSi == null && + topUpParentMappedFamilyFloatersSi == null) + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - 'Additional Premium', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight - .w500, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - gmcAddOnDependentPremiumValue != - null - ? '₹ $gmcAddOnDependentPremiumValue/Year' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 16, - ), - ), - ], - ))), + Checkbox( + value: isChecked, + onChanged: (bool? value) { + setState(() { + isChecked = value!; + }); + }, + activeColor: Color(0xFFE26728), + ), ], - ), - Row( + ))), + Expanded( + flex: 11, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.end, children: [ - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - 'GST', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight - .w500, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - dependentPremiumGst != - null - ? '₹ $dependentPremiumGst/-' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 16, - ), - ), - ], - ))), + Text( + 'I declare that the information I have provided is true and accurate to the best of my knowledge', + textAlign: Responsive.isDesktop( + context) + ? TextAlign.left + : TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 15, + color: Color(0xFF292929), + ), + ), ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: - Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - 'Total Payable', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight - .w500, - ), - ), - ], - ))), - Expanded( - flex: 5, - child: Container( - alignment: - Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - dependentTotalAmt != - null - ? '₹ $dependentTotalAmt/-' - : 'N/A', - textAlign: - TextAlign.start, - style: TextStyle( - fontSize: 16, - ), - ), - ], - ))), - ], - ), - ])) + ))), ], + ), + ), + SizedBox( + height: Responsive.isDesktop(context) ? 15 : 0), + Container( + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: Responsive.isDesktop(context) + ? 150 + : 100, + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed( + context, 'empDetails'); + }, + child: Text( + 'Back', + style: GoogleFonts.poppins( + color: Color(0xFFE26728)), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + side: BorderSide( + color: Color(0xFFE26728)), + ), + ), + ), + )), + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: + isChecked ? sendAddOnAPI : null, + child: Text( + 'Submit', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ), + ], + ), + )) + else + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + backFunction(); + }, + child: Text( + 'Back', + style: GoogleFonts.poppins( + color: Color(0xFFE26728)), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: + BorderSide(color: Color(0xFFE26728)), + ), + ), + ), + )), + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: + addOnsDependentMappedFamilyFloatersDependent != + null || + topUpMappedFamilyFloatersSi != + null || + topUpParentMappedFamilyFloatersSi != + null + ? () { + if (_topUpSiSwitcher == false) { + removeAddonsGmcSiToAPI(); + } else { + print('checkSiTopUp'); + checkSiTopUp(); + } + + if (_topUpParentSiSwitcher == + false) { + removeAddonsGmcParentSiToAPI(); + } else { + print('checkSiParentTopUp'); + checkSiParentTopUp(); + } + + if (_addOnsDependentSwitcher == + false) { + removeAddonsGmcDependentToAPI(); + } else { + print('checkDependentTopUp'); + checkDependentTopUp(); + sendAddonsGmcDependentToAPI(); + } + Navigator.pushNamed( + context, 'empReviewDetails'); + } + : null, + child: Text( + 'Continue ', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + ), )), ], ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 20, bottom: 20, left: 30, right: 30) - : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed(context, 'empDetails'); - }, - child: Text( - 'Back', - style: TextStyle(color: Color(0xFFE26728)), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide(color: Color(0xFFE26728)), - ), - ), - ), - )), - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { - if (_gmcSiSwitcher == true && - _gmcDependentSwitcher == true) { - sendAddonsGmcSiToAPI(); - sendAddonsGmcDependentToAPI(); - Navigator.pushNamed( - context, 'empReviewDetails', - arguments: { - 'siData': [ - { - 'gmcAddOnSiPremiumValue': - gmcAddOnSiPremiumValue, - 'siPremiumGst': siPremiumGst, - 'siTotalAmt': siTotalAmt, - } - ], - 'dependentData': [ - { - 'gmcAddOnDependentPremiumValue': - gmcAddOnDependentPremiumValue, - 'dependentPremiumGst': - dependentPremiumGst, - 'dependentTotalAmt': - dependentTotalAmt, - } - ] - }); - } else if (_gmcSiSwitcher == true) { - sendAddonsGmcSiToAPI(); - Navigator.pushNamed( - context, 'empReviewDetails', - arguments: { - 'siData': [ - { - 'gmcAddOnSiPremiumValue': - gmcAddOnSiPremiumValue, - 'siPremiumGst': siPremiumGst, - 'siTotalAmt': siTotalAmt, - } - ], - 'dependentData': [] - }); - } else if (_gmcDependentSwitcher == true) { - sendAddonsGmcDependentToAPI(); - Navigator.pushNamed( - context, 'empReviewDetails', - arguments: { - 'siData': [], - 'dependentData': [ - { - 'gmcAddOnDependentPremiumValue': - gmcAddOnDependentPremiumValue, - 'dependentPremiumGst': - dependentPremiumGst, - 'dependentTotalAmt': - dependentTotalAmt, - } - ] - }); - } else { - Navigator.pushNamed( - context, 'empReviewDetails', - arguments: { - 'siData': [], - 'dependentData': [] - }); - } - }, - child: Text( - 'Continue ', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - ), - ), - ), - )), - ], ), ), - ), ], ), ), @@ -2650,6 +4228,10 @@ class _addOnsDetailsState extends State { print(floaterData); print(relationshipOptions); print('test'); + print(_relationShipController); + print(_memberNameController); + print(_dobController); + dynamic popupName = floaterData['button_name']; // Check if the action is 'Edit' selectedRelationships = relationshipOptions @@ -2659,58 +4241,32 @@ class _addOnsDetailsState extends State { .toList(); print(selectedRelationships); - print(addOnsMappedFamilyFloatersDependent); + print(addOnsDependentMappedFamilyFloatersDependent); if (action == 'Add') { - print('Add'); - // Filter the addOnsMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true - dynamic getTrueObjects = addOnsMappedFamilyFloatersDependent - .where((element) => element['is_value_exist'] == true) - .toList(); + if (floaterData['form_type'] == 'parent_in_law' || + floaterData['form_type'] == 'parent') { + print('Add'); + // Filter the addOnsDependentMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true + dynamic getTrueObjects = addOnsDependentMappedFamilyFloatersDependent + .where((element) => element['is_value_exist'] == true) + .toList(); - print(getTrueObjects); + print(getTrueObjects); - List> getTrueDataObjects = getTrueObjects - .map>( - (element) => element['data'] as Map) - .toList(); + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); - print(getTrueDataObjects); + print(getTrueDataObjects); - List relationships = getTrueDataObjects.map((dataObject) { - return dataObject['relationship']; - }).toList(); + selectedRelationships.removeWhere((relationship) => + getTrueDataObjects.any((dataObject) => + dataObject['relationship'] == + relationship['relationship_name'])); - // Print the list of relationship values - print(relationships); - - List> filteredDataObjects = - getTrueDataObjects.where((dataObject) { - // Check if the relationship value of dataObject is not found in selectedRelationships - return !selectedRelationships.any((selectedRelationship) => - selectedRelationship['relationship_name'] == - dataObject['relationship']); - }).toList(); - - // Print the filtered data objects - print(filteredDataObjects); - - print("Not matching objects: $filteredDataObjects"); - - // List> notMatchingObjects = []; - - // Iterate through dataObject array - // for (var data in getTrueDataObjects) { - // String relationship = data['relationship']; - // - // // Check if relationship value does not match any relationship_name value in selectedRelationships - // if (!selectedRelationships - // .any((element) => element['relationship_name'] != relationship)) { - // notMatchingObjects.add(data); - // } - // } - - // Print the not matching objects - // print("Not matching objects: $notMatchingObjects"); + print(selectedRelationships); + } } if (action == 'Edit') { @@ -2725,8 +4281,13 @@ class _addOnsDetailsState extends State { context: context, builder: (BuildContext context) { return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + elevation: 0, + backgroundColor: Colors.transparent, content: SizedBox( - width: 800, + width: Responsive.isDesktop(context) ? 500 : 800, child: SingleChildScrollView( child: Card( elevation: 0, @@ -2751,7 +4312,7 @@ class _addOnsDetailsState extends State { CrossAxisAlignment.center, children: [ Text(popupName ?? '', - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xFFE26728), @@ -2763,132 +4324,115 @@ class _addOnsDetailsState extends State { ], ), SizedBox(height: 15), - Row( + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - flex: 4, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField( + Container( + width: double.infinity, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Relationship', + labelText: 'Relationship', + contentPadding: EdgeInsets.symmetric( + vertical: 5, horizontal: 5), + ), + value: action == 'Edit' + ? _relationShipController.text + : null, + onChanged: (value) { + _relationShipController.text = value!; + }, + items: selectedRelationships + .map((relationship) { + final String relationshipName = + relationship[ + 'relationship_name'] ?? + ''; + return DropdownMenuItem( + value: relationshipName, + child: Text(relationshipName), + ); + }).toList(), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + width: double.infinity, + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: TextFormField( + controller: _memberNameController, + onChanged: (value) => null, decoration: InputDecoration( border: OutlineInputBorder(), - hintText: 'Relationship', - labelText: 'Relationship', + hintText: 'Member Full Name', + labelText: 'Member Full Name', contentPadding: EdgeInsets.symmetric( - vertical: 5, horizontal: 5), + vertical: 10, + horizontal: 15), ), - value: action == 'Edit' - ? _relationShipController.text - : null, - onChanged: (value) { - _relationShipController.text = - value!; + validator: (value) { + if (value == null || + value.isEmpty) { + return 'Member Full Name is required'; + } + return null; }, - items: selectedRelationships - .map((relationship) { - final String relationshipName = - relationship[ - 'relationship_name'] ?? - ''; - return DropdownMenuItem( - value: relationshipName, - child: Text(relationshipName), - ); - }).toList(), ), - ], - ), + ), + ], ), ), - SizedBox(width: 10), - Expanded( - flex: 4, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: TextFormField( - controller: _memberNameController, - onChanged: (value) => null, - decoration: InputDecoration( - border: OutlineInputBorder(), - hintText: 'Member Full Name', - labelText: 'Member Full Name', - contentPadding: - EdgeInsets.symmetric( - vertical: 10, - horizontal: 15), + SizedBox(height: 10), + Container( + width: double.infinity, + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + child: TextFormField( + controller: _dobController, + onTap: () { + _selectDate(context, floaterData); + }, + readOnly: true, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'DD-MM-YYYY', + labelText: 'Date of Birth', + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today), + onPressed: () { + _selectDate( + context, floaterData); + }, ), - validator: (value) { - if (value == null || - value.isEmpty) { - return 'Member Full Name is required'; - } - return null; - }, - ), - ) - ], - ), - ), - ), - SizedBox(width: 10), - Expanded( - flex: 4, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Container( - child: TextFormField( - controller: _dobController, - onTap: () { - _selectDate(context, - floaterData['form_type']); - }, - readOnly: true, - decoration: InputDecoration( - border: OutlineInputBorder(), - hintText: 'DD-MM-YYYY', - labelText: 'Date of Birth', - suffixIcon: IconButton( - icon: - Icon(Icons.calendar_today), - onPressed: () { - // Open date picker when the icon is pressed - _selectDate( - context, - floaterData[ - 'form_type']); // Pass 'child' for child form type - }, - ), - contentPadding: - EdgeInsets.symmetric( - vertical: 10, - horizontal: 15, - ), + contentPadding: + EdgeInsets.symmetric( + vertical: 10, + horizontal: 15, ), ), - ) - ], - ), + ), + ), + ], ), ), ], @@ -2908,7 +4452,8 @@ class _addOnsDetailsState extends State { }, child: Text( 'Cancel', - style: TextStyle(color: Colors.white), + style: GoogleFonts.poppins( + color: Colors.white), ), style: ElevatedButton.styleFrom( backgroundColor: Color(0xFFE26728), @@ -2920,11 +4465,20 @@ class _addOnsDetailsState extends State { ), )), Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + // Check if any of the fields are empty + if (_relationShipController + .text.isEmpty || + _memberNameController + .text.isEmpty || + _dobController.text.isEmpty) { + ToastHelper.showWarningToast(context, + 'All fields are required'); + } else { // Create a map to hold the form data Map formData = { 'relationship': @@ -2932,7 +4486,6 @@ class _addOnsDetailsState extends State { 'memberName': _memberNameController.text, 'dateOfBirth': _dobController.text, - // Add more form fields as needed }; @@ -2942,20 +4495,23 @@ class _addOnsDetailsState extends State { // Close the dialog Navigator.of(context).pop(); - }, - child: Text( - 'Continue', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(5), - ), + } + }, + child: Text( + 'Save', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), ), ), - )), + ), + ), + ), ], ), ], @@ -2971,4 +4527,207 @@ class _addOnsDetailsState extends State { }, ); } + + List generateGmcCards(List data) { + List cards = []; + + for (var item in data) { + setState(() { + gmcPolicyName = item['Policy_Name']; + gmcFloaterTextHeading = item['floter_text_heading']; + gmcFloaterTextDescription = item['floter_text_description']; + gmcNotes = item['notes']; + gmcECardDownload = item['eCardDownload']; + // gmcSumInsured = item['Policy_Terms']['sum_insured']; + gmcMappedFamilyFloaters = item['mapped_family_floaters']; + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + print('getTrueObjects'); + print(getTrueObjects); + if (getTrueObjects.length > 0) { + print('true'); + gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"]; + } else { + print('false'); + gmcSumInsured = item['Policy_Terms']['sum_insured']; + } + gmcTypeName = item['type']; + }); + print('forEach Card'); + print(gmcMappedFamilyFloaters); + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + Widget card = getTrueObjects.length > 0 + ? Card( + elevation: 0, + 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Row( + children: [ + Text( + gmcTypeName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + if (gmcECardDownload != null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = + Uri.parse(gmcECardDownload); + // 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 $gmcECardDownload'); + } + }, + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: Icon( + Icons.file_download, + color: Color(0xFFE26728), + size: 25, + ), + ), + ), + ], + ), + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + gmcFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 16, + 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: gmcMappedFamilyFloaters + .where((item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + String formattedDate = formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 18 : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )) + : SizedBox(height: 0); + + cards.add(card); + } + + return cards; + } } diff --git a/lib/customAppBar/customAppBar.dart b/lib/customAppBar/customAppBar.dart index c943119..e60e363 100644 --- a/lib/customAppBar/customAppBar.dart +++ b/lib/customAppBar/customAppBar.dart @@ -17,7 +17,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { if (token != null && token.isNotEmpty) { if (hrtoken != null && hrtoken.isNotEmpty) { prefs.remove('token'); - Navigator.pushNamed(context, 'hrHome'); + Navigator.pushNamed(context, 'hrDashboard'); } else { await prefs.clear(); Navigator.pushNamed(context, 'phone'); @@ -99,13 +99,12 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { Navigator.pushNamed(context, "routeName"); }, ), - if (Responsive.isDesktop(context)) - NavBarItem( - text: "", - onTap: () { - Navigator.pushNamed(context, "routeName"); - }, - ), + NavBarItem( + text: "Inactive Policy", + onTap: () { + Navigator.pushNamed(context, 'oldPolicy'); + }, + ), NavBarItem( text: "Logout", onTap: () async { diff --git a/lib/empDetails.dart b/lib/empDetails.dart index b2d0029..452103a 100644 --- a/lib/empDetails.dart +++ b/lib/empDetails.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -13,6 +14,7 @@ import 'package:intl/intl.dart'; import 'dart:io'; import 'dart:async'; import 'package:nhancepolicy/responsive.dart'; +import 'package:url_launcher/url_launcher.dart'; class empDetails extends StatefulWidget { const empDetails({Key? key}) : super(key: key); @@ -22,12 +24,13 @@ class empDetails extends StatefulWidget { } class _empDetailsState extends State { + bool isLoading = true; dynamic _token; dynamic empCodeString; dynamic empPrimaryId; dynamic gpaEmpName; dynamic client_id; - List> gpaPolicies = []; + dynamic gpaPolicies; dynamic gpaPolicyName; dynamic gpaGridMaster; dynamic gpasumInsured; @@ -38,6 +41,11 @@ class _empDetailsState extends State { dynamic gpaSelfDob; dynamic gpaSelfRelationship; dynamic gpaSelfDetails; + dynamic gpaOpenForEnrollment; + dynamic gpaECardDownload; + dynamic gmcECardDownload; + int gmcOpenForEnrollment = 0; + dynamic gmcPolicies; dynamic gmcSlabRates = []; dynamic gmcMappedFamilyFloaters = []; dynamic gmcSelfName; @@ -48,6 +56,9 @@ class _empDetailsState extends State { dynamic gmcNotes; dynamic gmcGridMaster; dynamic gmcSumInsured; + dynamic gmcFloaterTextDescription; + dynamic gmcFloaterTextHeading; + dynamic gmcTypeName; dynamic clientName; dynamic clientLogo; late TextEditingController _relationShipController; @@ -70,6 +81,10 @@ class _empDetailsState extends State { dynamic selfEmailPersonal; dynamic selfEmpCode; dynamic selfFamilyFloaterKey; + dynamic selfEmpStatus; + dynamic gmcDataIsEmpty = 1; + dynamic gpaDataIsEmpty = 1; + dynamic hrPrimaryId; @override void initState() { @@ -80,6 +95,12 @@ class _empDetailsState extends State { // _loadToken(); Timer(Duration(seconds: 2), tokenAPI); + + Future.delayed(Duration(seconds: 3), () { + setState(() { + isLoading = false; + }); + }); } @override @@ -93,6 +114,12 @@ class _empDetailsState extends State { void tokenAPI() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); if (prefs.containsKey('hrtoken')) { + String? getHrToken = prefs.getString('hrtoken'); + Map? decodedToken = Jwt.parseJwt(getHrToken!); + print(decodedToken); + hrPrimaryId = decodedToken['id']; + print('hrPrimaryId'); + print(hrPrimaryId); _hrLoadToken(); } else { _loadToken(); @@ -101,6 +128,9 @@ class _empDetailsState extends State { Future _hrLoadToken() async { print('_hrLoadToken'); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('fromHrLoginMobileNo', mobileNumber); + // Retrieve the passed mobile number value dynamic login_by_hr = true; try { @@ -123,7 +153,7 @@ class _empDetailsState extends State { String status = data['status']; print(status); if (status == 'success') { - final SharedPreferences prefs = await SharedPreferences.getInstance(); + // final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('token', data['data']); // Decode the JWT token received from the API response @@ -143,9 +173,15 @@ class _empDetailsState extends State { // Redirect to another page final token = prefs.getString('token'); if (token != null && token.isNotEmpty) { - ToastHelper.showSuccessToast(context, 'Successfully Login'); + // ToastHelper.showSuccessToast(context, 'Successfully Login'); getSelfEmployeeProfile(); - getClientLogoAndDetails(); + if (prefs.containsKey('clientLogo') && + prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(); + } getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); fetchRelationshipList(); @@ -158,19 +194,18 @@ class _empDetailsState extends State { Navigator.pushReplacementNamed(context, 'phone'); } } else { - ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); + // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); // Show a Snackbar if the OTP is invalid // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); print('Invalid OTP. Please try again'); } } else { - ToastHelper.showErrorToast(context, 'Failed to verify OTP'); + // ToastHelper.showErrorToast(context, 'Failed to verify OTP'); throw Exception('Failed to verify OTP'); } } catch (e) { print('Error: $e'); - ToastHelper.showErrorToast( - context, 'Failed to verify OTP. Please try again.'); + ToastHelper.showErrorToast(context, 'Something went wrong'); // Show a Snackbar if there's an error while verifying OTP // ToastHelper.showErrorToast( // context, 'Failed to verify OTP. Please try again.'); @@ -199,7 +234,12 @@ class _empDetailsState extends State { // print(empPrimaryId); // Call the API when the page enters getSelfEmployeeProfile(); - getClientLogoAndDetails(); + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(); + } getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); fetchRelationshipList(); @@ -228,8 +268,12 @@ class _empDetailsState extends State { // print(data); if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('clientLogo', clientDetails['client']['client_logo']); + prefs.setString('clientName', clientDetails['client']['client_name']); setState(() { - dynamic clientDetails = data['data']; + // dynamic clientDetails = data['data']; // print(clientDetails); clientName = clientDetails['client']['client_name']; print(clientName); @@ -238,14 +282,14 @@ class _empDetailsState extends State { }); } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -255,8 +299,8 @@ class _empDetailsState extends State { } Future getSelfEmployeeProfile() async { - var url = Uri.parse( - Environment.apiUrl + 'getEmployeeProfile?emp_code=$empCodeString'); + var url = Uri.parse(Environment.apiUrl + + 'getEmployeeProfile?emp_code=$empCodeString&client_id=$client_id'); try { var response = await http.get( url, @@ -279,25 +323,28 @@ class _empDetailsState extends State { selfName = selfDetails['name']; selfMobile = selfDetails['mobile']; selfDesignation = selfDetails['designation']; - selfDob = selfDetails['dob']; - selfDoj = selfDetails['doj']; + selfDob = convertDateFormat(selfDetails['dob']); + selfDoj = convertDateFormat(selfDetails['doj']); selfGender = selfDetails['gender']; selfEmailCorporate = selfDetails['email_corporate']; selfEmailPersonal = selfDetails['email_personal']; selfEmpCode = selfDetails['emp_code']; selfFamilyFloaterKey = selfDetails['family_floater_key']; // print(clientDetails); + selfEmpStatus = selfDetails['emp_status']; }); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('selfEmpStatus', selfEmpStatus); } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -306,9 +353,23 @@ class _empDetailsState extends State { } } + String convertDateFormat(String? date) { + if (date == null || date.isEmpty) + return ''; // Return empty string if date is null or empty + + // Parse the date string to DateTime + DateTime dateTime = DateTime.parse(date); + + // Format the DateTime object to the desired format (DD-MM-YYYY) + String formattedDate = + '${dateTime.day.toString().padLeft(2, '0')}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.year}'; + + return formattedDate; + } + Future getGpaEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA'); try { var response = await http.get( url, @@ -323,8 +384,8 @@ class _empDetailsState extends State { print(data); if (data.containsKey('data')) { - dynamic gpaPolicies = data['data']; - print(gpaPolicies); + gpaPolicies = data['data']; + print('gpaPolicies'); // Assuming data is a List print(gpaPolicies); if (gpaPolicies.isNotEmpty) { @@ -333,7 +394,8 @@ class _empDetailsState extends State { print('GPA Policies found: $gpaPolicies'); gpaPolicyName = gpaPolicies['Policy_Name'].toString(); print(gpaPolicyName); - gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + gpasumInsured = gpaPolicies['mapped_family_floaters']['data'] + ['basic_cover_si']; print(gpasumInsured); gpaMappedFamilyFloaters = gpaPolicies['mapped_family_floaters']['data']; @@ -344,29 +406,27 @@ class _empDetailsState extends State { gpaSelfRelationship = gpaMappedFamilyFloaters['relationship'].toString(); gpaSelfDetails = gpaSelfRelationship + ' . ' + gpaSelfDob; - // gpaGridMaster = await gpaPolicies[0]['GridMaster']; - // gpaSlabRates = await gpaPolicies[0]['SlabRates']; - // gpaClintPolicyId = await gpaPolicies[0]['ClientPolicyId']; + gpaOpenForEnrollment = gpaPolicies['OpenForEnrollment']; - // gpaSelectedSI = - // gpaMappedFamilyFloaters['basic_cover_si'].toString(); + gpaECardDownload = gpaPolicies['eCardDownload']; }); } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); + 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, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast(context, 'Something went wrong'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + ToastHelper.showWarningToast(context, 'Something went wrong'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -377,7 +437,7 @@ class _empDetailsState extends State { Future getGmcEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC'); try { var response = await http.get( url, @@ -391,43 +451,26 @@ class _empDetailsState extends State { Map data = json.decode(response.body); print(data); - if (data.containsKey('data')) { - dynamic gmcPolicies = data['data']; - print(gmcPolicies); + if (data['status'] == 'success') { + setState(() { + gmcPolicies = data['data']; + print('gmcPolicies'); + }); // Assuming data is a List print(gmcPolicies); - if (gmcPolicies.isNotEmpty) { - setState(() { - print('GPM Policies found: $gmcPolicies'); - gmcPolicyName = gmcPolicies['Policy_Name'].toString(); - print(gmcPolicyName); - gmcNotes = gmcPolicies['notes'].toString(); - gmcSumInsured = - gmcPolicies['Policy_Terms']['sum_insured'].toString(); - print(gmcSumInsured); - print('gmcMappedFamilyFloaters'); - gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; - print('gmcMappedFamilyFloaters'); - print(gmcMappedFamilyFloaters); - }); - gmcMappedFamilyFloaters = - await gmcPolicies['mapped_family_floaters']; - print(gmcMappedFamilyFloaters); - } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); - print('No data found in the response'); - } } else { + setState(() { + gmcDataIsEmpty = 0; + }); // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -474,21 +517,34 @@ class _empDetailsState extends State { } } - Future _selectDate(BuildContext context, [String? formType]) async { + Future _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; final DateTime now = DateTime.now(); - if (formType == '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); + + // 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); + // } // Ensure initialDate is within the range of minDate and maxDate DateTime initialDate = @@ -546,8 +602,7 @@ class _empDetailsState extends State { print('Item deleted successfully'); } else { // Handle errors - ToastHelper.showErrorToast(context, - 'Failed to delete item. Status code: ${response.statusCode}'); + ToastHelper.showErrorToast(context, 'Failed to delete item'); print('Failed to delete item. Status code: ${response.statusCode}'); print('Response body: ${response.body}'); } @@ -563,6 +618,18 @@ class _empDetailsState extends State { print(formData); print(floatedData); print(action); + + final SharedPreferences prefs = await SharedPreferences.getInstance(); + dynamic primaryId; + dynamic is_createdby_hr; + if (prefs.containsKey('hrtoken')) { + primaryId = hrPrimaryId; + is_createdby_hr = 1; + } else { + primaryId = empPrimaryId; + is_createdby_hr = 0; + } + formDataList.add({ 'relationship': formData['relationship'], 'name': formData['memberName'], @@ -570,6 +637,8 @@ class _empDetailsState extends State { 'emp_code': empCodeString, 'client_id': client_id, 'client_policy_id': floatedData['client_policy_id'], + 'created_by': primaryId, + 'is_createdby_hr': is_createdby_hr, // Add the 'id' field only if action is 'Edit' if (action == 'Edit') 'id': floatedData['employee_id'], }); @@ -604,8 +673,7 @@ class _empDetailsState extends State { print('Form data sent successfully.'); } else { // Request failed, handle error - ToastHelper.showErrorToast( - context, 'Failed to send form data. Error: ${response.reasonPhrase}'); + ToastHelper.showErrorToast(context, 'Failed'); print('Failed to send form data. Error: ${response.reasonPhrase}'); } } @@ -627,6 +695,7 @@ class _empDetailsState extends State { mobileNumber = arguments["mobile"]; // Call your tokenAPI or _loadToken function here print("_hrLoadToken"); + print(mobileNumber); // _hrLoadToken(); } } else { @@ -634,295 +703,49 @@ class _empDetailsState extends State { // _loadToken(); mobileNumber = ''; } - if (gmcMappedFamilyFloaters == [] && gmcMappedFamilyFloaters == null) { + if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) { + print('body if'); + print(gpaPolicies); return Scaffold( appBar: CustomAppBar(), body: SingleChildScrollView( child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), color: Color(0xFFEFF3F6), child: Column( children: [ - Center( - child: Text('No Data Available'), - ) - ], - ), - ), - )); - } else { - List familyFloaterContainers = []; - for (var floater in gmcMappedFamilyFloaters) { - bool isValueExist = floater['is_value_exist']; - Map 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, + Card( + elevation: 0, child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( 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, - ), - ), - ], - ), - ), - ), - SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), - Expanded( - flex: Responsive.isDesktop(context) ? 9 : 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - floaterData['name'] ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop(context) ? 18 : 16, - fontWeight: FontWeight.w600, - ), - ), - Text( - '${floaterData['relationship']} - ${floaterData['dob']}', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop(context) ? 18 : 16, - ), - ), - ], - ), - ), - ), - if (isValueExist && floaterData['relationship'] != 'Self') - Expanded( - flex: Responsive.isDesktop(context) ? 1 : 2, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - deleteItem(floaterData); - }, - child: Text( - 'Delete', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop(context) ? 16 : 15, - color: Color( - 0xFFE26728), // Add underline decoration - ), - ), - ), - ) - ], - ), - ), - ), - Expanded( - flex: - (isValueExist && floaterData['relationship'] != 'Self') - ? Responsive.isDesktop(context) - ? 1 - : 2 - : Responsive.isDesktop(context) - ? 2 - : 4, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - if (floaterData['relationship'] == 'Self') { - openSelfForm('View'); - } else { - openForm(floaterData, 'Edit'); - } - }, - child: Text( - floaterData['relationship'] == 'Self' - ? 'View' - : 'Edit', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop(context) ? 16 : 15, - color: Color( - 0xFFE26728), // Add underline decoration - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - ), - ); - } else { - familyFloaterContainers.add(MouseRegion( - cursor: SystemMouseCursors.click, // Set cursor to pointer - child: GestureDetector( - onTap: () { - // Handle the click event to open the form - openForm(floaterData, 'Add'); - }, - child: Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF000000), - width: 1, - ), - borderRadius: BorderRadius.circular(5), - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(12) - : EdgeInsets.all(10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: Responsive.isDesktop(context) ? 1 : 4, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - color: Color(0xFF6A6A6A), - borderRadius: BorderRadius.circular(5), - ), - child: Icon( - Icons.person_add, - color: Colors.white, - size: 20, - ), - ), - ], - ), - ), - ), - SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), - Expanded( - flex: Responsive.isDesktop(context) ? 11 : 8, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - floaterData['button_name'] ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: - Responsive.isDesktop(context) ? 22 : 18, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - ), - ), - ], - ), - ), // Replace YourChildWidget with the widget you want to wrap - ), - )); - } - familyFloaterContainers.add(SizedBox(height: 15)); - } - return Scaffold( - appBar: CustomAppBar(), - body: SingleChildScrollView( - child: Container( - padding: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.2, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding - ) - : EdgeInsets.all(10), - color: Color(0xFFEFF3F6), - child: Column( - children: [ - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 20, bottom: 20, left: 30, right: 30) - : EdgeInsets.only( - top: 12, - bottom: 12, - left: 10, - right: 10), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 3, + Expanded( + flex: 6, child: Container( width: 150, height: 150, alignment: Alignment.centerLeft, child: Image.network( - clientLogo, - width: Responsive.isDesktop(context) - ? 80 - : 50, // Set the width here - height: Responsive.isDesktop(context) - ? 80 - : 80, // Set the height here + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { @@ -940,518 +763,566 @@ class _empDetailsState extends State { ), ); }, + errorBuilder: (BuildContext context, + Object error, StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, ), - )), - Expanded( - flex: 9, - child: Text( - clientName ?? '', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop(context) ? 20 : 18, - fontWeight: FontWeight.w600, ), ), - ) - ], + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, + ), + ), + ) + ], + ), ), ), - ), - SizedBox(height: 16), - Card( + SizedBox(height: 16), + Card( elevation: 0, - child: Padding( + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height, 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gpaPolicyName ?? 'NA', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, bottom: 12, left: 10, right: 10), + child: Center( + child: Text( + 'No Active Current policies ', + textAlign: TextAlign + .center, // Align text center within the Card + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + height: 5, ), - 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: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 16, - fontWeight: FontWeight.w600, - ), - ), - Text( - gpaSelfDetails ?? 'NA', - textAlign: TextAlign.left, - style: TextStyle( - 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: TextStyle( - fontSize: - Responsive.isDesktop( - context) - ? 16 - : 15, - color: Color( - 0xFFE26728), // Add underline decoration - ), - ), - ), - ) - ], - ))), - ], - ), - ), - ], + ), ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gmcPolicyName ?? 'NA', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: 15), - Container( - decoration: BoxDecoration( - color: Color( - 0xFFF9F9FB), // 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: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Please Note', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - fontWeight: FontWeight.w600, - ), - ), - Text( - gmcNotes ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 15, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: - Text('Please review your enrolled dependents.', - style: TextStyle( - fontSize: Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF181818), - fontWeight: FontWeight.w500, - )), - ), - SizedBox(height: 15), - Column( - children: familyFloaterContainers, - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 20, bottom: 20, left: 30, right: 30) - : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 12, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed(context, 'addOnsDetails'); - }, - child: Text( - 'Continue', - style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ), + )); + } else { + return Scaffold( + appBar: CustomAppBar(), + body: Stack(children: [ + SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress + .expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, + Object error, StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), + ), + ), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, + ), + ), + ) + ], + ), + ), + ), + SizedBox(height: 16), + if (gpaPolicies != null && gpaPolicies.length > 0) + Card( + elevation: 0, + 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: 8, + 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 + : 14, + ), + ), + Row( + children: [ + Text( + 'Group Personal Accident Coverage ', + textAlign: + TextAlign.left, + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 20 + : 16, + 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: 4, + 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 + : 14, + ), + ), + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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 + ), + ), + ), + ) + ], + ))), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + if (gmcPolicies != null && gmcPolicies.length > 0) + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ...generateCards(gmcPolicies), + ], + ), + SizedBox(height: 16), + if (gmcPolicies != null && gmcPolicies.length > 0) + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed( + context, 'addOnsDetails'); + }, + child: Text( + 'Continue', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ), + ), + ], ), - ], + ), ), - ), - ), - ); + if (isLoading) + Container( + color: Color(0xFFFFFCE5), // Semi-transparent background + child: Center( + child: // Your GIF loader widget + Image.asset( + height: 60, + width: 60, + 'assets/nhance-loader.gif'), // Adjust path to your GIF loader + ), + ), + ])); } } @@ -1470,7 +1341,33 @@ class _empDetailsState extends State { .toList(); print(selectedRelationships); - if (action == 'Edit') { + print(gmcMappedFamilyFloaters); + if (action == 'Add') { + if (floaterData['form_type'] == 'parent_in_law' || + floaterData['form_type'] == 'parent') { + print('Add'); + // Filter the addOnsDependentMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); + + print(getTrueDataObjects); + + selectedRelationships.removeWhere((relationship) => + getTrueDataObjects.any((dataObject) => + dataObject['relationship'] == + relationship['relationship_name'])); + + print(selectedRelationships); + } + } else { // Set values to all fields _relationShipController.text = floaterData['relationship'] ?? ''; _memberNameController.text = floaterData['name'] ?? ''; @@ -1515,7 +1412,7 @@ class _empDetailsState extends State { CrossAxisAlignment.center, children: [ Text(popupName ?? '', - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xFFE26728), @@ -1613,8 +1510,7 @@ class _empDetailsState extends State { child: TextFormField( controller: _dobController, onTap: () { - _selectDate(context, - floaterData['form_type']); + _selectDate(context, floaterData); }, readOnly: true, decoration: InputDecoration( @@ -1624,8 +1520,8 @@ class _empDetailsState extends State { suffixIcon: IconButton( icon: Icon(Icons.calendar_today), onPressed: () { - _selectDate(context, - floaterData['form_type']); + _selectDate( + context, floaterData); }, ), contentPadding: @@ -1656,7 +1552,8 @@ class _empDetailsState extends State { }, child: Text( 'Cancel', - style: TextStyle(color: Colors.white), + style: GoogleFonts.poppins( + color: Colors.white), ), style: ElevatedButton.styleFrom( backgroundColor: Color(0xFFE26728), @@ -1673,27 +1570,38 @@ class _empDetailsState extends State { alignment: Alignment.centerRight, child: ElevatedButton( onPressed: () { - // Create a map to hold the form data - Map formData = { - 'relationship': - _relationShipController.text, - 'memberName': - _memberNameController.text, - 'dateOfBirth': _dobController.text, + if (_relationShipController + .text.isEmpty || + _memberNameController + .text.isEmpty || + _dobController.text.isEmpty) { + ToastHelper.showWarningToast( + context, + 'All fields are required'); + } else { + Map formData = { + 'relationship': + _relationShipController.text, + 'memberName': + _memberNameController.text, + 'dateOfBirth': + _dobController.text, - // Add more form fields as needed - }; + // Add more form fields as needed + }; - // Call the function to send form data to API - saveFamilyMemberDetails( - formData, floaterData, action); + // Call the function to send form data to API + saveFamilyMemberDetails( + formData, floaterData, action); - // Close the dialog - Navigator.of(context).pop(); + // Close the dialog + Navigator.of(context).pop(); + } }, child: Text( 'Save', - style: TextStyle(color: Colors.white), + style: GoogleFonts.poppins( + color: Colors.white), ), style: ElevatedButton.styleFrom( backgroundColor: Color(0xFFE26728), @@ -1757,8 +1665,8 @@ class _empDetailsState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text('Self Details', - style: TextStyle( + Text('Member Details', + style: GoogleFonts.poppins( fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xFFE26728), @@ -2048,7 +1956,8 @@ class _empDetailsState extends State { }, child: Text( 'Close', - style: TextStyle(color: Colors.white), + style: GoogleFonts.poppins( + color: Colors.white), ), style: ElevatedButton.styleFrom( backgroundColor: Color(0xFFE26728), @@ -2074,4 +1983,473 @@ class _empDetailsState extends State { }, ); } + + List generateCards(List data) { + List cards = []; + + for (var item in data) { + print('item'); + print(item); + setState(() { + gmcPolicyName = item['Policy_Name']; + gmcFloaterTextHeading = item['floter_text_heading']; + gmcFloaterTextDescription = item['floter_text_description']; + gmcNotes = item['notes']; + gmcECardDownload = item['eCardDownload']; + + gmcMappedFamilyFloaters = item['mapped_family_floaters']; + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + print('getTrueObjects'); + print(getTrueObjects); + if (getTrueObjects.length > 0) { + print('true'); + gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"]; + } else { + print('false'); + gmcSumInsured = item['Policy_Terms']['sum_insured']; + } + String intOpenForEnrollment = item['OpenForEnrollment']; + gmcOpenForEnrollment = int.parse(intOpenForEnrollment); + gmcTypeName = item['type']; + }); + + List familyFloaterContainers = []; + for (var floater in gmcMappedFamilyFloaters) { + bool isValueExist = floater['is_value_exist']; + Map 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, + ), + ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), + Expanded( + flex: Responsive.isDesktop(context) ? 9 : 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['name'] ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + fontWeight: FontWeight.w600, + ), + ), + Text( + '${floaterData['relationship']} - ${floaterData['dob']}', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + ), + ), + ], + ), + ), + ), + if (gmcOpenForEnrollment != 0) + if (gmcECardDownload == null) + if (isValueExist && floaterData['relationship'] != 'Self') + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + deleteItem(floaterData); + }, + child: Text( + 'Delete', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 16 + : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), + if (gmcOpenForEnrollment != 0) + if (gmcECardDownload == null) + Expanded( + flex: (isValueExist && + floaterData['relationship'] != 'Self') + ? Responsive.isDesktop(context) + ? 1 + : 2 + : Responsive.isDesktop(context) + ? 2 + : 4, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + if (floaterData['relationship'] == 'Self') { + openSelfForm('View'); + } else { + openForm(floaterData, 'Edit'); + } + }, + child: Text( + floaterData['relationship'] == 'Self' + ? 'View' + : 'Edit', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 16 + : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), + ], + ), + ), + ); + } else { + familyFloaterContainers.add(MouseRegion( + cursor: SystemMouseCursors.click, // Set cursor to pointer + child: GestureDetector( + onTap: () { + // Handle the click event to open the form + if (gmcOpenForEnrollment != 0) { + if (gmcECardDownload == null) { + openForm(floaterData, 'Add'); + } + } + }, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(12) + : EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF6A6A6A), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.person_add, + color: Colors.white, + size: 20, + ), + ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), + Expanded( + flex: Responsive.isDesktop(context) ? 11 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['button_name'] ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 22 : 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ], + ), + ), // Replace YourChildWidget with the widget you want to wrap + ), + )); + } + familyFloaterContainers.add(SizedBox(height: 15)); + } + + Widget card = Card( + elevation: 0, + 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? 'NA', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Row( + children: [ + Text( + gmcTypeName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + if (gmcECardDownload != null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = + Uri.parse(gmcECardDownload); + + // 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 $gmcECardDownload'); + } + }, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: Icon( + Icons.file_download, + color: Color(0xFFE26728), + size: 25, + ), + ), + ), + ], + ), + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + gmcFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 10), + Container( + padding: + EdgeInsets.only(top: 0, bottom: 0, left: 10, right: 10), + child: Text(gmcFloaterTextDescription, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 14 : 11, + color: Color(0xFF727272), + )), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: Color( + 0xFFF9F9FB), // 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: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Please Note', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 14, + fontWeight: FontWeight.w600, + ), + ), + Text( + gmcNotes ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 15, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: + EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15), + child: Text('Please review your enrolled dependents.', + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w500, + )), + ), + SizedBox(height: 15), + Column( + children: familyFloaterContainers, + ), + ], + ), + )); + + cards.add(card); + } + + return cards; + } } diff --git a/lib/empReview.dart b/lib/empReview.dart index e87bf2a..cbe9aff 100644 --- a/lib/empReview.dart +++ b/lib/empReview.dart @@ -1,5 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:intl/intl.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/responsive.dart'; @@ -10,6 +12,7 @@ import 'package:http/http.dart' as http; import 'package:flutter/widgets.dart'; import 'package:flutter/services.dart'; import 'dart:convert'; +import 'package:url_launcher/url_launcher.dart'; class empReviewDetails extends StatefulWidget { const empReviewDetails({Key? key}) : super(key: key); @@ -25,16 +28,20 @@ class _empReviewDetailsState extends State { dynamic empPrimaryId; dynamic gpaEmpName; dynamic client_id; - List> gpaPolicies = []; + dynamic gpaPolicies; dynamic gpaPolicyName; dynamic gpaGridMaster; + dynamic gmcPolicies; dynamic gpasumInsured; - dynamic gpaClintPolicyId; - dynamic gpaMappedFamilyFloaters; + dynamic gpaClintPolicyId = 0; + dynamic gpaMappedFamilyFloaters = []; dynamic gpaSelfName; dynamic gpaSelfDob; dynamic gpaSelfRelationship; dynamic gpaSelfDetails; + dynamic gpaECardDownload; + dynamic gmcECardDownload; + dynamic gmcClintPolicyId = 0; dynamic gmcMappedFamilyFloaters = []; dynamic gmcSelfName; dynamic gmcSelfDob; @@ -43,32 +50,70 @@ class _empReviewDetailsState extends State { dynamic gmcPolicyName; dynamic gmcNotes; dynamic gmcSumInsured; + dynamic gmcTypeName; dynamic clientName; dynamic clientLogo; - dynamic addOnsMappedFamilyFloatersSi; - dynamic addOnsMappedFamilyFloatersDependent; - dynamic addOnsClientPolicyId; - dynamic addOnsSlabRates; + dynamic addOnsDependentMappedFamilyFloatersArray; + dynamic addOnsDependentClientPolicyId; dynamic gmcAddOnsselectedSI; dynamic gmcAddOnsselectedDependent; + dynamic gmcFloaterTextDescription; + dynamic gmcFloaterTextHeading; dynamic dependentValue; dynamic siValue; - dynamic gmcAddOnDependentPremiumValue; - dynamic gmcAddOnSiPremiumValue; - dynamic addOnsSumInsured; - dynamic dependentPremiumGst; - dynamic siPremiumGst; - dynamic addOnsPolicyName; - dynamic dependentTotalAmt; - dynamic siTotalAmt; + dynamic addOnsDependentSumInsured; + dynamic addOnsDependentPolicyName; + dynamic addOnsFloaterTextHeading; + dynamic addOnsDependentECardDownload; dynamic addOnsFamilyFloater; late DateTime? selectedDate; - dynamic totalPayableAmt; + int totalPayableAmt = 0; List> relationshipOptions = []; List> selectedRelationships = []; List> formDataList = []; - dynamic activeSiData; - dynamic activeDependentData; + dynamic topUpMappedFamilyFloatersSi; + dynamic topUpMappedFamilyFloatersSiArray; + dynamic topUpClientPolicyId; + dynamic topUpSlabRates; + dynamic topUpFamilyFloater; + dynamic topUpPolicyName; + dynamic topUpTypeName; + int topUpSiPremiumValue = 0; + int topUpSiPremiumGst = 0; + int topUpSiTotalAmt = 0; + int topUpParentSiPremiumValue = 0; + int topUpParentSiPremiumGst = 0; + int topUpParentSiTotalAmt = 0; + int addOnDependentPremiumValue = 0; + int addOnsDependentPremiumGst = 0; + int addOnsDependentTotalAmt = 0; + dynamic topUpSiValue; + dynamic topUpSiSelectedSI; + dynamic topUpSumInsured; + dynamic topUpFloaterTextHeading; + dynamic topUpECardDownload; + int showHideTopUpCard = 0; + int showHideAddOnsCard = 0; + int showHideTopUpParentCard = 0; + dynamic iAgreeForAddOn = []; + dynamic topUpSiParentPolicies = []; + dynamic topUpParentClientPolicyId; + dynamic topUpParentSlabRates; + dynamic topUpParentPolicyName; + dynamic topUpParentFamilyFloater; + dynamic topUpParentMappedFamilyFloatersSi; + dynamic topUpParentECardDownload; + dynamic topUpParentSiValue; + dynamic topUpParentSiSelectedSI; + dynamic topUpParentTypeName; + dynamic topUpParentFloterTextHeading; + int topUpParentOpenForEnrollment = 0; + int activeSiData = 0; + int activeSiParentData = 0; + int activeDependentData = 0; + int activePremiumSummary = 0; + dynamic gmcDataIsEmpty = 1; + dynamic gpaDataIsEmpty = 1; @override void initState() { @@ -81,6 +126,16 @@ class _empReviewDetailsState extends State { super.dispose(); } + String formatDate(String inputDate) { + // Parse the input date string + DateTime dateTime = DateFormat('dd-MM-yyyy').parse(inputDate); + + // Format the date to the desired format + String formattedDate = DateFormat('dd MMM yyyy').format(dateTime); + + return formattedDate; + } + Future _loadToken() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); final String? token = prefs.getString('token'); @@ -98,10 +153,18 @@ class _empReviewDetailsState extends State { // print(empPrimaryId); // Call the API when the page enters - getClientLogoAndDetails(); - getAddOnsEmpPolicyDetails(); + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(); + } + getGmcSiTopUp(); + getGmcSiParentTopUp(); + getGmcDependentAddOns(); getGpaEmpPolicyDetails(empPrimaryId); getGmcEmpPolicyDetails(empPrimaryId); + primarySummary(); } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) // For now, let's navigate to the login screen @@ -110,6 +173,78 @@ class _empReviewDetailsState extends State { } } + void primarySummary() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + if (prefs.containsKey('siData')) { + activeSiData = 1; + String? siDataJson = prefs.getString('siData'); + print('siDataJson'); + print(siDataJson); + + List siDataList = jsonDecode(siDataJson!); + if (siDataList.isNotEmpty) { + // Access the first map in the list + Map firstSiData = siDataList.first; + // Get the value of topUpSiPremiumValue + topUpSiPremiumValue = firstSiData['topUpSiPremiumValue']; + topUpSiPremiumGst = firstSiData['topUpSiPremiumGst']; + topUpSiTotalAmt = firstSiData['topUpSiTotalAmt']; + } + } + if (prefs.containsKey('siParentData')) { + activeSiParentData = 1; + String? siParentDataJson = prefs.getString('siParentData'); + print('siParentDataJson'); + print(siParentDataJson); + + List siParentDataList = jsonDecode(siParentDataJson!); + if (siParentDataList.isNotEmpty) { + // Access the first map in the list + Map firstSiParentData = siParentDataList.first; + // Get the value of topUpSiPremiumValue + topUpParentSiPremiumValue = + firstSiParentData['topUpParentSiPremiumValue']; + topUpParentSiPremiumGst = firstSiParentData['topUpParentSiPremiumGst']; + topUpParentSiTotalAmt = firstSiParentData['topUpParentSiTotalAmt']; + } + } + if (prefs.containsKey('dependentData')) { + activeDependentData = 1; + String? dependentDataJson = prefs.getString('dependentData'); + print('dependentDataJson'); + print(dependentDataJson); + + List dependentDataList = jsonDecode(dependentDataJson!); + if (dependentDataList.isNotEmpty) { + // Access the first map in the list + Map firstDependentListData = dependentDataList.first; + // Get the value of topUpSiPremiumValue + addOnDependentPremiumValue = + firstDependentListData['addOnDependentPremiumValue']; + addOnsDependentPremiumGst = + firstDependentListData['addOnsDependentPremiumGst']; + addOnsDependentTotalAmt = + firstDependentListData['addOnsDependentTotalAmt']; + } + } + if (prefs.containsKey('siData') && + prefs.containsKey('siParentData') && + prefs.containsKey('dependentData')) { + activePremiumSummary = 0; + } else { + activePremiumSummary = 1; + } + // Calculate the sum, skipping any missing values + + if (topUpSiTotalAmt != null) totalPayableAmt += topUpSiTotalAmt; + if (topUpParentSiTotalAmt != null) totalPayableAmt += topUpParentSiTotalAmt; + if (addOnsDependentTotalAmt != null) + totalPayableAmt += addOnsDependentTotalAmt; + + // Print or use the totalAmtSum value + print('Sum of Total Amounts: $totalPayableAmt'); + } + Future getClientLogoAndDetails() async { var url = Uri.parse(Environment.apiUrl + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); @@ -149,7 +284,7 @@ class _empReviewDetailsState extends State { Future getGpaEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GPA'); try { var response = await http.get( url, @@ -164,7 +299,7 @@ class _empReviewDetailsState extends State { print(data); if (data.containsKey('data')) { - dynamic gpaPolicies = data['data']; + gpaPolicies = data['data']; print(gpaPolicies); // Assuming data is a List print(gpaPolicies); @@ -174,7 +309,8 @@ class _empReviewDetailsState extends State { print('GPA Policies found: $gpaPolicies'); gpaPolicyName = gpaPolicies['Policy_Name']; print(gpaPolicyName); - gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + gpasumInsured = gpaPolicies['mapped_family_floaters']['data'] + ['basic_cover_si']; print(gpasumInsured); gpaMappedFamilyFloaters = gpaPolicies['mapped_family_floaters']['data']; @@ -183,34 +319,41 @@ class _empReviewDetailsState extends State { // gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile']; gpaSelfDob = gpaMappedFamilyFloaters['dob']; gpaSelfRelationship = gpaMappedFamilyFloaters['relationship']; + gpaSelfDetails = gpaSelfName + - ' - ' + + ' ~ ' + gpaSelfRelationship + - ' - ' + - gpaSelfDob; + ' ~ ' + + ' DOB : ' + + formatDate(gpaSelfDob); // gpaGridMaster = await gpaPolicies[0]['GridMaster']; // gpaSlabRates = await gpaPolicies[0]['SlabRates']; - // gpaClintPolicyId = await gpaPolicies[0]['ClientPolicyId']; + gpaClintPolicyId = gpaPolicies['ClientPolicyId']; + + gpaECardDownload = gpaPolicies['eCardDownload']; // gpaSelectedSI = // gpaMappedFamilyFloaters['basic_cover_si'].toString(); }); } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); + setState(() { + gpaDataIsEmpty = 0; + }); + ToastHelper.showWarningToast(context, 'No data found'); print('No data found in the response'); } } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + ToastHelper.showWarningToast(context, 'Something went wrong'); print('API request failed with status: ${data['status']}'); } } else { + setState(() { + gpaDataIsEmpty = 0; + }); // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + ToastHelper.showErrorToast(context, 'Something went wrong'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -221,7 +364,7 @@ class _empReviewDetailsState extends State { Future getGmcEmpPolicyDetails(empPrimaryId) async { var url = Uri.parse(Environment.apiUrl + - 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&client_id=$client_id&policy=GMC'); try { var response = await http.get( url, @@ -235,38 +378,29 @@ class _empReviewDetailsState extends State { Map data = await json.decode(response.body); print(data); - if (data.containsKey('data')) { - dynamic gmcPolicies = data['data']; - print(gmcPolicies); + if (data['status'] == 'success') { + setState(() { + gmcPolicies = data['data']; + print('gmcPolicies'); + }); // Assuming data is a List print(gmcPolicies); - if (gmcPolicies.isNotEmpty) { - setState(() { - print('GPM Policies found: $gmcPolicies'); - gmcPolicyName = gmcPolicies['Policy_Name']; - print(gmcPolicyName); - gmcNotes = gmcPolicies['notes']; - gmcSumInsured = gmcPolicies['Policy_Terms']['sum_insured']; - print(gmcSumInsured); - - gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; - print(gmcMappedFamilyFloaters); - }); - } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); - print('No data found in the response'); - } } else { + setState(() { + gmcDataIsEmpty = 0; + }); // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + setState(() { + gmcDataIsEmpty = 0; + }); // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -275,9 +409,9 @@ class _empReviewDetailsState extends State { } } - Future getAddOnsEmpPolicyDetails() async { + Future getGmcSiTopUp() async { var url = Uri.parse(Environment.apiUrl + - 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString'); + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-TOPUP'); try { var response = await http.get( url, @@ -288,51 +422,236 @@ class _empReviewDetailsState extends State { ); if (response.statusCode == 200) { print('response.statusCode == 200'); - Map data = await json.decode(response.body); - print('222222222'); + Map data = json.decode(response.body); print(data); if (data.containsKey('data')) { - dynamic addOnsPolicies = data['data']; - print(addOnsPolicies); - if (addOnsPolicies.isNotEmpty) { - setState(() { - addOnsClientPolicyId = - addOnsPolicies['addon_policy']['client_policy_id']; - print('AddonS'); - addOnsSumInsured = - addOnsPolicies['addon_policy']['policy_terms']['sum_insured']; - print(addOnsSumInsured); + dynamic topUpSiPolicies = data['data']; + print(topUpSiPolicies); + if (topUpSiPolicies.isNotEmpty) { + // setState(() { + topUpClientPolicyId = + topUpSiPolicies['gmc_si_topup']['client_policy_id']; - addOnsPolicyName = addOnsPolicies['addon_policy']['policy_name']; - print(addOnsPolicyName); + topUpSumInsured = topUpSiPolicies['gmc_si_topup'] + ['family_floaters_of_only_si_value']; + print(topUpSumInsured); - addOnsMappedFamilyFloatersSi = addOnsPolicies['addon_policy'] - ['family_floaters_of_only_si_array']; - print('addOnsMappedFamilyFloatersSi'); - print(addOnsMappedFamilyFloatersSi); + if (topUpSumInsured == 0) { + showHideTopUpCard = 0; + } else { + showHideTopUpCard = 1; + } - addOnsMappedFamilyFloatersDependent = - addOnsPolicies['addon_policy'] - ['family_floaters_of_dependent_and_si_array']; - print('addOnsMappedFamilyFloatersDependent'); - print(addOnsMappedFamilyFloatersDependent); - }); + topUpPolicyName = + await topUpSiPolicies['gmc_si_topup']['policy_name']; + + topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup'] + ['family_floaters_of_only_si_array']; + print('topUpMappedFamilyFloatersSiArray'); + print(topUpMappedFamilyFloatersSiArray); + + topUpTypeName = topUpSiPolicies['gmc_si_topup']['type']; + + topUpFloaterTextHeading = + topUpSiPolicies['gmc_si_topup']['floter_text_heading']; + + topUpECardDownload = + topUpSiPolicies['gmc_si_topup']['eCardDownload']; + // }); } else { - ToastHelper.showErrorToast( - context, 'No data found in the response'); + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); print('No data found in the response'); } } else { // Handle other status messages if needed - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGmcSiParentTopUp() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-SI-PARENT-TOPUP'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print('parent'); + print(data); + + if (data.containsKey('data')) { + setState(() { + topUpSiParentPolicies = data['data']; + print('topUpSiParentPolicies'); + print(topUpSiParentPolicies); + }); + if (topUpSiParentPolicies.isNotEmpty) { + // setState(() { + topUpParentClientPolicyId = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['client_policy_id']; + + topUpParentSlabRates = + await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates']; + print('topUpParentSlabRates'); + print(topUpParentSlabRates); + + topUpParentPolicyName = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['policy_name']; + + topUpParentFamilyFloater = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['policy_terms']['family_floater']; + print('topUpParentFamilyFloater'); + print(topUpParentFamilyFloater); + + topUpParentMappedFamilyFloatersSi = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_array']; + print('topUpParentMappedFamilyFloatersSi'); + print(topUpParentMappedFamilyFloatersSi); + + print('topUpECardDownload'); + topUpParentECardDownload = + topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload']; + print(topUpParentECardDownload); + String intOpenForEnrollment = + topUpSiParentPolicies['gmc_si_parent_topup'] + ['OpenForEnrollment']; + topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment); + print(topUpParentOpenForEnrollment); + + topUpParentTypeName = + topUpSiParentPolicies['gmc_si_parent_topup']['type']; + + topUpParentFloterTextHeading = + topUpSiParentPolicies['gmc_si_parent_topup'] + ['floter_text_heading']; + + topUpParentSiValue = + await topUpSiParentPolicies['gmc_si_parent_topup'] + ['family_floaters_of_only_si_value']; + + if (topUpParentSiValue == 0) { + showHideTopUpParentCard = 0; + } else { + showHideTopUpParentCard = 1; + } + // }); + } else { + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGmcDependentAddOns() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString&policy=GMC-DEPENDENT-ADDON'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print('222222222'); + print(data); + + if (data.containsKey('data')) { + dynamic addOnsDependentPolicies = data['data']; + print('addOnsDependentPolicies'); + print(addOnsDependentPolicies); + if (addOnsDependentPolicies.isNotEmpty) { + // setState(() { + addOnsDependentClientPolicyId = + addOnsDependentPolicies['gmc_dependent_addon'] + ['client_policy_id']; + print(addOnsDependentClientPolicyId); + + addOnsDependentSumInsured = + addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_si_value']; + print(addOnsDependentSumInsured); + + if (addOnsDependentSumInsured == 0) { + showHideAddOnsCard = 0; + } else { + showHideAddOnsCard = 1; + } + + addOnsDependentPolicyName = + addOnsDependentPolicies['gmc_dependent_addon']['policy_name']; + print(addOnsDependentPolicyName); + + addOnsDependentMappedFamilyFloatersArray = + await addOnsDependentPolicies['gmc_dependent_addon'] + ['family_floaters_of_dependent_and_si_array']; + print('addOnsDependentMappedFamilyFloatersArray'); + print(addOnsDependentMappedFamilyFloatersArray); + + addOnsFloaterTextHeading = + addOnsDependentPolicies['gmc_dependent_addon'] + ['floter_text_heading']; + + addOnsDependentECardDownload = + addOnsDependentPolicies['gmc_dependent_addon']['eCardDownload']; + } else { + // ToastHelper.showErrorToast( + // context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -342,23 +661,90 @@ class _empReviewDetailsState extends State { } Future sendAddOnAPI() async { - var url = Uri.parse(Environment.apiUrl + - 'iAgreeForAddOn?emp_code=$empCodeString&client_policy_id=$addOnsClientPolicyId&client_id=$client_id'); + if (addOnsDependentMappedFamilyFloatersArray != null) { + dynamic getDependentTrueObjects = addOnsDependentMappedFamilyFloatersArray + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getDependentTrueObjects); + + if (getDependentTrueObjects.isNotEmpty) { + iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId)); + } + } + + if (topUpMappedFamilyFloatersSiArray != null) { + dynamic getSiTrueObjects = topUpMappedFamilyFloatersSiArray + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getSiTrueObjects); + + if (getSiTrueObjects.isNotEmpty) { + iAgreeForAddOn.add(int.parse(topUpClientPolicyId)); + } + } + + if (topUpParentMappedFamilyFloatersSi != null) { + dynamic getSiTrueObjects = topUpParentMappedFamilyFloatersSi + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getSiTrueObjects); + + if (getSiTrueObjects.isNotEmpty) { + iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId)); + } + } + + print('gpaPolicies'); + print(gpaPolicies); + print('gmcPolicies'); + print(gmcPolicies); + + if (gpaDataIsEmpty != 0) { + iAgreeForAddOn.add(int.parse(gpaClintPolicyId)); + } + + if (gmcDataIsEmpty != 0) { + for (var item in gmcPolicies) { + // Extract ClientPolicyId value from each object + String clientPolicyId = item['ClientPolicyId']; + // Convert to integer and add to iAgreeForAddOn list + iAgreeForAddOn.add(int.parse(clientPolicyId)); + } + } + print('iAgreeForAddOn'); + iAgreeForAddOn = iAgreeForAddOn.toSet().toList(); + print(iAgreeForAddOn); // Output: [90, 92, 88, 89] + + Map apiParams = { + 'emp_code': empCodeString, + 'client_policy_id': iAgreeForAddOn, + 'client_id': client_id, + }; + print(apiParams); + + // Convert the list of objects to JSON + String formDataJson = jsonEncode(apiParams); + + var url = Uri.parse(Environment.apiUrl + 'iAgreeForAddOn'); try { - var response = await http.get( + var response = await http.post( url, headers: { 'Authorization': 'Bearer $_token', // Add token to the Authorization header }, + body: formDataJson, ); + if (response.statusCode == 200) { print('response.statusCode == 200'); ToastHelper.showSuccessToast(context, 'Saved Successfully...'); } else { // Handle other status codes - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); + ToastHelper.showErrorToast(context, 'Failed to Save'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -369,62 +755,8 @@ class _empReviewDetailsState extends State { @override Widget build(BuildContext context) { - dynamic arguments = ModalRoute.of(context)!.settings.arguments; - - if (arguments != null && arguments is Map) { - if (arguments.containsKey('siData') || - arguments.containsKey('dependentData')) { - print('siData'); - final List? siData = arguments['siData']; - print(siData); - if (siData != null && siData.isNotEmpty) { - gmcAddOnSiPremiumValue = siData[0]['gmcAddOnSiPremiumValue']; - siPremiumGst = siData[0]['siPremiumGst']; - siTotalAmt = siData[0]['siTotalAmt']; - activeSiData = '0'; - } else { - // Handle empty siData list - gmcAddOnSiPremiumValue = 'NA'; - siPremiumGst = 'NA'; - siTotalAmt = 'NA'; - activeSiData = '1'; - } - - print('dependentData'); - final List? dependentData = arguments['dependentData']; - print(dependentData); - if (dependentData != null && dependentData.isNotEmpty) { - gmcAddOnDependentPremiumValue = - dependentData[0]['gmcAddOnDependentPremiumValue'] ?? 'NA'; - dependentPremiumGst = dependentData[0]['dependentPremiumGst'] ?? 'NA'; - dependentTotalAmt = dependentData[0]['dependentTotalAmt'] ?? 'NA'; - activeDependentData = '0'; - } else { - // Handle empty dependentData list - gmcAddOnDependentPremiumValue = 'NA'; - dependentPremiumGst = 'NA'; - dependentTotalAmt = 'NA'; - activeDependentData = '1'; - } - if (dependentTotalAmt != 'NA' && siTotalAmt != 'NA') { - totalPayableAmt = dependentTotalAmt + siTotalAmt; - } else if (dependentTotalAmt == 'NA') { - totalPayableAmt = siTotalAmt; - } else if (siTotalAmt == 'NA') { - totalPayableAmt = dependentTotalAmt; - } else { - totalPayableAmt = 'NA'; - } - } - } else { - print("Arguments are null or not in the expected format"); - gmcAddOnDependentPremiumValue = 'NA'; - dependentPremiumGst = 'NA'; - dependentTotalAmt = 'NA'; - totalPayableAmt = 'NA'; - } - - if (gmcMappedFamilyFloaters == []) { + if ((gpaMappedFamilyFloaters == [] && gpaMappedFamilyFloaters == null) && + (gmcMappedFamilyFloaters == [] && gmcMappedFamilyFloaters == null)) { return Scaffold( appBar: CustomAppBar(), body: SingleChildScrollView( @@ -433,7 +765,11 @@ class _empReviewDetailsState extends State { child: Column( children: [ Center( - child: Text('No Data Available'), + child: Text('No Data Available', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + )), ) ], ), @@ -471,44 +807,48 @@ class _empReviewDetailsState extends State { child: Row( children: [ Expanded( - flex: 3, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.network( - clientLogo, - width: Responsive.isDesktop(context) - ? 80 - : 50, // Set the width here - height: Responsive.isDesktop(context) - ? 80 - : 80, // Set the height here - loadingBuilder: (BuildContext context, - Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: CircularProgressIndicator( - value: - loadingProgress.expectedTotalBytes != - null - ? loadingProgress - .cumulativeBytesLoaded / - loadingProgress - .expectedTotalBytes! - : null, - ), - ); - }, - ), - )), + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, Object error, + StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, + ), + ), + ), Expanded( flex: 9, child: Text( clientName ?? '', textAlign: TextAlign.right, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop(context) ? 20 : 18, fontWeight: FontWeight.w600, ), @@ -542,7 +882,7 @@ class _empReviewDetailsState extends State { Text( 'Review', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop(context) ? 20 @@ -570,7 +910,7 @@ class _empReviewDetailsState extends State { Text( 'Total Payable', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop(context) ? 18 @@ -593,7 +933,7 @@ class _empReviewDetailsState extends State { Text( '₹$totalPayableAmt/Year ', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop(context) ? 22 @@ -609,274 +949,832 @@ class _empReviewDetailsState extends State { ])), ), SizedBox(height: 16), - Card( - elevation: 0, - 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 + if (gpaPolicies != null && gpaPolicies.length > 0) + Card( + elevation: 0, + 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: 8, + 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 + : 14, + ), + ), + Row( + children: [ + Text( + 'Group Personal Accident Coverage', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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: 4, + 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 + : 14, + ), + ), + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), ), - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gpaPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) + 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 - : 14, - ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), + color: Color(0xFF232526), + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - ], - ), - )), + ], + ), + )), SizedBox(height: 16), - Card( - elevation: 0, - 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 + if (gmcPolicies != null && gmcPolicies.length > 0) + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ...generateGmcCards(gmcPolicies), + ], + ), + SizedBox(height: 16), + if (showHideTopUpCard == 1) + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), ), - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - gmcPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, + SizedBox(height: 15), + 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + topUpPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, + Row( + children: [ + Text( + 'Group Medical Coverage - Top Up', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + if (topUpECardDownload != + null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = Uri.parse( + topUpECardDownload); + + // 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 $topUpECardDownload'); + } + }, + child: MouseRegion( + cursor: + SystemMouseCursors + .click, + child: Icon( + Icons.file_download, + color: + Color(0xFFE26728), + size: 25, + ), + ), + ), + ], ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + topUpFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), ), - ), - Text( - '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, + Text( + '₹ ${topUpSumInsured != null ? topUpSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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: gmcMappedFamilyFloaters - .where( - (item) => item['is_value_exist'] == true) - .map((item) { - Map data = item['data']; - return 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( - '${data['name']} - ${data['relationship']} - ${data['dob']}', - style: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), + 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: topUpMappedFamilyFloatersSiArray + .where((item) => + item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + String formattedDate = + formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), ), ), - ), - ], - ); - }).toList(), + ], + ); + }).toList(), + ), ), - ), - ], - ), - )), - SizedBox(height: 16), + ], + ), + )), + SizedBox(height: showHideTopUpCard == 1 ? 16 : 0), + if (showHideTopUpParentCard == 1) + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + topUpParentPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Row( + children: [ + Text( + topUpParentTypeName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + if (topUpParentECardDownload != + null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = Uri.parse( + topUpParentECardDownload); + + // 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 $topUpParentECardDownload'); + } + }, + child: MouseRegion( + cursor: + SystemMouseCursors + .click, + child: Icon( + Icons.file_download, + color: + Color(0xFFE26728), + size: 25, + ), + ), + ), + ], + ), + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + topUpParentFloterTextHeading ?? + '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${topUpParentSiValue != null ? topUpParentSiValue : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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: topUpParentMappedFamilyFloatersSi + .where((item) => + item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + String formattedDate = + formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: showHideTopUpCard == 1 ? 16 : 0), + if (showHideAddOnsCard == 1) + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + 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: + Responsive.isDesktop(context) ? 9 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + addOnsDependentPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Row( + children: [ + Text( + 'Group Medical Coverage - Dependent AddOns', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + if (addOnsDependentECardDownload != + null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = Uri.parse( + addOnsDependentECardDownload); + + // 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 $addOnsDependentECardDownload'); + } + }, + child: MouseRegion( + cursor: + SystemMouseCursors + .click, + child: Icon( + Icons.file_download, + color: + Color(0xFFE26728), + size: 25, + ), + ), + ), + ], + ), + ], + ))), + Expanded( + flex: + Responsive.isDesktop(context) ? 3 : 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + addOnsFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${addOnsDependentSumInsured != null ? addOnsDependentSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + 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: + addOnsDependentMappedFamilyFloatersArray + .where((item) => + item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + return 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( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: showHideAddOnsCard == 1 ? 16 : 0), Card( elevation: 0, child: Padding( @@ -900,9 +1798,9 @@ class _empReviewDetailsState extends State { CrossAxisAlignment.start, children: [ Text( - 'Add Ons', + 'Premium Summary', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop( context) ? 18 @@ -917,310 +1815,6 @@ class _empReviewDetailsState extends State { ), ), SizedBox(height: 15), - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - addOnsPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Medical Coverage - Top Up', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${addOnsSumInsured != null ? addOnsSumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: addOnsMappedFamilyFloatersSi - .where( - (item) => item['is_value_exist'] == true) - .map((item) { - Map data = item['data']; - return 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( - '${data['name']} - ${data['relationship']} - ${data['dob']}', - style: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), - ), - ), - ), - ], - ); - }).toList(), - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(30) - : EdgeInsets.all(10), - child: Column( - children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add Ons', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 16, - color: Color(0xFF181818), - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - 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: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - addOnsPolicyName ?? '', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - 'Group Medical Coverage - Add Dependent', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 14, - ), - ), - Text( - '₹ ${addOnsSumInsured != null ? addOnsSumInsured : 'NA'}', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 20 - : 16, - 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: addOnsMappedFamilyFloatersDependent - .where( - (item) => item['is_value_exist'] == true) - .map((item) { - Map data = item['data']; - return 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( - '${data['name']} - ${data['relationship']} - ${data['dob']}', - style: TextStyle( - fontSize: - Responsive.isDesktop(context) - ? 18 - : 16, - color: Color(0xFF232526), - ), - ), - ), - ], - ); - }).toList(), - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: Responsive.isDesktop(context) - ? EdgeInsets.all(30) - : EdgeInsets.all(10), - child: Column( - children: [ Container( child: Row( crossAxisAlignment: CrossAxisAlignment.start, @@ -1246,9 +1840,9 @@ class _empReviewDetailsState extends State { child: Padding( padding: EdgeInsets.all(8.0), child: Text( - 'Premium Summary', + 'Policy ', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1265,7 +1859,7 @@ class _empReviewDetailsState extends State { child: Text( 'Additional Premium', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1282,7 +1876,7 @@ class _empReviewDetailsState extends State { child: Text( 'GST', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1299,7 +1893,7 @@ class _empReviewDetailsState extends State { child: Text( 'Total', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1312,7 +1906,7 @@ class _empReviewDetailsState extends State { ), ], ), - if (activeSiData == '0') + if (activeSiData == 1) TableRow( children: [ TableCell( @@ -1322,11 +1916,11 @@ class _empReviewDetailsState extends State { child: Text( Responsive.isDesktop( context) - ? 'Group Medical Coverage - Top Up' + ? topUpTypeName : 'GMC - Top Up', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1340,13 +1934,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$gmcAddOnSiPremiumValue/Year', + '₹$topUpSiPremiumValue/Year', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1360,13 +1954,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$siPremiumGst/-', + '₹$topUpSiPremiumGst/-', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1380,13 +1974,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$siTotalAmt/Year', + '₹$topUpSiTotalAmt/Year', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1397,7 +1991,92 @@ class _empReviewDetailsState extends State { ), ], ), - if (activeDependentData == '0') + if (activeSiParentData == 1) + TableRow( + children: [ + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + Responsive.isDesktop( + context) + ? topUpParentTypeName + : 'GMC - Parents Top Up', + textAlign: + TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$topUpParentSiPremiumValue/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.start + : TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$topUpParentSiPremiumGst/-', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.start + : TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$topUpParentSiTotalAmt/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.start + : TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + ], + ), + if (activeDependentData == 1) TableRow( children: [ TableCell( @@ -1411,7 +2090,7 @@ class _empReviewDetailsState extends State { : 'GMC - Dependent ', textAlign: TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1425,13 +2104,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$gmcAddOnDependentPremiumValue/Year', + '₹$addOnDependentPremiumValue/Year', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1445,13 +2124,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$dependentPremiumGst/-', + '₹$addOnsDependentPremiumGst/-', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1465,13 +2144,13 @@ class _empReviewDetailsState extends State { padding: EdgeInsets.all(8.0), child: Text( - '₹$dependentTotalAmt/Year', + '₹$addOnsDependentTotalAmt/Year', textAlign: Responsive.isDesktop( context) - ? TextAlign.end + ? TextAlign.start : TextAlign.start, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive .isDesktop( context) @@ -1506,7 +2185,7 @@ class _empReviewDetailsState extends State { Text( 'Total Payable', textAlign: TextAlign.left, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop( context) ? 20 @@ -1530,7 +2209,7 @@ class _empReviewDetailsState extends State { Text( '₹$totalPayableAmt/Year', textAlign: TextAlign.right, - style: TextStyle( + style: GoogleFonts.poppins( fontSize: Responsive.isDesktop( context) ? 18 @@ -1549,32 +2228,6 @@ class _empReviewDetailsState extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - flex: 11, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'I declare that the information I have provided is true and accurate to the best of my knowledge', - textAlign: - Responsive.isDesktop(context) - ? TextAlign.right - : TextAlign.start, - style: TextStyle( - fontSize: Responsive.isDesktop( - context) - ? 18 - : 15, - color: Color(0xFF292929), - ), - ), - ], - ))), Expanded( flex: 1, child: Container( @@ -1596,6 +2249,32 @@ class _empReviewDetailsState extends State { ), ], ))), + Expanded( + flex: 11, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'I declare that the information I have provided is true and accurate to the best of my knowledge', + textAlign: + Responsive.isDesktop(context) + ? TextAlign.left + : TextAlign.start, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 15, + color: Color(0xFF292929), + ), + ), + ], + ))), ], ), ), @@ -1613,13 +2292,20 @@ class _empReviewDetailsState extends State { : 100, alignment: Alignment.centerLeft, child: ElevatedButton( - onPressed: () { + onPressed: () async { + // Remove siData, siParentData, and dependentData from local storage + final SharedPreferences prefs = + await SharedPreferences + .getInstance(); + prefs.remove('siData'); + prefs.remove('siParentData'); + prefs.remove('dependentData'); Navigator.pushNamed( context, 'addOnsDetails'); }, child: Text( 'Back', - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFFE26728)), ), style: ElevatedButton.styleFrom( @@ -1644,7 +2330,8 @@ class _empReviewDetailsState extends State { isChecked ? sendAddOnAPI : null, child: Text( 'Submit', - style: TextStyle(color: Colors.white), + style: GoogleFonts.poppins( + color: Colors.white), ), style: ElevatedButton.styleFrom( backgroundColor: Color(0xFFE26728), @@ -1668,4 +2355,208 @@ class _empReviewDetailsState extends State { ); } } + + List generateGmcCards(List data) { + List cards = []; + + for (var item in data) { + setState(() { + gmcPolicyName = item['Policy_Name']; + gmcFloaterTextHeading = item['floter_text_heading']; + gmcFloaterTextDescription = item['floter_text_description']; + gmcNotes = item['notes']; + gmcECardDownload = item['eCardDownload']; + // gmcSumInsured = item['Policy_Terms']['sum_insured']; + gmcMappedFamilyFloaters = item['mapped_family_floaters']; + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + print('getTrueObjects'); + print(getTrueObjects); + if (getTrueObjects.length > 0) { + print('true'); + gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"]; + } else { + print('false'); + gmcSumInsured = item['Policy_Terms']['sum_insured']; + } + gmcTypeName = item['type']; + }); + print('forEach Card'); + print(gmcMappedFamilyFloaters); + dynamic getTrueObjects = gmcMappedFamilyFloaters + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + Widget card = getTrueObjects.length > 0 + ? Card( + elevation: 0, + 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Row( + children: [ + Text( + gmcTypeName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + if (gmcECardDownload != null) + GestureDetector( + onTap: () async { + // Convert the URL string to a Uri object + Uri uri = + Uri.parse(gmcECardDownload); + + // 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 $gmcECardDownload'); + } + }, + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: Icon( + Icons.file_download, + color: Color(0xFFE26728), + size: 25, + ), + ), + ), + ], + ), + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + gmcFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 16, + 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: gmcMappedFamilyFloaters + .where((item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + String formattedDate = formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 18 : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )) + : SizedBox(height: 0); + + cards.add(card); + } + + return cards; + } } diff --git a/lib/excel_verification.dart b/lib/excel_verification.dart index 8e44ae1..b0dba63 100644 --- a/lib/excel_verification.dart +++ b/lib/excel_verification.dart @@ -13,6 +13,9 @@ import 'package:flutter/foundation.dart' show kIsWeb; import 'package:excel/excel.dart'; import 'dart:io'; import 'package:intl/intl.dart'; +import 'package:csv/csv.dart'; + +import 'package:spreadsheet_decoder/spreadsheet_decoder.dart'; class excelVerify extends StatefulWidget { const excelVerify({Key? key}) : super(key: key); @@ -37,13 +40,17 @@ class _excelVerifyState extends State { dynamic columnIndexMismatchCount = 0; dynamic columnMissingCount = 0; List> extractedData = []; - dynamic policyName; - dynamic policyFirstPart; + dynamic argumentsData; List> originalData = []; // Original data source List> filteredData = []; // Filtered data source - dynamic client_policy_id; - dynamic policy_name; + dynamic policy_name; + dynamic clientPolicyId; + dynamic clientId; + dynamic policyType; + List> nonExcelFilteredData = []; + dynamic invalidRelationships = 0; + dynamic dobAgeCheckCount = 0; @override void initState() { super.initState(); @@ -53,6 +60,7 @@ class _excelVerifyState extends State { @override void dispose() { super.dispose(); + html.window.localStorage.remove('fileBytes'); } Future _loadToken() async { @@ -64,7 +72,7 @@ class _excelVerifyState extends State { }); Map? decodedToken = Jwt.parseJwt(token); clintID = decodedToken['client_id'].toString(); - await getPolicyName(clintID); + await getPolicyDetails(); } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) // For now, let's navigate to the login screen @@ -73,74 +81,40 @@ class _excelVerifyState extends State { } } - Future getPolicyName(String clintID) async { + Future getPolicyDetails() async { setState(() { - _isLoading = true; + clientPolicyId = argumentsData['client_policy_id']; + clientId = argumentsData['client_id']; + policyType = argumentsData['type']; + policy_name = argumentsData['policy_name']; }); - var url = - Uri.parse(Environment.apiUrl + 'getClientPolicy?client_id=' + clintID); - try { - var response = await http.get( - url, - headers: { - 'Authorization': 'Bearer $_token', - }, - ); - if (response.statusCode == 200) { - Map data = json.decode(response.body); - if (data['status'] == 'success') { - print(data); - setState(() { - dataPolicy = List>.from(data['data']); - print(dataPolicy); - - // Find the object where the 'type' matches the 'policyFirstPart' - Map matchingPolicy = dataPolicy.firstWhere( - (policy) => policy['type'] == policyFirstPart, - orElse: () => {} // Return an empty map if no matching policy is found - ); - print(matchingPolicy); - if (matchingPolicy != null) { - // Matching policy found - print('Matching Policy: $matchingPolicy'); - client_policy_id = matchingPolicy['client_policy_id']; - policy_name = matchingPolicy['policy_name']; - } else { - // No matching policy found - print('No matching policy found for $policyFirstPart'); - } - // getPolicyNameDetails = dataPolicy[0]['policy_name']; - // print(getPolicyNameDetails); - // getPolicyNo = dataPolicy[0]['client_policy_id']; - }); - - print('Successfully Sent'); - } else { - ToastHelper.showErrorToast( - context, 'API request failed with status: ${data['status']}'); - print('API request failed with status: ${data['status']}'); - } - } else { - ToastHelper.showErrorToast( - context, 'Request failed with status: ${response.statusCode}'); - print('Request failed with status: ${response.statusCode}'); - } - } catch (e) { - print('Exception occurred: $e'); - } finally { - setState(() { - _isLoading = false; - }); - } } + // Future _uploadFile1(importPolicyName) async { + // FilePickerResult? result = await FilePicker.platform.pickFiles( + // type: FileType.custom, + // allowedExtensions: ['xlsx', 'xls', 'csv'], + // ); + // + // if (result != null) { + // PlatformFile file = result.files.first; + // Uint8List fileBytes = file.bytes!; + // // Use the fileBytes as needed + // print('File name: ${file.name}'); + // print('File size: ${file.size}'); + // print('File bytes: $fileBytes'); + // _processExcelData(fileBytes); + // } else { + // // User canceled the picker + // } + // } + void _uploadFile(importPolicyName) async { print('Test'); if (kIsWeb) { print('kIsWeb'); final input = html.FileUploadInputElement(); - input.accept = '.xlsx'; + input.accept = '.xlsx,.xls,.csv'; input.click(); input.onChange.listen((event) async { final file = input.files!.first; @@ -159,7 +133,7 @@ class _excelVerifyState extends State { print('File Name: $fileName'); print('File Bytes: $fileBytes'); // Call the function to process Excel data here - _processExcelData(fileBytes); + _processExcelData(fileBytes, fileName); } } }); @@ -169,20 +143,33 @@ class _excelVerifyState extends State { } } - void _processExcelData(Uint8List fileBytes) { + void _processExcelData(Uint8List fileBytes, fileName) { + List> dataArray; + if (fileName.endsWith('.xlsx')) { + dataArray = decodeExcelData(fileBytes); + } else if (fileName.endsWith('.xls')) { + dataArray = decodeXLSData(fileBytes); + } else if (fileName.endsWith('.csv')) { + print('csv'); + dataArray = decodeCSVData(fileBytes); + } else { + throw UnsupportedError('Unsupported file format: $fileName'); + } + + print('_processExcelData'); // Decode the Excel file and extract relevant data // Assuming dataArray is your array containing Excel data - List> dataArray = decodeExcelData(fileBytes); - + // List> dataArray = decodeExcelData(fileBytes); + print(dataArray); // print(dataArray[0].toString()); // Extract Name, Age, and City from the array print(dataArray[0].length); - if (dataArray[0].length == 10) { + if (dataArray[0].length == 11) { for (int i = 0; i < dataArray.length; i++) { Map dataMap = { "Sno": dataArray[i][0].value, - "emp_code": dataArray[i][1].value, + "Emp_Code": dataArray[i][1].value, "Name": dataArray[i][2].value, "DOJ": dataArray[i][3].value, "Gender": dataArray[i][4].value, @@ -191,6 +178,7 @@ class _excelVerifyState extends State { "Mail": dataArray[i][7].value, "Mobile": dataArray[i][8].value, "SI": dataArray[i][9].value, + "Grade": dataArray[i][10].value, }; if (i == 0) { // print(dataMap); @@ -203,47 +191,79 @@ class _excelVerifyState extends State { // Do something with extracted data (e.g., display in UI) originalData = extractedData; filteredData = List.from(originalData); + print('filteredData'); print(filteredData); print(validationArray); validationArray[0].forEach((key, value) { print(key); print(value); - if (key.toString() != value.toString()) { + if (key.toString().trim().toLowerCase() != + value.toString().trim().toLowerCase()) { // If key and value are not equal, increment mismatch count columnIndexMismatchCount++; + print('columnIndexMismatchCount: $value'); } if (value.toString() == 'null') { // If value is null, increment missing count columnMissingCount++; + print('Value: $value'); } }); print('columnIndexMismatchCount: $columnIndexMismatchCount'); print('columnMissingCount: $columnMissingCount'); + + nonExcelFilteredData = filteredData.where((item) { + final relation = item['Relation']; + return relation != null && + relation.toString().trim().toLowerCase() != 'self'; + }).toList(); + print('nonExcelFilteredData'); + + print(nonExcelFilteredData); + print(nonExcelFilteredData.length); + if (argumentsData['type'] == 'GPA') { + if (nonExcelFilteredData.length > 0) { + print('nonSelf'); + invalidRelationships = nonExcelFilteredData.length; + } else { + print('Self'); + invalidRelationships = nonExcelFilteredData.length; + } + print('invalidRelationships: $invalidRelationships'); + } else { + invalidRelationships = 0; + } + + int invalidDobCount = countInvalidDobs(filteredData); + + print('Number of invalid DOBs: $invalidDobCount'); + + dobAgeCheckCount = invalidDobCount; } else { print('Some Column is Missing'); - var columnMissingCount = 10 - dataArray[0].length; + var columnMissingCount = 11 - dataArray[0].length; missingColumnErrorMsg = columnMissingCount; print(missingColumnErrorMsg); } } + // bool checkAllSelf(List> dataList) { + // // Check if any value of 'Relation' key is not 'Self' + // bool allSelf = dataList.every((data) => data['Relation'] == 'Self'); + // // If all values are 'Self', return true; otherwise, return false + // return allSelf; + // } + // Placeholder function for decoding Excel data List> decodeExcelData(Uint8List fileBytes) { - // Implement your logic to decode Excel data here - // This function should return your array containing Excel data - // For example, you can use the excel package to decode the Excel file - // Import the excel package in your pubspec.yaml file: - // dependencies: - // excel: ^1.1.0 - // Then use the following code to decode the Excel file: - - // Import the necessary packages - // import 'package:excel/excel.dart'; + print('decodeExcelData'); // Create an Excel instance from the fileBytes final excel = Excel.decodeBytes(fileBytes); + print('decodeExcelData'); + print(excel); // Assuming there's only one sheet in the Excel file final sheet = excel.tables.keys.first; @@ -263,6 +283,72 @@ class _excelVerifyState extends State { return dataArray; } + List> decodeXLSData(Uint8List fileBytes) { + final Excel excelData = Excel.decodeBytes(fileBytes); + final sheet = excelData.tables.keys.first; + final table = excelData.tables[sheet]!; + List> dataArray = []; + for (int rowIdx = 0; rowIdx < table.rows.length; rowIdx++) { + List rowData = []; + for (int colIdx = 0; colIdx < table.rows[rowIdx].length; colIdx++) { + var value = table.rows[rowIdx][colIdx]?.value; + rowData.add(Data(value, rowIdx, colIdx, sheet)); + } + dataArray.add(rowData); + } + return dataArray; + } + + List> decodeCSVData(Uint8List fileBytes) { + String csvString = utf8.decode(fileBytes); + List> csvData = const CsvToListConverter().convert(csvString); + List> dataArray = []; + + // Skip the header row (if it exists) and start from index 1 + for (int i = 1; i < csvData.length; i++) { + List rowData = []; + for (int j = 0; j < csvData[i].length; j++) { + // Assuming the CSV data is of type String + rowData.add(Data(csvData[i][j].toString(), i, j, 'Sheet1')); + } + dataArray.add(rowData); + } + return dataArray; + } + + int countInvalidDobs(List> data) { + int invalidCount = 0; + + for (var entry in data) { + DateTime dob; + + // if (entry['DOB'] is String) { + dob = DateTime.parse(entry['DOB'].toString()); + // } else if (entry['DOB'] is DateTime) { + // dob = entry['DOB']; + // } else { + // // Invalid DOB format, skip this entry + // continue; + // } + print(entry['Relation']); + if ((entry['Relation'].toString() == 'Son' || + entry['Relation'].toString() == 'Daughter')) { + if (DateTime.now().difference(dob).inDays > 25 * 365) { + print('child $dob'); + invalidCount++; + } + } else if ((entry['Relation'] != 'Son' && + entry['Relation'] != 'Daughter')) { + if (DateTime.now().difference(dob).inDays < 18 * 365) { + print('others $dob'); + invalidCount++; + } + } + } + + return invalidCount; + } + void _dragAndDropFile(html.File file) async { print('file'); print(file); @@ -287,10 +373,13 @@ class _excelVerifyState extends State { final decodedBytes = json.decode(jsonString); if (decodedBytes is List) { setState(() { - fileName = 'Retrieved File'; // Provide a default name + fileName = fileName ?? + 'Retrieved File'; // Provide a default name if fileName is null }); sendExcelFIleTOAPI( - Uint8List.fromList(decodedBytes.cast()), fileName!); + Uint8List.fromList(decodedBytes.cast()), + fileName!, + ); } } } @@ -301,44 +390,66 @@ class _excelVerifyState extends State { if (fileBytes == null) { print('return'); return; // No file selected - } - // // Prepare form data - // final formData = html.FormData(); - // formData.appendBlob('file', html.Blob([fileBytes]), fileName); - - // URL of the API where you want to send the file - final apiUrl = Environment.apiUrl + 'employeeUpload'; - - // Create a multipart request - final request = http.MultipartRequest('POST', Uri.parse(apiUrl)); - - // Attach the file to the request - // Set authorization token in headers - request.headers['Authorization'] = 'Bearer $_token'; - request.files.add(http.MultipartFile.fromBytes('file', fileBytes, - filename: fileName)); // Specify filename here - request.fields['client_id'] = clintID; - // if (policyFirstPart == 'GPA') { - request.fields['policy_id'] = client_policy_id; - // } else { - // request.fields['policy_id'] = '3'; - // } - - // Send the request - final response = await request.send(); - - // Check the status code of the response - if (response.statusCode == 200) { - // ToastHelper.showSuccessToast(context, 'File uploaded successfully'); - ToastHelper.showSuccessToast(context, 'Data Successfully Send...'); - print('File uploaded successfully'); - Navigator.pushNamed(context, 'hrHome'); } else { - // ToastHelper.showSuccessToast( - // context, 'Failed to upload file: ${response.reasonPhrase}'); - ToastHelper.showSuccessToast( - context, 'Failed to send data: ${response.reasonPhrase}'); - print('Failed to upload file: ${response.reasonPhrase}'); + print('else'); + // // Prepare form data + // final formData = html.FormData(); + // formData.appendBlob('file', html.Blob([fileBytes]), fileName); + + // URL of the API where you want to send the file + final apiUrl = Environment.apiUrl + 'employeeUpload'; + print('else'); + // Create a multipart request + final request = http.MultipartRequest('POST', Uri.parse(apiUrl)); + print('else'); + // Attach the file to the request + // Set authorization token in headers + request.headers['Authorization'] = 'Bearer $_token'; + // request.files.add(http.MultipartFile.fromBytes('file', fileBytes, + // filename: fileName)); + print('Filename: $fileName'); + request.files.add(http.MultipartFile.fromBytes( + 'file', + fileBytes, + filename: fileName ?? 'default_filename.xlsx', + )); + print('clintID: $clintID'); + request.fields['client_id'] = clintID; + print('clientPolicyId: $clientPolicyId'); + // if (policyFirstPart == 'GPA') { + request.fields['policy_id'] = clientPolicyId; + // } else { + // request.fields['policy_id'] = '3'; + // } + print('request : $request'); + // Send the request + final response = await request.send(); + print('else'); + // Read response stream as a string + final responseString = await response.stream.bytesToString(); + print('else'); + // Check the status code of the response + if (response.statusCode == 200) { + Map data = json.decode(responseString); + if (data['status'] == 'success') { + html.window.localStorage.remove('fileBytes'); + // ToastHelper.showSuccessToast(context, 'File uploaded successfully'); + ToastHelper.showSuccessToast( + context, 'Data Successfully Imported...'); + print('Data Successfully Imported'); + Navigator.pushNamed(context, 'hrPolicyDetails', + arguments: argumentsData); + } else { + // ToastHelper.showSuccessToast(context, 'File uploaded successfully'); + ToastHelper.showErrorToast(context, 'Failed to Imported...'); + // Navigator.pushNamed(context, 'hrHome'); + } + } else { + // ToastHelper.showSuccessToast( + // context, 'Failed to upload file: ${response.reasonPhrase}'); + ToastHelper.showSuccessToast(context, 'Something went wrong'); + print('Failed to upload file: ${response.reasonPhrase}'); + } } } @@ -351,20 +462,54 @@ class _excelVerifyState extends State { // Filter the data based on the search query filteredData = originalData.where((item) { // Implement your filter logic here, for example: - return item['emp_code'].toLowerCase().contains(query.toLowerCase()); + return item['Emp_Code'].toLowerCase().contains(query.toLowerCase()); }).toList(); } }); } + downloadSampleFile() { + final anchor = html.AnchorElement(href: 'assets/assets/Template_File.xlsx'); + anchor.download = 'Template_File.xlsx'; // Set the filename + anchor.click(); // Trigger a click on the anchor element + } + + resetErrorCount() { + setState(() { + fileBytes = null; + fileName = null; + _currentStep = 0; + + extractedData = []; + originalData = []; + filteredData = []; + validationArray = []; + nonExcelFilteredData = []; + print('filteredData'); + print(filteredData); + print(validationArray); + + missingColumnErrorMsg = 0; + print(missingColumnErrorMsg); + columnMissingCount = 0; + print(columnMissingCount); + columnIndexMismatchCount = 0; + print(columnIndexMismatchCount); + invalidRelationships = 0; + dobAgeCheckCount = 0; + + html.window.localStorage.remove('fileBytes'); + }); + } + @override Widget build(BuildContext context) { - // Retrieve the passed argument - dynamic importPolicyName = - ModalRoute.of(context)!.settings.arguments as String?; - - // List parts = importPolicyName.split(" - "); - policyFirstPart = importPolicyName; + dynamic arguments = ModalRoute.of(context)!.settings.arguments; + print('arguments'); + print(arguments); + if (arguments != null && arguments is Map) { + argumentsData = arguments; + } return Scaffold( appBar: CustomAppBar(), @@ -395,16 +540,73 @@ class _excelVerifyState extends State { alignment: Alignment.bottomCenter, padding: const EdgeInsets.all(16.0), child: Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + ElevatedButton( + onPressed: () { + html.window.localStorage.remove('fileBytes'); + fileBytes = null; + fileName = null; + _currentStep = 0; + missingColumnErrorMsg = 0; + columnIndexMismatchCount = 0; + columnMissingCount = 0; + invalidRelationships = 0; + dobAgeCheckCount = 0; + nonExcelFilteredData = []; + Navigator.pushNamed( + context, 'hrPolicyDetails', + arguments: argumentsData); + }, + child: Text( + 'Close', + style: TextStyle(color: Color(0xFFE26728)), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: BorderSide(color: Color(0xFFE26728)), + ), + ), + ), + // SizedBox(width: 10), + // if (fileName != null) + // ElevatedButton( + // onPressed: () { + // // Reset localStorage and fileBytes + // setState(() { + // html.window.localStorage + // .remove('fileBytes'); + // fileBytes = null; + // fileName = null; + // _currentStep = 0; + // }); + // }, + // child: Text( + // 'Reselect File', + // style: TextStyle(color: Color(0xFFE26728)), + // ), + // style: ElevatedButton.styleFrom( + // backgroundColor: Colors.white, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(5), + // side: + // BorderSide(color: Color(0xFFE26728)), + // ), + // ), + // ), + Spacer(), + SizedBox( + width: + 10), // This pushes the buttons to the right if (_currentStep != 0) ElevatedButton( onPressed: () { - controls - .onStepCancel!(); // Call onStepCancel function + controls.onStepCancel!(); }, child: Text( - 'Cancel', + 'Previous', style: TextStyle(color: Color(0xFFE26728)), ), style: ElevatedButton.styleFrom( @@ -419,10 +621,19 @@ class _excelVerifyState extends State { SizedBox(width: 10), if (_currentStep != 2) ElevatedButton( - onPressed: () { - controls - .onStepContinue!(); // Call onStepContinue function - }, + onPressed: _currentStep == 0 + ? (fileName != null + ? controls.onStepContinue! + : null) + : (_currentStep == 1 + ? (missingColumnErrorMsg == 0 && + columnIndexMismatchCount == + 0 && + invalidRelationships == 0 && + dobAgeCheckCount == 0 + ? controls.onStepContinue! + : null) + : null), child: const Text( 'NEXT', style: TextStyle(color: Colors.white), @@ -468,7 +679,9 @@ class _excelVerifyState extends State { } else if (_currentStep == 1) { // For the second step, allow continue if both errors are 0 if (missingColumnErrorMsg == 0 && - columnIndexMismatchCount == 0) { + columnIndexMismatchCount == 0 && + invalidRelationships == 0 && + dobAgeCheckCount == 0) { setState(() { _currentStep += 1; }); @@ -513,7 +726,7 @@ class _excelVerifyState extends State { children: [ Expanded( child: Text( - policy_name ?? '', + '$policy_name - ($policyType)', textAlign: TextAlign.center, style: TextStyle( fontSize: 20, @@ -558,26 +771,92 @@ class _excelVerifyState extends State { MainAxisAlignment .center, children: [ - if (fileName == null) - Text( - 'Drop files here to start uploading', - style: TextStyle( - fontSize: 16), - ), - SizedBox(height: 20), - if (fileName == null) - Text( - 'OR', - style: TextStyle( - fontSize: 16), - ), // Add spacing between texts - SizedBox(height: 20), + // if (fileName == null) + // ElevatedButton( + // onPressed: () => {}, + // child: Icon( + // Icons.download, + // color: Colors + // .grey), // You can replace the Icon with your custom button child + // style: + // ElevatedButton + // .styleFrom( + // shape: + // CircleBorder(), // Makes the button round + // padding: + // EdgeInsets.all( + // 18), // Change the button color as needed + // ), + // ), + // SizedBox(height: 20), + // if (fileName == null) + // Text( + // 'Drag and drop file to import', + // style: TextStyle( + // fontSize: 16, + // fontWeight: + // FontWeight + // .w600), + // ), // Add spacing between texts + // SizedBox(height: 20), fileName != null - ? Text( - 'File Uploaded: $fileName', - style: TextStyle( - fontSize: - 16), + ? Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Icon( + Icons + .upload_file, // Choose the appropriate icon + size: 35, + color: Color( + 0xFFE26728), // Adjust the size as needed + ), + SizedBox( + height: + 15), // Add some space between the icon and text + Text( + '$fileName', + style: TextStyle( + fontSize: + 16), + ), + SizedBox( + height: + 25), // Add some space between the icon and text + MouseRegion( + cursor: SystemMouseCursors + .click, // Set cursor to pointer on hover + child: + GestureDetector( + onTap: + () { + resetErrorCount(); + }, + child: + Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Icon( + Icons.delete_forever, // Choose the remove icon + size: + 20, // Adjust the size as needed + color: + Colors.red, // Set the color of the remove icon + ), + SizedBox( + width: 1), // Add some space between the icon and text + Text( + 'Remove', + style: + TextStyle(fontSize: 13, color: Color(0xFF727272)), + ), + ], + ), + ), + ) + ], ) : ElevatedButton( onPressed: () => @@ -596,6 +875,10 @@ class _excelVerifyState extends State { 0xFFE26728), ), ), + SizedBox(height: 20), + if (fileName == null) + Text( + 'Supported Files : XLSX') // Add more Text widgets for additional lines of text ], ), @@ -606,6 +889,43 @@ class _excelVerifyState extends State { ), ], ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + 'Ensure that the import file is in the correct format by comparing it with our template file.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + fontWeight: + FontWeight.w400, + )), + MouseRegion( + cursor: + SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + downloadSampleFile(); + }, + child: Text( + 'Template File', + style: TextStyle( + fontSize: 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ])) + ], + ) ], ), ), @@ -634,7 +954,7 @@ class _excelVerifyState extends State { missingColumnErrorMsg == 0 ? Icons.check_circle : Icons.error, - 'No of column missing - $missingColumnErrorMsg', + 'No of column missing : $missingColumnErrorMsg Column', iconColor: missingColumnErrorMsg == 0 ? Colors.green : Colors @@ -645,20 +965,29 @@ class _excelVerifyState extends State { columnIndexMismatchCount == 0 ? Icons.check_circle : Icons.error, - 'Column Index is Missmatching - $columnIndexMismatchCount', + 'Mismatch in Column Order : $columnIndexMismatchCount - Column', iconColor: columnIndexMismatchCount == 0 ? Colors.green : Colors.red, ), - // _buildRowWithIcon( - // columnMissingCount == 0 - // ? Icons.check_circle - // : Icons.error, - // 'Column Missing - $columnMissingCount', - // iconColor: columnMissingCount == 0 - // ? Colors.green - // : Colors.red, - // ), + _buildRowWithIcon( + invalidRelationships == 0 + ? Icons.check_circle + : Icons.error, + 'Invalid Relationships : $invalidRelationships - Rows', + iconColor: invalidRelationships == 0 + ? Colors.green + : Colors.red, + ), + _buildRowWithIcon( + dobAgeCheckCount == 0 + ? Icons.check_circle + : Icons.error, + 'Age Config - $dobAgeCheckCount - Rows', + iconColor: dobAgeCheckCount == 0 + ? Colors.green + : Colors.red, + ), ], ), ), @@ -773,7 +1102,7 @@ class _excelVerifyState extends State { return Card( elevation: 0, // Set elevation to 0 for no shadow child: PaginatedDataTable( - rowsPerPage: 10, // Adjust rows per page as needed + rowsPerPage: 25, // Adjust rows per page as needed columns: [ DataColumn(label: Text('S.No')), DataColumn(label: Text('Employee ID')), @@ -785,6 +1114,7 @@ class _excelVerifyState extends State { DataColumn(label: Text('Mail')), DataColumn(label: Text('Mobile No')), DataColumn(label: Text('SI')), + DataColumn(label: Text('Grade')), ], source: _DependenceDataSource0(filteredData), ), @@ -824,20 +1154,21 @@ class _DependenceDataSource0 extends DataTableSource { DataRow getRow(int index) { final row = _data[index]; - // Format date of birth to "July 10, 1996" - String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; + String dob = row['DOB'] != null ? formatDate(row['DOB']) : 'N/A'; + String doj = row['DOJ'] != null ? formatDate(row['DOJ']) : 'N/A'; return DataRow(cells: [ DataCell(Text(row['Sno'].toString())), - DataCell(Text(row['emp_code'].toString())), + DataCell(Text(row['Emp_Code'].toString())), DataCell(Text(row['Name'].toString())), - DataCell(Text(row['DOJ']?.toString() ?? 'N/A')), + DataCell(Text(doj)), DataCell(Text(row['Gender']?.toString() ?? 'N/A')), DataCell(Text(row['Relation']?.toString() ?? 'N/A')), DataCell(Text(dob)), DataCell(Text(row['Mail']?.toString() ?? 'N/A')), DataCell(Text(row['Mobile']?.toString() ?? 'N/A')), DataCell(Text(row['SI']?.toString() ?? 'N/A')), + DataCell(Text(row['Grade']?.toString() ?? 'N/A')), ]); } @@ -850,12 +1181,18 @@ class _DependenceDataSource0 extends DataTableSource { @override int get selectedRowCount => 0; - String formatDateString(String dateString) { - // Parse the date string to DateTime object - DateTime dateTime = DateTime.parse(dateString); - // Format the DateTime object to "July 03, 2024" - String formattedDate = DateFormat.yMMMMd().format(dateTime); - - return formattedDate; + String formatDate(dynamic dateValue) { + if (dateValue is String) { + // If the date is already in string format + DateTime dateTime = DateTime.parse(dateValue); + return DateFormat('dd-MM-yyyy').format(dateTime); + } else if (dateValue is DateCellValue) { + // If dateValue is an instance of DateCellValue + return DateFormat('dd-MM-yyyy') + .format(DateTime.parse(dateValue.toString())); + } else { + // Handle other cases or null values + return 'N/A'; + } } } diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart new file mode 100644 index 0000000..9f1d1ca --- /dev/null +++ b/lib/hrDashboard.dart @@ -0,0 +1,845 @@ +import 'dart:convert'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:http/http.dart' as http; +import 'customAppBar/customAppBar.dart'; +import 'customAppBar/toastHelper.dart'; +import 'package:universal_html/html.dart' as html; +import 'package:intl/intl.dart'; + +class hrDashboard extends StatefulWidget { + const hrDashboard({Key? key}) : super(key: key); + + @override + State createState() => _hrDashboardState(); +} + +class _hrDashboardState extends State { + bool isLoading = true; + late String _token; + dynamic getPolicyNo; + bool _isLoading = false; + dynamic getPolicyNameDetails; + dynamic clintID; + dynamic policy_name; + dynamic getCardArrays = []; + dynamic clientName; + dynamic clientLogo; + final List cardColors = [ + Color(0xFFFFE3D9), + Color(0xFFFFD9EE), + Color(0xFFDBFFDE), + Color(0xFFE4DFFF), + ]; + + @override + void initState() { + super.initState(); + _loadToken(); + Future.delayed(Duration(seconds: 3), () { + setState(() { + isLoading = false; + }); + }); + } + + @override + void dispose() { + super.dispose(); + } + + Future _loadToken() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final token = prefs.getString('hrtoken'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + Map? decodedToken = Jwt.parseJwt(token); + clintID = decodedToken['client_id'].toString(); + print(clintID); + if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) { + clientLogo = prefs.getString('clientLogo'); + clientName = prefs.getString('clientName'); + } else { + getClientLogoAndDetails(); + } + await getCashDepositDetails(clintID); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'hrLogin'); + } + } + + Future getClientLogoAndDetails() async { + var url = + Uri.parse(Environment.apiUrl + 'getClientDetails?client_id=$clintID'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('clientLogo', clientDetails['client']['client_logo']); + prefs.setString('clientName', clientDetails['client']['client_name']); + setState(() { + // dynamic clientDetails = data['data']; + // print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + }); + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getCashDepositDetails(String clintID) async { + setState(() { + _isLoading = true; + }); + var url = Uri.parse( + Environment.apiUrl + 'getCashDepositData?client_id=' + clintID); + try { + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + setState(() { + getCardArrays = List>.from(data['data']); + print(getCardArrays); + }); + } else { + // No matching policy found + print('No matching policy found for'); + } + } else { + print('API request failed with status'); + } + } catch (e) { + print('Exception occurred: $e'); + } + } + + Future downloadExcel(clintId, clintIdclintId, insurerName) async { + // API endpoint to download the Excel file + + // Send GET request to the API + var url = Uri.parse(Environment.apiUrl + + 'exportCashDepositData?client_id=$clintId&insurer_id=$clintIdclintId'); + + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + if (response.statusCode == 200) { + // Create a blob from the response body + final blob = html.Blob([response.bodyBytes]); + + // Generate a download URL for the blob + final url = html.Url.createObjectUrlFromBlob(blob); + + // Create a link element to trigger the download + final anchor = html.AnchorElement(href: url) + ..setAttribute('download', '$insurerName.xlsx') + ..click(); + + // Revoke the download URL to free up resources + html.Url.revokeObjectUrl(url); + } else { + // Handle error + print('Failed to download Excel file: ${response.statusCode}'); + } + } + + @override + Widget build(BuildContext context) { + if (getCardArrays == []) { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], + ), + ), + )); + } else { + int numCards = getCardArrays.length; + int numExpanded = numCards < 4 ? numCards : 4; + double cardHeight = MediaQuery.of(context).size.height / 4.5; + double policyHeight = MediaQuery.of(context).size.height / 4.5; + double cardWidth = MediaQuery.of(context).size.width / 6; + + return Scaffold( + appBar: CustomAppBar(), + body: Stack(children: [ + SingleChildScrollView( + child: Container( + padding: + EdgeInsets.only(top: 30, bottom: 30, left: 50, right: 50), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, bottom: 10, left: 20, right: 20) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo ?? '', + width: 80, // Set the width here + height: 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress + .expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + errorBuilder: (BuildContext context, + Object error, StackTrace? stackTrace) { + return Image.asset( + 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path + width: 80, + height: 80, + fit: BoxFit.cover, + ); + }, + ), + ), + ), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, + ), + ), + ) + ], + ), + ), + ), + SizedBox(height: 16), + Card( + elevation: 0, + child: Container( + width: double.infinity, + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(20) + : EdgeInsets.all( + 10), // Add padding to the container + child: Column(children: [ + Row(children: [ + Text( + 'Cash Transaction', + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ) + ]), + SizedBox(height: 8), + Row( + children: [ + // Create an Expanded widget with flex of 4 for each card + for (var cardData in getCardArrays) + Container( + width: + 300, // Set a fixed width for the card + height: cardHeight, + child: Card( + elevation: 3, + color: cardColors[ + getCardArrays.indexOf(cardData) % + cardColors.length], + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + ListTile( + title: SizedBox( + height: 50, + child: Text( + cardData['insurerName'], + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), + ), + ), + subtitle: Text( + 'Balance: ₹ ${cardData['balance']}', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), + ), + ), + SizedBox(height: 10), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 15), + child: GestureDetector( + onTap: () { + openForm( + cardData['depositData'], + cardData['insurerName'], + cardData['clientId'], + cardData['insurerId'], + cardColors[getCardArrays + .indexOf(cardData) % + cardColors.length], + ); + }, + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: Align( + alignment: + Alignment.centerRight, + child: Text( + 'View Details', + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontSize: 14, + fontWeight: + FontWeight.w300, + height: 1.5, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + ])), + ), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(20) + : EdgeInsets.all(10), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: List.generate( + numExpanded, + (index) { + var insurerName = getCardArrays[index] + ['insurerName']; + var policyDetails = + getCardArrays[index] + ['policyDetails']; + + // Determine the color for the policyDetails based on the index of the card in getCardArrays + var cardColorIndex = + getCardArrays.indexOf( + getCardArrays[index]) % + cardColors.length; + var cardColor = + cardColors[cardColorIndex]; + + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + insurerName, + style: GoogleFonts.poppins( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + SizedBox(height: 8), + Row( + children: List.generate( + policyDetails.length, + (index) => Container( + width: 300, + height: policyHeight, + child: GestureDetector( + onTap: () { + Navigator.pushNamed( + context, + 'hrPolicyDetails', + arguments: + policyDetails[ + index]); + }, + child: MouseRegion( + cursor: + SystemMouseCursors + .click, + child: Card( + elevation: 3, + color: + cardColor, // Use the determined color + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + ListTile( + title: SizedBox( + height: 50, + child: Text( + '${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})', + style: GoogleFonts + .poppins( + fontSize: + 16, + fontWeight: + FontWeight + .w500, + color: Color( + 0xFF000000), + height: + 1.5, + ), + softWrap: + true, // Allow text to wrap to the next line if needed + ), + ), + ), + SizedBox( + height: 8), + Padding( + padding: EdgeInsets + .only( + left: + 15, + right: + 15), + child: Row( + children: [ + Expanded( + flex: 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Draft', + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), + ), + Text( + policyDetails[index]['membersCountOfDraft'].toString(), + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), + ), + ], + ), + ), + Expanded( + flex: 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Enrolled', + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), + ), + Text( + policyDetails[index]['membersCountOfEnrolled'].toString(), + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), + ), + ], + ), + ), + Expanded( + flex: 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total', + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), + ), + Text( + policyDetails[index]['totalMembersCount'].toString(), + style: + GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), + ), + ], + ), + ), + ], + ), // Adjust the horizontal padding as needed + ) + ], + ), + ), + ), + ), + ), + ), + ), + SizedBox(height: 20), + ], + ); + }, + ), + ), + ), + ], + ) + ], + ), + )) + ], + ), + ), + ), + if (isLoading) + Container( + color: Color(0xFFFFFCE5), // Semi-transparent background + child: Center( + child: // Your GIF loader widget + Image.asset( + height: 60, + width: 60, + 'assets/nhance-loader.gif'), // Adjust path to your GIF loader + ), + ), + ])); + } + } + + void openForm(dynamic floaterData, dynamic insurerName, dynamic clintId, + dynamic insurerId, dynamic cardColors) { + print(clintId); + print(insurerId); + print(floaterData); + print(floaterData); + print('test'); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + elevation: 0, + backgroundColor: Colors.transparent, + content: SizedBox( + width: 1000, + child: SingleChildScrollView( + child: Card( + elevation: 0, + child: Column( + children: [ + Container( + child: Column( + children: [ + Container( + padding: + EdgeInsets.all(10), // Set your desired padding + color: + cardColors, // Set your desired background color + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 10, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text(insurerName ?? '', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.black, + )), + ], + ), + ), + ), + Expanded( + flex: 1, + child: Container( + alignment: Alignment + .centerRight, // Align text to the center + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + downloadExcel( + clintId, insurerId, insurerName); + }, + child: Icon( + Icons + .download, // Replace with your desired icon + color: Colors + .black, // Replace with your desired icon color + ), + ), + ), + ), + ), + Expanded( + flex: 1, + child: Container( + alignment: Alignment + .centerRight, // Align text to the center + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Icon( + Icons + .close, // Replace with your desired icon + color: Colors + .black, // Replace with your desired icon color + ), + ), + ), + ), + ), + ], + ), + ), + SizedBox(height: 15), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: _buildDataTable(context, floaterData), + ), + ) + ], + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + }, + ); + } + + Widget _buildDataTable(BuildContext context, dynamic tableData) { + print('tableData'); + print(tableData); + + // Check if tableData is a list + if (tableData is List) { + // If tableData is a list and not empty + if (tableData.isNotEmpty && tableData[0] is Map) { + return Card( + elevation: 0, // Set elevation to 0 for no shadow + child: PaginatedDataTable( + rowsPerPage: 10, // Adjust rows per page as needed + columns: [ + DataColumn(label: Text('Date')), + DataColumn(label: Text('Description')), + DataColumn(label: Text('Transaction Type')), + DataColumn(label: Text('Amount')), + DataColumn(label: Text('Balance')), + ], + source: _DependenceDataSource(context, tableData), + ), + ); + } else { + // If tableData is empty or not in the expected format + return Text('No Data Available', textAlign: TextAlign.center); + } + } else { + // If tableData is not a list, return a message indicating invalid data + return Text('Invalid Data Format', textAlign: TextAlign.center); + } + } +} + +class _DependenceDataSource extends DataTableSource { + final List> _data; + final BuildContext context; + _DependenceDataSource(this.context, List tableData) + : _data = tableData.map((e) => e as Map).toList(); + + @override + DataRow getRow(int index) { + final row = _data[index]; + + // Format date of birth to "July 10, 1996" + String created_Date = + row['created_at'] != null ? formatDateString(row['created_at']) : 'N/A'; + + return DataRow( + // Setting row background color + cells: [ + DataCell(Text(created_Date)), + DataCell(Text(row['description'] ?? 'N/A')), + DataCell(Text(row['transaction_type'].toString() ?? '')), + DataCell(Text(row['amount'] ?? 'N/A')), + DataCell(Text(row['balance'] ?? 'N/A')), + ], + ); + } + + @override + bool get isRowCountApproximate => false; + + @override + int get rowCount => _data.length; + + @override + int get selectedRowCount => 0; + + String formatDateString(String dateString) { + // Parse the input date string + DateTime inputDate = DateTime.parse(dateString); + + // Format the date as DD-MM-YYYY HH:mm A + String formattedDate = DateFormat('dd-MM-yyyy hh:mm a').format(inputDate); + + return formattedDate; + } +} diff --git a/lib/hrHome.dart b/lib/hrHome.dart index d2d91df..e03469c 100644 --- a/lib/hrHome.dart +++ b/lib/hrHome.dart @@ -13,8 +13,10 @@ import 'package:universal_html/html.dart' as html; import 'dart:typed_data'; import 'dart:io'; import 'package:flutter/foundation.dart' show kIsWeb; -import 'package:excel/excel.dart'; import 'package:intl/intl.dart'; +import 'package:excel/excel.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:path/path.dart' as path; class MyHrHome extends StatefulWidget { const MyHrHome({Key? key}) : super(key: key); @@ -28,7 +30,8 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { late String _token; List> getEmpDependenceByClintIdGMC = []; List> getEmpDependenceByClintIdGPA = []; - List> getEmpDependenceByClintIdAddOns = []; + List> getEmpDependenceByClintIdAddOnsSi = []; + List> getEmpDependenceByClintIdAddOnsDependent = []; dynamic getPolicyNameDetails0; dynamic getPolicyNameDetails1; dynamic getPolicyNameDetails2; @@ -44,13 +47,16 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { List> filteredDataGpa = []; // Filtered data source List> originalDataGmc = []; // Original data source List> filteredDataGmc = []; // Filtered data source - List> originalDataAddOns = []; // Original data source - List> filteredDataAddOns = []; + List> originalDataAddOnsSi = []; // Original data source + List> filteredDataAddOnsSi = []; + List> originalDataAddOnsDependent = + []; // Original data source + List> filteredDataAddOnsDependent = []; @override void initState() { super.initState(); - _tabController = TabController(length: 3, vsync: this); + _tabController = TabController(length: 4, vsync: this); _loadToken(); } @@ -98,7 +104,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { setState(() { dataPolicy = List>.from(data['data']); print(dataPolicy); - reversedDataPolicy = dataPolicy.reversed.toList(); + // reversedDataPolicy = dataPolicy.reversed.toList(); // getPolicyNameDetails0 = dataPolicy[0]['policy_name']; // print(getPolicyNameDetails0); // getPolicyNameDetails1 = dataPolicy[1]['policy_name']; @@ -113,7 +119,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { // print(getPolicyNameDetails2); }); // Code to execute periodically every 2 seconds - reversedDataPolicy.forEach((policy) { + dataPolicy.forEach((policy) { if (policy['type'] == 'GPA') { String clientPolicyId = policy['client_policy_id']; String clientId = policy['client_id']; @@ -122,11 +128,11 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { String clientPolicyId = policy['client_policy_id']; String clientId = policy['client_id']; getEmployeeAndDependenceGMC(clientId, clientPolicyId); - } else if (policy['type'] == 'AddOn') { + } else if (policy['type'] == 'SI TopUp') { String clientPolicyId = policy['client_policy_id']; String clientId = policy['client_id']; getEmployeeAndDependenceAddOnsSi(clientId, clientPolicyId); - } else if (policy['type'] == 'AddOn-DEPENDENT') { + } else if (policy['type'] == 'Dependent AddOn') { String clientPolicyId = policy['client_policy_id']; String clientId = policy['client_id']; getEmployeeAndDependenceAddOnsDependent(clientId, clientPolicyId); @@ -176,6 +182,8 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { List>.from(data['data']); originalDataGpa = getEmpDependenceByClintIdGPA; filteredDataGpa = List.from(originalDataGpa); + print('filteredDataGpa'); + print(filteredDataGpa); }); } else { ToastHelper.showWarningToast( @@ -254,10 +262,10 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { Map data = json.decode(response.body); if (data['status'] == 'success') { setState(() { - getEmpDependenceByClintIdAddOns = + getEmpDependenceByClintIdAddOnsSi = List>.from(data['data']); - originalDataAddOns = getEmpDependenceByClintIdAddOns; - filteredDataAddOns = List.from(originalDataAddOns); + originalDataAddOnsSi = getEmpDependenceByClintIdAddOnsSi; + filteredDataAddOnsSi = List.from(originalDataAddOnsSi); }); } else { ToastHelper.showErrorToast( @@ -296,10 +304,12 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { Map data = json.decode(response.body); if (data['status'] == 'success') { setState(() { - getEmpDependenceByClintIdAddOns = + getEmpDependenceByClintIdAddOnsDependent = List>.from(data['data']); - originalDataAddOns = getEmpDependenceByClintIdAddOns; - filteredDataAddOns = List.from(originalDataAddOns); + originalDataAddOnsDependent = + getEmpDependenceByClintIdAddOnsDependent; + filteredDataAddOnsDependent = + List.from(originalDataAddOnsDependent); }); } else { ToastHelper.showErrorToast( @@ -328,10 +338,14 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { } else if (importPolicyName == 'GMC') { // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1; argumentDetails = 'GMC'; - } else { - // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; - argumentDetails = 'ADDONS'; } + // else if (importPolicyName == 'SI-TopUp') { + // // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + // argumentDetails = 'SI-TopUp'; + // } else if (importPolicyName == 'Dependent-AddOn') { + // // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + // argumentDetails = 'Dependent-AddOn'; + // } Navigator.pushNamed(context, 'excelVerify', arguments: argumentDetails); return; @@ -383,14 +397,14 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { }); } - void searchAddOns(String query) { + void searchAddOnsSi(String query) { setState(() { if (query.isEmpty) { // If search query is empty, show all data - filteredDataAddOns = List.from(originalDataAddOns); + filteredDataAddOnsSi = List.from(originalDataAddOnsSi); } else { // Filter the data based on the search query - filteredDataAddOns = originalDataAddOns.where((item) { + filteredDataAddOnsSi = originalDataAddOnsSi.where((item) { // Implement your filter logic here, for example: return item['emp_code'].toLowerCase().contains(query.toLowerCase()); }).toList(); @@ -398,6 +412,58 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { }); } + void searchAddOnsDependent(String query) { + setState(() { + if (query.isEmpty) { + // If search query is empty, show all data + filteredDataAddOnsDependent = List.from(originalDataAddOnsDependent); + } else { + // Filter the data based on the search query + filteredDataAddOnsDependent = originalDataAddOnsDependent.where((item) { + // Implement your filter logic here, for example: + return item['emp_code'].toLowerCase().contains(query.toLowerCase()); + }).toList(); + } + }); + } + + Future downloadExcel() async { + // API endpoint to download the Excel file + + // Send GET request to the API + var url = Uri.parse(Environment.apiUrl + + 'exportDataByClientPolicyId?client_id=$clintID&client_policy_id=62'); + + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + if (response.statusCode == 200) { + // Create a blob from the response body + final blob = html.Blob([response.bodyBytes]); + + // Generate a download URL for the blob + final url = html.Url.createObjectUrlFromBlob(blob); + + // Create a link element to trigger the download + final anchor = html.AnchorElement(href: url) + ..setAttribute('download', 'excel_file.xlsx') + ..click(); + + // Revoke the download URL to free up resources + html.Url.revokeObjectUrl(url); + } else { + // Handle error + print('Failed to download Excel file: ${response.statusCode}'); + } + } + @override Widget build(BuildContext context) { if (dataPolicy == []) { @@ -434,16 +500,15 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { ), indicatorSize: TabBarIndicatorSize.label, controller: _tabController, - tabs: reversedDataPolicy != null && - reversedDataPolicy.isNotEmpty - ? reversedDataPolicy.map((policy) { + tabs: dataPolicy != null && dataPolicy.isNotEmpty + ? dataPolicy.map((policy) { return Tab( child: Container( width: double.infinity, alignment: Alignment.center, padding: EdgeInsets.symmetric(vertical: 0), child: Text( - '${policy['type']}-${policy['policy_name']}'), + '${policy['type']} : ${policy['policy_name']}'), ), ); }).toList() @@ -478,107 +543,185 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { padding: const EdgeInsets.all(20), child: _isLoading ? Center(child: CircularProgressIndicator()) - : Column( - children: [ - Row( + : filteredDataGpa.isNotEmpty + ? SingleChildScrollView( + child: Column( children: [ - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, + Row( + children: [ + Expanded( + flex: 8, child: Container( - width: - 350, // Set your desired width here - height: - 40, // Set your desired height here - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 255, - 255, - 255, - 0.5), // Shadow color with opacity - offset: Offset(5, - 5), // Shadow position (horizontal, vertical) - blurRadius: - 10, // Blur radius - spreadRadius: - 0, // Spread radius + alignment: + Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius.circular( + 5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: + InputDecoration( + hintText: 'Search', + suffixIcon: + Icon(Icons.search), + contentPadding: + EdgeInsets.all( + 10), // Adjust the horizontal padding + border: + OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchGpa, // Call the search method on text change + ), + )), + ), + Expanded( + flex: 2, + child: Container( + alignment: + Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + {downloadExcel()}, + child: Text( + 'Export', + style: TextStyle( + color: + Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), ), ], + ), + ), + ), + SizedBox(width: 5), + Expanded( + flex: 2, + child: Container( + alignment: + Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + _uploadFile('GPA'), + child: Text( + 'Import Data', + style: TextStyle( + color: + Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: + _buildDataTableGPA(context), + ), + ) + ], + ), + ], + )) + : Container( + height: + MediaQuery.of(context).size.height, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Center( + child: ElevatedButton( + onPressed: () => + _uploadFile('GPA'), + child: Text( + 'Import Data', + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), ), - child: TextField( - textAlignVertical: - TextAlignVertical - .center, // Center the text vertically - decoration: InputDecoration( - hintText: 'Search', - suffixIcon: - Icon(Icons.search), - contentPadding: EdgeInsets.all( - 10), // Adjust the horizontal padding - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color( - 0xFFf5f5f7)), // Set border color to gray - ), - ), - onChanged: - searchGpa, // Call the search method on text change - ), - )), - ), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.centerRight, - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () => - _uploadFile('GPA'), - child: Text( - 'Import Data', - style: TextStyle( - color: Colors.white), - ), - style: ElevatedButton - .styleFrom( - backgroundColor: - Color(0xFFE26728), - shape: - RoundedRectangleBorder( - borderRadius: - BorderRadius - .circular(5), - ), - ), - ), - ), - ], + ), ), - ), - ), - ], + ) + ], + ), ), - SizedBox(height: 20), - Row( - children: [ - Expanded( - child: SingleChildScrollView( - child: _buildDataTableGPA(context), - ), - ) - ], - ), - ], - ), ), ), Center( @@ -586,107 +729,151 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { padding: const EdgeInsets.all(20), child: _isLoading ? Center(child: CircularProgressIndicator()) - : Column( - children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, - child: Container( - width: - 350, // Set your desired width here - height: - 40, // Set your desired height here - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 255, - 255, - 255, - 0.5), // Shadow color with opacity - offset: Offset(5, - 5), // Shadow position (horizontal, vertical) - blurRadius: - 10, // Blur radius - spreadRadius: - 0, // Spread radius - ), - ], - borderRadius: - BorderRadius.circular(5), - ), - child: TextField( - textAlignVertical: - TextAlignVertical - .center, // Center the text vertically - decoration: InputDecoration( - hintText: 'Search', - suffixIcon: - Icon(Icons.search), - contentPadding: EdgeInsets.all( - 10), // Adjust the horizontal padding - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color( - 0xFFf5f5f7)), // Set border color to gray - ), - ), - onChanged: - searchGmc, // Call the search method on text change - ), - )), - ), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.centerRight, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () => - _uploadFile('GMC'), - child: Text( - 'Import', - style: TextStyle( - color: Colors.white), - ), - style: ElevatedButton - .styleFrom( - backgroundColor: - Color(0xFFE26728), - shape: - RoundedRectangleBorder( + : filteredDataGmc.isNotEmpty + ? SingleChildScrollView( + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: + Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], borderRadius: BorderRadius .circular(5), ), - ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: + InputDecoration( + hintText: 'Search', + suffixIcon: Icon( + Icons.search), + contentPadding: + EdgeInsets.all( + 10), // Adjust the horizontal padding + border: + OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchGmc, // Call the search method on text change + ), + )), + ), + Expanded( + flex: 2, + child: Container( + alignment: + Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + _uploadFile( + 'GMC'), + child: Text( + 'Import', + style: TextStyle( + color: Colors + .white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color( + 0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), + ) + ], ), - ) - ], + ), + ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: _buildDataTableGMC( + context), + ), + ) + ], + ), + ], + ), + ) + : Container( + height: + MediaQuery.of(context).size.height, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Center( + child: ElevatedButton( + onPressed: () => + _uploadFile('GMC'), + child: Text( + 'Import Data', + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), ), - ), - ), - ], + ) + ], + ), ), - SizedBox(height: 20), - Row( - children: [ - Expanded( - child: SingleChildScrollView( - child: _buildDataTableGMC(context), - ), - ) - ], - ), - ], - ), ), ), Center( @@ -694,108 +881,269 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { padding: const EdgeInsets.all(20), child: _isLoading ? Center(child: CircularProgressIndicator()) - : Column( - children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, - child: Container( - width: - 350, // Set your desired width here - height: - 40, // Set your desired height here - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 255, - 255, - 255, - 0.5), // Shadow color with opacity - offset: Offset(5, - 5), // Shadow position (horizontal, vertical) - blurRadius: - 10, // Blur radius - spreadRadius: - 0, // Spread radius - ), - ], - borderRadius: - BorderRadius.circular(5), - ), - child: TextField( - textAlignVertical: - TextAlignVertical - .center, // Center the text vertically - decoration: InputDecoration( - hintText: 'Search', - suffixIcon: - Icon(Icons.search), - contentPadding: EdgeInsets.all( - 10), // Adjust the horizontal padding - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color( - 0xFFf5f5f7)), // Set border color to gray - ), - ), - onChanged: - searchAddOns, // Call the search method on text change - ), - )), - ), - // Expanded( - // flex: 2, - // child: Container( - // alignment: Alignment.centerRight, - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.spaceEvenly, - // children: [ - // Expanded( - // child: ElevatedButton( - // onPressed: () => - // _uploadFile('ADDONS'), - // child: Text( - // 'Import', - // style: TextStyle( - // color: Colors.white), - // ), - // style: ElevatedButton - // .styleFrom( - // backgroundColor: - // Color(0xFFE26728), - // shape: - // RoundedRectangleBorder( - // borderRadius: - // BorderRadius - // .circular(5), - // ), - // ), - // ), - // ) - // ], - // ), - // ), - // ), - ], - ), - SizedBox(height: 20), - Row( - children: [ - Expanded( - child: SingleChildScrollView( - child: - _buildDataTableAddOns(context), + : filteredDataAddOnsSi.isNotEmpty + ? SingleChildScrollView( + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: + Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius + .circular(5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: + InputDecoration( + hintText: 'Search', + suffixIcon: Icon( + Icons.search), + contentPadding: + EdgeInsets.all( + 10), // Adjust the horizontal padding + border: + OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchAddOnsSi, // Call the search method on text change + ), + )), + ), + // Expanded( + // flex: 2, + // child: Container( + // alignment: Alignment.centerRight, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceEvenly, + // children: [ + // Expanded( + // child: ElevatedButton( + // onPressed: () => + // _uploadFile('ADDONS'), + // child: Text( + // 'Import', + // style: TextStyle( + // color: Colors.white), + // ), + // style: ElevatedButton + // .styleFrom( + // backgroundColor: + // Color(0xFFE26728), + // shape: + // RoundedRectangleBorder( + // borderRadius: + // BorderRadius + // .circular(5), + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // ), + ], ), - ) - ], + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: + _buildDataTableAddOnsSi( + context), + ), + ) + ], + ), + ], + ), + ) + : Container( + height: + MediaQuery.of(context).size.height, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Center( + child: Text( + 'No Data Available', + style: TextStyle( + color: Colors.black), + ), + ) + ], + ), + ), + ), + ), + Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : filteredDataAddOnsDependent.isNotEmpty + ? SingleChildScrollView( + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: + Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius + .circular(5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: + InputDecoration( + hintText: 'Search', + suffixIcon: Icon( + Icons.search), + contentPadding: + EdgeInsets.all( + 10), // Adjust the horizontal padding + border: + OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchAddOnsDependent, // Call the search method on text change + ), + )), + ), + // Expanded( + // flex: 2, + // child: Container( + // alignment: Alignment.centerRight, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceEvenly, + // children: [ + // Expanded( + // child: ElevatedButton( + // onPressed: () => + // _uploadFile('ADDONS'), + // child: Text( + // 'Import', + // style: TextStyle( + // color: Colors.white), + // ), + // style: ElevatedButton + // .styleFrom( + // backgroundColor: + // Color(0xFFE26728), + // shape: + // RoundedRectangleBorder( + // borderRadius: + // BorderRadius + // .circular(5), + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: + _buildDataTableAddOnsDependent( + context), + ), + ) + ], + ), + ], + ), + ) + : Container( + height: + MediaQuery.of(context).size.height, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Center( + child: Text( + 'No Data Available', + style: TextStyle( + color: Colors.black), + ), + ) + ], + ), ), - ], - ), ), ), ], @@ -817,7 +1165,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { return Card( elevation: 0, // Set elevation to 0 for no shadow child: PaginatedDataTable( - rowsPerPage: 5, // Adjust rows per page as needed + rowsPerPage: 25, // Adjust rows per page as needed columns: [ DataColumn(label: Text('Employee ID')), DataColumn(label: Text('Name')), @@ -840,7 +1188,7 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { return Card( elevation: 0, // Set elevation to 0 for no shadow child: PaginatedDataTable( - rowsPerPage: 5, // Adjust rows per page as needed + rowsPerPage: 25, // Adjust rows per page as needed columns: [ DataColumn(label: Text('Employee ID')), DataColumn(label: Text('Name')), @@ -855,15 +1203,15 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { } } - Widget _buildDataTableAddOns(context) { - if (filteredDataAddOns.isEmpty) { + Widget _buildDataTableAddOnsSi(context) { + if (filteredDataAddOnsSi.isEmpty) { SizedBox(height: 25); return Text('No available data'); } else { return Card( elevation: 0, // Set elevation to 0 for no shadow child: PaginatedDataTable( - rowsPerPage: 5, // Adjust rows per page as needed + rowsPerPage: 25, // Adjust rows per page as needed columns: [ DataColumn(label: Text('Employee ID')), DataColumn(label: Text('Name')), @@ -872,7 +1220,30 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { DataColumn(label: Text('Gender')), DataColumn(label: Text('Mobile No')), ], - source: _DependenceDataSource2(filteredDataAddOns, context), + source: _DependenceDataSource2(filteredDataAddOnsSi, context), + ), + ); + } + } + + Widget _buildDataTableAddOnsDependent(context) { + if (filteredDataAddOnsDependent.isEmpty) { + SizedBox(height: 25); + return Text('No available data'); + } else { + return Card( + elevation: 0, // Set elevation to 0 for no shadow + child: PaginatedDataTable( + rowsPerPage: 25, // Adjust rows per page as needed + columns: [ + DataColumn(label: Text('Employee ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Relationship')), + DataColumn(label: Text('Date of Birth')), + DataColumn(label: Text('Gender')), + DataColumn(label: Text('Mobile No')), + ], + source: _DependenceDataSource2(filteredDataAddOnsDependent, context), ), ); } @@ -897,7 +1268,7 @@ class _DependenceDataSource0 extends DataTableSource { isClickable = true; // Making 'Self' rows clickable } // Format date of birth to "July 10, 1996" - String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; return DataRow( color: MaterialStateColor.resolveWith( @@ -934,9 +1305,11 @@ class _DependenceDataSource0 extends DataTableSource { arguments: {'mobile': row['mobile']}); } - String _formatDate(String date) { - DateTime parsedDate = DateTime.parse(date); - String formattedDate = DateFormat.yMMMMd().format(parsedDate); + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "dd-mm-yyyy" + String formattedDate = DateFormat('dd-MM-yyyy').format(dateTime); return formattedDate; } } @@ -960,7 +1333,7 @@ class _DependenceDataSource1 extends DataTableSource { } // Format date of birth to "July 10, 1996" - String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; return DataRow( color: MaterialStateColor.resolveWith((states) => rowColor), @@ -994,9 +1367,12 @@ class _DependenceDataSource1 extends DataTableSource { arguments: {'mobile': row['mobile']}); } - String _formatDate(String date) { - DateTime parsedDate = DateTime.parse(date); - String formattedDate = DateFormat.yMMMMd().format(parsedDate); + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "dd-mm-yyyy" + String formattedDate = DateFormat('dd-MM-yyyy').format(dateTime); + return formattedDate; } } @@ -1020,7 +1396,7 @@ class _DependenceDataSource2 extends DataTableSource { } // Format date of birth to "July 10, 1996" - String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; return DataRow( color: MaterialStateColor.resolveWith((states) => rowColor), @@ -1054,9 +1430,75 @@ class _DependenceDataSource2 extends DataTableSource { arguments: {'mobile': row['mobile']}); } - String _formatDate(String date) { - DateTime parsedDate = DateTime.parse(date); - String formattedDate = DateFormat.yMMMMd().format(parsedDate); + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "dd-mm-yyyy" + String formattedDate = DateFormat('dd-MM-yyyy').format(dateTime); + + return formattedDate; + } +} + +class _DependenceDataSource3 extends DataTableSource { + final List> _data; + final BuildContext context; + _DependenceDataSource3(this._data, this.context); + + @override + DataRow getRow(int index) { + final row = _data[index]; + Color rowColor = Colors.transparent; + TextStyle textStyle = TextStyle(color: Colors.black); + bool isClickable = false; + + if (row['relationship'] == 'Self') { + rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows + textStyle = TextStyle(color: Colors.black); + isClickable = true; // Making 'Self' rows clickable + } + + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; + + return DataRow( + color: MaterialStateColor.resolveWith((states) => rowColor), + cells: [ + DataCell( + Text(row['emp_code'].toString(), style: textStyle), + onTap: isClickable + ? () => _navigateToAnotherPage(row) + : null, // Navigation only for 'Self' rows + ), + DataCell(Text(row['name'].toString(), style: textStyle)), + DataCell(Text(row['relationship'].toString(), style: textStyle)), + DataCell(Text(dob, style: textStyle)), + DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)), + DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)), + ]); + } + + @override + bool get isRowCountApproximate => false; + + @override + int get rowCount => _data.length; + + @override + int get selectedRowCount => 0; + + void _navigateToAnotherPage(row) { + print(row); + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': row['mobile']}); + } + + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "dd-mm-yyyy" + String formattedDate = DateFormat('dd-MM-yyyy').format(dateTime); + return formattedDate; } } diff --git a/lib/hrLogin.dart b/lib/hrLogin.dart index d256f19..6a968bf 100644 --- a/lib/hrLogin.dart +++ b/lib/hrLogin.dart @@ -7,6 +7,9 @@ import 'package:nhancepolicy/models/environment.dart'; import 'dart:convert'; import 'dart:io'; import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:flutter_animated_button/flutter_animated_button.dart'; class MyHrLogin extends StatefulWidget { const MyHrLogin({Key? key}); @@ -24,17 +27,30 @@ class _MyPhoneState extends State { void initState() { countryController.text = "+91"; super.initState(); + checkTokenAvailability(); + } + + Future checkTokenAvailability() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? hrtoken = prefs.getString('hrtoken'); + + if (hrtoken != null && hrtoken.isNotEmpty) { + // Token available, navigate to home page + Navigator.pushReplacementNamed(context, 'hrDashboard', + arguments: {'mobile': ''}); + } } void toggleLoginType() { Navigator.pushNamed(context, 'phone'); // Navigate to another page } - Future verifyMobileNumber(String mobileNumber) async { + Future verifyMobileNumber() async { try { + var enteredMobileNumber = mobileController.text; final response = await http.post( Uri.parse(Environment.apiUrl + 'verifyHrWithMobileNumber'), - body: json.encode({'mobile_number': mobileNumber}), + body: json.encode({'mobile_number': enteredMobileNumber}), headers: { HttpHeaders.contentTypeHeader: 'application/json', }, @@ -43,34 +59,41 @@ class _MyPhoneState extends State { if (response.statusCode == 200) { Map data = json.decode(response.body); bool userVerification = data['data']['user_verification']; - return userVerification; + String message = data['data']['message']; + if (userVerification) { + ToastHelper.showSuccessToast(context, message); + Navigator.pushNamed(context, 'hrVerify', + arguments: enteredMobileNumber); + } else { + ToastHelper.showErrorToast(context, message); + print('Invalid mobile number'); + } } else { ToastHelper.showErrorToast(context, 'Failed to verify mobile number'); throw Exception('Failed to verify mobile number'); } } catch (e) { print('Error: $e'); - ToastHelper.showErrorToast(context, 'Error: $e'); - return false; + ToastHelper.showErrorToast(context, 'Something went wrong'); } } - void handleSubmit() async { - if (_formKey.currentState!.validate()) { - // var enteredMobileNumber = countryController.text + mobileController.text; - var enteredMobileNumber = mobileController.text; - - bool isValid = await verifyMobileNumber(enteredMobileNumber); - - if (isValid) { - ToastHelper.showSuccessToast(context, 'Mobile No Verified...'); - Navigator.pushNamed(context, 'hrVerify', - arguments: enteredMobileNumber); - } else { - ToastHelper.showErrorToast(context, 'Invalid mobile number'); - } - } - } + // void handleSubmit() async { + // if (_formKey.currentState!.validate()) { + // // var enteredMobileNumber = countryController.text + mobileController.text; + // var enteredMobileNumber = mobileController.text; + // + // bool isValid = await verifyMobileNumber(enteredMobileNumber); + // + // if (isValid) { + // ToastHelper.showSuccessToast(context, 'Mobile No Verified...'); + // Navigator.pushNamed(context, 'hrVerify', + // arguments: enteredMobileNumber); + // } else { + // ToastHelper.showErrorToast(context, 'Invalid mobile number'); + // } + // } + // } @override Widget build(BuildContext context) { @@ -142,7 +165,7 @@ class _MyPhoneState extends State { ), SizedBox(width: 5), Text( - 'Customer Login', + 'Member Login', style: TextStyle( color: Color(0xFF000000), // Text color // Add other text styles as needed @@ -269,36 +292,35 @@ class _MyPhoneState extends State { flex: 4, child: Align( alignment: Alignment.centerLeft, - child: MouseRegion( - cursor: - SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'phone'); - }, - child: Row( - children: [ - Icon( - Icons - .west, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - SizedBox(width: 5), - Text( - 'Customer Login', - style: TextStyle( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - ], - ), + child: AnimatedButton( + animatedOn: + AnimatedOn.onHover, + onPress: () { + Navigator.pushNamed( + context, 'phone'); + }, + onChanges: (change) {}, + height: 30, + width: 150, + text: 'Member Login', + isReverse: true, + selectedTextColor: + Colors.black, + transitionType: TransitionType + .RIGHT_CENTER_ROUNDER, + textStyle: + GoogleFonts.poppins( + fontSize: 16, + letterSpacing: 0, + color: Color(0xFF00989E), + fontWeight: FontWeight.w300, ), + backgroundColor: Colors.white, + selectedBackgroundColor: + Color(0xFF00989E), + borderColor: + Color(0xFF00989E), + borderWidth: 1, ), )), Expanded( @@ -360,7 +382,7 @@ class _MyPhoneState extends State { children: [ Expanded( child: Text( - "Have a Health Insurance Policy number, but never signed in? Don't worry, We got you covered", + "Login to manage the employee enrollment and overall health insurance programme of your organisation", style: TextStyle( fontSize: 12, color: Color(0xFF000000)), @@ -460,7 +482,7 @@ class _MyPhoneState extends State { BorderRadius.circular(10), ), ), - onPressed: handleSubmit, + onPressed: verifyMobileNumber, child: Text( "Login With OTP", style: TextStyle( diff --git a/lib/hrPolicyDetails.dart b/lib/hrPolicyDetails.dart new file mode 100644 index 0000000..809fe4c --- /dev/null +++ b/lib/hrPolicyDetails.dart @@ -0,0 +1,746 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:nhancepolicy/customAppBar/customAppBar.dart'; +import 'package:nhancepolicy/excel_verification.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'dart:convert'; +import 'dart:async'; +import 'package:http/http.dart' as http; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:universal_html/html.dart' as html; +import 'dart:typed_data'; +import 'dart:io'; +import 'package:flutter/foundation.dart' show kIsWeb; +import 'package:intl/intl.dart'; +import 'package:excel/excel.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:path/path.dart' as path; + +class hrPolicyDetails extends StatefulWidget { + const hrPolicyDetails({Key? key}) : super(key: key); + + @override + State createState() => _HrPolicyDetailsState(); +} + +class _HrPolicyDetailsState extends State + with TickerProviderStateMixin { + Uint8List? fileBytes; + late String _token; + List> getEmpDependenceByClintId = []; + bool _isLoading = false; + // dynamic clintID; + late TabController _tabController; + // List dataPolicy = []; + List reversedDataPolicy = []; + List> originalData = []; // Original data source + List> filteredData = []; // Filtered data source + dynamic argumentsData; + dynamic policyType; + dynamic policyName; + dynamic clientPolicyId; + dynamic clientId; + int inceptionType = 0; + TextEditingController searchController = TextEditingController(); + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 4, vsync: this); + _loadToken(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + Future _loadToken() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final token = prefs.getString('hrtoken'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + Map? decodedToken = Jwt.parseJwt(token); + // clintID = decodedToken['client_id']; + getPolicyDetails(); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'hrLogin'); + } + } + + Future getPolicyDetails() async { + setState(() { + _isLoading = true; + }); + try { + setState(() { + if (argumentsData != null && argumentsData is Map) { + if (argumentsData['type'] == 'GPA') { + clientPolicyId = argumentsData['client_policy_id']; + clientId = argumentsData['client_id']; + policyType = argumentsData['type']; + policyName = argumentsData['policy_name']; + String int_inception_type = argumentsData['inception_type']; + inceptionType = int.parse(int_inception_type); + getEmployeeAndDependence(clientId, clientPolicyId); + } else if (argumentsData['type'] == 'GMC') { + clientPolicyId = argumentsData['client_policy_id']; + clientId = argumentsData['client_id']; + policyType = argumentsData['type']; + policyName = argumentsData['policy_name']; + String int_inception_type = argumentsData['inception_type']; + inceptionType = int.parse(int_inception_type); + getEmployeeAndDependence(clientId, clientPolicyId); + } else if (argumentsData['type'] == 'SI TopUp') { + clientPolicyId = argumentsData['client_policy_id']; + clientId = argumentsData['client_id']; + policyType = argumentsData['type']; + policyName = argumentsData['policy_name']; + String int_inception_type = argumentsData['inception_type']; + inceptionType = int.parse(int_inception_type); + getEmployeeAndDependence(clientId, clientPolicyId); + } else if (argumentsData['type'] == 'Dependent AddOn') { + clientPolicyId = argumentsData['client_policy_id']; + clientId = argumentsData['client_id']; + policyType = argumentsData['type']; + policyName = argumentsData['policy_name']; + String int_inception_type = argumentsData['inception_type']; + inceptionType = int.parse(int_inception_type); + getEmployeeAndDependence(clientId, clientPolicyId); + } + } + }); + } catch (e) { + print('Exception occurred: $e'); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + Future getEmployeeAndDependence(clintID, getPolicyNo) async { + setState(() { + _isLoading = true; + }); + var url = Uri.parse(Environment.apiUrl + + 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + setState(() { + getEmpDependenceByClintId = + List>.from(data['data']); + originalData = getEmpDependenceByClintId; + filteredData = List.from(originalData); + print('filteredData'); + print(filteredData); + }); + } else { + // ToastHelper.showWarningToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // ToastHelper.showWarningToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + print('Exception occurred: $e'); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + void _uploadFile(type) async { + var argumentType; + if (type == 'GPA') { + // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails2; + argumentType = 'GPA'; + } else if (type == 'GMC') { + // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1; + argumentType = 'GMC'; + } + // else if (importPolicyName == 'SI-TopUp') { + // // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + // argumentDetails = 'SI-TopUp'; + // } else if (importPolicyName == 'Dependent-AddOn') { + // // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + // argumentDetails = 'Dependent-AddOn'; + // } + + Navigator.pushNamed(context, 'excelVerify', arguments: argumentsData); + // return; + // if (kIsWeb) { + // final input = html.FileUploadInputElement(); + // input.accept = '.xlsx'; + // input.click(); + // input.onChange.listen((event) async { + // final file = input.files!.first; + // final reader = html.FileReader(); + // reader.readAsArrayBuffer(file); + // reader.onLoadEnd.listen((event) async { + // final Uint8List? fileBytes = reader.result as Uint8List?; + // if (fileBytes != null) { + // // Call function to process Excel data + // } + // }); + // }); + // } + } + + // Implement a method to handle the search functionality + void search(String query) { + print(query); + // Check if the query is empty + if (query.isEmpty) { + // If search query is empty, show all data + setState(() { + filteredData = List.from(originalData); + }); + } else { + // Filter the original data based on the search query + setState(() { + filteredData = originalData.where((row) { + // Implement your filter logic here + // For example, check if any field in the row contains the query + // Adjust this logic based on your data structure + return row['emp_code'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()) || + row['name'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()) || + row['relationship'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()) || + row['dob'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()) || + row['gender'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()) || + row['mobile'] + .toString() + .toLowerCase() + .contains(query.toLowerCase()); + }).toList(); + }); + } + print(filteredData.length); + } + + Future downloadExcel() async { + // API endpoint to download the Excel file + + // Send GET request to the API + var url = Uri.parse(Environment.apiUrl + + 'exportDataByClientPolicyId?client_id=$clientId&client_policy_id=$clientPolicyId'); + + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + // Check if the request was successful (status code 200) + if (response.statusCode == 200) { + // Create a blob from the response body + final blob = html.Blob([response.bodyBytes]); + + // Generate a download URL for the blob + final url = html.Url.createObjectUrlFromBlob(blob); + + // Create a link element to trigger the download + final anchor = html.AnchorElement(href: url) + ..setAttribute('download', '$policyName - ($policyType).xlsx') + ..click(); + + // Revoke the download URL to free up resources + html.Url.revokeObjectUrl(url); + } else { + // Handle error + print('Failed to download Excel file: ${response.statusCode}'); + } + } + + @override + Widget build(BuildContext context) { + dynamic arguments = ModalRoute.of(context)!.settings.arguments; + print('arguments'); + print(arguments); + if (arguments != null && arguments is Map) { + argumentsData = arguments; + } + if (filteredData == []) { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], + ), + ), + )); + } else { + return Scaffold( + appBar: CustomAppBar(), + body: Container( + padding: const EdgeInsets.all(20), + color: Color(0xFFEFF3F6), + child: Card( + elevation: 0, + child: SingleChildScrollView( + child: Column( + children: [ + Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : originalData.isNotEmpty + ? SingleChildScrollView( + child: Column( + children: [ + Container( + padding: EdgeInsets.all( + 10), // Set your desired padding + color: Color( + 0xFFE26728), // Set your desired background color + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, // Align text to the center + child: Text( + '$policyName - ($policyType)', + textAlign: TextAlign + .center, // Align text to the center + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.white, + ), + ), + ), + ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, // Align text to the center + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + Navigator.pushNamed( + context, + 'hrDashboard'); + }, + child: Icon( + Icons + .close, // Replace with your desired icon + color: Colors + .white, // Replace with your desired icon color + ), + ), + ), + ), + ), + ], + ), + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + flex: (policyType == 'GPA' || + policyType == 'GMC') + ? 8 + : 10, + child: Container( + alignment: Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius.circular( + 5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: InputDecoration( + hintText: 'Search', + suffixIcon: + Icon(Icons.search), + contentPadding: + EdgeInsets.all( + 10), // Adjust the horizontal padding + border: + OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + controller: + searchController, + onChanged: + search, // Call the search method on text change + ), + )), + ), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + {downloadExcel()}, + child: Text( + 'Export', + style: TextStyle( + color: + Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular(5), + ), + ), + ), + ), + ], + ), + ), + ), + SizedBox( + width: (policyType == 'GPA' || + policyType == 'GMC') + ? 5 + : 0), + if ((policyType == 'GPA' || + policyType == 'GMC') && + inceptionType == 2) + Expanded( + flex: 2, + child: Container( + alignment: + Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + _uploadFile( + policyType), + child: Text( + 'Import Data', + style: TextStyle( + color: + Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular( + 5), + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: + _buildDataTableGPA(context), + ), + ) + ], + ), + ], + )) + : Container( + height: MediaQuery.of(context).size.height, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all( + 10), // Set your desired padding + color: Color( + 0xFFE26728), // Set your desired background color + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerLeft, // Align text to the center + child: Text( + (policyName != null && + policyType != null) + ? '$policyName - ($policyType)' + : '', + textAlign: TextAlign + .center, // Align text to the center + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: + FontWeight.w500, + color: Colors.white, + ), + ), + ), + ), + Expanded( + flex: 6, + child: Container( + alignment: Alignment + .centerRight, // Align text to the center + child: MouseRegion( + cursor: SystemMouseCursors + .click, + child: GestureDetector( + onTap: () { + Navigator.pushNamed( + context, + 'hrDashboard'); + }, + child: Icon( + Icons + .close, // Replace with your desired icon + color: Colors + .white, // Replace with your desired icon color + ), + ), + ), + ), + ), + ], + ), + ), + SizedBox(height: 200), + if (inceptionType == 2) + Center( + child: ElevatedButton( + onPressed: () => + _uploadFile(policyType), + child: Text( + 'Import Data', + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + ) + else + Center( + child: Text( + 'No Data Available', + style: GoogleFonts.poppins( + fontSize: 16, + letterSpacing: 0, + color: Colors.black, + fontWeight: FontWeight.w300, + ), + ), + ) + ], + ), + ), + ), + ), + ], + ), + )), + ), + ); + } + } + + Widget _buildDataTableGPA(context) { + if (filteredData.isEmpty) { + SizedBox(height: 25); + return Text('No available data'); + } else { + return Card( + elevation: 0, // Set elevation to 0 for no shadow + child: PaginatedDataTable( + rowsPerPage: 25, // Adjust rows per page as needed + columns: [ + DataColumn(label: Text('Employee ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Relationship')), + DataColumn(label: Text('Date of Birth')), + DataColumn(label: Text('Gender')), + DataColumn(label: Text('Mobile No')), + ], + source: _DependenceDataSource0(filteredData, context), + ), + ); + } + } +} + +class _DependenceDataSource0 extends DataTableSource { + final List> _data; + final BuildContext context; + _DependenceDataSource0(this._data, this.context); + + @override + DataRow getRow(int index) { + final row = _data[index]; + Color rowColor = Colors.transparent; + TextStyle textStyle = TextStyle(color: Colors.black); + bool isClickable = false; + + if (row['relationship'] == 'Self') { + rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows + textStyle = TextStyle(color: Colors.black); + isClickable = true; // Making 'Self' rows clickable + } + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; + + return DataRow( + color: MaterialStateColor.resolveWith( + (states) => rowColor), // Setting row background color + cells: [ + DataCell( + Text(row['emp_code'].toString(), style: textStyle), + onTap: isClickable + ? () => _navigateToAnotherPage(row) + : null, // Navigation only for 'Self' rows + ), + DataCell(Text(row['name'].toString(), style: textStyle)), + DataCell(Text(row['relationship'].toString(), style: textStyle)), + DataCell(Text(dob, style: textStyle)), + DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)), + DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)), + ], + ); + } + + @override + bool get isRowCountApproximate => false; + + @override + int get rowCount => _data.length; + + @override + int get selectedRowCount => 0; + + void _navigateToAnotherPage(row) { + print(row['mobile']); + // Navigation logic here + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': row['mobile']}); + } + + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "dd-mm-yyyy" + String formattedDate = DateFormat('dd-MM-yyyy').format(dateTime); + return formattedDate; + } +} + +// Sample Data class representing each element in the array +class Data { + final dynamic value; + final int row; + final int column; + final String sheet; + + Data(this.value, this.row, this.column, this.sheet); +} diff --git a/lib/hrVerify.dart b/lib/hrVerify.dart index 3b914fb..0528640 100644 --- a/lib/hrVerify.dart +++ b/lib/hrVerify.dart @@ -24,10 +24,18 @@ class _MyVerifyState extends State { late Timer _timer; int _secondsRemaining = 30; bool _isTimerRunning = false; + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; + dynamic clientName; + dynamic clientLogo; @override void initState() { super.initState(); + checkTokenAvailability(); // Start the timer when the widget is initialized startTimer(); } @@ -52,6 +60,16 @@ class _MyVerifyState extends State { }); } + Future checkTokenAvailability() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? hrtoken = prefs.getString('hrtoken'); + + if (hrtoken != null && hrtoken.isNotEmpty) { + // Token available, navigate to home page + Navigator.pushReplacementNamed(context, 'hrDashboard'); + } + } + Future resendOTP(String mobileNumber) async { print(mobileNumber); // Update the UI as needed @@ -85,8 +103,7 @@ class _MyVerifyState extends State { } catch (e) { // Handle API call errors print('Error: $e'); - ToastHelper.showErrorToast( - context, 'Failed to resend OTP. Please try again.'); + ToastHelper.showErrorToast(context, 'Something went wrong'); // ScaffoldMessenger.of(context).showSnackBar( // SnackBar( // content: Text('Failed to resend OTP. Please try again.'), @@ -110,16 +127,32 @@ class _MyVerifyState extends State { if (response.statusCode == 200) { Map data = json.decode(response.body); + _token = data['data']; print(data); String status = data['status']; print(status); if (status == 'success') { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('hrtoken', data['data']); + + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(data['data']); + print(decodedToken); + empCodeString = decodedToken['emp_code'].toString(); + prefs.setString('empCode', empCodeString); + empPrimaryId = decodedToken['id']; + prefs.setString('empPrimaryId', empPrimaryId); + gpaEmpName = decodedToken['name'].toString(); + prefs.setString('gpaEmpName', gpaEmpName); + client_id = decodedToken['client_id']; + prefs.setString('client_id', client_id); + getClientLogoAndDetails(); + + print('Successfully Login'); final hrtoken = prefs.getString('hrtoken'); if (hrtoken != null && hrtoken.isNotEmpty) { ToastHelper.showSuccessToast(context, 'Successfully Login'); - Navigator.pushNamed(context, 'hrHome'); + Navigator.pushNamed(context, 'hrDashboard'); } else { // Token is empty or null, handle accordingly (e.g., navigate to login screen) // For now, let's navigate to the login screen @@ -153,6 +186,53 @@ class _MyVerifyState extends State { } } + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + // print('response.statusCode == 200'); + Map data = json.decode(response.body); + // print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('clientLogo', clientDetails['client']['client_logo']); + prefs.setString('clientName', clientDetails['client']['client_name']); + setState(() { + // dynamic clientDetails = data['data']; + // print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + }); + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + @override Widget build(BuildContext context) { // Retrieve the passed mobile number value diff --git a/lib/main.dart b/lib/main.dart index a63c4fb..6a94274 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,8 +9,11 @@ import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/phone.dart'; import 'package:nhancepolicy/verify.dart'; import 'package:nhancepolicy/home.dart'; +import 'package:nhancepolicy/hrDashboard.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:nhancepolicy/hrLogin.dart'; +import 'package:nhancepolicy/hrPolicyDetails.dart'; +import 'package:nhancepolicy/oldPolicy.dart'; Future main() async { await dotenv.load(fileName: Environment.fileName); @@ -29,6 +32,9 @@ Future main() async { 'empDetails': (context) => empDetails(), 'addOnsDetails': (context) => addOnsDetails(), 'empReviewDetails': (context) => empReviewDetails(), + 'hrDashboard': (context) => hrDashboard(), + 'hrPolicyDetails': (context) => hrPolicyDetails(), + 'oldPolicy': (context) => oldPolicy(), }, )); } diff --git a/lib/oldPolicy.dart b/lib/oldPolicy.dart new file mode 100644 index 0000000..ea7ed8a --- /dev/null +++ b/lib/oldPolicy.dart @@ -0,0 +1,385 @@ +import 'dart:convert'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:intl/intl.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:http/http.dart' as http; +import 'customAppBar/customAppBar.dart'; +import 'customAppBar/toastHelper.dart'; + +class oldPolicy extends StatefulWidget { + const oldPolicy({Key? key}) : super(key: key); + + @override + State createState() => _oldPolicyState(); +} + +class _oldPolicyState extends State { + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic client_id; + dynamic gpaEmpName; + dynamic oldPolicyList; + dynamic oldPolicyName; + dynamic oldPolicyClientId; + dynamic oldPolicyClientPolicyId; + dynamic oldPolicySiGstValue; + dynamic oldPolicySiPremiumValue; + dynamic oldPolicySiValue; + dynamic oldPolicyType; + dynamic oldPolicyEmployeePolicy; + dynamic oldPolicyDataIsEmpty = 1; + dynamic oldPolicyTypeHeading; + dynamic oldPolicyFloaterTextHeading; + dynamic oldPolicyStartDate; + dynamic oldPolicyEndDate; + + @override + void initState() { + super.initState(); + _loadToken(); + } + + @override + void dispose() { + super.dispose(); + } + + Future _loadToken() async { + print('_loadToken'); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(token); + print(decodedToken); + empCodeString = prefs.getString('empCode'); + print(empCodeString); // Check if emp_code is correct + empPrimaryId = prefs.getString('empPrimaryId'); + gpaEmpName = prefs.getString('gpaEmpName'); + client_id = prefs.getString('client_id'); + print(client_id); + getOldPolicyDetails(); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } + } + + Future getOldPolicyDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeeActiveOrInactivePolicy?client_id=$client_id&emp_code=$empCodeString&type=Inactive'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + setState(() { + oldPolicyList = data['data']; + print('gmcPolicies'); + }); + // Assuming data is a List + print(oldPolicyList); + } else { + setState(() { + oldPolicyDataIsEmpty = 0; + }); + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + setState(() { + oldPolicyDataIsEmpty = 0; + }); + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: CustomAppBar(), + body: _buildBody(), + ); + } + + Widget _buildBody() { + if (oldPolicyList == null) { + return Center(child: _buildNoDataWidget()); + } else if (oldPolicyList!.isEmpty) { + return Center(child: _buildNoDataWidget()); + } else { + return _buildPolicyListWidget(); + } + } + + Widget _buildNoDataWidget() { + return SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], + ), + ), + ); + } + + Widget _buildPolicyListWidget() { + return Stack( + children: [ + SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + if (oldPolicyDataIsEmpty == 1) + ...generateGmcCards(oldPolicyList), + ], + ), + ), + ) + ], + ); + } + + List generateGmcCards(List data) { + List cards = []; + + print('data'); + print(data); + + for (var item in data) { + setState(() { + oldPolicyName = item['policy_name']; + oldPolicyTypeHeading = item['heading']; + oldPolicyFloaterTextHeading = item['floter_text_heading']; + oldPolicyClientId = item['client_id']; + oldPolicyClientPolicyId = item['client_policy_id']; + oldPolicySiGstValue = item['si_gst_value']; + oldPolicySiPremiumValue = item['si_premium_value']; + oldPolicySiValue = item['si_value']; + oldPolicyType = item['policy_type']; + oldPolicyStartDate = item['policy_start_date']; + oldPolicyEndDate = item['policy_end_date']; + oldPolicyEmployeePolicy = item['EmployeePolicy']; + }); + + Widget card = Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(20) + : 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: 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + oldPolicyName ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Text( + oldPolicyTypeHeading ?? '', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + oldPolicyFloaterTextHeading ?? '', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${oldPolicySiValue != null ? oldPolicySiValue : 'NA'}', + textAlign: TextAlign.right, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 20 + : 16, + 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: oldPolicyEmployeePolicy.map((data) { + String formattedDate = formatDate(data['dob']); + return 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( + '${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 18 : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only(top: 0, bottom: 0, left: 25, right: 25) + : EdgeInsets.only(top: 0, bottom: 0, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RichText( + text: TextSpan( + text: 'Policy Period : ', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF232526), + ), + children: [ + TextSpan( + text: + '$oldPolicyStartDate To $oldPolicyEndDate', + style: GoogleFonts.poppins( + fontSize: 14, + color: Color(0xFF232526), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + )); + + cards.add(card); + cards.add(SizedBox(height: 10)); + } + + return cards; + } + + String formatDate(String inputDate) { + // Parse the input date string + DateTime dateTime = DateTime.parse(inputDate); + + // Format the date to 'dd MMMM yyyy' + String formattedDate = DateFormat('dd MMMM yyyy').format(dateTime); + + return formattedDate; + } +} diff --git a/lib/phone.dart b/lib/phone.dart index 24049e5..e46015f 100644 --- a/lib/phone.dart +++ b/lib/phone.dart @@ -7,6 +7,9 @@ import 'dart:convert'; import 'dart:io'; import 'package:nhancepolicy/responsive.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_animated_button/flutter_animated_button.dart'; +import 'package:google_fonts/google_fonts.dart'; class MyPhone extends StatefulWidget { const MyPhone({Key? key}); @@ -24,53 +27,76 @@ class _MyPhoneState extends State { void initState() { countryController.text = "+91"; super.initState(); + checkTokenAvailability(); + } + + Future checkTokenAvailability() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + + if (token != null && token.isNotEmpty) { + // Token available, navigate to home page + Navigator.pushReplacementNamed(context, 'empDetails', + arguments: {'mobile': ''}); + } } void toggleLoginType() { Navigator.pushNamed(context, 'hrLogin'); // Navigate to another page } - Future verifyMobileNumber(String mobileNumber) async { + Future verifyMobileNumber() async { try { - final response = await http.post( - Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'), - body: json.encode({'mobile_number': mobileNumber}), - headers: { - HttpHeaders.contentTypeHeader: 'application/json', - }, - ); + if (_formKey.currentState!.validate()) { + // var enteredMobileNumber = countryController.text + mobileController.text; + var enteredMobileNumber = mobileController.text; + final response = await http.post( + Uri.parse(Environment.apiUrl + 'verifyEmployeeNumber'), + body: json.encode({'mobile_number': enteredMobileNumber}), + headers: { + HttpHeaders.contentTypeHeader: 'application/json', + }, + ); - if (response.statusCode == 200) { - Map data = json.decode(response.body); - bool userVerification = data['data']['user_verification']; - return userVerification; - } else { - ToastHelper.showErrorToast(context, 'Failed to verify mobile number'); - throw Exception('Failed to verify mobile number'); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + bool userVerification = data['data']['user_verification']; + String message = data['data']['message']; + if (userVerification) { + ToastHelper.showSuccessToast(context, message); + Navigator.pushNamed(context, 'verify', + arguments: enteredMobileNumber); + } else { + ToastHelper.showErrorToast(context, message); + print('Invalid mobile number'); + } + } else { + ToastHelper.showErrorToast(context, 'Something went wrong'); + throw Exception('Failed to verify mobile number'); + } } } catch (e) { - ToastHelper.showErrorToast(context, '$e'); + ToastHelper.showErrorToast(context, 'Something went wrong'); print('Error: $e'); - return false; } } - void handleSubmit() async { - if (_formKey.currentState!.validate()) { - // var enteredMobileNumber = countryController.text + mobileController.text; - var enteredMobileNumber = mobileController.text; - - bool isValid = await verifyMobileNumber(enteredMobileNumber); - - if (isValid) { - ToastHelper.showSuccessToast(context, 'Mobile No Verified..'); - Navigator.pushNamed(context, 'verify', arguments: enteredMobileNumber); - } else { - ToastHelper.showErrorToast(context, 'Invalid mobile number..'); - print('Invalid mobile number'); - } - } - } + // void handleSubmit() async { + // if (_formKey.currentState!.validate()) { + // // var enteredMobileNumber = countryController.text + mobileController.text; + // var enteredMobileNumber = mobileController.text; + // + // bool isValid = await verifyMobileNumber(enteredMobileNumber); + // + // if (isValid) { + // ToastHelper.showSuccessToast(context, 'Mobile No Verified..'); + // Navigator.pushNamed(context, 'verify', arguments: enteredMobileNumber); + // } else { + // ToastHelper.showErrorToast(context, 'Invalid mobile number..'); + // print('Invalid mobile number'); + // } + // } + // } @override Widget build(BuildContext context) { @@ -155,7 +181,7 @@ class _MyPhoneState extends State { children: [ SizedBox( height: _size.height / - 6.4), // Adjust the spacing between the rows + 8.0), // Adjust the spacing between the rows Row( mainAxisAlignment: MainAxisAlignment .center, // Align to the center @@ -167,9 +193,7 @@ class _MyPhoneState extends State { ? Alignment.centerLeft : Alignment.bottomCenter, child: Image.asset( - _size.width <= 1100 - ? 'assets/mobileViewLogo.png' - : 'assets/Nhance-Logo-Final 1.png', + 'assets/mobileViewLogo.png', width: 150, height: 150, ), @@ -273,43 +297,41 @@ class _MyPhoneState extends State { Expanded( flex: 2, child: Align( - alignment: - Alignment.centerRight, - child: MouseRegion( - cursor: - SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - children: [ - Text( - 'HR Login', - style: TextStyle( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], - ), + alignment: Alignment.centerLeft, + child: AnimatedButton( + animatedOn: + AnimatedOn.onHover, + onPress: () { + Navigator.pushNamed( + context, 'hrLogin'); + }, + onChanges: (change) {}, + height: 30, + width: 150, + text: 'HR Login', + isReverse: true, + selectedTextColor: + Colors.black, + transitionType: TransitionType + .LEFT_CENTER_ROUNDER, + textStyle: + GoogleFonts.poppins( + fontSize: 16, + letterSpacing: 0, + color: Color(0xFF00989E), + fontWeight: FontWeight.w300, ), + backgroundColor: Colors.white, + selectedBackgroundColor: + Color(0xFF00989E), + borderColor: + Color(0xFF00989E), + borderWidth: 1, ), )), ], ), - SizedBox(height: 15), + SizedBox(height: 10), Container( margin: Responsive.isDesktop(context) ? EdgeInsets.symmetric( @@ -321,7 +343,7 @@ class _MyPhoneState extends State { children: [ Text( "Welcome to Nhance", - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 16, fontWeight: FontWeight.bold, ), @@ -330,7 +352,7 @@ class _MyPhoneState extends State { ), ), SizedBox( - height: 15, + height: 10, ), Container( margin: Responsive.isDesktop(context) @@ -343,8 +365,8 @@ class _MyPhoneState extends State { children: [ Expanded( child: Text( - "Have a Health Insurance Policy number, but never signed in? Don't worry, We got you covered", - style: TextStyle( + "Login with your mobile number and OTP to review and enroll for exciting health benefits for you and your family", + style: GoogleFonts.poppins( fontSize: 12, color: Color(0xFF000000)), textAlign: TextAlign.center, @@ -443,10 +465,10 @@ class _MyPhoneState extends State { BorderRadius.circular(10), ), ), - onPressed: handleSubmit, + onPressed: verifyMobileNumber, child: Text( "Login With OTP", - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFFFFFFFF)), ), ), @@ -464,7 +486,7 @@ class _MyPhoneState extends State { SizedBox(height: 30), Text( "Benefits of Login", - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 20, fontWeight: FontWeight.bold, ), @@ -568,28 +590,28 @@ class _MyPhoneState extends State { text: TextSpan( text: 'By continuing, you agree with our ', - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), children: [ TextSpan( text: 'privacy policy ', - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFF00989E), fontSize: 9, ), ), TextSpan( text: 'and ', - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), ), TextSpan( text: 'terms of use', - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFF00989E), fontSize: 9, ), @@ -612,7 +634,7 @@ class _MyPhoneState extends State { return Image.asset( 'assets/login_web.jpg', height: _size.height, - fit: BoxFit.fill, + fit: BoxFit.cover, ); } else { return SizedBox(); diff --git a/lib/verify.dart b/lib/verify.dart index a8f5f46..3e709b3 100644 --- a/lib/verify.dart +++ b/lib/verify.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:pinput/pinput.dart'; import 'dart:async'; @@ -28,10 +29,14 @@ class _MyVerifyState extends State { dynamic empPrimaryId; dynamic gpaEmpName; dynamic client_id; + dynamic _token; + dynamic clientName; + dynamic clientLogo; @override void initState() { super.initState(); + checkTokenAvailability(); // Start the timer when the widget is initialized startTimer(); } @@ -56,6 +61,17 @@ class _MyVerifyState extends State { }); } + Future checkTokenAvailability() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + + if (token != null && token.isNotEmpty) { + // Token available, navigate to home page + Navigator.pushReplacementNamed(context, 'empDetails', + arguments: {'mobile': ''}); + } + } + Future resendOTP(String mobileNumber) async { print(mobileNumber); // Update the UI as needed @@ -105,6 +121,7 @@ class _MyVerifyState extends State { if (response.statusCode == 200) { Map data = json.decode(response.body); print(data); + _token = data['data']; String status = data['status']; print(status); if (status == 'success') { @@ -122,6 +139,7 @@ class _MyVerifyState extends State { prefs.setString('gpaEmpName', gpaEmpName); client_id = decodedToken['client_id']; prefs.setString('client_id', client_id); + getClientLogoAndDetails(); print('Successfully Login'); @@ -144,13 +162,12 @@ class _MyVerifyState extends State { print('Invalid OTP. Please try again'); } } else { - ToastHelper.showErrorToast(context, 'Failed to verify OTP'); + ToastHelper.showWarningToast(context, 'Something went wrong'); throw Exception('Failed to verify OTP'); } } catch (e) { print('Error: $e'); - ToastHelper.showErrorToast( - context, 'Failed to verify OTP. Please try again.'); + ToastHelper.showWarningToast(context, 'Something went wrong'); // Show a Snackbar if there's an error while verifying OTP // ToastHelper.showErrorToast( // context, 'Failed to verify OTP. Please try again.'); @@ -158,6 +175,53 @@ class _MyVerifyState extends State { } } + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + // print('response.statusCode == 200'); + Map data = json.decode(response.body); + // print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('clientLogo', clientDetails['client']['client_logo']); + prefs.setString('clientName', clientDetails['client']['client_name']); + setState(() { + // dynamic clientDetails = data['data']; + // print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + }); + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + // ToastHelper.showErrorToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + @override Widget build(BuildContext context) { // Retrieve the passed mobile number value @@ -237,7 +301,7 @@ class _MyVerifyState extends State { children: [ SizedBox( height: _size.height / - 6.4), // Adjust the spacing between the rows + 8.0), // Adjust the spacing between the rows Row( mainAxisAlignment: MainAxisAlignment .center, // Align to the center @@ -249,9 +313,7 @@ class _MyVerifyState extends State { ? Alignment.centerLeft : Alignment.bottomCenter, child: Image.asset( - _size.width <= 1100 - ? 'assets/mobileViewLogo.png' - : 'assets/Nhance-Logo-Final 1.png', + 'assets/mobileViewLogo.png', width: 150, height: 150, ), @@ -276,7 +338,7 @@ class _MyVerifyState extends State { children: [ Text( 'HR Login', - style: TextStyle( + style: GoogleFonts.poppins( color: Color( 0xFF000000), // Text color // Add other text styles as needed @@ -366,7 +428,7 @@ class _MyVerifyState extends State { children: [ Text( "Welcome to Nhance", - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 16, fontWeight: FontWeight.bold, ), @@ -435,7 +497,7 @@ class _MyVerifyState extends State { _isTimerRunning ? Text( "Resend OTP in $_secondsRemaining seconds", - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.black), ) : InkWell( @@ -444,7 +506,7 @@ class _MyVerifyState extends State { }, child: Text( "Resend OTP", - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.blue), ), ), @@ -478,7 +540,7 @@ class _MyVerifyState extends State { }, child: Text( "Submit", - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFFFFFFFF)), ), ), @@ -490,10 +552,10 @@ class _MyVerifyState extends State { horizontal: 150), child: Column( children: [ - SizedBox(height: 30), + SizedBox(height: 20), Text( "Benefits of Login", - style: TextStyle( + style: GoogleFonts.poppins( fontSize: 20, fontWeight: FontWeight.bold, ), @@ -548,7 +610,9 @@ class _MyVerifyState extends State { SizedBox( height: 10), Text( - "View Policy"), + "View Policy", + style: GoogleFonts + .poppins()), ], ), ), @@ -567,7 +631,9 @@ class _MyVerifyState extends State { SizedBox( height: 10), Text( - "Manage Claims"), + "Manage Claims", + style: GoogleFonts + .poppins()), ], ), ), @@ -597,28 +663,28 @@ class _MyVerifyState extends State { text: TextSpan( text: 'By continuing, you agree with our ', - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), children: [ TextSpan( text: 'privacy policy ', - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFF00989E), fontSize: 9, ), ), TextSpan( text: 'and ', - style: TextStyle( + style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), ), TextSpan( text: 'terms of use', - style: TextStyle( + style: GoogleFonts.poppins( color: Color(0xFF00989E), fontSize: 9, ), @@ -641,7 +707,7 @@ class _MyVerifyState extends State { return Image.asset( 'assets/login_web.jpg', height: _size.height, - fit: BoxFit.fill, + fit: BoxFit.cover, ); } else { return SizedBox(); diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 13ceb2a..fc6e2af 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,9 +7,13 @@ #include "generated_plugin_registrant.h" #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) smart_auth_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "SmartAuthPlugin"); smart_auth_plugin_register_with_registrar(smart_auth_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 9cadb0a..4ebc56f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST smart_auth + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index b47dc21..48b0136 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,9 +8,11 @@ import Foundation import path_provider_foundation import shared_preferences_foundation import smart_auth +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SmartAuthPlugin.register(with: registry.registrar(forPlugin: "SmartAuthPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.yaml b/pubspec.yaml index e61a388..1ed6d9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,13 +43,16 @@ dependencies: adaptive_navbar: ^0.0.3 jwt_decode: ^0.3.1 google_fonts: ^6.2.1 - file_picker: ^6.2.0 + file_picker: ^8.0.3 csv: ^6.0.0 data_tables: ^1.4.0 universal_html: ^2.2.4 excel: ^4.0.3 intl: ^0.19.0 toastification: ^1.2.1 + flutter_animated_button: ^2.0.3 + spreadsheet_decoder: ^2.2.0 + url_launcher: ^6.2.6 dev_dependencies: diff --git a/web/assets/Sample.xlsx b/web/assets/Sample.xlsx new file mode 100644 index 0000000..aa86020 Binary files /dev/null and b/web/assets/Sample.xlsx differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png index b749bfe..ab01983 100644 Binary files a/web/icons/Icon-192.png and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png index 88cfd48..8c5e656 100644 Binary files a/web/icons/Icon-512.png and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png index eb9b4d7..ab01983 100644 Binary files a/web/icons/Icon-maskable-192.png and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png index d69c566..8c5e656 100644 Binary files a/web/icons/Icon-maskable-512.png and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html index 003c4c7..885e90d 100644 --- a/web/index.html +++ b/web/index.html @@ -95,7 +95,7 @@ if(loadingIndicator){ loadingIndicator.remove(); } - },10000); + },5000); }; diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 1e90c87..e3b1e46 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,11 @@ #include "generated_plugin_registrant.h" #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { SmartAuthPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SmartAuthPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ffb020c..e4b507c 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST smart_auth + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST