4661 lines
227 KiB
Dart
Executable File
4661 lines
227 KiB
Dart
Executable File
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:nhance_app_pwa/customAppBar/enrollmentAppBar.dart';
|
|
import 'package:nhance_app_pwa/pages/enrollment/service/api_service.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
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';
|
|
|
|
import '../../customAppBar/customFooter.dart';
|
|
import '../../customAppBar/responsive.dart';
|
|
import '../../customAppBar/tabs.dart';
|
|
import '../../customAppBar/toastHelper.dart';
|
|
import '../service/SessionManager.dart';
|
|
import '../service/TokenService.dart';
|
|
|
|
import 'package:nhance_app_pwa/logger.dart';
|
|
|
|
class empReviewDetails extends StatefulWidget {
|
|
const empReviewDetails({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<empReviewDetails> createState() => _empReviewDetailsState();
|
|
}
|
|
|
|
class _empReviewDetailsState extends State<empReviewDetails> {
|
|
List<String> typeOrder = [
|
|
'GPA',
|
|
'GMC',
|
|
'GMC - OPD',
|
|
'GMC - Parents',
|
|
'GMC - Topup',
|
|
'GMC - Topup(Parents)'
|
|
];
|
|
late ApiService apiService;
|
|
bool isLoading = true;
|
|
bool isChecked = false; // Declare the _isSwitched variable here
|
|
bool disclaimeStatus = false; // Declare the _isSwitched variable here
|
|
bool topUpSiIsChecked = false; // Declare the _isSwitched variable here
|
|
bool topUpParentIsChecked = false; // Declare the _isSwitched variable here
|
|
bool addOnsDependentIsChecked = false; // Declare the _isSwitched variable here
|
|
|
|
dynamic _token;
|
|
dynamic enrollmentEmpCodeString;
|
|
dynamic enrollmentEmpPrimaryId;
|
|
dynamic enrollmentGpaEmpName;
|
|
dynamic enrollmentClient_id;
|
|
dynamic gpaPolicies;
|
|
dynamic gpaPolicyName;
|
|
dynamic gpaGridMaster;
|
|
dynamic gmcPolicies;
|
|
dynamic gpasumInsured;
|
|
dynamic gpaClintPolicyId;
|
|
dynamic gpaMappedFamilyFloaters = [];
|
|
dynamic gpaSelfName;
|
|
dynamic gpaSelfDob;
|
|
dynamic gpaSelfRelationship;
|
|
dynamic gpaSelfDetails;
|
|
dynamic gpaECardDownload;
|
|
dynamic gpaTotalAmt;
|
|
dynamic gmcTotalAmt;
|
|
dynamic gmcDisclaimer;
|
|
dynamic gmcClintPolicyId = 0;
|
|
dynamic gmcSelfName;
|
|
dynamic gmcSelfDob;
|
|
dynamic gmcSelfRelationship;
|
|
dynamic gmcSelfDetails;
|
|
dynamic clientName;
|
|
dynamic clientLogo;
|
|
dynamic addOnsDependentMappedFamilyFloatersArray;
|
|
dynamic addOnsDependentClientPolicyId;
|
|
dynamic gmcAddOnsselectedSI;
|
|
dynamic gmcAddOnsselectedDependent;
|
|
dynamic dependentValue;
|
|
dynamic siValue;
|
|
late int addOnsDependentSumInsured;
|
|
dynamic addOnsDependentPolicyName;
|
|
dynamic addOnsDependentPolicyType;
|
|
dynamic addOnsFloaterTextHeading;
|
|
dynamic addOnsDependentECardDownload;
|
|
dynamic addOnsDependentDisclaimer;
|
|
dynamic addOnsFamilyFloater;
|
|
late DateTime? selectedDate;
|
|
double totalPayableAmt = 0.0;
|
|
List<Map<String, String>> relationshipOptions = [];
|
|
List<Map<String, String>> selectedRelationships = [];
|
|
List<Map<String, dynamic>> formDataList = [];
|
|
dynamic topUpMappedFamilyFloatersSi;
|
|
dynamic topUpMappedFamilyFloatersSiArray;
|
|
dynamic topUpClientPolicyId;
|
|
dynamic topUpSlabRates;
|
|
dynamic topUpFamilyFloater;
|
|
dynamic topUpPolicyName;
|
|
dynamic topUpPolicyType;
|
|
dynamic topUpTypeName;
|
|
dynamic topUpSiPremiumValue;
|
|
dynamic topUpSiPremiumGst;
|
|
dynamic topUpSiTotalAmt;
|
|
dynamic topUpParentSiPremiumValue;
|
|
dynamic topUpParentSiPremiumGst;
|
|
dynamic topUpParentSiTotalAmt;
|
|
// int addOnDependentPremiumValue = 0;
|
|
dynamic addOnDependentPremiumValue;
|
|
dynamic addOnsDependentPremiumGst;
|
|
dynamic addOnsDependentTotalAmt;
|
|
dynamic topUpSiValue;
|
|
dynamic topUpSiSelectedSI;
|
|
dynamic topUpSumInsured;
|
|
dynamic topUpFloaterTextHeading;
|
|
dynamic opdFloaterTextHeading;
|
|
dynamic topUpECardDownload;
|
|
int topUpIsPremiumSummary = 0;
|
|
dynamic topUpDisclaimer;
|
|
|
|
int showHideTopUpCard = 0;
|
|
int showHideOpdCard = 0;
|
|
int showHideAddOnsCard = 0;
|
|
int showHideTopUpParentCard = 0;
|
|
dynamic iAgreeForAddOn = [];
|
|
dynamic topUpSiParentPolicies = [];
|
|
dynamic topUpParentClientPolicyId;
|
|
dynamic topUpParentSlabRates;
|
|
dynamic topUpParentPolicyName;
|
|
dynamic topUpParentPolicyType;
|
|
dynamic topUpParentFamilyFloater;
|
|
dynamic topUpParentMappedFamilyFloatersSi;
|
|
dynamic topUpParentECardDownload;
|
|
int topUpParentIsPremiumSummary = 0;
|
|
dynamic topUpParentSiValue;
|
|
dynamic topUpParentSiSelectedSI;
|
|
dynamic topUpParentTypeName;
|
|
dynamic topUpParentFloterTextHeading;
|
|
dynamic topUpParentDisclaimer;
|
|
// int topUpParentOpenForEnrollment = 0;
|
|
dynamic opdPolicies = [];
|
|
dynamic opdClientPolicyId;
|
|
dynamic opdSlabRates;
|
|
dynamic opdFamilyFloater;
|
|
dynamic opdPolicyName;
|
|
dynamic opdPolicyType;
|
|
dynamic opdMappedFamilyFloatersSi;
|
|
dynamic opdECardDownload;
|
|
int opdOpenForEnrollment = 0;
|
|
dynamic opdTypeName;
|
|
dynamic opdSiValue;
|
|
dynamic opdSiSelectedSI;
|
|
dynamic opdSiPremiumValue;
|
|
dynamic opdSiPremiumGst;
|
|
dynamic opdSiTotalAmt;
|
|
int opdIsPremiumSummary = 0;
|
|
dynamic opdDisclaimer;
|
|
int activeSiData = 0;
|
|
int activeOPDSiData = 0;
|
|
int activeSiParentData = 0;
|
|
int activeDependentData = 0;
|
|
int activePremiumSummary = 0;
|
|
dynamic gmcDataIsEmpty = 1;
|
|
dynamic gpaDataIsEmpty = 1;
|
|
dynamic enrollmentEmpClientBranchId;
|
|
dynamic selfEmpStatus;
|
|
dynamic topUpOpenForEnrollment;
|
|
dynamic topUpParentOpenForEnrollment;
|
|
dynamic addOnsDependentOpenForEnrollment;
|
|
int addOnsDependentIsPremiumSummary = 0;
|
|
bool gmcEnrollmentStatus = false;
|
|
bool gpahasPremiumSummary = false;
|
|
bool gmchasPremiumSummary = false;
|
|
List<Map<String, dynamic>> allDisclaimer =
|
|
[]; // Declare this to store all disclaimers
|
|
bool isTokenAvailable = false;
|
|
bool isEnrollCompletedStatus = false;
|
|
final session = SessionManager();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
apiService = ApiService(context); // Initialize ApiService here
|
|
_loadToken();
|
|
Future.delayed(Duration(seconds: 3), () {
|
|
setState(() {
|
|
isLoading = false;
|
|
});
|
|
});
|
|
// checkboxValues = List<bool>.filled(allDisclaimer.length, false);
|
|
|
|
getTokenStatus();
|
|
}
|
|
|
|
Future<void> getTokenStatus() async {
|
|
final token = await TokenService.getPostToken();
|
|
|
|
setState(() {
|
|
isTokenAvailable = token != null && token.isNotEmpty;
|
|
logDebug('isTokenAvailable $isTokenAvailable');
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
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-MM-yyyy').format(dateTime);
|
|
|
|
return formattedDate;
|
|
}
|
|
|
|
Future<void> _loadToken() async {
|
|
logDebug('_loadToken');
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final String? token = await TokenService.getPreToken();
|
|
if (token != null && token.isNotEmpty) {
|
|
selfEmpStatus = prefs.getString('selfEmpStatus');
|
|
enrollmentEmpClientBranchId = session.enrollmentEmpClientBranchId;
|
|
enrollmentEmpCodeString = session.enrollmentEmpCodeString;
|
|
logDebug(enrollmentEmpCodeString); // Check if emp_code is correct
|
|
enrollmentEmpPrimaryId = session.enrollmentEmpPrimaryId;
|
|
enrollmentGpaEmpName = session.enrollmentGpaEmpName;
|
|
enrollmentClient_id = session.enrollmentClient_id;
|
|
logDebug(enrollmentClient_id);
|
|
|
|
// Call the API when the page enters
|
|
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
|
clientLogo = prefs.getString('clientLogo');
|
|
clientName = prefs.getString('clientName');
|
|
} else {
|
|
getClientLogoAndDetails();
|
|
}
|
|
getGmcSiTopUp();
|
|
getGmcOPD();
|
|
getGmcSiParentTopUp();
|
|
getGmcDependentAddOns();
|
|
getGpaEmpPolicyDetails(enrollmentEmpPrimaryId);
|
|
getGmcEmpPolicyDetails(enrollmentEmpPrimaryId);
|
|
primarySummary();
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
|
|
// Future<void> _loadToken() async {
|
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
// final String? token = prefs.getString('enrollToken');
|
|
// if (token != null && token.isNotEmpty) {
|
|
// setState(() {
|
|
// _token = token;
|
|
// });
|
|
// selfEmpStatus = prefs.getString('selfEmpStatus');
|
|
// enrollmentEmpClientBranchId =
|
|
// prefs.getString('enrollmentEmpClientBranchId');
|
|
// enrollmentEmpCodeString = prefs.getString('enrollmentEmpCodeString');
|
|
// logDebug(enrollmentEmpCodeString); // Check if emp_code is correct
|
|
// enrollmentEmpPrimaryId = prefs.getString('enrollmentEmpPrimaryId');
|
|
// enrollmentGpaEmpName = prefs.getString('enrollmentGpaEmpName');
|
|
// enrollmentClient_id = prefs.getString('enrollmentClient_id');
|
|
// logDebug(enrollmentClient_id);
|
|
//
|
|
// // Call the API when the page enters
|
|
// if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
|
// clientLogo = prefs.getString('clientLogo');
|
|
// clientName = prefs.getString('clientName');
|
|
// } else {
|
|
// getClientLogoAndDetails();
|
|
// }
|
|
// getGmcSiTopUp();
|
|
// getGmcSiParentTopUp();
|
|
// getGmcDependentAddOns();
|
|
// getGpaEmpPolicyDetails(enrollmentEmpPrimaryId);
|
|
// getGmcEmpPolicyDetails(enrollmentEmpPrimaryId);
|
|
// primarySummary();
|
|
// _sortDisclaimerByTypeOrder();
|
|
// } else {
|
|
// // Token is empty or null, handle accordingly (e.g., navigate to login screen)
|
|
// ToastHelper.showErrorToast(context, 'Session Out');
|
|
// context.go('/login');
|
|
// // Navigator.pushReplacementNamed(context, 'login');
|
|
// }
|
|
// }
|
|
|
|
/// 0 = hide, 1 = full summary, 2 = total only
|
|
int parsePremiumSummaryMode(dynamic value) {
|
|
if (value == null) return 0;
|
|
if (value is bool) return value ? 1 : 0;
|
|
if (value is num) return value.toInt();
|
|
final normalized = value.toString().trim().toLowerCase();
|
|
if (normalized == 'true' || normalized == 'yes') return 1;
|
|
if (normalized == 'false' || normalized == 'no') return 0;
|
|
return int.tryParse(normalized) ?? 0;
|
|
}
|
|
|
|
bool shouldShowPremiumSummary(int mode) => mode == 1 || mode == 2;
|
|
bool shouldShowFullPremiumBreakdown(int mode) => mode == 1;
|
|
|
|
bool _policyListHasFullPremiumBreakdown(dynamic policies) {
|
|
if (policies is! List) return false;
|
|
for (final policy in policies) {
|
|
if (policy is! Map) continue;
|
|
if (shouldShowFullPremiumBreakdown(
|
|
parsePremiumSummaryMode(policy['is_premium_summery']))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// True when any visible premium-summary row needs Additional Premium / GST columns.
|
|
bool hasAnyFullPremiumBreakdown() {
|
|
return _policyListHasFullPremiumBreakdown(gpaPolicies) ||
|
|
_policyListHasFullPremiumBreakdown(gmcPolicies) ||
|
|
(activeSiData == 1 &&
|
|
shouldShowFullPremiumBreakdown(topUpIsPremiumSummary)) ||
|
|
(activeOPDSiData == 1 &&
|
|
shouldShowFullPremiumBreakdown(opdIsPremiumSummary)) ||
|
|
(activeSiParentData == 1 &&
|
|
shouldShowFullPremiumBreakdown(topUpParentIsPremiumSummary)) ||
|
|
(activeDependentData == 1 &&
|
|
shouldShowFullPremiumBreakdown(addOnsDependentIsPremiumSummary));
|
|
}
|
|
|
|
Widget _premiumSummaryHeaderCell(
|
|
BuildContext context,
|
|
String label, {
|
|
TextAlign textAlign = TextAlign.start,
|
|
}) {
|
|
return TableCell(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(8.0),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Text(
|
|
label,
|
|
textAlign: textAlign,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 16 : 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _premiumSummaryValueCell(
|
|
BuildContext context,
|
|
String value, {
|
|
TextAlign textAlign = TextAlign.start,
|
|
}) {
|
|
return TableCell(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(8.0),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Text(
|
|
value,
|
|
textAlign: textAlign,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 14 : 12,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
List<Widget> buildPremiumSummaryRowCells({
|
|
required BuildContext context,
|
|
required String policyLabel,
|
|
required String premiumValue,
|
|
required String gstValue,
|
|
required String totalValue,
|
|
required bool includeBreakdownColumns,
|
|
required bool showBreakdownValues,
|
|
}) {
|
|
final totalAlign =
|
|
includeBreakdownColumns ? TextAlign.start : TextAlign.end;
|
|
return [
|
|
_premiumSummaryValueCell(context, policyLabel),
|
|
if (includeBreakdownColumns) ...[
|
|
_premiumSummaryValueCell(
|
|
context, showBreakdownValues ? premiumValue : ''),
|
|
_premiumSummaryValueCell(context, showBreakdownValues ? gstValue : ''),
|
|
],
|
|
_premiumSummaryValueCell(context, totalValue, textAlign: totalAlign),
|
|
];
|
|
}
|
|
|
|
bool isPremiumEnabled(dynamic value) {
|
|
return parsePremiumSummaryMode(value) != 0;
|
|
}
|
|
|
|
bool _isOpenForEnrollment(dynamic value) {
|
|
if (value is int) return value == 1;
|
|
return value?.toString() == '1';
|
|
}
|
|
|
|
void primarySummary() async {
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if (prefs.containsKey('siData')) {
|
|
activeSiData = 1;
|
|
String? siDataJson = prefs.getString('siData');
|
|
logDebug('siDataJson');
|
|
logDebug(siDataJson);
|
|
|
|
List<dynamic> siDataList = jsonDecode(siDataJson!);
|
|
if (siDataList.isNotEmpty) {
|
|
// Access the first map in the list
|
|
Map<String, dynamic> firstSiData = siDataList.first;
|
|
// Get the value of topUpSiPremiumValue
|
|
topUpSiPremiumValue = firstSiData['topUpSiPremiumValue'];
|
|
topUpSiPremiumGst = firstSiData['topUpSiPremiumGst'];
|
|
topUpSiTotalAmt = firstSiData['topUpSiTotalAmt'];
|
|
}
|
|
}
|
|
if (prefs.containsKey('opdData')) {
|
|
activeOPDSiData = 1;
|
|
String? opdDataJson = prefs.getString('opdData');
|
|
logDebug('siDataJson');
|
|
logDebug(opdDataJson);
|
|
List<dynamic> siDataList = jsonDecode(opdDataJson!);
|
|
if (siDataList.isNotEmpty) {
|
|
// Access the first map in the list
|
|
Map<String, dynamic> firstSiData = siDataList.first;
|
|
// Get the value of topUpSiPremiumValue
|
|
opdSiPremiumValue = firstSiData['opdSiPremiumValue'];
|
|
opdSiPremiumGst = firstSiData['opdSiPremiumGst'];
|
|
opdSiTotalAmt = firstSiData['opdSiTotalAmt'];
|
|
}
|
|
}
|
|
if (prefs.containsKey('siParentData')) {
|
|
activeSiParentData = 1;
|
|
String? siParentDataJson = prefs.getString('siParentData');
|
|
logDebug('siParentDataJson');
|
|
logDebug(siParentDataJson);
|
|
|
|
List<dynamic> siParentDataList = jsonDecode(siParentDataJson!);
|
|
if (siParentDataList.isNotEmpty) {
|
|
// Access the first map in the list
|
|
Map<String, dynamic> 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');
|
|
logDebug('dependentDataJson');
|
|
logDebug('activeDependentData $activeDependentData');
|
|
logDebug(dependentDataJson);
|
|
|
|
List<dynamic> dependentDataList = jsonDecode(dependentDataJson!);
|
|
if (dependentDataList.isNotEmpty) {
|
|
// Access the first map in the list
|
|
Map<String, dynamic> firstDependentListData = dependentDataList.first;
|
|
// Get the value of topUpSiPremiumValue
|
|
logDebug('150000000000');
|
|
addOnDependentPremiumValue =
|
|
firstDependentListData['addOnDependentPremiumValue'];
|
|
logDebug(addOnDependentPremiumValue);
|
|
addOnsDependentPremiumGst =
|
|
firstDependentListData['addOnsDependentPremiumGst'];
|
|
logDebug(addOnsDependentPremiumGst);
|
|
addOnsDependentTotalAmt =
|
|
firstDependentListData['addOnsDependentTotalAmt'];
|
|
logDebug(addOnsDependentTotalAmt);
|
|
}
|
|
}
|
|
|
|
if (prefs.containsKey('siData') && prefs.containsKey('opdData') &&
|
|
prefs.containsKey('siParentData') &&
|
|
prefs.containsKey('dependentData')) {
|
|
activePremiumSummary = 0;
|
|
} else {
|
|
activePremiumSummary = 1;
|
|
}
|
|
// Calculate the sum, skipping any missing values
|
|
|
|
logDebug('topUpSiTotalAmt: $topUpSiTotalAmt');
|
|
logDebug('topUpParentSiTotalAmt: $topUpParentSiTotalAmt');
|
|
logDebug('addOnsDependentTotalAmt: $addOnsDependentTotalAmt');
|
|
logDebug('gpaTotalAmt: $gpaTotalAmt');
|
|
logDebug('gmcTotalAmt: $gmcTotalAmt');
|
|
|
|
if (topUpSiTotalAmt != null) totalPayableAmt += topUpSiTotalAmt;
|
|
if (opdSiTotalAmt != null) totalPayableAmt += opdSiTotalAmt;
|
|
if (topUpParentSiTotalAmt != null) totalPayableAmt += topUpParentSiTotalAmt;
|
|
if (addOnsDependentTotalAmt != null) totalPayableAmt += addOnsDependentTotalAmt;
|
|
|
|
logDebug('Final Total Payable Amount: $totalPayableAmt');
|
|
}
|
|
|
|
void _sortDisclaimerByTypeOrder() {
|
|
allDisclaimer.sort((a, b) {
|
|
int indexA = typeOrder.indexOf(a['type']);
|
|
int indexB = typeOrder.indexOf(b['type']);
|
|
return indexA.compareTo(indexB);
|
|
});
|
|
}
|
|
|
|
Future<void> getClientLogoAndDetails() async {
|
|
try {
|
|
// if (enrollmentClient_id == null ||
|
|
// enrollmentEmpCodeString == null ||
|
|
// enrollmentEmpClientBranchId == null) {
|
|
// return;
|
|
// }
|
|
final empClientId = await session.client_id;
|
|
final empClientBranchId = await session.empClientBranchId;
|
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
|
empClientId,
|
|
empClientBranchId,
|
|
enrollmentClient_id!,
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
dynamic clientDetails = response['data'];
|
|
logDebug(clientDetails);
|
|
clientName = clientDetails['client']['client_name'];
|
|
logDebug(clientName);
|
|
clientLogo = clientDetails['client']['client_logo'];
|
|
logDebug(clientLogo);
|
|
} else {
|
|
// Handle other status messages if needed
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGpaEmpPolicyDetails(enrollmentEmpPrimaryId) async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGpaEmpPolicyDetailsToApi(
|
|
enrollmentEmpPrimaryId,
|
|
enrollmentEmpCodeString!,
|
|
enrollmentClient_id!,
|
|
'GPA',
|
|
enrollmentEmpClientBranchId!);
|
|
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
gpaPolicies = response['data'];
|
|
logDebug('gpaPolicies');
|
|
|
|
for (var policy in gpaPolicies) {
|
|
if (isPremiumEnabled(policy['is_premium_summery'])) {
|
|
gpahasPremiumSummary = true;
|
|
logDebug('gpahasPremiumSummary $gpahasPremiumSummary');
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (var item in gpaPolicies) {
|
|
// Extract disclaimer value from each object
|
|
if (_isOpenForEnrollment(item['OpenForEnrollment'])) {
|
|
dynamic disclaimer = item['disclaimer'];
|
|
if (disclaimer != null && disclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (disclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': disclaimer,
|
|
'checked': false,
|
|
'type': item['type']
|
|
});
|
|
} else if (disclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
disclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': item['type']
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
setState(() {
|
|
gpaDataIsEmpty = 0;
|
|
});
|
|
// Handle other status codes
|
|
ToastHelper.showWarningToast(context, 'Unable to process. Please try again later');
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcEmpPolicyDetails(enrollmentEmpPrimaryId) async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGmcEmpPolicyDetailsToApi(
|
|
enrollmentEmpPrimaryId,
|
|
enrollmentEmpCodeString!,
|
|
enrollmentClient_id!,
|
|
'GMC',
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
gmcPolicies = response['data'];
|
|
logDebug('gmcPolicies $gmcPolicies');
|
|
|
|
for (var policy in gmcPolicies) {
|
|
if (isPremiumEnabled(policy['is_premium_summery'])) {
|
|
gmchasPremiumSummary = true;
|
|
logDebug('gmchasPremiumSummary $gmchasPremiumSummary');
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (var item in gmcPolicies) {
|
|
if (_isOpenForEnrollment(item['OpenForEnrollment'])) {
|
|
dynamic disclaimer = item['disclaimer'];
|
|
if (disclaimer != null && disclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (disclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': disclaimer,
|
|
'checked': false,
|
|
'type': item['type']
|
|
});
|
|
} else if (disclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
disclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': item['type']
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
// Assuming data is a List
|
|
logDebug(gmcPolicies);
|
|
} else {
|
|
setState(() {
|
|
gmcDataIsEmpty = 0;
|
|
});
|
|
// Handle other status codes
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcSiTopUp() async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGmcSiTopUpToApi(
|
|
enrollmentClient_id!,
|
|
enrollmentEmpCodeString!,
|
|
'GMC-SI-TOPUP',
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
dynamic topUpSiPolicies = response['data'];
|
|
logDebug(topUpSiPolicies);
|
|
if (topUpSiPolicies.isNotEmpty) {
|
|
// setState(() {
|
|
topUpClientPolicyId =
|
|
topUpSiPolicies['gmc_si_topup']['client_policy_id'];
|
|
logDebug('topUpClientPolicyId12345 $topUpClientPolicyId');
|
|
|
|
topUpSumInsured = topUpSiPolicies['gmc_si_topup']
|
|
['family_floaters_of_only_si_value'];
|
|
logDebug(topUpSumInsured);
|
|
|
|
if (topUpSumInsured == 0) {
|
|
showHideTopUpCard = 0;
|
|
} else {
|
|
showHideTopUpCard = 1;
|
|
}
|
|
|
|
topUpOpenForEnrollment =
|
|
topUpSiPolicies['gmc_si_topup']['OpenForEnrollment'];
|
|
|
|
topUpPolicyName =
|
|
await topUpSiPolicies['gmc_si_topup']['policy_name'];
|
|
|
|
topUpPolicyType = await topUpSiPolicies['gmc_si_topup']['type'];
|
|
|
|
topUpMappedFamilyFloatersSiArray = topUpSiPolicies['gmc_si_topup']
|
|
['family_floaters_of_only_si_array'];
|
|
logDebug('topUpMappedFamilyFloatersSiArray');
|
|
logDebug(topUpMappedFamilyFloatersSiArray);
|
|
|
|
topUpTypeName = topUpSiPolicies['gmc_si_topup']['type'];
|
|
|
|
topUpFloaterTextHeading =
|
|
topUpSiPolicies['gmc_si_topup']['floter_text_heading'];
|
|
|
|
topUpECardDownload =
|
|
topUpSiPolicies['gmc_si_topup']['eCardDownload'];
|
|
|
|
setState(() {
|
|
topUpIsPremiumSummary = parsePremiumSummaryMode(topUpSiPolicies['gmc_si_topup']?['is_premium_summery']);
|
|
});
|
|
|
|
|
|
|
|
// if(topUpIsPremiumSummary == '1'){
|
|
// tabHide = '0';
|
|
// }
|
|
|
|
topUpDisclaimer =
|
|
await topUpSiPolicies['gmc_si_topup']['disclaimer'];
|
|
|
|
if (_isOpenForEnrollment(topUpOpenForEnrollment) && activeSiData == 1) {
|
|
if (topUpDisclaimer != null && topUpDisclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (topUpDisclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': topUpDisclaimer,
|
|
'checked': false,
|
|
'type': topUpTypeName
|
|
});
|
|
} else if (topUpDisclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
topUpDisclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': topUpTypeName
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
|
|
// allDisclaimer = allDisclaimer.toSet().toList();
|
|
// });
|
|
} else {
|
|
logDebug('No data found in the response');
|
|
}
|
|
} else {
|
|
// Handle other status messages if needed
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcOPD() async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGmcSiTopUpToApi(
|
|
enrollmentClient_id!,
|
|
enrollmentEmpCodeString!,
|
|
'GMC-OPD',
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
setState(() {
|
|
opdPolicies = response['data'];
|
|
});
|
|
if (opdPolicies.isNotEmpty) {
|
|
int _toInt(dynamic value) {
|
|
if (value is int) return value;
|
|
if (value is double) return value.toInt();
|
|
return int.tryParse(value?.toString() ?? '0') ?? 0;
|
|
}
|
|
|
|
final opdNode = opdPolicies['gmc_opd'];
|
|
opdClientPolicyId = opdNode['client_policy_id'];
|
|
opdSlabRates = opdNode['SlabRates'];
|
|
opdFloaterTextHeading = opdNode['floter_text_heading'];
|
|
opdPolicyName = opdNode['policy_name'];
|
|
opdPolicyType = opdNode['type'];
|
|
opdFamilyFloater = opdNode['policy_terms']['family_floater'];
|
|
opdMappedFamilyFloatersSi =
|
|
opdNode['family_floaters_of_only_si_array'];
|
|
opdECardDownload = opdNode['eCardDownload'];
|
|
opdOpenForEnrollment = _toInt(opdNode['OpenForEnrollment']);
|
|
opdTypeName = opdNode['type'];
|
|
opdSiValue = opdNode['family_floaters_of_only_si_value'];
|
|
logDebug(opdSiValue);
|
|
|
|
if (opdSiValue == 0) {
|
|
showHideOpdCard = 0;
|
|
} else {
|
|
showHideOpdCard = 1;
|
|
}
|
|
opdSiSelectedSI = opdSiValue != 0 ? opdSiValue.toString() : null;
|
|
|
|
// // OPD can have SI value 0 initially; still show card when policy exists.
|
|
// showHideOpdCard = (opdPolicyName != null ||
|
|
// opdPolicyType != null ||
|
|
// (opdMappedFamilyFloatersSi is List &&
|
|
// opdMappedFamilyFloatersSi.isNotEmpty))
|
|
// ? 1
|
|
// : 0;
|
|
|
|
setState(() {
|
|
opdSiPremiumValue =
|
|
_toInt(opdNode['family_floaters_of_only_si_premium_value']);
|
|
opdSiPremiumGst =
|
|
_toInt(opdNode['family_floaters_of_only_si_gst_value']);
|
|
opdSiTotalAmt = opdSiPremiumValue + opdSiPremiumGst;
|
|
opdIsPremiumSummary =
|
|
parsePremiumSummaryMode(opdNode?['is_premium_summery']);
|
|
});
|
|
|
|
opdDisclaimer = opdNode['disclaimer'];
|
|
|
|
if (_isOpenForEnrollment(opdOpenForEnrollment) &&
|
|
activeOPDSiData == 1) {
|
|
if (opdDisclaimer != null && opdDisclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (opdDisclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': opdDisclaimer,
|
|
'checked': false,
|
|
'type': opdTypeName
|
|
});
|
|
} else if (opdDisclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
opdDisclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': opdTypeName
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
} else {
|
|
logDebug('No data found in the response');
|
|
}
|
|
} else {
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcSiParentTopUp() async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGmcSiParentTopUpToApi(
|
|
enrollmentClient_id!,
|
|
enrollmentEmpCodeString!,
|
|
'GMC-SI-PARENT-TOPUP',
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
setState(() {
|
|
topUpSiParentPolicies = response['data'];
|
|
logDebug('topUpSiParentPolicies');
|
|
logDebug(topUpSiParentPolicies);
|
|
});
|
|
if (topUpSiParentPolicies.isNotEmpty) {
|
|
topUpParentClientPolicyId =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['client_policy_id'];
|
|
|
|
topUpParentSlabRates =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']['SlabRates'];
|
|
logDebug('topUpParentSlabRates');
|
|
logDebug(topUpParentSlabRates);
|
|
|
|
topUpParentPolicyName =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['policy_name'];
|
|
|
|
topUpParentPolicyType =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']['type'];
|
|
|
|
topUpParentFamilyFloater =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['policy_terms']['family_floater'];
|
|
logDebug('topUpParentFamilyFloater');
|
|
logDebug(topUpParentFamilyFloater);
|
|
|
|
topUpParentMappedFamilyFloatersSi =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['family_floaters_of_only_si_array'];
|
|
logDebug('topUpParentMappedFamilyFloatersSi');
|
|
logDebug(topUpParentMappedFamilyFloatersSi);
|
|
|
|
logDebug('topUpECardDownload');
|
|
topUpParentECardDownload =
|
|
topUpSiParentPolicies['gmc_si_parent_topup']['eCardDownload'];
|
|
|
|
setState(() {
|
|
topUpParentIsPremiumSummary = parsePremiumSummaryMode(topUpSiParentPolicies['gmc_si_parent_topup']?['is_premium_summery']);
|
|
logDebug(topUpParentECardDownload);
|
|
});
|
|
|
|
|
|
|
|
// if(topUpParentIsPremiumSummary == '1'){
|
|
// tabHide = '0';
|
|
// }
|
|
// String intOpenForEnrollment =
|
|
// topUpSiParentPolicies['gmc_si_parent_topup']
|
|
// ['OpenForEnrollment'];
|
|
// topUpParentOpenForEnrollment = int.parse(intOpenForEnrollment);
|
|
// logDebug(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;
|
|
}
|
|
|
|
topUpParentOpenForEnrollment =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['OpenForEnrollment'];
|
|
|
|
topUpParentDisclaimer =
|
|
await topUpSiParentPolicies['gmc_si_parent_topup']
|
|
['disclaimer'];
|
|
|
|
if (_isOpenForEnrollment(topUpParentOpenForEnrollment) &&
|
|
activeSiParentData == 1) {
|
|
if (topUpParentDisclaimer != null &&
|
|
topUpParentDisclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (topUpParentDisclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': topUpParentDisclaimer,
|
|
'checked': false,
|
|
'type': topUpParentTypeName
|
|
});
|
|
} else if (topUpParentDisclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
topUpParentDisclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': topUpParentTypeName
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
} else {
|
|
logDebug('No data found in the response');
|
|
}
|
|
} else {
|
|
// Handle other status messages if needed
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcDependentAddOns() async {
|
|
try {
|
|
if (enrollmentClient_id == null ||
|
|
enrollmentEmpCodeString == null ||
|
|
enrollmentEmpClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getGmcDependentAddOnsToApi(
|
|
enrollmentClient_id!,
|
|
enrollmentEmpCodeString!,
|
|
'GMC-DEPENDENT-ADDON',
|
|
enrollmentEmpClientBranchId!);
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
dynamic addOnsDependentPolicies = response['data'];
|
|
logDebug('addOnsDependentPolicies');
|
|
logDebug(addOnsDependentPolicies);
|
|
if (addOnsDependentPolicies.isNotEmpty) {
|
|
addOnsDependentClientPolicyId =
|
|
addOnsDependentPolicies['gmc_dependent_addon']
|
|
['client_policy_id'];
|
|
logDebug(addOnsDependentClientPolicyId);
|
|
|
|
addOnsDependentSumInsured = int.parse(
|
|
addOnsDependentPolicies['gmc_dependent_addon']
|
|
['family_floaters_of_dependent_and_si_value']
|
|
.toString());
|
|
logDebug('addOnsDependentSumInsured $addOnsDependentSumInsured');
|
|
|
|
var value = int.parse(addOnsDependentPolicies['gmc_dependent_addon']
|
|
['family_floaters_of_dependent_and_si_premium_value']
|
|
.toString());
|
|
logDebug(value);
|
|
|
|
final checkValue = addOnsDependentSumInsured + value;
|
|
logDebug('checkValue $checkValue');
|
|
if (checkValue == 0) {
|
|
showHideAddOnsCard = 0;
|
|
} else {
|
|
showHideAddOnsCard = 1;
|
|
}
|
|
|
|
// if (addOnsDependentSumInsured == 0) {
|
|
// showHideAddOnsCard = 0;
|
|
// } else {
|
|
// showHideAddOnsCard = 1;
|
|
// }
|
|
|
|
addOnsDependentPolicyName =
|
|
addOnsDependentPolicies['gmc_dependent_addon']['policy_name'];
|
|
logDebug(addOnsDependentPolicyName);
|
|
|
|
addOnsDependentPolicyType =
|
|
addOnsDependentPolicies['gmc_dependent_addon']['type'];
|
|
logDebug(addOnsDependentPolicyType);
|
|
|
|
addOnsDependentMappedFamilyFloatersArray =
|
|
await addOnsDependentPolicies['gmc_dependent_addon']
|
|
['family_floaters_of_dependent_and_si_array'];
|
|
logDebug('addOnsDependentMappedFamilyFloatersArray');
|
|
logDebug(addOnsDependentMappedFamilyFloatersArray);
|
|
|
|
addOnsFloaterTextHeading =
|
|
addOnsDependentPolicies['gmc_dependent_addon']
|
|
['floter_text_heading'];
|
|
|
|
addOnsDependentECardDownload =
|
|
addOnsDependentPolicies['gmc_dependent_addon']['eCardDownload'];
|
|
|
|
addOnsDependentDisclaimer =
|
|
await addOnsDependentPolicies['gmc_dependent_addon']
|
|
['disclaimer'];
|
|
logDebug(
|
|
'addOnsDependentOpenForEnrollment $addOnsDependentDisclaimer');
|
|
addOnsDependentOpenForEnrollment =
|
|
await addOnsDependentPolicies['gmc_dependent_addon']
|
|
['OpenForEnrollment'];
|
|
|
|
setState(() {
|
|
addOnsDependentIsPremiumSummary = parsePremiumSummaryMode(addOnsDependentPolicies['gmc_dependent_addon']?['is_premium_summery']);
|
|
});
|
|
|
|
|
|
|
|
// if(addOnsDependentIsPremiumSummary == '1'){
|
|
// tabHide = '0';
|
|
// }
|
|
logDebug(
|
|
'addOnsDependentOpenForEnrollment $addOnsDependentOpenForEnrollment');
|
|
logDebug('activeDependentData $activeDependentData');
|
|
if (_isOpenForEnrollment(addOnsDependentOpenForEnrollment) &&
|
|
activeDependentData == 1) {
|
|
logDebug('addOnsDependentOpenForEnrollment');
|
|
if (addOnsDependentDisclaimer != null &&
|
|
addOnsDependentDisclaimer.isNotEmpty) {
|
|
// Temporary list to hold new entries
|
|
List<Map<String, dynamic>> newEntries = [];
|
|
|
|
if (addOnsDependentDisclaimer is String) {
|
|
// Wrap string in a map with id and checked
|
|
newEntries.add({
|
|
'id': allDisclaimer.length + 1, // Unique ID based on length
|
|
'text': addOnsDependentDisclaimer,
|
|
'checked': false,
|
|
'type': addOnsDependentPolicyType
|
|
});
|
|
} else if (addOnsDependentDisclaimer is List) {
|
|
// Convert each string in the list to a map with id and checked
|
|
newEntries.addAll(
|
|
List<Map<String, dynamic>>.from(
|
|
addOnsDependentDisclaimer.map((text) => {
|
|
'id': allDisclaimer.length + newEntries.length + 1,
|
|
'text': text,
|
|
'checked': false,
|
|
'type': addOnsDependentPolicyType
|
|
}),
|
|
),
|
|
);
|
|
} else {
|
|
logDebug('Unexpected type for disclaimer');
|
|
}
|
|
|
|
// Add new entries to the main list, ensuring no duplicate texts
|
|
newEntries.forEach((entry) {
|
|
if (!allDisclaimer
|
|
.any((item) => item['text'] == entry['text'])) {
|
|
allDisclaimer.add(entry);
|
|
}
|
|
});
|
|
|
|
// Sort disclaimers after adding
|
|
_sortDisclaimerByTypeOrder();
|
|
}
|
|
}
|
|
} else {
|
|
logDebug('No data found in the response');
|
|
}
|
|
} else {
|
|
// Handle other status messages if needed
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> sendAddOnAPI() async {
|
|
setState(() {
|
|
isLoading = true;
|
|
});
|
|
if (addOnsDependentMappedFamilyFloatersArray != null) {
|
|
dynamic getDependentTrueObjects = addOnsDependentMappedFamilyFloatersArray
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
logDebug('getDependentTrueObjects : $getDependentTrueObjects');
|
|
|
|
if (getDependentTrueObjects.isNotEmpty) {
|
|
iAgreeForAddOn.add(int.parse(addOnsDependentClientPolicyId));
|
|
}
|
|
}
|
|
|
|
if (topUpMappedFamilyFloatersSiArray != null) {
|
|
dynamic getSiTrueObjects = topUpMappedFamilyFloatersSiArray
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
logDebug('getSiTrueObjects : $getSiTrueObjects');
|
|
|
|
if (getSiTrueObjects.isNotEmpty) {
|
|
iAgreeForAddOn.add(int.parse(topUpClientPolicyId));
|
|
}
|
|
}
|
|
|
|
if (opdMappedFamilyFloatersSi != null) {
|
|
dynamic getSiTrueObjects = opdMappedFamilyFloatersSi
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
logDebug('getSiTrueObjects : $getSiTrueObjects');
|
|
|
|
if (getSiTrueObjects.isNotEmpty) {
|
|
iAgreeForAddOn.add(int.parse(opdClientPolicyId));
|
|
}
|
|
}
|
|
|
|
if (topUpParentMappedFamilyFloatersSi != null) {
|
|
dynamic getSiTrueObjects = topUpParentMappedFamilyFloatersSi
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
logDebug('getSiTrueObjects $getSiTrueObjects');
|
|
|
|
if (getSiTrueObjects.isNotEmpty) {
|
|
iAgreeForAddOn.add(int.parse(topUpParentClientPolicyId));
|
|
}
|
|
}
|
|
|
|
logDebug('gpaPolicies');
|
|
logDebug(gpaPolicies);
|
|
logDebug('gmcPolicies');
|
|
logDebug(gmcPolicies);
|
|
logDebug('iAgreeForAddOn $iAgreeForAddOn');
|
|
|
|
if (gpaDataIsEmpty != 0) {
|
|
logDebug('gpaDataIsEmpty : $gpaDataIsEmpty');
|
|
for (var item in gpaPolicies) {
|
|
logDebug('ClientPolicyId');
|
|
// Extract ClientPolicyId value from each object
|
|
String clientPolicyId = item['ClientPolicyId'];
|
|
// Convert to integer and add to iAgreeForAddOn list
|
|
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
|
}
|
|
}
|
|
logDebug('iAgreeForAddOn $iAgreeForAddOn');
|
|
|
|
if (gmcDataIsEmpty != 0) {
|
|
for (var item in gmcPolicies) {
|
|
logDebug('ClientPolicyId');
|
|
// Extract ClientPolicyId value from each object
|
|
String clientPolicyId = item['ClientPolicyId'];
|
|
// Convert to integer and add to iAgreeForAddOn list
|
|
iAgreeForAddOn.add(int.parse(clientPolicyId));
|
|
}
|
|
}
|
|
logDebug('iAgreeForAddOn');
|
|
iAgreeForAddOn = iAgreeForAddOn.toSet().toList();
|
|
logDebug(iAgreeForAddOn); // Output: [90, 92, 88, 89]
|
|
|
|
Map<String, dynamic> apiParams = {
|
|
'emp_code': enrollmentEmpCodeString,
|
|
'client_policy_id': iAgreeForAddOn,
|
|
'client_id': enrollmentClient_id,
|
|
};
|
|
logDebug(apiParams);
|
|
|
|
// Convert the list of objects to JSON
|
|
String formDataJson = jsonEncode(apiParams);
|
|
|
|
try {
|
|
final response = await apiService.sendAddOnToAPI(apiParams);
|
|
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
isLoading = false;
|
|
isChecked = false;
|
|
topUpSiIsChecked = false;
|
|
topUpParentIsChecked = false;
|
|
addOnsDependentIsChecked = false;
|
|
});
|
|
logDebug('response.statusCode == 200');
|
|
ToastHelper.showSuccessToast(context, 'Saved Successfully...');
|
|
_showSuccessDialog();
|
|
} else {
|
|
setState(() {
|
|
isLoading = false;
|
|
});
|
|
// Handle other status codes
|
|
ToastHelper.showErrorToast(context, 'Failed to Save');
|
|
_showErrorDialog();
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
setState(() {
|
|
isLoading = false;
|
|
});
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
void _showSuccessDialog() {
|
|
setState(() {
|
|
isEnrollCompletedStatus = true;
|
|
});
|
|
|
|
// Wait 3 seconds, then navigate to home page
|
|
Future.delayed(const Duration(seconds: 3), () {
|
|
if (isTokenAvailable) {
|
|
context.go('/home');
|
|
// Navigator.pushNamed(context, 'home');
|
|
} else {
|
|
context.go('/empDetails');
|
|
// Navigator.pushNamed(context, 'empDetails');
|
|
}
|
|
});
|
|
|
|
// showDialog(
|
|
// context: context,
|
|
// builder: (BuildContext context) {
|
|
// return AlertDialog(
|
|
// backgroundColor: Colors.white,
|
|
// title: Text(
|
|
// 'Success',
|
|
// style: GoogleFonts.poppins(
|
|
// color: Colors.green,
|
|
// ),
|
|
// ),
|
|
// content: Text('Enrollment Completed'),
|
|
// actions: <Widget>[
|
|
// TextButton(
|
|
// child: Text(
|
|
// 'OK',
|
|
// style: GoogleFonts.poppins(
|
|
// color: Color(0xFFE26728),
|
|
// ),
|
|
// ),
|
|
// onPressed: () {
|
|
// Navigator.of(context).pop();
|
|
// setState(() {
|
|
// isEnrollCompletedStatus = true;
|
|
// });
|
|
//
|
|
// // Navigator.popAndPushNamed(context, 'home');
|
|
// },
|
|
// ),
|
|
// ],
|
|
// );
|
|
// },
|
|
// );
|
|
}
|
|
|
|
void _showErrorDialog() {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text(
|
|
'Error',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.red,
|
|
),
|
|
),
|
|
content: Text('Unable to process. Please try again later. Enrollemnt not completed'),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text(
|
|
'OK',
|
|
style: GoogleFonts.poppins(
|
|
color: Color(0xFFE26728),
|
|
),
|
|
),
|
|
onPressed: () {
|
|
context.pop();
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// Function to open URL in the default browser
|
|
Future<void> _launchURL(String url) async {
|
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
|
logDebug('_launchURL $uri');
|
|
if (uri != null) {
|
|
logDebug('If $uri');
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
} else {
|
|
logDebug('else $uri');
|
|
throw 'Could not launch $url';
|
|
}
|
|
}
|
|
|
|
bool isSubmitEnabled() {
|
|
// // Convert to integers and handle null values by defaulting to 0
|
|
// bool enrollmentConditionsMet =
|
|
// (int.tryParse(topUpOpenForEnrollment ?? '0') != 0) &&
|
|
// (int.tryParse(topUpParentOpenForEnrollment ?? '0') != 0) &&
|
|
// (int.tryParse(addOnsDependentOpenForEnrollment ?? '0') != 0);
|
|
//
|
|
// logDebug('enrollmentConditionsMet: $enrollmentConditionsMet');
|
|
// logDebug('gmcEnrollmentStatus: $gmcEnrollmentStatus');
|
|
|
|
// return isChecked &&
|
|
// enrollmentConditionsMet &&
|
|
// gmcEnrollmentStatus &&
|
|
// (activeSiData == 1 ? topUpSiIsChecked : true) &&
|
|
// (activeSiParentData == 1 ? topUpParentIsChecked : true) &&
|
|
// (activeDependentData == 1 ? addOnsDependentIsChecked : true);
|
|
disclaimeStatus = allDisclaimer.every((item) => item['checked'] == true);
|
|
|
|
// Combine the `disclaimeStatus` and `isChecked` conditions
|
|
return isChecked && disclaimeStatus;
|
|
}
|
|
|
|
bool isEnrollmentOpen(List<dynamic>? policyList) {
|
|
// Check if the policy list is null or empty
|
|
if (policyList == null || policyList.isEmpty) {
|
|
return false; // Return false if there are no policies
|
|
}
|
|
|
|
// Check each policy in the list
|
|
for (var policy in policyList) {
|
|
// Default to "0" if OpenForEnrollment is null
|
|
String openForEnrollment = policy["OpenForEnrollment"] ?? "0";
|
|
|
|
// If any policy's OpenForEnrollment is "0", return false
|
|
if (openForEnrollment == "0") {
|
|
return false;
|
|
}
|
|
}
|
|
// If none of the policies have OpenForEnrollment as "0", return true
|
|
return true;
|
|
}
|
|
|
|
double allTotalSum() {
|
|
double total = 0.0; // Initialize to avoid unwanted accumulation
|
|
|
|
if (topUpSiTotalAmt != null &&
|
|
shouldShowPremiumSummary(topUpIsPremiumSummary)) {
|
|
total += topUpSiTotalAmt!;
|
|
}
|
|
if (opdSiTotalAmt != null &&
|
|
shouldShowPremiumSummary(opdIsPremiumSummary)) {
|
|
total += opdSiTotalAmt!;
|
|
}
|
|
if (topUpParentSiTotalAmt != null &&
|
|
shouldShowPremiumSummary(topUpParentIsPremiumSummary)) {
|
|
total += topUpParentSiTotalAmt!;
|
|
}
|
|
if (addOnsDependentTotalAmt != null &&
|
|
shouldShowPremiumSummary(addOnsDependentIsPremiumSummary)) {
|
|
total += addOnsDependentTotalAmt!;
|
|
}
|
|
if (gpaTotalAmt != null) total += gpaTotalAmt!;
|
|
if (gmcTotalAmt != null) total += gmcTotalAmt!;
|
|
|
|
return total;
|
|
}
|
|
|
|
void _showExitConfirmation(BuildContext context) {
|
|
double myheight = MediaQuery.of(context).size.height;
|
|
showDialog(
|
|
context: context,
|
|
barrierDismissible: false, // User must tap a button to dismiss dialog
|
|
builder: (dialogContext) => AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(5.0), // Rounded corners
|
|
),
|
|
backgroundColor: Colors.white,
|
|
contentPadding: EdgeInsets.zero,
|
|
title: Text(
|
|
'Log Out Confirmation',
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
content: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Text(
|
|
'Are you sure you want to log out?',
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 18,
|
|
color: Color(0xFF898C81),
|
|
),
|
|
),
|
|
),
|
|
actions: [
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceEvenly, // Space buttons evenly
|
|
children: [
|
|
SizedBox(
|
|
width:
|
|
MediaQuery.of(context).size.width * 0.3, // Set button width
|
|
child: TextButton(
|
|
onPressed: () => Navigator.pop(dialogContext),
|
|
style: TextButton.styleFrom(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
),
|
|
side: BorderSide(
|
|
color: Color(0xFFE26728), // Border color
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Text(
|
|
'Cancel',
|
|
style: GoogleFonts.poppins(
|
|
color: Color(0xFFE26728),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width:
|
|
MediaQuery.of(context).size.width * 0.3, // Set button width
|
|
child: TextButton(
|
|
onPressed: () => TokenService().logout(context),
|
|
style: TextButton.styleFrom(
|
|
backgroundColor: Color(0xFFE26728), // Background color
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
),
|
|
),
|
|
child: FittedBox(
|
|
fit: BoxFit
|
|
.scaleDown, // Prevents wrapping while adjusting text size
|
|
child: Text(
|
|
'Log Out',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white,
|
|
fontSize: 16,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10), // Add spacing below buttons
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
|
return PopScope(
|
|
canPop: false,
|
|
onPopInvokedWithResult: (didPop, result) {
|
|
if (didPop) return;
|
|
context.go('/addOnsDetails');
|
|
},
|
|
child: Scaffold(
|
|
appBar: CustomAppBar(),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
color: Color(0xFFEFF3F6),
|
|
child: Column(
|
|
children: [
|
|
Center(
|
|
child: Text('No Data Available',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)));
|
|
} else {
|
|
return isEnrollCompletedStatus == true
|
|
? PopScope(
|
|
canPop: false,
|
|
onPopInvokedWithResult: (didPop, result) {
|
|
if (didPop) return;
|
|
_showExitConfirmation(context);
|
|
},
|
|
child: Scaffold(
|
|
backgroundColor: const Color(
|
|
0xFFF2F6FA), // Matches your light gray background
|
|
appBar: CustomAppBar(),
|
|
body: Center(
|
|
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: Colors.white,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min, // Shrink wrap to content
|
|
children: [
|
|
SizedBox(height: 20),
|
|
Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Image.network(
|
|
clientLogo ?? '', // Nhance logo
|
|
height: 40,
|
|
errorBuilder: (BuildContext context, Object error,
|
|
StackTrace? stackTrace) {
|
|
return Image.asset(
|
|
'assets/Solid_gray.png',
|
|
height: 40,
|
|
fit: BoxFit.contain,
|
|
);
|
|
},
|
|
),
|
|
// Image.network(
|
|
// 'https://i.imgur.com/qOihOvk.png', // Prodapt logo
|
|
// height: 28,
|
|
// ),
|
|
],
|
|
),
|
|
SizedBox(height: 32),
|
|
Icon(Icons.check_circle,
|
|
size: 70, color: Color(0xFF1A73E8)),
|
|
SizedBox(height: 24),
|
|
Text(
|
|
'Congratulations!',
|
|
style: TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFF2D2A4A),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
Text(
|
|
'You have completed your enrolment. You can now close this Page',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Color(0xFF2D2A4A),
|
|
),
|
|
),
|
|
// const SizedBox(height: 12),
|
|
Container(
|
|
width: 180,
|
|
height: 150,
|
|
alignment: Alignment.centerRight,
|
|
child: ElevatedButton(
|
|
onPressed: () => {
|
|
if (isTokenAvailable)
|
|
{
|
|
context.go('/home')
|
|
// Navigator.pushNamed(context, 'home')
|
|
}
|
|
else
|
|
{
|
|
context.go('/empDetails')
|
|
// Navigator.pushNamed(context, 'empDetails')
|
|
}
|
|
},
|
|
child: Text(
|
|
'Return to Home',
|
|
style: GoogleFonts.poppins(color: Colors.white),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFFE26728),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// const SizedBox(height: 20),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
floatingActionButtonLocation: Responsive.isDesktop(context)
|
|
? null
|
|
: isTokenAvailable
|
|
? FloatingActionButtonLocation.miniEndFloat
|
|
: null,
|
|
bottomNavigationBar: Responsive.isDesktop(context)
|
|
? null
|
|
: CustomBottomNavigationBar(
|
|
onTabChanged: (index) {
|
|
// Add your navigation logic here
|
|
// For example:
|
|
if (index == 0) {
|
|
context.go('/home');
|
|
// Navigator.pushNamed(context, 'home');
|
|
} else if (index == 1) {
|
|
context.go('/claims');
|
|
// Navigator.pushNamed(context, 'claims');
|
|
} else if (index == 2) {
|
|
context.go('/profile');
|
|
// Navigator.pushNamed(context, 'profile');
|
|
} else if (index == 3) {
|
|
context.go('/help');
|
|
// Navigator.pushNamed(context, 'help');
|
|
} else if (index == 4) {
|
|
context.go('/wellness');
|
|
// Navigator.pushNamed(context, 'wellness');
|
|
}
|
|
},
|
|
icons: [
|
|
Icons.home_outlined,
|
|
Icons.sticky_note_2_outlined,
|
|
Icons.person_outline_outlined,
|
|
Icons.headset_mic_outlined,
|
|
Icons.health_and_safety_outlined,
|
|
],
|
|
labels: [
|
|
"Home",
|
|
"Claims",
|
|
"Profile",
|
|
"Help",
|
|
"wellness",
|
|
],
|
|
initialIndex:
|
|
0, // Initial index of the bottom navigation bar
|
|
),
|
|
))
|
|
: PopScope(
|
|
canPop: false,
|
|
onPopInvokedWithResult: (didPop, result) {
|
|
if (didPop) return;
|
|
context.go('/addOnsDetails');
|
|
},
|
|
child: Scaffold(
|
|
backgroundColor: Colors.white,
|
|
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,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 80,
|
|
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: 200,
|
|
height: 200,
|
|
alignment: Alignment.centerLeft,
|
|
child: Image.network(
|
|
clientLogo ?? '',
|
|
// width: 200, // Set the width here
|
|
// height: 200, // 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),
|
|
if (gpahasPremiumSummary ||
|
|
gmchasPremiumSummary ||
|
|
shouldShowPremiumSummary(topUpIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(topUpParentIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(addOnsDependentIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(opdIsPremiumSummary))...[
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(
|
|
10), // Add padding to the container
|
|
child: Column(children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 12,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Review',
|
|
textAlign: TextAlign.left,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 18,
|
|
color:
|
|
Color(0xFF181818),
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Total Payable',
|
|
textAlign: TextAlign.left,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 16,
|
|
color:
|
|
Color(0xFF181818),
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'₹${formatAmount(allTotalSum())}/Year',
|
|
textAlign: TextAlign.left,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 22
|
|
: 18,
|
|
color:
|
|
Color(0xFFE26728),
|
|
fontWeight:
|
|
FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
])),
|
|
),
|
|
SizedBox(height: 16),
|
|
],
|
|
|
|
if (gpaPolicies != null && gpaPolicies.length > 0)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...generateGpaCards(gpaPolicies),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
if (gmcPolicies != null && gmcPolicies.length > 0)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...generateGmcCards(gmcPolicies),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
if (showHideAddOnsCard == 1)
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
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
|
|
: 7,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign:
|
|
TextAlign.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 14,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
Responsive.isDesktop(
|
|
context)
|
|
? addOnsDependentPolicyName
|
|
: addOnsDependentPolicyType,
|
|
textAlign:
|
|
TextAlign
|
|
.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 16,
|
|
fontWeight:
|
|
FontWeight
|
|
.w600,
|
|
),
|
|
),
|
|
if (addOnsDependentECardDownload !=
|
|
null)
|
|
GestureDetector(
|
|
onTap:
|
|
() async {
|
|
_launchURL(
|
|
addOnsDependentECardDownload);
|
|
},
|
|
child:
|
|
MouseRegion(
|
|
cursor:
|
|
SystemMouseCursors
|
|
.click,
|
|
child: Icon(
|
|
Icons
|
|
.file_download,
|
|
color: Color(
|
|
0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(
|
|
context)
|
|
? 3
|
|
: 5,
|
|
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(
|
|
'₹ ${formatNullableAmount(addOnsDependentSumInsured)}',
|
|
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<Widget>((item) {
|
|
Map<String, dynamic> data = item['data'];
|
|
final dobDate = 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']} - ${dobDate}',
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(
|
|
context)
|
|
? 18
|
|
: 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(height: showHideAddOnsCard == 1 ? 16 : 0),
|
|
if (showHideTopUpCard == 1)
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
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
|
|
: 7,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign:
|
|
TextAlign.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
Responsive.isDesktop(
|
|
context)
|
|
? topUpPolicyName
|
|
: topUpPolicyType,
|
|
textAlign:
|
|
TextAlign
|
|
.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight
|
|
.w600,
|
|
),
|
|
),
|
|
if (topUpECardDownload !=
|
|
null)
|
|
GestureDetector(
|
|
onTap:
|
|
() async {
|
|
_launchURL(
|
|
topUpECardDownload);
|
|
},
|
|
child:
|
|
MouseRegion(
|
|
cursor:
|
|
SystemMouseCursors
|
|
.click,
|
|
child: Icon(
|
|
Icons
|
|
.file_download,
|
|
color: Color(
|
|
0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(
|
|
context)
|
|
? 3
|
|
: 5,
|
|
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
|
|
: 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${formatNullableAmount(topUpSumInsured)}',
|
|
textAlign:
|
|
TextAlign.right,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 15,
|
|
right: 15)
|
|
: EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 5,
|
|
right: 5),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children:
|
|
topUpMappedFamilyFloatersSiArray
|
|
.where((item) =>
|
|
item['is_value_exist'] ==
|
|
true)
|
|
.map<Widget>((item) {
|
|
Map<String, dynamic> data =
|
|
item['data'];
|
|
String formattedDate = 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
|
|
: 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(height: showHideTopUpCard == 1 ? 16 : 0),
|
|
if (showHideOpdCard == 1)
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFFFFF1DD),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: 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
|
|
: 7,
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text(
|
|
Responsive.isDesktop(
|
|
context)
|
|
? opdPolicyName
|
|
: opdPolicyType,
|
|
textAlign: TextAlign.left,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
if (opdECardDownload != null)
|
|
GestureDetector(
|
|
onTap: () async {
|
|
_launchURL(
|
|
opdECardDownload);
|
|
},
|
|
child: MouseRegion(
|
|
cursor:
|
|
SystemMouseCursors
|
|
.click,
|
|
child: Icon(
|
|
Icons.file_download,
|
|
color: Color(
|
|
0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(
|
|
context)
|
|
? 3
|
|
: 5,
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
opdFloaterTextHeading ?? '',
|
|
textAlign: TextAlign.right,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${formatNullableAmount(opdSiValue)}',
|
|
textAlign: TextAlign.right,
|
|
style:
|
|
GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 15,
|
|
right: 15)
|
|
: EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 5,
|
|
right: 5),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children:
|
|
(opdMappedFamilyFloatersSi ??
|
|
[])
|
|
.where((item) =>
|
|
item['is_value_exist'] ==
|
|
true)
|
|
.map<Widget>((item) {
|
|
Map<String, dynamic> data =
|
|
item['data'];
|
|
String formattedDate =
|
|
data['dob'] ?? '';
|
|
return Row(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Icon(Icons.arrow_right,
|
|
color:
|
|
Color(0xFFE26728)),
|
|
SizedBox(
|
|
width: Responsive.isDesktop(
|
|
context)
|
|
? 10
|
|
: 5),
|
|
Expanded(
|
|
child: Text(
|
|
'${data['name']} ~ ${data['relationship']} ~ DOB : $formattedDate',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(height: showHideOpdCard == 1 ? 16 : 0),
|
|
if (showHideTopUpParentCard == 1)
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
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
|
|
: 7,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign:
|
|
TextAlign.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Container(
|
|
// padding: EdgeInsets.all(8.0),
|
|
child: Row(
|
|
children: [
|
|
Flexible(
|
|
child: Text(
|
|
Responsive.isDesktop(
|
|
context)
|
|
? topUpParentPolicyName
|
|
: topUpParentPolicyType,
|
|
textAlign:
|
|
TextAlign
|
|
.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight
|
|
.w600,
|
|
),
|
|
softWrap:
|
|
true,
|
|
overflow:
|
|
TextOverflow
|
|
.visible,
|
|
),
|
|
),
|
|
if (topUpParentECardDownload !=
|
|
null)
|
|
GestureDetector(
|
|
onTap:
|
|
() async {
|
|
_launchURL(
|
|
topUpParentECardDownload);
|
|
},
|
|
child:
|
|
MouseRegion(
|
|
cursor:
|
|
SystemMouseCursors
|
|
.click,
|
|
child: Icon(
|
|
Icons
|
|
.file_download,
|
|
color: Color(
|
|
0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(
|
|
context)
|
|
? 3
|
|
: 5,
|
|
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
|
|
: 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${formatNullableAmount(topUpParentSiValue)}',
|
|
textAlign:
|
|
TextAlign.right,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 14,
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 15,
|
|
right: 15)
|
|
: EdgeInsets.only(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 5,
|
|
right: 5),
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children:
|
|
topUpParentMappedFamilyFloatersSi
|
|
.where((item) =>
|
|
item['is_value_exist'] ==
|
|
true)
|
|
.map<Widget>((item) {
|
|
Map<String, dynamic> data =
|
|
item['data'];
|
|
String formattedDate = 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
|
|
: 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(
|
|
height: showHideTopUpParentCard == 1 ? 16 : 0),
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
if (gpahasPremiumSummary ||
|
|
gmchasPremiumSummary ||
|
|
shouldShowPremiumSummary(topUpIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(topUpParentIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(addOnsDependentIsPremiumSummary) ||
|
|
shouldShowPremiumSummary(opdIsPremiumSummary))...[
|
|
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(
|
|
'Premium Summary',
|
|
textAlign:
|
|
TextAlign.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 16,
|
|
color: Color(
|
|
0xFF181818),
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
child: Row(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 12,
|
|
child: Container(
|
|
alignment: Alignment
|
|
.centerLeft, // Adjust padding as needed
|
|
child: Builder(
|
|
builder: (context) {
|
|
final bool includeBreakdownColumns =
|
|
hasAnyFullPremiumBreakdown();
|
|
return Table(
|
|
columnWidths: includeBreakdownColumns
|
|
? {
|
|
0: FlexColumnWidth(2),
|
|
1: FlexColumnWidth(2),
|
|
2: FlexColumnWidth(2),
|
|
3: FlexColumnWidth(2),
|
|
}
|
|
: {
|
|
0: FlexColumnWidth(3),
|
|
1: FlexColumnWidth(1),
|
|
},
|
|
children: [
|
|
TableRow(
|
|
children: [
|
|
_premiumSummaryHeaderCell(
|
|
context, 'Policy '),
|
|
if (includeBreakdownColumns) ...[
|
|
_premiumSummaryHeaderCell(
|
|
context,
|
|
'Additional Premium'),
|
|
_premiumSummaryHeaderCell(
|
|
context, 'GST'),
|
|
],
|
|
_premiumSummaryHeaderCell(
|
|
context,
|
|
'Total',
|
|
textAlign: includeBreakdownColumns
|
|
? TextAlign.start
|
|
: TextAlign.end,
|
|
),
|
|
],
|
|
),
|
|
if (gpaPolicies != null &&
|
|
gpaPolicies.length > 0)
|
|
...gpaBuildPolicyRows(
|
|
gpaPolicies,
|
|
context,
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
),
|
|
if (gmcPolicies != null &&
|
|
gmcPolicies.length > 0)
|
|
...gmcBuildPolicyRows(
|
|
gmcPolicies,
|
|
context,
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
),
|
|
if (activeSiData == 1 &&
|
|
shouldShowPremiumSummary(
|
|
topUpIsPremiumSummary))
|
|
TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: Responsive.isDesktop(context)
|
|
? (topUpPolicyName ??
|
|
'Default Top Up Name')
|
|
: 'GMC - Top Up',
|
|
premiumValue:
|
|
'₹$topUpSiPremiumValue/Year',
|
|
gstValue:
|
|
'₹$topUpSiPremiumGst/-',
|
|
totalValue:
|
|
'₹$topUpSiTotalAmt/Year',
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
showBreakdownValues:
|
|
shouldShowFullPremiumBreakdown(
|
|
topUpIsPremiumSummary),
|
|
),
|
|
),
|
|
if (activeOPDSiData == 1 &&
|
|
shouldShowPremiumSummary(
|
|
opdIsPremiumSummary))
|
|
TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: Responsive.isDesktop(context)
|
|
? (opdPolicyName ??
|
|
'Default OPD Name')
|
|
: 'GMC - OPD',
|
|
premiumValue:
|
|
'₹$opdSiPremiumValue/Year',
|
|
gstValue:
|
|
'₹$opdSiPremiumGst/-',
|
|
totalValue:
|
|
'₹$opdSiTotalAmt/Year',
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
showBreakdownValues:
|
|
shouldShowFullPremiumBreakdown(
|
|
opdIsPremiumSummary),
|
|
),
|
|
),
|
|
if (activeSiParentData == 1 &&
|
|
shouldShowPremiumSummary(
|
|
topUpParentIsPremiumSummary))
|
|
TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: Responsive.isDesktop(context)
|
|
? (topUpParentPolicyName ??
|
|
'Default Parent Top Up Name')
|
|
: 'GMC - Parents Top Up',
|
|
premiumValue:
|
|
'₹$topUpParentSiPremiumValue/Year',
|
|
gstValue:
|
|
'₹$topUpParentSiPremiumGst/-',
|
|
totalValue:
|
|
'₹$topUpParentSiTotalAmt/Year',
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
showBreakdownValues:
|
|
shouldShowFullPremiumBreakdown(
|
|
topUpParentIsPremiumSummary),
|
|
),
|
|
),
|
|
if (activeDependentData == 1 &&
|
|
shouldShowPremiumSummary(
|
|
addOnsDependentIsPremiumSummary))
|
|
TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: Responsive.isDesktop(context)
|
|
? (addOnsDependentPolicyName ??
|
|
'Default Add Dependent Up Name')
|
|
: 'GMC - Dependent',
|
|
premiumValue:
|
|
'₹$addOnDependentPremiumValue/Year',
|
|
gstValue:
|
|
'₹$addOnsDependentPremiumGst/-',
|
|
totalValue:
|
|
'₹$addOnsDependentTotalAmt/Year',
|
|
includeBreakdownColumns:
|
|
includeBreakdownColumns,
|
|
showBreakdownValues:
|
|
shouldShowFullPremiumBreakdown(
|
|
addOnsDependentIsPremiumSummary),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
Container(
|
|
child: Row(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.start,
|
|
children: [
|
|
Text(
|
|
'Total Payable',
|
|
textAlign:
|
|
TextAlign.left,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 20
|
|
: 16,
|
|
color: Color(
|
|
0xFF181818),
|
|
fontWeight:
|
|
FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
alignment:
|
|
Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.end,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.end,
|
|
children: [
|
|
Text(
|
|
'₹${formatAmount(allTotalSum())}/Year',
|
|
textAlign:
|
|
TextAlign.right,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 16,
|
|
color: Color(
|
|
0xFFE26728),
|
|
fontWeight:
|
|
FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
)))
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
],
|
|
|
|
|
|
|
|
Container(
|
|
alignment: Alignment.topLeft,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment
|
|
.start, // Aligns top
|
|
children: [
|
|
Checkbox(
|
|
value: isChecked,
|
|
onChanged: (bool? value) {
|
|
setState(() {
|
|
isChecked = value!;
|
|
});
|
|
},
|
|
activeColor:
|
|
const Color(0xFFE26728),
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
'I declare that the information I have provided is true and accurate to the best of my knowledge',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(
|
|
context)
|
|
? 18
|
|
: 15,
|
|
color: const Color(0xFF292929),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: Responsive.isDesktop(context)
|
|
? 15
|
|
: 10),
|
|
Container(
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: allDisclaimer.isEmpty
|
|
? [] // If allDisclaimer is empty, show nothing
|
|
: allDisclaimer
|
|
.map<Widget>((entry) {
|
|
int id = entry[
|
|
'id']; // ID of disclaimer
|
|
String disclaimer = entry[
|
|
'text']; // Disclaimer text
|
|
bool isChecked = entry[
|
|
'checked']; // Checked state
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets
|
|
.only(
|
|
bottom:
|
|
12.0), // spacing between disclaimers
|
|
child: Row(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment
|
|
.start, // Align top
|
|
children: [
|
|
Checkbox(
|
|
value:
|
|
isChecked, // Bind to the checked value
|
|
onChanged:
|
|
(bool? value) {
|
|
setState(() {
|
|
// Update the checked status
|
|
allDisclaimer
|
|
.firstWhere(
|
|
(item) =>
|
|
item['id'] ==
|
|
id,
|
|
)['checked'] =
|
|
value!;
|
|
logDebug(
|
|
allDisclaimer);
|
|
});
|
|
},
|
|
activeColor: const Color(
|
|
0xFFE26728), // Custom color
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
disclaimer,
|
|
style: GoogleFonts
|
|
.poppins(
|
|
fontSize: Responsive
|
|
.isDesktop(
|
|
context)
|
|
? 18
|
|
: 15,
|
|
color: const Color(
|
|
0xFF292929),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
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: () async {
|
|
// Remove siData, siParentData, and dependentData from local storage
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
prefs.remove('siData');
|
|
prefs.remove('siParentData');
|
|
prefs.remove('dependentData');
|
|
prefs.remove('opdData');
|
|
context.go('/addOnsDetails');
|
|
// Navigator.pushNamed(
|
|
// context, 'addOnsDetails');
|
|
},
|
|
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: isSubmitEnabled()
|
|
? sendAddOnAPI
|
|
: null,
|
|
child: Text(
|
|
'Submit',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white),
|
|
),
|
|
style:
|
|
ElevatedButton.styleFrom(
|
|
backgroundColor:
|
|
Color(0xFFE26728),
|
|
shape:
|
|
RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(
|
|
5),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(height: 30)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (isLoading)
|
|
Container(
|
|
color: Color(0x98FFFCE5), // 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
|
|
),
|
|
),
|
|
if (Responsive.isDesktop(context) ||
|
|
(!Responsive.isDesktop(context) && !isTokenAvailable))
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Container(
|
|
width: double.infinity, // Make the footer full width
|
|
child: CustomFooter(),
|
|
),
|
|
),
|
|
]),
|
|
// floatingActionButton: Responsive.isDesktop(context)
|
|
// ? null
|
|
// : isTokenAvailable
|
|
// ? FloatingActionButton(
|
|
// onPressed: () => Navigator.push(
|
|
// context,
|
|
// MaterialPageRoute(builder: (context) => chatbot()),
|
|
// ),
|
|
// child: Icon(Icons.chat),
|
|
// )
|
|
// : null,
|
|
floatingActionButtonLocation: Responsive.isDesktop(context)
|
|
? null
|
|
: isTokenAvailable
|
|
? FloatingActionButtonLocation.miniEndFloat
|
|
: null,
|
|
bottomNavigationBar: Responsive.isDesktop(context)
|
|
? null
|
|
: isTokenAvailable
|
|
? CustomBottomNavigationBar(
|
|
onTabChanged: (index) {
|
|
// Add your navigation logic here
|
|
// repositionBotman();
|
|
if (index == 0) {
|
|
context.push('/home');
|
|
} else if (index == 1) {
|
|
context.push('/claims');
|
|
} else if (index == 2) {
|
|
context.push('/faqs');
|
|
} else if (index == 3) {
|
|
context.push('/profile');
|
|
} else if (index == 4) {
|
|
context.push('/help');
|
|
}
|
|
// else if (index == 4) {
|
|
// // context.push('/wellness');
|
|
// // Wellness tab clicked → show popup
|
|
// if(!isRetailLoggedIn)
|
|
// PopupHelper.showRedirectPopup(
|
|
// context: context,
|
|
// apiService: apiService,
|
|
// empPrimaryId: session.empPrimaryId,
|
|
// );
|
|
// }
|
|
},
|
|
icons: [
|
|
Icons.home_outlined,
|
|
Icons.sticky_note_2_outlined,
|
|
Icons.question_answer_outlined,
|
|
Icons.person_outline_outlined,
|
|
Icons.headset_mic_outlined,
|
|
],
|
|
labels: ["Home", "Claims", "FAQs", "Profile","Help"],
|
|
initialIndex: 0, // Initial index of the bottom navigation bar
|
|
)
|
|
: null,
|
|
));
|
|
}
|
|
}
|
|
|
|
double toDoubleSafe(dynamic value) {
|
|
if (value == null) return 0.0;
|
|
if (value is num) return value.toDouble();
|
|
if (value is String) return double.tryParse(value) ?? 0.0;
|
|
return 0.0;
|
|
}
|
|
|
|
|
|
List<Widget> generateGpaCards(List<dynamic> data) {
|
|
List<Widget> cards = [];
|
|
|
|
for (var item in data) {
|
|
logDebug('item');
|
|
logDebug(item);
|
|
|
|
String? gpaPolicyName = item['Policy_Name'];
|
|
String? gpaPolicyType = item['type'];
|
|
String? gpaECardDownload = item['eCardDownload'];
|
|
|
|
double gpaGstValue = toDoubleSafe(item['si_gst_value']);
|
|
double gpaSiPremiumValue = toDoubleSafe(item['si_premium_value']);
|
|
|
|
double gpaTotalableValue = gpaSiPremiumValue + gpaGstValue;
|
|
|
|
bool isValueValid = (gpaSiPremiumValue != 0 && gpaGstValue != 0);
|
|
final int premiumSummaryMode =
|
|
parsePremiumSummaryMode(item['is_premium_summery']);
|
|
// 0 = hide, 1 = full summary, 2 = total only
|
|
final bool showFullPremiumSummary =
|
|
premiumSummaryMode == 1 && isValueValid;
|
|
final bool showPremiumTotalOnly =
|
|
premiumSummaryMode == 2 && gpaTotalableValue != 0;
|
|
|
|
String? gpaSumInsured;
|
|
|
|
logDebug('GPA Disclaimer $allDisclaimer');
|
|
|
|
// local checkbox list
|
|
List<bool> checkboxValues =
|
|
List<bool>.generate(allDisclaimer.length, (_) => false);
|
|
|
|
// ---------------------------------------------
|
|
// FIX: mapped_family_floaters is ALREADY A LIST
|
|
// ---------------------------------------------
|
|
List<dynamic> gpaMappedFamilyFloaters =
|
|
item['mapped_family_floaters'] is List
|
|
? item['mapped_family_floaters']
|
|
: [];
|
|
|
|
// ---------------------------------------------
|
|
// Filter TRUE objects
|
|
// ---------------------------------------------
|
|
List<dynamic> getTrueObjects = gpaMappedFamilyFloaters
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
// ---------------------------------------------
|
|
// FIX: safe selection of Sum Insured
|
|
// ---------------------------------------------
|
|
if (getTrueObjects.isNotEmpty) {
|
|
gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"];
|
|
} else {
|
|
gpaSumInsured = item['Policy_Terms']?['sumInsured2'];
|
|
}
|
|
|
|
// ---------------------------------------------
|
|
// FIX: OpenForEnrollment can be int or String
|
|
// ---------------------------------------------
|
|
int gpaOpenForEnrollment = 0;
|
|
dynamic enroll = item['OpenForEnrollment'];
|
|
|
|
if (enroll is int) {
|
|
gpaOpenForEnrollment = enroll;
|
|
} else if (enroll is String) {
|
|
gpaOpenForEnrollment = int.tryParse(enroll) ?? 0;
|
|
}
|
|
List<Widget> familyFloaterContainers = [];
|
|
|
|
for (var floater in gpaMappedFamilyFloaters) {
|
|
bool isValueExist = floater['is_value_exist'];
|
|
Map<String, dynamic> floaterData = floater['data'];
|
|
final dobDate = floaterData['dob'] ?? '';
|
|
gpaSelfDetails = floaterData['name'] +
|
|
' ~ ' +
|
|
floaterData['relationship'] +
|
|
' ~ ' +
|
|
' DOB : ' + dobDate;
|
|
|
|
if (isValueExist) {
|
|
familyFloaterContainers.add(
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15)
|
|
: EdgeInsets.only(top: 0, bottom: 0, left: 5, right: 5),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Icon(Icons.arrow_right,
|
|
color: Color(0xFFE26728)), // Arrow icon
|
|
SizedBox(
|
|
width: Responsive.isDesktop(context)
|
|
? 10
|
|
: 5), // Space between icon and text
|
|
Expanded(
|
|
child: Text(
|
|
gpaSelfDetails ?? '',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
familyFloaterContainers.add(SizedBox(height: 15));
|
|
}
|
|
|
|
Widget card = Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFFFFF1DD),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: EdgeInsets.all(10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 9 : 7,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 13,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
Responsive.isDesktop(context)
|
|
? '$gpaPolicyName'
|
|
: '$gpaPolicyType',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
if (item['eCardDownload'] != null)
|
|
GestureDetector(
|
|
onTap: () async {
|
|
_launchURL(item['eCardDownload']);
|
|
},
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Icon(
|
|
Icons.file_download,
|
|
color: Color(0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 3 : 5,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
'Sum Insured',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 18 : 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${formatNullableAmount(gpaSumInsured)}',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
Column(
|
|
children: familyFloaterContainers,
|
|
),
|
|
if (Responsive.isDesktop(context) &&
|
|
(showFullPremiumSummary || showPremiumTotalOnly))
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showFullPremiumSummary) ...[
|
|
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(
|
|
(gpaSiPremiumValue ?? '').toString(),
|
|
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(
|
|
(gpaGstValue ?? '').toString(),
|
|
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(
|
|
(gpaTotalableValue ?? '').toString(),
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
if (!Responsive.isDesktop(context) &&
|
|
(showFullPremiumSummary || showPremiumTotalOnly))
|
|
Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showFullPremiumSummary) ...[
|
|
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(
|
|
(gpaSiPremiumValue ?? '').toString(),
|
|
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(
|
|
(gpaGstValue ?? '').toString(),
|
|
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(
|
|
(gpaTotalableValue ?? '').toString(),
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
]))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
cards.add(card);
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
|
|
String formatAmount(double value) {
|
|
return value % 1 == 0
|
|
? value.toInt().toString()
|
|
: value.toStringAsFixed(2);
|
|
}
|
|
|
|
String formatNullableAmount(dynamic value, {String fallback = 'NA'}) {
|
|
if (value == null) return fallback;
|
|
final numericValue = value is num
|
|
? value.toDouble()
|
|
: double.tryParse(value.toString());
|
|
if (numericValue == null) return value.toString();
|
|
return formatAmount(numericValue);
|
|
}
|
|
|
|
List<Widget> generateGmcCards(List<dynamic> data) {
|
|
List<Widget> cards = [];
|
|
// gmcEnrollmentStatus = isEnrollmentOpen(data);
|
|
for (var item in data) {
|
|
String gmcPolicyName = item['Policy_Name'] ?? '';
|
|
String gmcPolicyType = item['type'] ?? '';
|
|
String gmcFloaterTextHeading = item['floter_text_heading'] ?? '';
|
|
String gmcFloaterTextDescription = item['floter_text_description'] ?? '';
|
|
String gmcNotes = item['notes'] ?? '';
|
|
String gmcECardDownload = item['eCardDownload'] ?? '';
|
|
|
|
// -------------------------------
|
|
// SAFE numeric conversion
|
|
// -------------------------------
|
|
double gmcGstValue =
|
|
double.tryParse(item['family_floaters_of_dependent_and_gst_value']?.toString() ?? '0') ?? 0.0;
|
|
|
|
double gmcSiPremiumValue =
|
|
double.tryParse(item['family_floaters_of_dependent_and_si_premium_value']?.toString() ?? '0') ?? 0.0;
|
|
|
|
double gmcTotalableValue = gmcGstValue + gmcSiPremiumValue;
|
|
|
|
bool gmcIsValueValid = (gmcSiPremiumValue > 0 && gmcGstValue > 0);
|
|
final int gmcPremiumSummaryMode =
|
|
parsePremiumSummaryMode(item['is_premium_summery']);
|
|
// 0 = hide, 1 = full summary, 2 = total only
|
|
final bool showFullGmcPremiumSummary =
|
|
gmcPremiumSummaryMode == 1 && gmcIsValueValid;
|
|
final bool showGmcPremiumTotalOnly =
|
|
gmcPremiumSummaryMode == 2 && gmcTotalableValue != 0;
|
|
|
|
// -------------------------------
|
|
// SAFE list handling
|
|
// -------------------------------
|
|
List gmcMappedFamilyFloaters = item['mapped_family_floaters'] is List
|
|
? item['mapped_family_floaters']
|
|
: [];
|
|
|
|
logDebug('GPA Disclaimer $allDisclaimer');
|
|
|
|
// -------------------------------
|
|
// Find objects where is_value_exist == true
|
|
// -------------------------------
|
|
List trueObjects = gmcMappedFamilyFloaters
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
// -------------------------------
|
|
// SAFE Suinsured calculation
|
|
// -------------------------------
|
|
double gmcSumInsured;
|
|
|
|
if (trueObjects.isNotEmpty) {
|
|
gmcSumInsured = toDoubleSafe(trueObjects[0]["data"]["basic_cover_si"]);
|
|
} else {
|
|
gmcSumInsured = toDoubleSafe(item['Policy_Terms']?['sum_insured']);
|
|
}
|
|
|
|
String gmcTypeName = gmcPolicyType;
|
|
|
|
logDebug("gmcMappedFamilyFloaters: $gmcMappedFamilyFloaters");
|
|
logDebug("trueObjects: $trueObjects");
|
|
|
|
Widget card = trueObjects.length > 0
|
|
? Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(
|
|
0xFFFFF1DD), // Set background color for the container
|
|
borderRadius: BorderRadius.circular(
|
|
5), // Set border radius for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 25, right: 25)
|
|
: EdgeInsets.only(
|
|
top: 10, bottom: 10, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 9 : 7,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
Responsive.isDesktop(context)
|
|
? gmcPolicyName
|
|
: gmcPolicyType,
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 20
|
|
: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
if (item['eCardDownload'] != null)
|
|
GestureDetector(
|
|
onTap: () async {
|
|
_launchURL(
|
|
item['eCardDownload']);
|
|
},
|
|
child: MouseRegion(
|
|
cursor:
|
|
SystemMouseCursors.click,
|
|
child: Icon(
|
|
Icons.file_download,
|
|
color: Color(0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 3 : 5,
|
|
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
|
|
: 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${formatNullableAmount(gmcSumInsured)}',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 20
|
|
: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 0, bottom: 0, left: 15, right: 15)
|
|
: EdgeInsets.only(
|
|
top: 0, bottom: 0, left: 5, right: 5),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: gmcMappedFamilyFloaters
|
|
.where((item) => item['is_value_exist'] == true)
|
|
.map<Widget>((item) {
|
|
Map<String, dynamic> data = item['data'];
|
|
String formattedDate = 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 : 14,
|
|
color: Color(0xFF232526),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
if (Responsive.isDesktop(context) &&
|
|
(showFullGmcPremiumSummary || showGmcPremiumTotalOnly))
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showFullGmcPremiumSummary) ...[
|
|
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(
|
|
formatAmount(gmcSiPremiumValue),
|
|
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(
|
|
formatAmount(gmcGstValue),
|
|
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(
|
|
formatAmount(gmcTotalableValue),
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
if (!Responsive.isDesktop(context) &&
|
|
(showFullGmcPremiumSummary || showGmcPremiumTotalOnly))
|
|
Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showFullGmcPremiumSummary) ...[
|
|
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(
|
|
formatAmount(gmcSiPremiumValue),
|
|
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(
|
|
formatAmount(gmcGstValue),
|
|
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(
|
|
formatAmount(gmcTotalableValue),
|
|
textAlign: TextAlign.start,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
]))
|
|
],
|
|
),
|
|
))
|
|
: SizedBox(height: 0);
|
|
|
|
cards.add(card);
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
|
|
double calculateGpaTotalAmt(List<Map<String, dynamic>> policies) {
|
|
double total = policies
|
|
.where((policy) =>
|
|
policy is Map<String, dynamic> &&
|
|
shouldShowPremiumSummary(
|
|
parsePremiumSummaryMode(policy['is_premium_summery'])))
|
|
.map((policy) =>
|
|
(policy["si_gst_value"] ?? 0) + (policy["si_premium_value"] ?? 0))
|
|
.fold(0.0, (sum, value) => sum + value);
|
|
|
|
logDebug('Calculated gpaTotalAmt: $total'); // Debug print
|
|
return total;
|
|
}
|
|
|
|
double calculateGmcTotalAmt(List<Map<String, dynamic>> policies) {
|
|
double total = policies
|
|
.where((policy) =>
|
|
policy is Map<String, dynamic> &&
|
|
shouldShowPremiumSummary(
|
|
parsePremiumSummaryMode(policy['is_premium_summery'])))
|
|
.map((policy) =>
|
|
(policy["family_floaters_of_dependent_and_gst_value"] ?? 0) +
|
|
(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0))
|
|
.fold(0.0, (sum, value) => sum + value);
|
|
|
|
logDebug('Calculated gmcTotalAmt: $total'); // Debug print
|
|
return total;
|
|
}
|
|
|
|
List<TableRow> gpaBuildPolicyRows(
|
|
dynamic policies,
|
|
BuildContext context, {
|
|
bool includeBreakdownColumns = true,
|
|
}) {
|
|
if (policies is! List) {
|
|
return []; // Return empty list if policies is not a list
|
|
}
|
|
gpaTotalAmt = calculateGpaTotalAmt(policies.cast<Map<String, dynamic>>());
|
|
|
|
logDebug('gpaTotalAmt $gpaTotalAmt');
|
|
return (policies as List)
|
|
.where((policy) => policy is Map<String,
|
|
dynamic>) // Ensure each item is a Map<String, dynamic>
|
|
.map((policy) {
|
|
var siGstValue = policy["si_gst_value"] ?? 0;
|
|
var siPremiumValue = policy["si_premium_value"] ?? 0;
|
|
final int premiumMode =
|
|
parsePremiumSummaryMode(policy['is_premium_summery']);
|
|
final total =
|
|
(siPremiumValue is num ? siPremiumValue.toDouble() : 0.0) +
|
|
(siGstValue is num ? siGstValue.toDouble() : 0.0);
|
|
|
|
// 0 = hide, 1 = full, 2 = total only
|
|
if (premiumMode == 0) return null;
|
|
if (premiumMode == 1 && (siGstValue == 0 || siPremiumValue == 0)) {
|
|
return null;
|
|
}
|
|
if (premiumMode == 2 && total == 0) return null;
|
|
|
|
final bool showBreakdownValues =
|
|
shouldShowFullPremiumBreakdown(premiumMode);
|
|
final policyLabel = Responsive.isDesktop(context)
|
|
? (policy["Policy_Name"] ?? 'Default Policy Name')
|
|
: policy['type'];
|
|
final totalValue =
|
|
'₹${(policy["si_premium_value"] ?? 0) + (policy["si_gst_value"] ?? 0)}/Year';
|
|
|
|
return TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: policyLabel?.toString() ?? '',
|
|
premiumValue: '₹${policy["si_premium_value"]}/Year',
|
|
gstValue: '₹${policy["si_gst_value"]}/-',
|
|
totalValue: totalValue,
|
|
includeBreakdownColumns: includeBreakdownColumns,
|
|
showBreakdownValues: showBreakdownValues,
|
|
),
|
|
);
|
|
})
|
|
.whereType<TableRow>() // Filter out null values
|
|
.toList();
|
|
}
|
|
|
|
List<TableRow> gmcBuildPolicyRows(
|
|
dynamic policies,
|
|
BuildContext context, {
|
|
bool includeBreakdownColumns = true,
|
|
}) {
|
|
logDebug('gmcBuildPolicyRows $policies');
|
|
|
|
if (policies is! List) {
|
|
return []; // Return empty list if policies is not a list
|
|
}
|
|
gmcTotalAmt = calculateGmcTotalAmt(policies.cast<Map<String, dynamic>>());
|
|
|
|
logDebug('gmcTotalAmt $gmcTotalAmt');
|
|
return (policies as List)
|
|
.where((policy) => policy is Map<String,
|
|
dynamic>) // Ensure each item is a Map<String, dynamic>
|
|
.map((policy) {
|
|
var siGstValue =
|
|
policy["family_floaters_of_dependent_and_gst_value"] ?? 0;
|
|
var siPremiumValue =
|
|
policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0;
|
|
final int premiumMode =
|
|
parsePremiumSummaryMode(policy['is_premium_summery']);
|
|
final total =
|
|
(siPremiumValue is num ? siPremiumValue.toDouble() : 0.0) +
|
|
(siGstValue is num ? siGstValue.toDouble() : 0.0);
|
|
|
|
// 0 = hide, 1 = full, 2 = total only
|
|
if (premiumMode == 0) return null;
|
|
if (premiumMode == 1 && (siGstValue == 0 || siPremiumValue == 0)) {
|
|
return null;
|
|
}
|
|
if (premiumMode == 2 && total == 0) return null;
|
|
|
|
final bool showBreakdownValues =
|
|
shouldShowFullPremiumBreakdown(premiumMode);
|
|
final policyLabel = Responsive.isDesktop(context)
|
|
? (policy["Policy_Name"] ?? 'Default Policy Name')
|
|
: policy['type'];
|
|
final totalValue =
|
|
'₹${(policy["family_floaters_of_dependent_and_si_premium_value"] ?? 0) + (policy["family_floaters_of_dependent_and_gst_value"] ?? 0)}/Year';
|
|
|
|
return TableRow(
|
|
children: buildPremiumSummaryRowCells(
|
|
context: context,
|
|
policyLabel: policyLabel?.toString() ?? '',
|
|
premiumValue:
|
|
'₹${policy["family_floaters_of_dependent_and_si_premium_value"]}/Year',
|
|
gstValue:
|
|
'₹${policy["family_floaters_of_dependent_and_gst_value"]}/-',
|
|
totalValue: totalValue,
|
|
includeBreakdownColumns: includeBreakdownColumns,
|
|
showBreakdownValues: showBreakdownValues,
|
|
),
|
|
);
|
|
})
|
|
.whereType<TableRow>() // Filter out null values
|
|
.toList();
|
|
}
|
|
}
|