diff --git a/assets/mobileViewLogo.png b/assets/mobileViewLogo.png new file mode 100644 index 0000000..0ac0669 Binary files /dev/null and b/assets/mobileViewLogo.png differ diff --git a/assets/nhance_client_logo.png b/assets/nhance_client_logo.png new file mode 100644 index 0000000..f316a3f Binary files /dev/null and b/assets/nhance_client_logo.png differ diff --git a/lib/addons.dart b/lib/addons.dart index ba4d107..1a296c2 100644 --- a/lib/addons.dart +++ b/lib/addons.dart @@ -1,6 +1,16 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'customAppBar/customAppBar.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/widgets.dart'; +import 'package:flutter/services.dart'; +import 'dart:convert'; +import 'package:intl/intl.dart'; class addOnsDetails extends StatefulWidget { const addOnsDetails({Key? key}) : super(key: key); @@ -10,477 +20,1490 @@ class addOnsDetails extends StatefulWidget { } class _addOnsDetailsState extends State { - bool _isSwitched = false; // Declare the _isSwitched variable here + bool _gmcDependentSwitcher = false; // Declare the _isSwitched variable here + bool _gmcSiSwitcher = false; + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; + List> gpaPolicies = []; + dynamic gpaPolicyName; + dynamic gpaGridMaster; + dynamic gpasumInsured; + dynamic gpaClintPolicyId; + dynamic gpaMappedFamilyFloaters; + dynamic gpaSelfName; + dynamic gpaSelfDob; + dynamic gpaSelfRelationship; + dynamic gpaSelfDetails; + dynamic gmcMappedFamilyFloaters; + dynamic gmcSelfName; + dynamic gmcSelfDob; + dynamic gmcSelfRelationship; + dynamic gmcSelfDetails; + dynamic gmcPolicyName; + dynamic gmcNotes; + dynamic gmcSumInsured; + dynamic clientName; + dynamic clientLogo; + dynamic addOnsMappedFamilyFloatersSi; + dynamic addOnsMappedFamilyFloatersDependent; + dynamic addOnsClientPolicyId; + dynamic addOnsSlabRates; + dynamic gmcAddOnsselectedSI; + dynamic gmcAddOnsselectedDependent; + dynamic dependentValue; + dynamic siValue; + dynamic gmcAddOnDependentPremiumValue; + dynamic gmcAddOnSiPremiumValue; + dynamic dependentPremiumGst; + dynamic siPremiumGst; + dynamic addOnsPolicyName; + dynamic dependentTotalAmt; + dynamic siTotalAmt; + dynamic addOnsFamilyFloater; + late TextEditingController _relationShipController; + late TextEditingController _dobController; + late TextEditingController _memberNameController; + late DateTime? selectedDate; + List> relationshipOptions = []; + List> selectedRelationships = []; + List> formDataList = []; + late DateTime _selectedDate = DateTime.now(); // Define _selectedDate here @override void initState() { super.initState(); + _dobController = TextEditingController(); + _memberNameController = TextEditingController(); + _relationShipController = TextEditingController(); + _loadToken(); } @override void dispose() { + _dobController.dispose(); + _memberNameController.dispose(); + _relationShipController.dispose(); super.dispose(); } + Future _loadToken() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(token); + print(decodedToken); + empCodeString = prefs.getString('empCode'); + print(empCodeString); // Check if emp_code is correct + empPrimaryId = prefs.getString('empPrimaryId'); + gpaEmpName = prefs.getString('gpaEmpName'); + client_id = prefs.getString('client_id'); + print(client_id); + + // print(empPrimaryId); + // Call the API when the page enters + getClientLogoAndDetails(); + getAddOnsEmpPolicyDetails(); + fetchRelationshipList(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } + } + + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGpaEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gpaPolicies = data['data']; + print(gpaPolicies); + // Assuming data is a List + print(gpaPolicies); + if (gpaPolicies.isNotEmpty) { + setState(() { + // You can use gpaPolicies as needed + print('GPA Policies found: $gpaPolicies'); + gpaPolicyName = gpaPolicies['Policy_Name'].toString(); + print(gpaPolicyName); + gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + print(gpasumInsured); + gpaMappedFamilyFloaters = + gpaPolicies['mapped_family_floaters']['data']; + print(gpaMappedFamilyFloaters); + gpaSelfName = gpaMappedFamilyFloaters['name'].toString() ?? ''; + // gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile']; + gpaSelfDob = gpaMappedFamilyFloaters['dob'].toString() ?? ''; + gpaSelfRelationship = + gpaMappedFamilyFloaters['relationship'].toString() ?? ''; + gpaSelfDetails = gpaSelfName + + ' - ' + + gpaSelfRelationship + + ' - ' + + gpaSelfDob; + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGmcEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gmcPolicies = data['data']; + print(gmcPolicies); + // Assuming data is a List + print(gmcPolicies); + if (gmcPolicies.isNotEmpty) { + setState(() { + print('GPM Policies found: $gmcPolicies'); + gmcPolicyName = gmcPolicies['Policy_Name'].toString(); + print(gmcPolicyName); + gmcNotes = gmcPolicies['notes'].toString(); + gmcSumInsured = + gmcPolicies['Policy_Terms']['sum_insured'].toString(); + print(gmcSumInsured); + + gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; + print(gmcMappedFamilyFloaters); + // gmcSelfName = gpaMappedFamilyFloaters['name'].toString(); + // // selfMobileNo = gpaMappedFamilyFloaters['mobile']; + // gmcSelfDob = gpaMappedFamilyFloaters['dob'].toString(); + // gmcSelfRelationship = + // gpaMappedFamilyFloaters['relationship'].toString(); + // gmcSelfDetails = gmcSelfRelationship + ' . ' + gmcSelfDob; + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + // Handle other status messages if needed + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getAddOnsEmpPolicyDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print('222222222'); + print(data); + + if (data.containsKey('data')) { + dynamic addOnsPolicies = data['data']; + print(addOnsPolicies); + if (addOnsPolicies.isNotEmpty) { + // setState(() { + addOnsClientPolicyId = + addOnsPolicies['addon_policy']['client_policy_id']; + + addOnsSlabRates = await addOnsPolicies['addon_policy']['SlabRates']; + print(addOnsSlabRates); + + addOnsPolicyName = + await addOnsPolicies['addon_policy']['policy_name']; + + addOnsFamilyFloater = await addOnsPolicies['addon_policy'] + ['policy_terms']['family_floater']; + print('addOnsFamilyFloater'); + print(addOnsFamilyFloater); + setState(() { + addOnsMappedFamilyFloatersDependent = + addOnsPolicies['addon_policy'] + ['family_floaters_of_dependent_and_si_array']; + print('addOnsMappedFamilyFloatersDependent'); + print(addOnsMappedFamilyFloatersDependent); + }); + + addOnsMappedFamilyFloatersSi = await addOnsPolicies['addon_policy'] + ['family_floaters_of_only_si_array']; + print('addOnsMappedFamilyFloatersSi'); + print(addOnsMappedFamilyFloatersSi); + + gmcAddOnDependentPremiumValue = await addOnsPolicies['addon_policy'] + ['family_floaters_of_dependent_and_si_premium_value']; + + dependentValue = await addOnsPolicies['addon_policy'] + ['family_floaters_of_dependent_and_si_value']; + gmcAddOnsselectedDependent = + dependentValue != null ? dependentValue.toString() : null; + if (gmcAddOnsselectedDependent != null) { + _gmcDependentSwitcher = true; + if (gmcAddOnDependentPremiumValue != null) { + calculationForDependentSumValue('Add'); + } + } + + gmcAddOnSiPremiumValue = await addOnsPolicies['addon_policy'] + ['family_floaters_of_only_si_premium_value']; + + siValue = await addOnsPolicies['addon_policy'] + ['family_floaters_of_only_si_value']; + gmcAddOnsselectedSI = siValue != null ? siValue.toString() : null; + if (gmcAddOnsselectedSI != null) { + print('gmcAddOnsselectedSI'); + _gmcSiSwitcher = true; + if (gmcAddOnSiPremiumValue != null) { + print('gmcAddOnSiPremiumValue'); + calculationForSiSumValue('Add'); + } + } + + // }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future calculationForDependentSumValue(String action) async { + double premiumValue; + if (action == 'Add') { + premiumValue = double.parse(gmcAddOnDependentPremiumValue.toString()); + } else { + Map? findedSiObject = addOnsSlabRates.firstWhere( + (element) => element['si'] == gmcAddOnsselectedDependent.toString(), + orElse: () => null, + ); + + print('findedSiObject'); + print(findedSiObject); + + if (findedSiObject != null) { + gmcAddOnDependentPremiumValue = findedSiObject['premium']; + premiumValue = double.parse(findedSiObject['premium'].toString()); + } else { + // Handle the case when no matching object is found + print( + 'No matching object found for gmcAddOnsselectedDependent: $gmcAddOnsselectedDependent'); + return; // Exit the function early + } + } + const gstRate = 18.0; + dependentPremiumGst = premiumValue * (gstRate / 100); + print(dependentPremiumGst); + + dependentTotalAmt = premiumValue + dependentPremiumGst; + } + + Future calculationForSiSumValue(action) async { + double premiumValue; + if (action == 'Add') { + print('Add'); + print(addOnsFamilyFloater); + if (addOnsFamilyFloater == '0') { + print('calculationForSiSumValue'); + int lengthArray = addOnsMappedFamilyFloatersSi.length; + + premiumValue = + double.parse(gmcAddOnSiPremiumValue.toString()) * lengthArray; + gmcAddOnSiPremiumValue = premiumValue; + } else { + premiumValue = double.parse(gmcAddOnSiPremiumValue.toString()); + } + } else { + Map? findedSiObject = addOnsSlabRates.firstWhere( + (element) => element['si'] == gmcAddOnsselectedSI.toString(), + orElse: () => null, + ); + + print('findedSiObject'); + print(findedSiObject); + + if (findedSiObject != null) { + if (addOnsFamilyFloater == '0') { + print('calculationForSiSumValue'); + int lengthArray = addOnsMappedFamilyFloatersSi.length; + + premiumValue = + double.parse(findedSiObject['premium'].toString()) * lengthArray; + gmcAddOnSiPremiumValue = premiumValue; + } else { + premiumValue = double.parse(findedSiObject['premium'].toString()); + gmcAddOnSiPremiumValue = premiumValue; + } + } else { + // Handle the case when no matching object is found + print( + 'No matching object found for gmcAddOnsselectedDependent: $gmcAddOnsselectedDependent'); + return; // Exit the function early + } + } + print('premium'); + print(premiumValue); + const gstRate = 18.0; + siPremiumGst = premiumValue * (gstRate / 100); + print(siPremiumGst); + + siTotalAmt = premiumValue + siPremiumGst; + } + + Future fetchRelationshipList() async { + // Replace the URL with your API endpoint + final url = Uri.parse(Environment.apiUrl + 'relationshipList'); + try { + final response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + final List data = jsonDecode(response.body)['data']; + for (var item in data) { + String relationshipName = item['relationship_name']; + String dependent = item['dependent']; + + relationshipOptions.add({ + 'relationship_name': relationshipName, + 'dependent': dependent, + }); + } + // final List relationships = + // List.from(data.map((item) => item['relationship_name'])); + // setState(() { + // relationshipOptions = relationships; + // }); + } else { + ToastHelper.showErrorToast( + context, 'Failed to fetch relationship list'); + throw Exception('Failed to fetch relationship list'); + } + } catch (error) { + ToastHelper.showErrorToast( + context, 'Error fetching relationship list: $error'); + print('Error fetching relationship list: $error'); + // Handle error accordingly, e.g., show a snackbar with an error message + } + } + + Future _selectDate(BuildContext context, [String? formType]) async { + late DateTime minDate; + late DateTime maxDate; + + final DateTime now = DateTime.now(); + + if (formType == 'child') { + // For 'child' form type, allow 0-25 age + minDate = DateTime(now.year - 25, now.month, now.day); + maxDate = now; + } else { + // For other form types, allow 18-100 age + minDate = DateTime(1900); + maxDate = DateTime(now.year - 18, now.month, now.day); + } + + // Ensure initialDate is within the range of minDate and maxDate + DateTime initialDate = + _selectedDate ?? maxDate; // Use maxDate if _selectedDate is null + initialDate = initialDate.isBefore(minDate) ? minDate : initialDate; + initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate; + + final DateTime? picked = await showDatePicker( + context: context, + initialDate: initialDate, + firstDate: minDate, + lastDate: maxDate, + selectableDayPredicate: (DateTime date) { + return date.isAfter(minDate.subtract(const Duration(days: 1))) && + date.isBefore(maxDate.add(const Duration(days: 1))); + }, + ); + + if (picked != null && picked != _selectedDate) { + setState(() { + _selectedDate = picked; + _dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate); + }); + } + } + + Future deleteItem(Map deletedItem) async { + print(deletedItem); + // Define your API endpoint + var id = deletedItem['employee_id']; + final String apiUrl = Environment.apiUrl + 'deleteDependence?id=$id'; + + try { + // Make the DELETE request to the API endpoint + final http.Response response = await http.get( + Uri.parse(apiUrl), + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + // Check if the request was successful (status code 200) + if (response.statusCode == 200) { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + relationshipOptions.clear(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + getAddOnsEmpPolicyDetails(); + ToastHelper.showSuccessToast(context, 'Item deleted successfully'); + print('Item deleted successfully'); + } else { + // Handle errors + ToastHelper.showSuccessToast(context, + 'Failed to delete item. Status code: ${response.statusCode}'); + print('Failed to delete item. Status code: ${response.statusCode}'); + print('Response body: ${response.body}'); + } + } catch (error) { + // Handle network errors + print('Error deleting item: $error'); + } + } + + void saveAddOnsDetails(Map formData, + Map floatedData, action) async { + // Construct the array of objects + print(formData); + print(floatedData); + print(action); + formDataList.add({ + 'relationship': formData['relationship'], + 'name': formData['memberName'], + 'dob': formData['dateOfBirth'], + 'emp_code': empCodeString, + 'client_id': client_id, + 'client_policy_id': floatedData['client_policy_id'], + 'is_addon_value': 1, + // Add the 'id' field only if action is 'Edit' + if (action == 'Edit') 'id': floatedData['employee_id'], + }); + + // Convert the list of objects to JSON + String formDataJson = jsonEncode(formDataList); + + // Prepare the API request + var url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence'); + var response = await http.post( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + body: formDataJson, + ); + + // Check the response + if (response.statusCode == 200) { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + relationshipOptions.clear(); + // Request successful, handle response + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + getAddOnsEmpPolicyDetails(); + ToastHelper.showSuccessToast(context, 'Saved Successfully...'); + print('Form data sent successfully.'); + } else { + // Request failed, handle error + ToastHelper.showErrorToast( + context, 'Failed to send form data. Error: ${response.reasonPhrase}'); + print('Failed to send form data. Error: ${response.reasonPhrase}'); + } + } + + void cancelPopUp() { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + } + + void sendAddonsGmcDependentToAPI() async { + print(_gmcDependentSwitcher); + print('continue'); + print(gmcAddOnsselectedDependent); + if (_gmcDependentSwitcher == true) { + if (gmcAddOnsselectedDependent == null || + gmcAddOnsselectedDependent.isEmpty) { + return; // Return if gmcAddOnsselectedDependent is null or empty + } else { + print('createOrUpdateEmployeePolicySiAmount'); + try { + dynamic getTrueObjects = addOnsMappedFamilyFloatersDependent + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); + + print(getTrueDataObjects); + + List> selectedValues = []; + // try { + print('fff'); + if (getTrueDataObjects != null || getTrueDataObjects.isNotEmpty) { + for (var floater in getTrueDataObjects) { + String employee_id = floater['employee_id']; + String client_policy_id = floater['client_policy_id'].toString(); + + // Create a map containing the floater details and its selected values + Map floaterData = { + 'basic_cover_si': gmcAddOnsselectedDependent, + 'client_policy_id': client_policy_id, + 'employee_id': employee_id, + 'client_id': client_id, + }; + + // Add the map to the list + selectedValues.add(floaterData); + } + print(selectedValues); + } + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse( + Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount'); + final response = await http.post( + url, + body: jsonEncode(selectedValues), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + // Member saved successfully + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + // Navigator.pushNamed(context, 'empReviewDetails'); + ToastHelper.showSuccessToast(context, 'Saved successfully!'); + print('Saved successfully!'); + } + } else { + // Failed to save member + // ToastHelper.showErrorToast(context, "Operation Failed!"); + ToastHelper.showErrorToast(context, 'Failed to save'); + print('Operation Failed!'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + } else { + // Navigator.pushNamed(context, 'empReviewDetails'); + } + } + + void sendAddonsGmcSiToAPI() async { + print(_gmcSiSwitcher); + print('continue'); + print(gmcAddOnsselectedSI); + if (_gmcSiSwitcher == true) { + if (gmcAddOnsselectedSI == null || gmcAddOnsselectedSI.isEmpty) { + return; // Return if gmcAddOnsselectedDependent is null or empty + } else { + print('createOrUpdateEmployeePolicySiAmount'); + try { + dynamic getTrueObjects = addOnsMappedFamilyFloatersSi + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); + + print(getTrueDataObjects); + + List> selectedValues = []; + // try { + print('fff'); + if (getTrueDataObjects != null || getTrueDataObjects.isNotEmpty) { + for (var floater in getTrueDataObjects) { + String employee_id = floater['employee_id']; + String client_policy_id = floater['client_policy_id'].toString(); + + // Create a map containing the floater details and its selected values + Map floaterData = { + 'basic_cover_si': gmcAddOnsselectedSI, + 'client_policy_id': client_policy_id, + 'employee_id': employee_id, + 'client_id': client_id, + }; + + // Add the map to the list + selectedValues.add(floaterData); + } + print(selectedValues); + } + + // Iterate through familyMembers list and send each member's data to the API + final url = Uri.parse( + Environment.apiUrl + 'createOrUpdateEmployeePolicySiAmount'); + final response = await http.post( + url, + body: jsonEncode(selectedValues), + headers: { + 'Content-Type': 'application/json', + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + // Member saved successfully + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + // Navigator.pushNamed(context, 'empReviewDetails'); + ToastHelper.showSuccessToast(context, 'Saved successfully!'); + print('Saved successfully!'); + } + } else { + // Failed to save member + // ToastHelper.showErrorToast(context, "Operation Failed!"); + ToastHelper.showSuccessToast(context, 'Failed to Save...'); + print('Operation Failed!'); + } + } catch (error) { + print('Error saving family members'); + // ToastHelper.showErrorToast(context, "Error saving family members"); + } + } + } else { + // Navigator.pushNamed(context, 'empReviewDetails'); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: CustomAppBar(), - body: SingleChildScrollView( - child: Container( - padding: EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.1, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding + if (addOnsMappedFamilyFloatersDependent == null) { + return Scaffold( + appBar: CustomAppBar(), + body: Center( + child: Container( + color: Color(0xFFEFF3F6), + child: Center( + child: Text('No Data Available'), + ), ), - color: Color(0xFFEFF3F6), - child: Column( - children: [ - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.asset( - 'assets/Group.png', - width: 80, // Set the width of the image - height: 80, // Set the height of the image - fit: BoxFit.contain, // Adjust the fit as needed + ), + ); + } else { + List familyFloaterContainers = []; + for (var floater in addOnsMappedFamilyFloatersDependent) { + bool isValueExist = floater['is_value_exist']; + Map floaterData = floater['data']; + + if (isValueExist) { + familyFloaterContainers.add( + Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(15) + : EdgeInsets.only(top: 8, bottom: 8, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(10) + : EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF00989E), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.account_circle, + color: Colors.white, + size: 32, ), - )), - Expanded( - flex: 6, - child: Text( - 'Bharti Airtel', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), + Expanded( + flex: Responsive.isDesktop(context) ? 9 : 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['name'] ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + fontWeight: FontWeight.w600, + ), + ), + Text( + '${floaterData['relationship']} - ${floaterData['dob']}', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + ), + ), + ], + ), + ), + ), + if (isValueExist && floaterData['relationship'] != 'Self') + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + deleteItem(floaterData); + }, + child: Text( + 'Delete', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 16 : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], ), - ) - ], + ), + ), + Expanded( + flex: + (isValueExist && floaterData['relationship'] != 'Self') + ? Responsive.isDesktop(context) + ? 1 + : 2 + : Responsive.isDesktop(context) + ? 2 + : 4, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + openForm(floaterData, 'Edit'); + }, + child: Text( + floaterData['relationship'] == 'Self' + ? 'View' + : 'Edit', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 16 : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), + ], + ), + ), + ); + } else { + familyFloaterContainers.add(MouseRegion( + cursor: SystemMouseCursors.click, // Set cursor to pointer + child: GestureDetector( + onTap: () { + // Handle the click event to open the form + openForm(floaterData, 'Add'); + }, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(12) + : EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF6A6A6A), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.person_add, + color: Colors.white, + size: 20, + ), + ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), + Expanded( + flex: Responsive.isDesktop(context) ? 11 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['button_name'] ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 22 : 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ], + ), + ), // Replace YourChildWidget with the widget you want to wrap + ), + )); + } + familyFloaterContainers.add(SizedBox(height: 15)); + } + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 3, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo, + width: Responsive.isDesktop(context) + ? 80 + : 50, // Set the width here + height: Responsive.isDesktop(context) + ? 80 + : 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: + loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + ), + )), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, + ), + ), + ) + ], + ), ), ), - ), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gpaPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Employee Name • Self • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Employee Name • Self • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Spouse Name • Spouse • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Sons Name • Son • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Daughters Name • Daughter • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - child: Column( - children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add Ons', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, + Text( + 'Group Personal Accident Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, fontWeight: FontWeight.w600, - color: Color(0xFF181818)), - ), - Text( - 'Increase your medical cover for your family or add parents or parent in laws by paying additional premium', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - color: Color(0xFF181818), + ), ), - ), - ], - ))), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: Color( - 0xFFDDF3FF), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: EdgeInsets.only( - top: 25, bottom: 25, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add On Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), ), - ), - Text( - 'Group Medical Coverage - Top Up', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Switch( - value: _isSwitched, - onChanged: (value) { - setState(() { - _isSwitched = value; - // Add your logic here based on the toggle state - }); - }, - activeColor: Color( - 0xFFE26728), // Color when the switch is ON - inactiveTrackColor: Colors - .grey, // Color of the switch track when OFF - ), - ], - ))), - ], + ], + ))), + ], + ), ), - ), - SizedBox(height: 15), - Container( + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + gpaSelfDetails ?? '', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: gmcMappedFamilyFloaters + .where( + (item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 18, + fontWeight: FontWeight.w600, + color: Color(0xFF181818)), + ), + Text( + 'Increase your medical cover for your family or add parents or parent in laws by paying additional premium', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 15, + color: Color(0xFF181818), + ), + ), + ], + ))), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( decoration: BoxDecoration( color: Color( 0xFFDDF3FF), // Set background color for the container borderRadius: BorderRadius.circular( 5), // Set border radius for the container ), - padding: EdgeInsets.only( - top: 25, bottom: 25, left: 25, right: 25), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(25) + : EdgeInsets.all(10), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - flex: 6, + flex: Responsive.isDesktop(context) + ? 6 + : 10, child: Container( alignment: Alignment.centerLeft, child: Column( @@ -490,61 +1513,85 @@ class _addOnsDetailsState extends State { CrossAxisAlignment.start, children: [ Text( - 'Add On Name', + addOnsPolicyName ?? '', textAlign: TextAlign.left, style: TextStyle( - fontSize: 18, + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, ), ), Text( - 'Group Medical Coverage - Add Parents', + 'Group Medical Coverage - Top Up ', textAlign: TextAlign.left, style: TextStyle( - fontSize: 20, + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, fontWeight: FontWeight.w600, ), ), ], ))), - Expanded( - flex: 3, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField( - onChanged: (value) {}, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Sum Insured', - labelText: 'Sum Insured', - contentPadding: - EdgeInsets.symmetric( - vertical: 5, - horizontal: 5), + if (Responsive.isDesktop(context) && + _gmcSiSwitcher == true) + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + gmcAddOnsselectedSI = + value; + }); + calculationForSiSumValue( + 'Edit'); + }, + decoration: InputDecoration( + border: + OutlineInputBorder(), + hintText: 'Sum Insured', + labelText: 'Sum Insured', + contentPadding: + EdgeInsets.symmetric( + vertical: 5, + horizontal: 5), + ), + value: gmcAddOnsselectedSI, + items: (addOnsSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), ), - value: null, - items: [ - DropdownMenuItem( - value: 'Item 1', - child: Text('₹ 3,00,000'), - ), - DropdownMenuItem( - value: 'Item 2', - child: Text('₹ 4,00,000'), - ), - ], - ), - ], - ))), + ], + ))), Expanded( - flex: 3, + flex: Responsive.isDesktop(context) + ? 3 + : 2, child: Container( alignment: Alignment.centerRight, child: Column( @@ -554,10 +1601,10 @@ class _addOnsDetailsState extends State { CrossAxisAlignment.end, children: [ Switch( - value: _isSwitched, + value: _gmcSiSwitcher, onChanged: (value) { setState(() { - _isSwitched = value; + _gmcSiSwitcher = value; // Add your logic here based on the toggle state }); }, @@ -570,194 +1617,125 @@ class _addOnsDetailsState extends State { ))), ], ), - SizedBox(height: 20), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 4, - child: Container( - width: 50, - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - DropdownButtonFormField( - onChanged: (value) {}, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: 'Relationship', - labelText: 'Relationship', - contentPadding: - EdgeInsets.symmetric( - vertical: 5, - horizontal: 5), - ), - value: null, - items: [ - DropdownMenuItem( - value: 'Item 1', - child: Text('Father'), - ), - DropdownMenuItem( - value: 'Item 2', - child: Text('Mother'), - ), - ], - ), - ], - ))), - SizedBox(width: 10), - Expanded( - flex: 4, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: TextFormField( - onChanged: (value) => null, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: - 'Member Full Name', - labelText: - 'Member Full Name', - contentPadding: - EdgeInsets.symmetric( - vertical: 10, - horizontal: 15), - ), - validator: (value) { - if (value == null || - value.isEmpty) { - return 'Member Full Name is required'; - } - return null; - }, - ), - ) - ], - ))), - SizedBox(width: 10), - Expanded( - flex: 4, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Container( - child: TextFormField( - onChanged: (value) => null, - decoration: InputDecoration( - border: - OutlineInputBorder(), - hintText: 'DD-MM-YYYY', - labelText: - 'Date of Birth', - contentPadding: - EdgeInsets.symmetric( - vertical: 10, - horizontal: 15), - ), - validator: (value) { - if (value == null || - value.isEmpty) { - return 'Date of Birth is required'; - } - return null; - }, - ), - ) - ], - ))), - ], - ), - SizedBox(height: 10), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, + if (_gmcSiSwitcher == true) + SizedBox(height: 10), + if (!Responsive.isDesktop(context) && + _gmcSiSwitcher == true) + Row( children: [ Expanded( flex: 12, child: Container( - alignment: Alignment.centerRight, + width: 50, + alignment: Alignment.center, child: Column( mainAxisAlignment: - MainAxisAlignment.end, + MainAxisAlignment.center, crossAxisAlignment: - CrossAxisAlignment.end, + CrossAxisAlignment.center, children: [ - Align( - alignment: - Alignment.centerRight, - child: SizedBox( - width: - 180, // Set the desired width - child: TextButton( - onPressed: () => null, - child: Row( - mainAxisAlignment: - MainAxisAlignment - .end, - children: [ - Icon( - Icons - .person_remove, - color: Color( - 0xFF62696C), // Set the color of the icon - ), - SizedBox( - width: - 8), // Add space between icon and text - Text( - 'Remove', - style: TextStyle( - color: Color( - 0xFF62696C), // Set the color of the text - ), - ) - ], - ), - ), + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + gmcAddOnsselectedSI = + value; + }); + calculationForSiSumValue( + 'Edit'); + }, + decoration: InputDecoration( + border: + OutlineInputBorder(), + hintText: 'Sum Insured', + labelText: 'Sum Insured', + contentPadding: + EdgeInsets.symmetric( + vertical: 5, + horizontal: 5), ), + value: gmcAddOnsselectedSI, + items: (addOnsSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), ), ], ))), - ]), - SizedBox(height: 20), - Container( - decoration: BoxDecoration( - border: Border.all( - color: - Color(0xFF000000), // Set border color - width: 1, // Set border width - ), - // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container + ], ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( + if (_gmcSiSwitcher == true) + SizedBox(height: 10), + if (_gmcSiSwitcher == + true) // Add space between rows + Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - flex: 1, + flex: 12, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: addOnsMappedFamilyFloatersSi + .where((item) => + item['is_value_exist'] == + true) + .map((item) { + Map data = + item['data']; + return Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color( + 0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop( + context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: TextStyle( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ) + ], + ), + if (_gmcSiSwitcher == true) + SizedBox(height: 20), + if (Responsive.isDesktop(context) && + _gmcSiSwitcher == true) + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, child: Container( alignment: Alignment.center, child: Column( @@ -766,28 +1744,288 @@ class _addOnsDetailsState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ - Container( - padding: EdgeInsets.all( - 5), // Padding around the icon - decoration: BoxDecoration( - color: Color( - 0xFF6A6A6A), // Background color of the icon container - borderRadius: - BorderRadius.circular( - 5), // Radius of the container + Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, ), - child: Icon( - Icons - .person_add, // Icon data - color: Colors.white, - size: - 20, // Color of the icon + ), + Text( + gmcAddOnSiPremiumValue != + null + ? '₹ $gmcAddOnSiPremiumValue/Year' + : 'N/A', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 18, ), ), ], ))), Expanded( - flex: 11, + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + siPremiumGst != null + ? '₹ $siPremiumGst/-' + : 'N/A', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + siTotalAmt != null + ? '₹ $siTotalAmt/-' + : 'N/A', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && + _gmcSiSwitcher == true) + Container( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + gmcAddOnSiPremiumValue != + null + ? '₹ $gmcAddOnSiPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + 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: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + siPremiumGst != null + ? '₹ $siPremiumGst/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + 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: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + siTotalAmt != null + ? '₹ $siTotalAmt/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) + ], + ), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: Color( + 0xFFDDF3FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(25) + : EdgeInsets.all(10), + child: Column( + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, child: Container( alignment: Alignment.centerLeft, child: Column( @@ -797,178 +2035,940 @@ class _addOnsDetailsState extends State { CrossAxisAlignment.start, children: [ Text( - 'Add Parent', + addOnsPolicyName ?? '', textAlign: TextAlign.left, style: TextStyle( - fontSize: 22, - fontWeight: - FontWeight.w500, + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 14, ), ), + Text( + 'Group Medical Coverage - Add Dependent', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: + FontWeight.w600, + ), + ), + ], + ))), + if (Responsive.isDesktop(context) && + _gmcDependentSwitcher) + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + gmcAddOnsselectedDependent = + value; + }); + calculationForDependentSumValue( + 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: 5, + horizontal: + 5), + ), + value: + gmcAddOnsselectedDependent, + items: (addOnsSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ], + ))), + Expanded( + flex: 3, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Switch( + value: + _gmcDependentSwitcher, + onChanged: (value) { + setState(() { + _gmcDependentSwitcher = + value; + // Add your logic here based on the toggle state + }); + }, + activeColor: Color( + 0xFFE26728), // Color when the switch is ON + inactiveTrackColor: Colors + .grey, // Color of the switch track when OFF + ), ], ))), ], ), + if (_gmcDependentSwitcher == true) + SizedBox(height: 10), + if (!Responsive.isDesktop(context) && + _gmcDependentSwitcher == true) + Row( + children: [ + Expanded( + flex: 3, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField< + String>( + onChanged: (value) { + setState(() { + gmcAddOnsselectedDependent = + value; + }); + calculationForDependentSumValue( + 'Edit'); + }, + decoration: + InputDecoration( + border: + OutlineInputBorder(), + hintText: 'Sum Insured', + labelText: + 'Sum Insured', + contentPadding: + EdgeInsets + .symmetric( + vertical: 5, + horizontal: + 5), + ), + value: + gmcAddOnsselectedDependent, + items: (addOnsSlabRates ?? + []) + .map< + DropdownMenuItem< + String>>( + (addOn) { + return DropdownMenuItem< + String>( + value: addOn['si'] + .toString(), + child: Text( + '₹ ${addOn['si']}'), + ); + }).toList(), + ), + ], + ))), + ], + ), + SizedBox(height: 20), + if (_gmcDependentSwitcher == true) + Column( + children: familyFloaterContainers, + ), + if (_gmcDependentSwitcher) + SizedBox(height: 20), + if (Responsive.isDesktop(context) && + _gmcDependentSwitcher) + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + gmcAddOnDependentPremiumValue != + null + ? '₹ $gmcAddOnDependentPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'GST', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + dependentPremiumGst != + null + ? '₹ $dependentPremiumGst/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w500, + ), + ), + Text( + dependentTotalAmt != null + ? '₹ $dependentTotalAmt/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + ), + ), + ], + ))), + ], + ), + if (!Responsive.isDesktop(context) && + _gmcDependentSwitcher == true) + Container( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Additional Premium', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + gmcAddOnDependentPremiumValue != + null + ? '₹ $gmcAddOnDependentPremiumValue/Year' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + 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: TextStyle( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + dependentPremiumGst != + null + ? '₹ $dependentPremiumGst/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: + Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + 'Total Payable', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight + .w500, + ), + ), + ], + ))), + Expanded( + flex: 5, + child: Container( + alignment: + Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + Text( + dependentTotalAmt != + null + ? '₹ $dependentTotalAmt/-' + : 'N/A', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: 16, + ), + ), + ], + ))), + ], + ), + ])) + ], + )), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed(context, 'empDetails'); + }, + child: Text( + 'Back', + style: TextStyle(color: Color(0xFFE26728)), ), - SizedBox(height: 20), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Additional Premium', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), - ), - Text( - '₹3099/Year', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'GST', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), - ), - Text( - '₹557.82/-', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 5, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Total Payable', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), - ), - Text( - '₹3656.82/Year', - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - ], + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: BorderSide(color: Color(0xFFE26728)), + ), ), - ], + ), + )), + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + if (_gmcSiSwitcher == true && + _gmcDependentSwitcher == true) { + sendAddonsGmcSiToAPI(); + sendAddonsGmcDependentToAPI(); + Navigator.pushNamed( + context, 'empReviewDetails', + arguments: { + 'siData': [ + { + 'gmcAddOnSiPremiumValue': + gmcAddOnSiPremiumValue, + 'siPremiumGst': siPremiumGst, + 'siTotalAmt': siTotalAmt, + } + ], + 'dependentData': [ + { + 'gmcAddOnDependentPremiumValue': + gmcAddOnDependentPremiumValue, + 'dependentPremiumGst': + dependentPremiumGst, + 'dependentTotalAmt': + dependentTotalAmt, + } + ] + }); + } else if (_gmcSiSwitcher == true) { + sendAddonsGmcSiToAPI(); + Navigator.pushNamed( + context, 'empReviewDetails', + arguments: { + 'siData': [ + { + 'gmcAddOnSiPremiumValue': + gmcAddOnSiPremiumValue, + 'siPremiumGst': siPremiumGst, + 'siTotalAmt': siTotalAmt, + } + ], + 'dependentData': [] + }); + } else if (_gmcDependentSwitcher == true) { + sendAddonsGmcDependentToAPI(); + Navigator.pushNamed( + context, 'empReviewDetails', + arguments: { + 'siData': [], + 'dependentData': [ + { + 'gmcAddOnDependentPremiumValue': + gmcAddOnDependentPremiumValue, + 'dependentPremiumGst': + dependentPremiumGst, + 'dependentTotalAmt': + dependentTotalAmt, + } + ] + }); + } else { + Navigator.pushNamed( + context, 'empReviewDetails', + arguments: { + 'siData': [], + 'dependentData': [] + }); + } + }, + child: Text( + 'Continue ', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + ), )), ], ), - )), - SizedBox(height: 16), - Card( + ), + ), + ], + ), + ), + ), + ); + } + } + + void openForm(Map floaterData, action) { + print(action); + print(floaterData); + print(relationshipOptions); + print('test'); + dynamic popupName = floaterData['button_name']; + // Check if the action is 'Edit' + selectedRelationships = relationshipOptions + .where( + (option) => option['dependent'] == floaterData['form_type'], + ) + .toList(); + + print(selectedRelationships); + print(addOnsMappedFamilyFloatersDependent); + if (action == 'Add') { + print('Add'); + // Filter the addOnsMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true + dynamic getTrueObjects = addOnsMappedFamilyFloatersDependent + .where((element) => element['is_value_exist'] == true) + .toList(); + + print(getTrueObjects); + + List> getTrueDataObjects = getTrueObjects + .map>( + (element) => element['data'] as Map) + .toList(); + + print(getTrueDataObjects); + + List relationships = getTrueDataObjects.map((dataObject) { + return dataObject['relationship']; + }).toList(); + + // Print the list of relationship values + print(relationships); + + List> filteredDataObjects = + getTrueDataObjects.where((dataObject) { + // Check if the relationship value of dataObject is not found in selectedRelationships + return !selectedRelationships.any((selectedRelationship) => + selectedRelationship['relationship_name'] == + dataObject['relationship']); + }).toList(); + + // Print the filtered data objects + print(filteredDataObjects); + + print("Not matching objects: $filteredDataObjects"); + + // List> notMatchingObjects = []; + + // Iterate through dataObject array + // for (var data in getTrueDataObjects) { + // String relationship = data['relationship']; + // + // // Check if relationship value does not match any relationship_name value in selectedRelationships + // if (!selectedRelationships + // .any((element) => element['relationship_name'] != relationship)) { + // notMatchingObjects.add(data); + // } + // } + + // Print the not matching objects + // print("Not matching objects: $notMatchingObjects"); + } + + if (action == 'Edit') { + // Set values to all fields + _relationShipController.text = floaterData['relationship'] ?? ''; + _memberNameController.text = floaterData['name'] ?? ''; + _dobController.text = floaterData['dob'] ?? ''; + // Add more fields as needed + } + + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 800, + child: SingleChildScrollView( + child: Card( elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // Add padding to the container - child: Row( + child: Padding( + padding: EdgeInsets.all(30), + child: Column( children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed(context, 'empDetails'); - }, - child: Text( - 'Back', - style: TextStyle(color: Color(0xFFE26728)), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide(color: Color(0xFFE26728)), + Container( + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text(popupName ?? '', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFFE26728), + )), + ], + ), + ), ), - ), + ], ), - )), - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed( - context, 'empReviewDetails'); - }, - child: Text( - 'Continue', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), + SizedBox(height: 15), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 4, + child: Container( + width: 50, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Relationship', + labelText: 'Relationship', + contentPadding: + EdgeInsets.symmetric( + vertical: 5, horizontal: 5), + ), + value: action == 'Edit' + ? _relationShipController.text + : null, + onChanged: (value) { + _relationShipController.text = + value!; + }, + items: selectedRelationships + .map((relationship) { + final String relationshipName = + relationship[ + 'relationship_name'] ?? + ''; + return DropdownMenuItem( + value: relationshipName, + child: Text(relationshipName), + ); + }).toList(), + ), + ], + ), + ), ), - ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: TextFormField( + controller: _memberNameController, + onChanged: (value) => null, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Member Full Name', + labelText: 'Member Full Name', + contentPadding: + EdgeInsets.symmetric( + vertical: 10, + horizontal: 15), + ), + validator: (value) { + if (value == null || + value.isEmpty) { + return 'Member Full Name is required'; + } + return null; + }, + ), + ) + ], + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Container( + child: TextFormField( + controller: _dobController, + onTap: () { + _selectDate(context, + floaterData['form_type']); + }, + readOnly: true, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'DD-MM-YYYY', + labelText: 'Date of Birth', + suffixIcon: IconButton( + icon: + Icon(Icons.calendar_today), + onPressed: () { + // Open date picker when the icon is pressed + _selectDate( + context, + floaterData[ + 'form_type']); // Pass 'child' for child form type + }, + ), + contentPadding: + EdgeInsets.symmetric( + vertical: 10, + horizontal: 15, + ), + ), + ), + ) + ], + ), + ), + ), + ], ), - )), + SizedBox(height: 15), + Row( + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + // Close the dialog without sending data + cancelPopUp(); + Navigator.of(context).pop(); + }, + child: Text( + 'Cancel', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + // Create a map to hold the form data + Map formData = { + 'relationship': + _relationShipController.text, + 'memberName': + _memberNameController.text, + 'dateOfBirth': _dobController.text, + + // Add more form fields as needed + }; + + // Call the function to send form data to API + saveAddOnsDetails( + formData, floaterData, action); + + // Close the dialog + Navigator.of(context).pop(); + }, + child: Text( + 'Continue', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ], + ), + ), ], ), ), ), - ], + ), ), - ), - ), + ); + }, ); } } diff --git a/lib/customAppBar/customAppBar.dart b/lib/customAppBar/customAppBar.dart index f04702b..c943119 100644 --- a/lib/customAppBar/customAppBar.dart +++ b/lib/customAppBar/customAppBar.dart @@ -1,36 +1,64 @@ import 'package:flutter/material.dart'; import 'package:adaptive_navbar/adaptive_navbar.dart'; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:nhancepolicy/responsive.dart'; class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { @override Size get preferredSize => Size.fromHeight(kToolbarHeight); + Future logout(BuildContext context) async { + final prefs = await SharedPreferences.getInstance(); + final String? hrtoken = prefs.getString('hrtoken'); + final String? token = prefs.getString('token'); + + if (token != null && token.isNotEmpty) { + if (hrtoken != null && hrtoken.isNotEmpty) { + prefs.remove('token'); + Navigator.pushNamed(context, 'hrHome'); + } else { + await prefs.clear(); + Navigator.pushNamed(context, 'phone'); + } + } else if (hrtoken != null && hrtoken.isNotEmpty) { + await prefs.clear(); + Navigator.pushNamed(context, 'hrLogin'); + } + // Navigator.pushNamed(context, "phone"); + } + @override Widget build(BuildContext context) { final sw = MediaQuery.of(context).size.width; return Scaffold( - backgroundColor: Color(0xFF00989E), // Set background color for AppBar + backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar appBar: PreferredSize( preferredSize: preferredSize, child: SafeArea( child: Container( - padding: EdgeInsets.symmetric(horizontal: 16.0), + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric(horizontal: 16.0) + : EdgeInsets.symmetric(horizontal: 0), child: Row( children: [ // Logo Column Expanded( - flex: 3, + flex: Responsive.isDesktop(context) ? 3 : 9, child: Row( - mainAxisAlignment: MainAxisAlignment - .spaceEvenly, // Adjust the alignment as needed + mainAxisAlignment: Responsive.isDesktop(context) + ? MainAxisAlignment.spaceEvenly + : MainAxisAlignment + .start, // Adjust the alignment as needed children: [ Container( margin: EdgeInsets.only(top: 10, bottom: 10), width: 230, height: 230, child: Image.asset( - 'assets/Group_3.png', + 'assets/nhance_client_logo.png', fit: BoxFit.contain, // Adjust the fit as needed ), ), @@ -49,36 +77,45 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { ), // AdaptiveNavBar Column Expanded( - flex: 9, + flex: Responsive.isDesktop(context) ? 9 : 3, child: AdaptiveNavBar( screenWidth: sw, - backgroundColor: Color(0xFF00989E), + backgroundColor: Color(0xFFFFFCE5), leading: Container(), // Set an empty container as we have the logo separately title: Text(''), navBarItems: [ - NavBarItem( - text: "", - onTap: () { - Navigator.pushNamed(context, "routeName"); - }, - ), - NavBarItem( - text: "", - onTap: () { - Navigator.pushNamed(context, "routeName"); - }, - ), - NavBarItem( - text: "", - onTap: () { - Navigator.pushNamed(context, "routeName"); - }, - ), + if (Responsive.isDesktop(context)) + NavBarItem( + text: "", + onTap: () { + Navigator.pushNamed(context, "routeName"); + }, + ), + if (Responsive.isDesktop(context)) + NavBarItem( + text: "", + onTap: () { + Navigator.pushNamed(context, "routeName"); + }, + ), + if (Responsive.isDesktop(context)) + NavBarItem( + text: "", + onTap: () { + Navigator.pushNamed(context, "routeName"); + }, + ), NavBarItem( text: "Logout", - onTap: () { - Navigator.pushNamed(context, "phone"); + onTap: () async { + logout(context); + // Clear local storage (SharedPreferences) + // final prefs = await SharedPreferences.getInstance(); + // prefs.clear(); + // ToastHelper.showSuccessToast( + // context, 'Logout Successfully...'); + // Navigator.pushNamed(context, "phone"); }, ), ], diff --git a/lib/customAppBar/toastHelper.dart b/lib/customAppBar/toastHelper.dart index ec1a706..8221dd8 100644 --- a/lib/customAppBar/toastHelper.dart +++ b/lib/customAppBar/toastHelper.dart @@ -1,17 +1,212 @@ import 'package:flutter/material.dart'; // import 'package:fluttertoast/fluttertoast.dart'; +import 'package:toastification/toastification.dart'; class ToastHelper { static void showSuccessToast(BuildContext context, String message) { - _showToast(context, message, Colors.green); + toastification.show( + context: context, + type: ToastificationType.success, + style: ToastificationStyle.flatColored, + autoCloseDuration: const Duration(seconds: 2), + title: Text(message), + // you can also use RichText widget for title and description parameters + // description: RichText( + // text: const TextSpan(text: 'This is a sample toast message. ')), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 100), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: const Icon(Icons.check), + primaryColor: Colors.green, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); } static void showWarningToast(BuildContext context, String message) { - _showToast(context, message, Colors.orange); + toastification.show( + context: context, + type: ToastificationType.warning, + style: ToastificationStyle.flatColored, + autoCloseDuration: const Duration(seconds: 2), + title: Text(message), + // you can also use RichText widget for title and description parameters + // description: RichText( + // text: const TextSpan(text: 'This is a sample toast message. ')), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 100), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: const Icon(Icons.warning), + primaryColor: Colors.amberAccent, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); } static void showErrorToast(BuildContext context, String message) { - _showToast(context, message, Colors.red); + toastification.show( + context: context, + type: ToastificationType.error, + style: ToastificationStyle.flatColored, + autoCloseDuration: const Duration(seconds: 2), + title: Text(message), + // you can also use RichText widget for title and description parameters + // description: RichText( + // text: const TextSpan(text: 'This is a sample toast message. ')), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 100), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: const Icon(Icons.error), + primaryColor: Colors.redAccent, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); + // _showToast(context, message, Colors.red); + } + + static void showInfoToast(BuildContext context, String message) { + toastification.show( + context: context, + type: ToastificationType.info, + style: ToastificationStyle.flatColored, + autoCloseDuration: const Duration(seconds: 2), + title: Text(message), + // you can also use RichText widget for title and description parameters + // description: RichText( + // text: const TextSpan(text: 'This is a sample toast message. ')), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 100), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: const Icon(Icons.info), + primaryColor: Colors.lightBlue, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); + // _showToast(context, message, Colors.red); } static void _showToast(BuildContext context, String message, Color color) { diff --git a/lib/empDetails.dart b/lib/empDetails.dart index d66b5a2..b2d0029 100644 --- a/lib/empDetails.dart +++ b/lib/empDetails.dart @@ -1,6 +1,18 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'customAppBar/customAppBar.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/widgets.dart'; +import 'package:flutter/services.dart'; +import 'dart:convert'; +import 'package:intl/intl.dart'; +import 'dart:io'; +import 'dart:async'; +import 'package:nhancepolicy/responsive.dart'; class empDetails extends StatefulWidget { const empDetails({Key? key}) : super(key: key); @@ -10,756 +22,2056 @@ class empDetails extends StatefulWidget { } class _empDetailsState extends State { + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; + List> gpaPolicies = []; + dynamic gpaPolicyName; + dynamic gpaGridMaster; + dynamic gpasumInsured; + dynamic gpaClintPolicyId; + dynamic gpaSlabRates = []; + dynamic gpaMappedFamilyFloaters; + dynamic gpaSelfName; + dynamic gpaSelfDob; + dynamic gpaSelfRelationship; + dynamic gpaSelfDetails; + dynamic gmcSlabRates = []; + dynamic gmcMappedFamilyFloaters = []; + dynamic gmcSelfName; + dynamic gmcSelfDob; + dynamic gmcSelfRelationship; + dynamic gmcSelfDetails; + dynamic gmcPolicyName; + dynamic gmcNotes; + dynamic gmcGridMaster; + dynamic gmcSumInsured; + dynamic clientName; + dynamic clientLogo; + late TextEditingController _relationShipController; + late TextEditingController _dobController; + late TextEditingController _memberNameController; + late DateTime? selectedDate; + List> relationshipOptions = []; + List> selectedRelationships = []; + List> formDataList = []; + late DateTime _selectedDate = DateTime.now(); // Define _selectedDate here + dynamic mobileNumber; + dynamic selfRelationship; + dynamic selfName; + dynamic selfMobile; + dynamic selfDesignation; + dynamic selfDob; + dynamic selfDoj; + dynamic selfGender; + dynamic selfEmailCorporate; + dynamic selfEmailPersonal; + dynamic selfEmpCode; + dynamic selfFamilyFloaterKey; + @override void initState() { super.initState(); + _dobController = TextEditingController(); + _memberNameController = TextEditingController(); + _relationShipController = TextEditingController(); + // _loadToken(); + + Timer(Duration(seconds: 2), tokenAPI); } @override void dispose() { + _dobController.dispose(); + _memberNameController.dispose(); + _relationShipController.dispose(); super.dispose(); } + void tokenAPI() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + if (prefs.containsKey('hrtoken')) { + _hrLoadToken(); + } else { + _loadToken(); + } + } + + Future _hrLoadToken() async { + print('_hrLoadToken'); + // Retrieve the passed mobile number value + dynamic login_by_hr = true; + try { + final response = await http.post( + Uri.parse(Environment.apiUrl + 'getVerifiedUserData'), + body: json.encode({ + 'mobile_number': mobileNumber, + 'otp': 0, + 'login_by_hr': login_by_hr + }), + headers: { + HttpHeaders.contentTypeHeader: 'application/json', + }, + ); + + if (response.statusCode == 200) { + print('API Success'); + Map data = json.decode(response.body); + print(data); + String status = data['status']; + print(status); + if (status == 'success') { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('token', data['data']); + + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(data['data']); + print(decodedToken); + empCodeString = decodedToken['emp_code'].toString(); + prefs.setString('empCode', empCodeString); + empPrimaryId = decodedToken['id']; + prefs.setString('empPrimaryId', empPrimaryId); + gpaEmpName = decodedToken['name'].toString(); + prefs.setString('gpaEmpName', gpaEmpName); + client_id = decodedToken['client_id']; + prefs.setString('client_id', client_id); + + print('Successfully Login'); + + // Redirect to another page + final token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + getSelfEmployeeProfile(); + getClientLogoAndDetails(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + // Navigator.pushReplacementNamed(context, 'empDetails', + // arguments: {'mobile': ''}); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } + } else { + ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); + // Show a Snackbar if the OTP is invalid + // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); + print('Invalid OTP. Please try again'); + } + } else { + ToastHelper.showErrorToast(context, 'Failed to verify OTP'); + throw Exception('Failed to verify OTP'); + } + } catch (e) { + print('Error: $e'); + ToastHelper.showErrorToast( + context, 'Failed to verify OTP. Please try again.'); + // Show a Snackbar if there's an error while verifying OTP + // ToastHelper.showErrorToast( + // context, 'Failed to verify OTP. Please try again.'); + print('Failed to verify OTP. Please try again.'); + } + } + + Future _loadToken() async { + print('_loadToken'); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(token); + print(decodedToken); + empCodeString = prefs.getString('empCode'); + print(empCodeString); // Check if emp_code is correct + empPrimaryId = prefs.getString('empPrimaryId'); + gpaEmpName = prefs.getString('gpaEmpName'); + client_id = prefs.getString('client_id'); + print(client_id); + + // print(empPrimaryId); + // Call the API when the page enters + getSelfEmployeeProfile(); + getClientLogoAndDetails(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } + } + + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + // print('response.statusCode == 200'); + Map data = json.decode(response.body); + // print(data); + + if (data.containsKey('data')) { + setState(() { + dynamic clientDetails = data['data']; + // print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + }); + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getSelfEmployeeProfile() async { + var url = Uri.parse( + Environment.apiUrl + 'getEmployeeProfile?emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + // print('response.statusCode == 200'); + Map data = json.decode(response.body); + // print(data); + + if (data.containsKey('data')) { + setState(() { + dynamic selfDetails = data['data']; + print(selfDetails); + mobileNumber = selfDetails['relationship']; + selfRelationship = selfDetails['relationship']; + selfName = selfDetails['name']; + selfMobile = selfDetails['mobile']; + selfDesignation = selfDetails['designation']; + selfDob = selfDetails['dob']; + selfDoj = selfDetails['doj']; + selfGender = selfDetails['gender']; + selfEmailCorporate = selfDetails['email_corporate']; + selfEmailPersonal = selfDetails['email_personal']; + selfEmpCode = selfDetails['emp_code']; + selfFamilyFloaterKey = selfDetails['family_floater_key']; + // print(clientDetails); + }); + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGpaEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gpaPolicies = data['data']; + print(gpaPolicies); + // Assuming data is a List + print(gpaPolicies); + if (gpaPolicies.isNotEmpty) { + setState(() { + // You can use gpaPolicies as needed + print('GPA Policies found: $gpaPolicies'); + gpaPolicyName = gpaPolicies['Policy_Name'].toString(); + print(gpaPolicyName); + gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + print(gpasumInsured); + gpaMappedFamilyFloaters = + gpaPolicies['mapped_family_floaters']['data']; + print(gpaMappedFamilyFloaters); + gpaSelfName = gpaMappedFamilyFloaters['name'].toString(); + // gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile']; + gpaSelfDob = gpaMappedFamilyFloaters['dob'].toString(); + gpaSelfRelationship = + gpaMappedFamilyFloaters['relationship'].toString(); + gpaSelfDetails = gpaSelfRelationship + ' . ' + gpaSelfDob; + // gpaGridMaster = await gpaPolicies[0]['GridMaster']; + // gpaSlabRates = await gpaPolicies[0]['SlabRates']; + + // gpaClintPolicyId = await gpaPolicies[0]['ClientPolicyId']; + + // gpaSelectedSI = + // gpaMappedFamilyFloaters['basic_cover_si'].toString(); + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGmcEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('GMC response.statusCode == 200'); + Map data = json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gmcPolicies = data['data']; + print(gmcPolicies); + // Assuming data is a List + print(gmcPolicies); + if (gmcPolicies.isNotEmpty) { + setState(() { + print('GPM Policies found: $gmcPolicies'); + gmcPolicyName = gmcPolicies['Policy_Name'].toString(); + print(gmcPolicyName); + gmcNotes = gmcPolicies['notes'].toString(); + gmcSumInsured = + gmcPolicies['Policy_Terms']['sum_insured'].toString(); + print(gmcSumInsured); + print('gmcMappedFamilyFloaters'); + gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; + print('gmcMappedFamilyFloaters'); + print(gmcMappedFamilyFloaters); + }); + gmcMappedFamilyFloaters = + await gmcPolicies['mapped_family_floaters']; + print(gmcMappedFamilyFloaters); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future fetchRelationshipList() async { + // Replace the URL with your API endpoint + final url = Uri.parse(Environment.apiUrl + 'relationshipList'); + try { + final response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + final List data = jsonDecode(response.body)['data']; + for (var item in data) { + String relationshipName = item['relationship_name']; + String dependent = item['dependent']; + + relationshipOptions.add({ + 'relationship_name': relationshipName, + 'dependent': dependent, + }); + } + // final List relationships = + // List.from(data.map((item) => item['relationship_name'])); + // setState(() { + // relationshipOptions = relationships; + // }); + } else { + throw Exception('Failed to fetch relationship list'); + } + } catch (error) { + // ToastHelper.showErrorToast( + // context, 'Error fetching relationship list: $error'); + print('Error fetching relationship list: $error'); + // Handle error accordingly, e.g., show a snackbar with an error message + } + } + + Future _selectDate(BuildContext context, [String? formType]) async { + late DateTime minDate; + late DateTime maxDate; + + final DateTime now = DateTime.now(); + + if (formType == 'child') { + // For 'child' form type, allow 0-25 age + minDate = DateTime(now.year - 25, now.month, now.day); + maxDate = now; + } else { + // For other form types, allow 18-100 age + minDate = DateTime(1900); + maxDate = DateTime(now.year - 18, now.month, now.day); + } + + // Ensure initialDate is within the range of minDate and maxDate + DateTime initialDate = + _selectedDate ?? maxDate; // Use maxDate if _selectedDate is null + initialDate = initialDate.isBefore(minDate) ? minDate : initialDate; + initialDate = initialDate.isAfter(maxDate) ? maxDate : initialDate; + + final DateTime? picked = await showDatePicker( + context: context, + initialDate: initialDate, + firstDate: minDate, + lastDate: maxDate, + selectableDayPredicate: (DateTime date) { + return date.isAfter(minDate.subtract(const Duration(days: 1))) && + date.isBefore(maxDate.add(const Duration(days: 1))); + }, + ); + + if (picked != null && picked != _selectedDate) { + setState(() { + _selectedDate = picked; + _dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate); + }); + } + } + + Future deleteItem(Map deletedItem) async { + print(deletedItem); + // Define your API endpoint + var id = deletedItem['employee_id']; + final String apiUrl = Environment.apiUrl + 'deleteDependence?id=$id'; + + try { + // Make the DELETE request to the API endpoint + final http.Response response = await http.get( + Uri.parse(apiUrl), + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + + // Check if the request was successful (status code 200) + if (response.statusCode == 200) { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + relationshipOptions.clear(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + ToastHelper.showSuccessToast(context, 'Item deleted successfully'); + print('Item deleted successfully'); + } else { + // Handle errors + ToastHelper.showErrorToast(context, + 'Failed to delete item. Status code: ${response.statusCode}'); + print('Failed to delete item. Status code: ${response.statusCode}'); + print('Response body: ${response.body}'); + } + } catch (error) { + // Handle network errors + print('Error deleting item: $error'); + } + } + + void saveFamilyMemberDetails(Map formData, + Map floatedData, action) async { + // Construct the array of objects + print(formData); + print(floatedData); + print(action); + formDataList.add({ + 'relationship': formData['relationship'], + 'name': formData['memberName'], + 'dob': formData['dateOfBirth'], + 'emp_code': empCodeString, + 'client_id': client_id, + 'client_policy_id': floatedData['client_policy_id'], + // Add the 'id' field only if action is 'Edit' + if (action == 'Edit') 'id': floatedData['employee_id'], + }); + + // Convert the list of objects to JSON + String formDataJson = jsonEncode(formDataList); + + // Prepare the API request + var url = Uri.parse(Environment.apiUrl + 'addEmployeeAndDependence'); + var response = await http.post( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + body: formDataJson, + ); + + // Check the response + if (response.statusCode == 200) { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + relationshipOptions.clear(); + // Request successful, handle response + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + fetchRelationshipList(); + ToastHelper.showSuccessToast(context, 'Saved Successfully.'); + print('Form data sent successfully.'); + } else { + // Request failed, handle error + ToastHelper.showErrorToast( + context, 'Failed to send form data. Error: ${response.reasonPhrase}'); + print('Failed to send form data. Error: ${response.reasonPhrase}'); + } + } + + void cancelPopUp() { + formDataList.clear(); + selectedRelationships.clear(); + _relationShipController.clear(); + _memberNameController.clear(); + _dobController.clear(); + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: CustomAppBar(), - body: SingleChildScrollView( - child: Container( - padding: EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.1, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding - ), - color: Color(0xFFEFF3F6), - child: Column( - children: [ - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.asset( - 'assets/Group.png', - width: 80, // Set the width of the image - height: 80, // Set the height of the image - fit: BoxFit.contain, // Adjust the fit as needed - ), - )), - Expanded( - flex: 6, - child: Text( - 'Bharti Airtel', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ) - ], - ), - ), + dynamic arguments = ModalRoute.of(context)!.settings.arguments; + + if (arguments != null && arguments is Map) { + if (arguments.containsKey('mobile')) { + mobileNumber = arguments["mobile"]; + // Call your tokenAPI or _loadToken function here + print("_hrLoadToken"); + // _hrLoadToken(); + } + } else { + print("Arguments are null or not in the expected format"); + // _loadToken(); + mobileNumber = ''; + } + if (gmcMappedFamilyFloaters == [] && gmcMappedFamilyFloaters == null) { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], ), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 10), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 10, right: 10), - child: Text( - 'This is a floater sum insured. A floater is a type ot sum insured that provides coverage to more than one member ot a tamily at the same time. Simply put, its a single insurance cover tor the entire family.', - style: TextStyle( - fontSize: 14, - color: Color(0xFF727272), - )), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - color: Color( - 0xFFF9F9FB), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Please Note', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - Text( - 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF000000), // Set border color - width: 1, // Set border width + ), + )); + } else { + List familyFloaterContainers = []; + for (var floater in gmcMappedFamilyFloaters) { + bool isValueExist = floater['is_value_exist']; + Map floaterData = floater['data']; + + if (isValueExist) { + familyFloaterContainers.add( + Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(15) + : EdgeInsets.only(top: 8, bottom: 8, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(10) + : EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF00989E), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.account_circle, + color: Colors.white, + size: 32, ), - // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all( - 10), // Padding around the icon - decoration: BoxDecoration( - color: Color( - 0xFF00989E), // Background color of the icon container - borderRadius: BorderRadius.circular( - 5), // Radius of the container - ), - child: Icon( - Icons.account_circle, // Icon data - color: Colors.white, - size: 32, // Color of the icon - ), - ), - ], - ))), - Expanded( - flex: 9, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Employee', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - Text( - 'Self • 6565656565 • 22/10/1997', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'View', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 16, - color: Color(0xFFE26728), - ), - ), - ], - ))), - ], - ), - ), - ], + ], + ), ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 10), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 10, right: 10), - child: Text( - 'This is a floater sum insured. A floater is a type ot sum insured that provides coverage to more than one member ot a tamily at the same time. Simply put, its a single insurance cover tor the entire family.', - style: TextStyle( - fontSize: 14, - color: Color(0xFF727272), - )), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - color: Color( - 0xFFF9F9FB), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Please Note', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - Text( - 'Can add Employee + Spouse + 2 dependent children', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Text('Please review your enrolled dependents.', - style: TextStyle( - fontSize: 18, - color: Color(0xFF727272), - fontWeight: FontWeight.w500, - )), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF000000), // Set border color - width: 1, // Set border width + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 0), + Expanded( + flex: Responsive.isDesktop(context) ? 9 : 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['name'] ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 18 : 16, + fontWeight: FontWeight.w600, ), - // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all( - 10), // Padding around the icon - decoration: BoxDecoration( - color: Color( - 0xFF00989E), // Background color of the icon container - borderRadius: BorderRadius.circular( - 5), // Radius of the container - ), - child: Icon( - Icons.account_circle, // Icon data - color: Colors.white, - size: 32, // Color of the icon - ), - ), - ], - ))), - Expanded( - flex: 9, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Employee', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - Text( - 'Self • DOB - 22/10/1997', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'View', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 16, - color: Color(0xFFE26728), - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF000000), // Set border color - width: 1, // Set border width + Text( + '${floaterData['relationship']} - ${floaterData['dob']}', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 18 : 16, ), - // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all( - 10), // Padding around the icon - decoration: BoxDecoration( - color: Color( - 0xFF00989E), // Background color of the icon container - borderRadius: BorderRadius.circular( - 5), // Radius of the container - ), - child: Icon( - Icons.account_circle, // Icon data - color: Colors.white, - size: 32, // Color of the icon - ), - ), - ], - ))), - Expanded( - flex: 8, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Spouse Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - ), - ), - Text( - 'Spouse • DOB - 22/10/1999', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - ], - ))), - Expanded( - flex: 1, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Delete', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 16, - color: Color(0xFFE26728), - ), - ), - ], - ))), - Expanded( - flex: 1, - child: Container( - alignment: Alignment.topRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'View', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 16, - color: Color(0xFFE26728), - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF000000), // Set border color - width: 1, // Set border width - ), - // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.all( - 5), // Padding around the icon - decoration: BoxDecoration( - color: Color( - 0xFF6A6A6A), // Background color of the icon container - borderRadius: BorderRadius.circular( - 5), // Radius of the container - ), - child: Icon( - Icons.person_add, // Icon data - color: Colors.white, - size: 20, // Color of the icon - ), - ), - ], - ))), - Expanded( - flex: 11, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add Child', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.w500, - ), - ), - ], - ))), - ], - ), - ), - ], + ], + ), ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 12, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed(context, 'addOnsDetails'); + ), + if (isValueExist && floaterData['relationship'] != 'Self') + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + deleteItem(floaterData); + }, + child: Text( + 'Delete', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 16 : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ), + ), + ), + Expanded( + flex: + (isValueExist && floaterData['relationship'] != 'Self') + ? Responsive.isDesktop(context) + ? 1 + : 2 + : Responsive.isDesktop(context) + ? 2 + : 4, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + if (floaterData['relationship'] == 'Self') { + openSelfForm('View'); + } else { + openForm(floaterData, 'Edit'); + } }, child: Text( - 'Continue', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), + floaterData['relationship'] == 'Self' + ? 'View' + : 'Edit', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 16 : 15, + color: Color( + 0xFFE26728), // Add underline decoration ), ), ), - )), + ) + ], + ), + ), + ), + ], + ), + ), + ); + } else { + familyFloaterContainers.add(MouseRegion( + cursor: SystemMouseCursors.click, // Set cursor to pointer + child: GestureDetector( + onTap: () { + // Handle the click event to open the form + openForm(floaterData, 'Add'); + }, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), + width: 1, + ), + borderRadius: BorderRadius.circular(5), + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(12) + : EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 4, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFF6A6A6A), + borderRadius: BorderRadius.circular(5), + ), + child: Icon( + Icons.person_add, + color: Colors.white, + size: 20, + ), + ), + ], + ), + ), + ), + SizedBox(width: Responsive.isDesktop(context) ? 5 : 10), + Expanded( + flex: Responsive.isDesktop(context) ? 11 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + floaterData['button_name'] ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 22 : 18, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ], + ), + ), // Replace YourChildWidget with the widget you want to wrap + ), + )); + } + familyFloaterContainers.add(SizedBox(height: 15)); + } + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 3, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo, + width: Responsive.isDesktop(context) + ? 80 + : 50, // Set the width here + height: Responsive.isDesktop(context) + ? 80 + : 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: + loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + ), + )), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, + ), + ), + ) + ], + ), + ), + ), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gpaPolicyName ?? 'NA', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Personal Accident Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 10), + Container( + padding: EdgeInsets.only( + top: 0, bottom: 0, left: 10, right: 10), + child: Text( + 'This is a floater sum insured. A floater is a type ot sum insured that provides coverage to more than one member ot a tamily at the same time. Simply put, its a single insurance cover tor the entire family.', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 14 : 11, + color: Color(0xFF727272), + )), + ), + SizedBox( + height: Responsive.isDesktop(context) ? 15 : 15), + // Container( + // decoration: BoxDecoration( + // color: Color( + // 0xFFF9F9FB), // Set background color for the container + // borderRadius: BorderRadius.circular( + // 5), // Set border radius for the container + // ), + // padding: EdgeInsets.only( + // top: 15, bottom: 15, left: 25, right: 25), + // child: Row( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Expanded( + // flex: 12, + // child: Container( + // alignment: Alignment.centerLeft, + // child: Column( + // mainAxisAlignment: + // MainAxisAlignment.start, + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Text( + // 'Please Note', + // textAlign: TextAlign.left, + // style: TextStyle( + // fontSize: 18, + // fontWeight: FontWeight.w600, + // ), + // ), + // Text( + // 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', + // textAlign: TextAlign.left, + // style: TextStyle( + // fontSize: 18, + // ), + // ), + // ], + // ))), + // ], + // ), + // ), + Container( + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFF000000), // Set border color + width: 1, // Set border width + ), + // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 8, bottom: 8, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 1 : 2, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: Responsive.isDesktop( + context) + ? EdgeInsets.all(10) + : EdgeInsets.all( + 5), // Padding around the icon + decoration: BoxDecoration( + color: Color( + 0xFF00989E), // Background color of the icon container + borderRadius: BorderRadius.circular( + 5), // Radius of the container + ), + child: Icon( + Icons + .account_circle, // Icon data + color: Colors.white, + size: 32, // Color of the icon + ), + ), + ], + ))), + Expanded( + flex: Responsive.isDesktop(context) ? 9 : 8, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gpaSelfName ?? 'NA', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 16, + fontWeight: FontWeight.w600, + ), + ), + Text( + gpaSelfDetails ?? 'NA', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 16, + ), + ), + ], + ))), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.topRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + openSelfForm('View'); + }, + child: Text( + 'View', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop( + context) + ? 16 + : 15, + color: Color( + 0xFFE26728), // Add underline decoration + ), + ), + ), + ) + ], + ))), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? 'NA', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 10), + Container( + padding: EdgeInsets.only( + top: 0, bottom: 0, left: 10, right: 10), + child: Text( + 'This is a floater sum insured. A floater is a type ot sum insured that provides coverage to more than one member ot a tamily at the same time. Simply put, its a single insurance cover tor the entire family.', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) ? 14 : 11, + color: Color(0xFF727272), + )), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: Color( + 0xFFF9F9FB), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Please Note', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + fontWeight: FontWeight.w600, + ), + ), + Text( + gmcNotes ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 15, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15), + child: + Text('Please review your enrolled dependents.', + style: TextStyle( + fontSize: Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w500, + )), + ), + SizedBox(height: 15), + Column( + children: familyFloaterContainers, + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed(context, 'addOnsDetails'); + }, + child: Text( + 'Continue', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } + } + + void openForm(Map floaterData, action) { + print(action); + print(floaterData); + print(relationshipOptions); + print('test'); + // Check if the action is 'Edit' + dynamic popupName = floaterData['button_name']; + + selectedRelationships = relationshipOptions + .where( + (option) => option['dependent'] == floaterData['form_type'], + ) + .toList(); + + print(selectedRelationships); + if (action == 'Edit') { + // Set values to all fields + _relationShipController.text = floaterData['relationship'] ?? ''; + _memberNameController.text = floaterData['name'] ?? ''; + _dobController.text = floaterData['dob'] ?? ''; + // Add more fields as needed + } + + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + elevation: 0, + backgroundColor: Colors.transparent, + content: SizedBox( + width: Responsive.isDesktop(context) ? 500 : 800, + child: SingleChildScrollView( + child: Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(15), + child: Column( + children: [ + Container( + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text(popupName ?? '', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFFE26728), + )), + ], + ), + ), + ), + ], + ), + SizedBox(height: 15), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + DropdownButtonFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Relationship', + labelText: 'Relationship', + contentPadding: EdgeInsets.symmetric( + vertical: 5, horizontal: 5), + ), + value: action == 'Edit' + ? _relationShipController.text + : null, + onChanged: (value) { + _relationShipController.text = value!; + }, + items: selectedRelationships + .map((relationship) { + final String relationshipName = + relationship[ + 'relationship_name'] ?? + ''; + return DropdownMenuItem( + value: relationshipName, + child: Text(relationshipName), + ); + }).toList(), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + width: double.infinity, + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: TextFormField( + controller: _memberNameController, + onChanged: (value) => null, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Member Full Name', + labelText: 'Member Full Name', + contentPadding: + EdgeInsets.symmetric( + vertical: 10, + horizontal: 15), + ), + validator: (value) { + if (value == null || + value.isEmpty) { + return 'Member Full Name is required'; + } + return null; + }, + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + width: double.infinity, + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + child: TextFormField( + controller: _dobController, + onTap: () { + _selectDate(context, + floaterData['form_type']); + }, + readOnly: true, + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'DD-MM-YYYY', + labelText: 'Date of Birth', + suffixIcon: IconButton( + icon: Icon(Icons.calendar_today), + onPressed: () { + _selectDate(context, + floaterData['form_type']); + }, + ), + contentPadding: + EdgeInsets.symmetric( + vertical: 10, + horizontal: 15, + ), + ), + ), + ), + ], + ), + ), + ], + ), + SizedBox(height: 15), + Row( + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + // Close the dialog without sending data + cancelPopUp(); + Navigator.of(context).pop(); + }, + child: Text( + 'Cancel', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + // Create a map to hold the form data + Map formData = { + 'relationship': + _relationShipController.text, + 'memberName': + _memberNameController.text, + 'dateOfBirth': _dobController.text, + + // Add more form fields as needed + }; + + // Call the function to send form data to API + saveFamilyMemberDetails( + formData, floaterData, action); + + // Close the dialog + Navigator.of(context).pop(); + }, + child: Text( + 'Save', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ], + ), + ), ], ), ), ), - ], + ), ), - ), - ), + ); + }, + ); + } + + void openSelfForm(action) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + elevation: 0, + backgroundColor: Colors.transparent, + content: SizedBox( + width: Responsive.isDesktop(context) ? 1000 : 800, + child: SingleChildScrollView( + child: Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(15), + child: Column( + children: [ + Container( + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text('Self Details', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFFE26728), + )), + ], + ), + ), + ), + ], + ), + SizedBox(height: 20), + if (Responsive.isDesktop(context)) + Row( + children: [ + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfEmpCode ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Employee ID', + labelText: 'Employee ID', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfName ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Employee Name', + labelText: 'Employee Name', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfRelationship ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Relationship', + labelText: 'Relationship', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + ], + ), + SizedBox( + height: Responsive.isDesktop(context) ? 30 : 0), + if (Responsive.isDesktop(context)) + Row( + children: [ + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfMobile ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Mobile No', + labelText: 'Mobile No', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfEmailPersonal ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Email personal', + labelText: 'Email personal', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfEmailCorporate ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Email Corporate', + labelText: 'Email Corporate', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + ], + ), + SizedBox( + height: Responsive.isDesktop(context) ? 30 : 0), + if (Responsive.isDesktop(context)) + Row( + children: [ + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: + selfGender == 'M' ? 'Male' : 'Female', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Gender', + labelText: 'Gender', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfDob ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Date of Birth', + labelText: 'Date of Birth', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + SizedBox(width: 10), + Expanded( + flex: 4, + child: TextFormField( + readOnly: true, + initialValue: selfDoj ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Date of Joining', + labelText: 'Date of Joining', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ), + ], + ), + SizedBox( + height: Responsive.isDesktop(context) ? 30 : 0), + if (!Responsive.isDesktop(context)) + ListView(shrinkWrap: true, children: [ + TextFormField( + readOnly: true, + initialValue: selfEmpCode ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Employee ID', + labelText: 'Employee ID', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfName ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Employee Name', + labelText: 'Employee Name', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfRelationship ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Relationship', + labelText: 'Relationship', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfMobile ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Mobile No', + labelText: 'Mobile No', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfEmailPersonal ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Email personal', + labelText: 'Email personal', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfEmailCorporate ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Email Corporate', + labelText: 'Email Corporate', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: + selfGender == 'M' ? 'Male' : 'Female', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Gender', + labelText: 'Gender', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfDob ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Date of Birth', + labelText: 'Date of Birth', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + SizedBox(height: 15), + TextFormField( + readOnly: true, + initialValue: selfDoj ?? '', + decoration: InputDecoration( + border: OutlineInputBorder(), + hintText: 'Date of Joining', + labelText: 'Date of Joining', + contentPadding: EdgeInsets.symmetric( + vertical: 10, horizontal: 15), + ), + ), + ]), + SizedBox(height: 15), + Row( + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text( + 'Close', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + ); + }, ); } } diff --git a/lib/empReview.dart b/lib/empReview.dart index cd10303..e87bf2a 100644 --- a/lib/empReview.dart +++ b/lib/empReview.dart @@ -1,6 +1,15 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; +import 'package:nhancepolicy/models/environment.dart'; +import 'package:nhancepolicy/responsive.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'customAppBar/customAppBar.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/widgets.dart'; +import 'package:flutter/services.dart'; +import 'dart:convert'; class empReviewDetails extends StatefulWidget { const empReviewDetails({Key? key}) : super(key: key); @@ -11,10 +20,60 @@ class empReviewDetails extends StatefulWidget { class _empReviewDetailsState extends State { bool isChecked = false; // Declare the _isSwitched variable here + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; + List> gpaPolicies = []; + dynamic gpaPolicyName; + dynamic gpaGridMaster; + dynamic gpasumInsured; + dynamic gpaClintPolicyId; + dynamic gpaMappedFamilyFloaters; + dynamic gpaSelfName; + dynamic gpaSelfDob; + dynamic gpaSelfRelationship; + dynamic gpaSelfDetails; + dynamic gmcMappedFamilyFloaters = []; + dynamic gmcSelfName; + dynamic gmcSelfDob; + dynamic gmcSelfRelationship; + dynamic gmcSelfDetails; + dynamic gmcPolicyName; + dynamic gmcNotes; + dynamic gmcSumInsured; + dynamic clientName; + dynamic clientLogo; + dynamic addOnsMappedFamilyFloatersSi; + dynamic addOnsMappedFamilyFloatersDependent; + dynamic addOnsClientPolicyId; + dynamic addOnsSlabRates; + dynamic gmcAddOnsselectedSI; + dynamic gmcAddOnsselectedDependent; + dynamic dependentValue; + dynamic siValue; + dynamic gmcAddOnDependentPremiumValue; + dynamic gmcAddOnSiPremiumValue; + dynamic addOnsSumInsured; + dynamic dependentPremiumGst; + dynamic siPremiumGst; + dynamic addOnsPolicyName; + dynamic dependentTotalAmt; + dynamic siTotalAmt; + dynamic addOnsFamilyFloater; + late DateTime? selectedDate; + dynamic totalPayableAmt; + List> relationshipOptions = []; + List> selectedRelationships = []; + List> formDataList = []; + dynamic activeSiData; + dynamic activeDependentData; @override void initState() { super.initState(); + _loadToken(); } @override @@ -22,885 +81,1591 @@ class _empReviewDetailsState extends State { super.dispose(); } + Future _loadToken() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + + empCodeString = prefs.getString('empCode'); + print(empCodeString); // Check if emp_code is correct + empPrimaryId = prefs.getString('empPrimaryId'); + gpaEmpName = prefs.getString('gpaEmpName'); + client_id = prefs.getString('client_id'); + print(client_id); + + // print(empPrimaryId); + // Call the API when the page enters + getClientLogoAndDetails(); + getAddOnsEmpPolicyDetails(); + getGpaEmpPolicyDetails(empPrimaryId); + getGmcEmpPolicyDetails(empPrimaryId); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } + } + + Future getClientLogoAndDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getClientDetails?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = await json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic clientDetails = data['data']; + print(clientDetails); + clientName = clientDetails['client']['client_name']; + print(clientName); + clientLogo = clientDetails['client']['client_logo']; + print(clientLogo); + } else { + // Handle other status messages if needed + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGpaEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GPA'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = await json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gpaPolicies = data['data']; + print(gpaPolicies); + // Assuming data is a List + print(gpaPolicies); + if (gpaPolicies.isNotEmpty) { + setState(() { + // You can use gpaPolicies as needed + print('GPA Policies found: $gpaPolicies'); + gpaPolicyName = gpaPolicies['Policy_Name']; + print(gpaPolicyName); + gpasumInsured = gpaPolicies['Policy_Terms']['sumInsured2']; + print(gpasumInsured); + gpaMappedFamilyFloaters = + gpaPolicies['mapped_family_floaters']['data']; + print(gpaMappedFamilyFloaters); + gpaSelfName = gpaMappedFamilyFloaters['name']; + // gpaSelfMobileNo = gpaMappedFamilyFloaters['mobile']; + gpaSelfDob = gpaMappedFamilyFloaters['dob']; + gpaSelfRelationship = gpaMappedFamilyFloaters['relationship']; + gpaSelfDetails = gpaSelfName + + ' - ' + + gpaSelfRelationship + + ' - ' + + gpaSelfDob; + // gpaGridMaster = await gpaPolicies[0]['GridMaster']; + // gpaSlabRates = await gpaPolicies[0]['SlabRates']; + + // gpaClintPolicyId = await gpaPolicies[0]['ClientPolicyId']; + + // gpaSelectedSI = + // gpaMappedFamilyFloaters['basic_cover_si'].toString(); + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getGmcEmpPolicyDetails(empPrimaryId) async { + var url = Uri.parse(Environment.apiUrl + + 'getEmployeePolicy?id=$empPrimaryId&emp_code=$empCodeString&policy=GMC'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = await json.decode(response.body); + print(data); + + if (data.containsKey('data')) { + dynamic gmcPolicies = data['data']; + print(gmcPolicies); + // Assuming data is a List + print(gmcPolicies); + if (gmcPolicies.isNotEmpty) { + setState(() { + print('GPM Policies found: $gmcPolicies'); + gmcPolicyName = gmcPolicies['Policy_Name']; + print(gmcPolicyName); + gmcNotes = gmcPolicies['notes']; + gmcSumInsured = gmcPolicies['Policy_Terms']['sum_insured']; + print(gmcSumInsured); + + gmcMappedFamilyFloaters = gmcPolicies['mapped_family_floaters']; + print(gmcMappedFamilyFloaters); + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future getAddOnsEmpPolicyDetails() async { + var url = Uri.parse(Environment.apiUrl + + 'getAddOnPolicy?client_id=$client_id&emp_code=$empCodeString'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + Map data = await json.decode(response.body); + print('222222222'); + print(data); + + if (data.containsKey('data')) { + dynamic addOnsPolicies = data['data']; + print(addOnsPolicies); + if (addOnsPolicies.isNotEmpty) { + setState(() { + addOnsClientPolicyId = + addOnsPolicies['addon_policy']['client_policy_id']; + print('AddonS'); + addOnsSumInsured = + addOnsPolicies['addon_policy']['policy_terms']['sum_insured']; + print(addOnsSumInsured); + + addOnsPolicyName = addOnsPolicies['addon_policy']['policy_name']; + print(addOnsPolicyName); + + addOnsMappedFamilyFloatersSi = addOnsPolicies['addon_policy'] + ['family_floaters_of_only_si_array']; + print('addOnsMappedFamilyFloatersSi'); + print(addOnsMappedFamilyFloatersSi); + + addOnsMappedFamilyFloatersDependent = + addOnsPolicies['addon_policy'] + ['family_floaters_of_dependent_and_si_array']; + print('addOnsMappedFamilyFloatersDependent'); + print(addOnsMappedFamilyFloatersDependent); + }); + } else { + ToastHelper.showErrorToast( + context, 'No data found in the response'); + print('No data found in the response'); + } + } else { + // Handle other status messages if needed + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + + Future sendAddOnAPI() async { + var url = Uri.parse(Environment.apiUrl + + 'iAgreeForAddOn?emp_code=$empCodeString&client_policy_id=$addOnsClientPolicyId&client_id=$client_id'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': + 'Bearer $_token', // Add token to the Authorization header + }, + ); + if (response.statusCode == 200) { + print('response.statusCode == 200'); + ToastHelper.showSuccessToast(context, 'Saved Successfully...'); + } else { + // Handle other status codes + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + // Handle exceptions + print('Exception occurred: $e'); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: CustomAppBar(), - body: SingleChildScrollView( - child: Container( - padding: EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.1, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding - ), - color: Color(0xFFEFF3F6), - child: Column( - children: [ - Card( - elevation: 0, - child: Container( - width: double.infinity, - height: 75, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // Add padding to the container - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerLeft, - child: Image.asset( - 'assets/Group.png', - width: 80, // Set the width of the image - height: 80, // Set the height of the image - fit: BoxFit.contain, // Adjust the fit as needed + dynamic arguments = ModalRoute.of(context)!.settings.arguments; + + if (arguments != null && arguments is Map) { + if (arguments.containsKey('siData') || + arguments.containsKey('dependentData')) { + print('siData'); + final List? siData = arguments['siData']; + print(siData); + if (siData != null && siData.isNotEmpty) { + gmcAddOnSiPremiumValue = siData[0]['gmcAddOnSiPremiumValue']; + siPremiumGst = siData[0]['siPremiumGst']; + siTotalAmt = siData[0]['siTotalAmt']; + activeSiData = '0'; + } else { + // Handle empty siData list + gmcAddOnSiPremiumValue = 'NA'; + siPremiumGst = 'NA'; + siTotalAmt = 'NA'; + activeSiData = '1'; + } + + print('dependentData'); + final List? dependentData = arguments['dependentData']; + print(dependentData); + if (dependentData != null && dependentData.isNotEmpty) { + gmcAddOnDependentPremiumValue = + dependentData[0]['gmcAddOnDependentPremiumValue'] ?? 'NA'; + dependentPremiumGst = dependentData[0]['dependentPremiumGst'] ?? 'NA'; + dependentTotalAmt = dependentData[0]['dependentTotalAmt'] ?? 'NA'; + activeDependentData = '0'; + } else { + // Handle empty dependentData list + gmcAddOnDependentPremiumValue = 'NA'; + dependentPremiumGst = 'NA'; + dependentTotalAmt = 'NA'; + activeDependentData = '1'; + } + if (dependentTotalAmt != 'NA' && siTotalAmt != 'NA') { + totalPayableAmt = dependentTotalAmt + siTotalAmt; + } else if (dependentTotalAmt == 'NA') { + totalPayableAmt = siTotalAmt; + } else if (siTotalAmt == 'NA') { + totalPayableAmt = dependentTotalAmt; + } else { + totalPayableAmt = 'NA'; + } + } + } else { + print("Arguments are null or not in the expected format"); + gmcAddOnDependentPremiumValue = 'NA'; + dependentPremiumGst = 'NA'; + dependentTotalAmt = 'NA'; + totalPayableAmt = 'NA'; + } + + if (gmcMappedFamilyFloaters == []) { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], + ), + ), + )); + } else { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Card( + elevation: 0, + child: Container( + width: double.infinity, + height: 75, + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, bottom: 20, left: 30, right: 30) + : EdgeInsets.only( + top: 12, + bottom: 12, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 3, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerLeft, + child: Image.network( + clientLogo, + width: Responsive.isDesktop(context) + ? 80 + : 50, // Set the width here + height: Responsive.isDesktop(context) + ? 80 + : 80, // Set the height here + loadingBuilder: (BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: + loadingProgress.expectedTotalBytes != + null + ? loadingProgress + .cumulativeBytesLoaded / + loadingProgress + .expectedTotalBytes! + : null, + ), + ); + }, + ), + )), + Expanded( + flex: 9, + child: Text( + clientName ?? '', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop(context) ? 20 : 18, + fontWeight: FontWeight.w600, ), - )), - Expanded( - flex: 6, - child: Text( - 'Bharti Airtel', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, ), - ), - ) - ], + ) + ], + ), ), ), - ), - SizedBox(height: 16), - Card( - elevation: 0, - child: Container( - width: double.infinity, - padding: EdgeInsets.only( - top: 20, - bottom: 20, - left: 30, - right: 30), // 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: TextStyle( - fontSize: 20, - color: Color(0xFF181818), - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - Row( - children: [ - Expanded( - flex: 2, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Total Payable', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - color: Color(0xFF181818), - ), - ), - ], - ))), - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - '₹6016.82/Year ', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 22, - color: Color(0xFFE26728), - fontWeight: FontWeight.w500, - ), - ), - ], - ))), - ], - ), - ])), - ), - SizedBox(height: 16), - Card( + SizedBox(height: 16), + Card( elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Personal Accident Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Employee Name • Self • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Plan Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Medical Coverage', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Employee Name • Self • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Spouse Name • Spouse • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Sons Name • Son • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Daughters Name • Daughter • DOB - 22/10/1997', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - child: Column( - children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Add Ons', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - 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: EdgeInsets.only( - top: 15, bottom: 15, left: 25, right: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - 'Addon Name', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - 'Group Medical Coverage - Add Parents', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'Floater Sum Insured', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - ), - ), - Text( - '₹ 3,00,000', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - padding: EdgeInsets.only( - top: 0, bottom: 0, left: 15, right: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Fathers Name • Father • DOB - 19/08/1948', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.arrow_right, - color: Color(0xFFE26728)), // Arrow icon - SizedBox( - width: 10), // Space between icon and text - Expanded( - child: Text( - 'Mothers Name • Mother • DOB - 19/08/1950', - style: TextStyle( - fontSize: 18, - color: Color(0xFF232526), - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - )), - SizedBox(height: 16), - Card( - elevation: 0, - child: Padding( - padding: EdgeInsets.all(30), - child: Column( - children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment - .centerLeft, // Adjust padding as needed - child: Table( - columnWidths: { - 0: FlexColumnWidth( - 2), // Adjust column width as needed - 1: FlexColumnWidth(2), - }, + 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: [ - TableRow( - children: [ - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'Premium Summary', - textAlign: TextAlign.start, - style: TextStyle( - fontWeight: - FontWeight.bold), - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'Additional Premium', - textAlign: TextAlign.start, - style: TextStyle( - fontWeight: - FontWeight.bold), - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'GST', - textAlign: TextAlign.start, - style: TextStyle( - fontWeight: - FontWeight.bold), - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'Total', - textAlign: TextAlign.start, - style: TextStyle( - fontWeight: - FontWeight.bold), - ), - ), - ), - ], - ), - TableRow( - children: [ - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'Group Medical Coverage - Top Up', - textAlign: TextAlign.start, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹2000/Year', - textAlign: TextAlign.end, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹360/-', - textAlign: TextAlign.end, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹2360/Year', - textAlign: TextAlign.end, - ), - ), - ), - ], - ), - TableRow( - children: [ - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - 'Group Medical Coverage - Top Up', - textAlign: TextAlign.start, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹2000/Year', - textAlign: TextAlign.end, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹360/-', - textAlign: TextAlign.end, - ), - ), - ), - TableCell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Text( - '₹2360/Year', - textAlign: TextAlign.end, - ), - ), - ), - ], + Text( + 'Review', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 20 + : 18, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), ), ], - ), - )) - ], - ), + ))), + ], ), - 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: TextStyle( - fontSize: 20, - color: Color(0xFF181818), - fontWeight: FontWeight.w600, - ), - ), - ], - ))), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - '₹6016.82/Year', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - color: Color(0xFFE26728), - fontWeight: FontWeight.w500, - ), - ), - ], - ))) - ], - ), - ), - SizedBox(height: 15), - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 11, - child: Container( - alignment: Alignment.centerRight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'I declare that the information I have provided is true and accurate to the best of my knowledge', - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 18, - color: Color(0xFF292929), - ), - ), - ], - ))), - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Checkbox( - value: isChecked, - onChanged: (bool? value) { - setState(() { - isChecked = value!; - }); - }, - activeColor: Color(0xFFE26728), - ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - child: Row( - children: [ - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, + Row( + children: [ + Expanded( + flex: 6, + child: Container( alignment: Alignment.centerLeft, - child: ElevatedButton( - onPressed: () { - Navigator.pushNamed( - context, 'addOnsDetails'); - }, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Total Payable', + textAlign: TextAlign.left, + style: TextStyle( + 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( + '₹$totalPayableAmt/Year ', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 22 + : 18, + color: Color(0xFFE26728), + fontWeight: FontWeight.w500, + ), + ), + ], + ))), + ], + ), + ])), + ), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gpaPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Personal Accident Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gpasumInsured != null ? gpasumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( child: Text( - 'Back', - style: - TextStyle(color: Color(0xFFE26728)), + gpaSelfDetails ?? '', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(5), - side: BorderSide( + ), + ], + ), + ], + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + gmcPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: gmcMappedFamilyFloaters + .where( + (item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + addOnsPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage - Top Up', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${addOnsSumInsured != null ? addOnsSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: addOnsMappedFamilyFloatersSi + .where( + (item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + 'Add Ons', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFF181818), + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFF1DD), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 15, bottom: 15, left: 25, right: 25) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + addOnsPolicyName ?? '', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + 'Group Medical Coverage - Add Dependent', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'Floater Sum Insured', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 14, + ), + ), + Text( + '₹ ${addOnsSumInsured != null ? addOnsSumInsured : 'NA'}', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + ), + ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 0, bottom: 0, left: 15, right: 15) + : EdgeInsets.only( + top: 0, bottom: 0, left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: addOnsMappedFamilyFloatersDependent + .where( + (item) => item['is_value_exist'] == true) + .map((item) { + Map data = item['data']; + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.arrow_right, + color: Color(0xFFE26728)), // Arrow icon + SizedBox( + width: Responsive.isDesktop(context) + ? 10 + : 5), // Space between icon and text + Expanded( + child: Text( + '${data['name']} - ${data['relationship']} - ${data['dob']}', + style: TextStyle( + fontSize: + Responsive.isDesktop(context) + ? 18 + : 16, + color: Color(0xFF232526), + ), + ), + ), + ], + ); + }).toList(), + ), + ), + ], + ), + )), + SizedBox(height: 16), + Card( + elevation: 0, + child: Padding( + padding: Responsive.isDesktop(context) + ? EdgeInsets.all(30) + : EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment + .centerLeft, // Adjust padding as needed + child: Table( + columnWidths: { + 0: FlexColumnWidth( + 2), // Adjust column width as needed + 1: FlexColumnWidth(2), + 2: FlexColumnWidth( + 2), // Adjust column width as needed + 3: FlexColumnWidth(2), + }, + children: [ + TableRow( + children: [ + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + 'Premium Summary', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 16 + : 14, + fontWeight: + FontWeight.bold), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + 'Additional Premium', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 16 + : 14, + fontWeight: + FontWeight.bold), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + 'GST', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 16 + : 14, + fontWeight: + FontWeight.bold), + ), + ), + ), + TableCell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + 'Total', + textAlign: TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 16 + : 14, + fontWeight: + FontWeight.bold), + ), + ), + ), + ], + ), + if (activeSiData == '0') + TableRow( + children: [ + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + Responsive.isDesktop( + context) + ? 'Group Medical Coverage - Top Up' + : 'GMC - Top Up', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$gmcAddOnSiPremiumValue/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$siPremiumGst/-', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$siTotalAmt/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + ], + ), + if (activeDependentData == '0') + TableRow( + children: [ + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + Responsive.isDesktop( + context) + ? 'Group Medical Coverage - Add Dependent' + : 'GMC - Dependent ', + textAlign: + TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$gmcAddOnDependentPremiumValue/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$dependentPremiumGst/-', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + TableCell( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: Text( + '₹$dependentTotalAmt/Year', + textAlign: + Responsive.isDesktop( + context) + ? TextAlign.end + : TextAlign.start, + style: TextStyle( + fontSize: Responsive + .isDesktop( + context) + ? 14 + : 12), + ), + ), + ), + ], + ), + ], + ), + )) + ], + ), + ), + 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: TextStyle( + 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( + '₹$totalPayableAmt/Year', + textAlign: TextAlign.right, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 16, + color: Color(0xFFE26728), + fontWeight: FontWeight.w500, + ), + ), + ], + ))) + ], + ), + ), + SizedBox(height: 15), + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 11, + child: Container( + alignment: Alignment.centerRight, + child: Column( + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'I declare that the information I have provided is true and accurate to the best of my knowledge', + textAlign: + Responsive.isDesktop(context) + ? TextAlign.right + : TextAlign.start, + style: TextStyle( + fontSize: Responsive.isDesktop( + context) + ? 18 + : 15, + color: Color(0xFF292929), + ), + ), + ], + ))), + Expanded( + flex: 1, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Checkbox( + value: isChecked, + onChanged: (bool? value) { + setState(() { + isChecked = value!; + }); + }, + activeColor: Color(0xFFE26728), + ), + ], + ))), + ], + ), + ), + SizedBox( + height: Responsive.isDesktop(context) ? 15 : 0), + Container( + child: Row( + children: [ + Expanded( + flex: 6, + child: Container( + width: 150, + height: Responsive.isDesktop(context) + ? 150 + : 100, + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed( + context, 'addOnsDetails'); + }, + child: Text( + 'Back', + style: TextStyle( color: Color(0xFFE26728)), ), - ), - ), - )), - Expanded( - flex: 6, - child: Container( - width: 150, - height: 150, - alignment: Alignment.centerRight, - child: ElevatedButton( - onPressed: () {}, - child: Text( - 'Submit', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(5), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + side: BorderSide( + color: Color(0xFFE26728)), + ), ), ), - ), - )), - ], + )), + Expanded( + flex: 6, + child: Container( + width: 150, + height: 150, + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: + isChecked ? sendAddOnAPI : null, + child: Text( + 'Submit', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5), + ), + ), + ), + )), + ], + ), ), - ), - ], - ), - )), - ], + ], + ), + )), + ], + ), ), ), - ), - ); + ); + } } } diff --git a/lib/excel_verification.dart b/lib/excel_verification.dart index 0055d25..8e44ae1 100644 --- a/lib/excel_verification.dart +++ b/lib/excel_verification.dart @@ -5,11 +5,14 @@ import 'package:nhancepolicy/customAppBar/customAppBar.dart'; import 'dart:convert'; import 'dart:async'; import 'package:http/http.dart' as http; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:universal_html/html.dart' as html; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:excel/excel.dart'; +import 'dart:io'; +import 'package:intl/intl.dart'; class excelVerify extends StatefulWidget { const excelVerify({Key? key}) : super(key: key); @@ -38,6 +41,8 @@ class _excelVerifyState extends State { dynamic policyFirstPart; List> originalData = []; // Original data source List> filteredData = []; // Filtered data source + dynamic client_policy_id; + dynamic policy_name; @override void initState() { @@ -52,8 +57,8 @@ class _excelVerifyState extends State { Future _loadToken() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - final token = prefs.getString('token'); - if (token != null) { + final token = prefs.getString('hrtoken'); + if (token != null && token.isNotEmpty) { setState(() { _token = token; }); @@ -61,8 +66,10 @@ class _excelVerifyState extends State { clintID = decodedToken['client_id'].toString(); await getPolicyName(clintID); } else { - _token = 'null'; - // Handle the case when token is not available + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'hrLogin'); } } @@ -86,16 +93,37 @@ class _excelVerifyState extends State { setState(() { dataPolicy = List>.from(data['data']); print(dataPolicy); - getPolicyNameDetails = dataPolicy[0]['policy_name']; - print(getPolicyNameDetails); - getPolicyNo = dataPolicy[0]['client_policy_id']; + + // Find the object where the 'type' matches the 'policyFirstPart' + Map matchingPolicy = dataPolicy.firstWhere( + (policy) => policy['type'] == policyFirstPart, + orElse: () => {} // Return an empty map if no matching policy is found + ); + print(matchingPolicy); + if (matchingPolicy != null) { + // Matching policy found + print('Matching Policy: $matchingPolicy'); + client_policy_id = matchingPolicy['client_policy_id']; + policy_name = matchingPolicy['policy_name']; + } else { + // No matching policy found + print('No matching policy found for $policyFirstPart'); + } + // getPolicyNameDetails = dataPolicy[0]['policy_name']; + // print(getPolicyNameDetails); + // getPolicyNo = dataPolicy[0]['client_policy_id']; }); print('Successfully Sent'); } else { + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -108,7 +136,9 @@ class _excelVerifyState extends State { } void _uploadFile(importPolicyName) async { + print('Test'); if (kIsWeb) { + print('kIsWeb'); final input = html.FileUploadInputElement(); input.accept = '.xlsx'; input.click(); @@ -116,22 +146,26 @@ class _excelVerifyState extends State { final file = input.files!.first; final reader = html.FileReader(); reader.readAsArrayBuffer(file); - reader.onLoadEnd.listen((event) async { + await reader.onLoadEnd.first; // Wait for the file to be loaded + if (reader.readyState == html.FileReader.DONE) { Uint8List? fileBytes = reader.result as Uint8List?; if (fileBytes != null) { - // Call function to process Excel data setState(() { fileName = file.name; }); // Save fileBytes to local storage final jsonString = json.encode(fileBytes); html.window.localStorage['fileBytes'] = jsonString; - print(fileName); - print(fileBytes); + print('File Name: $fileName'); + print('File Bytes: $fileBytes'); + // Call the function to process Excel data here _processExcelData(fileBytes); } - }); + } }); + } else { + // Handle non-web platforms here (e.g., show an error message) + print('File upload is only supported on web platforms.'); } } @@ -147,8 +181,8 @@ class _excelVerifyState extends State { if (dataArray[0].length == 10) { for (int i = 0; i < dataArray.length; i++) { Map dataMap = { - "S.No": dataArray[i][0].value, - "Emp Code": dataArray[i][1].value, + "Sno": dataArray[i][0].value, + "emp_code": dataArray[i][1].value, "Name": dataArray[i][2].value, "DOJ": dataArray[i][3].value, "Gender": dataArray[i][4].value, @@ -284,11 +318,11 @@ class _excelVerifyState extends State { request.files.add(http.MultipartFile.fromBytes('file', fileBytes, filename: fileName)); // Specify filename here request.fields['client_id'] = clintID; - if (policyFirstPart == 'GPA') { - request.fields['policy_id'] = '1'; - } else { - request.fields['policy_id'] = '3'; - } + // if (policyFirstPart == 'GPA') { + request.fields['policy_id'] = client_policy_id; + // } else { + // request.fields['policy_id'] = '3'; + // } // Send the request final response = await request.send(); @@ -296,11 +330,14 @@ class _excelVerifyState extends State { // Check the status code of the response if (response.statusCode == 200) { // ToastHelper.showSuccessToast(context, 'File uploaded successfully'); + ToastHelper.showSuccessToast(context, 'Data Successfully Send...'); print('File uploaded successfully'); Navigator.pushNamed(context, 'hrHome'); } else { // ToastHelper.showSuccessToast( // context, 'Failed to upload file: ${response.reasonPhrase}'); + ToastHelper.showSuccessToast( + context, 'Failed to send data: ${response.reasonPhrase}'); print('Failed to upload file: ${response.reasonPhrase}'); } } @@ -326,12 +363,9 @@ class _excelVerifyState extends State { dynamic importPolicyName = ModalRoute.of(context)!.settings.arguments as String?; - List parts = importPolicyName.split(" - "); - policyFirstPart = - parts.isNotEmpty ? parts[0] : ''; // Accessing the first element - print(policyFirstPart); // Output: GMC + // List parts = importPolicyName.split(" - "); + policyFirstPart = importPolicyName; - print(importPolicyName); return Scaffold( appBar: CustomAppBar(), body: SafeArea( @@ -357,66 +391,67 @@ class _excelVerifyState extends State { currentStep: _currentStep, controlsBuilder: (BuildContext context, ControlsDetails controls) { - return Positioned( - bottom: 0, - right: 0, - left: 0, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - if (_currentStep != 0) - ElevatedButton( - onPressed: controls.onStepCancel, - child: Text( - 'Cancel', - style: - TextStyle(color: Color(0xFFE26728)), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide( - color: Color(0xFFE26728)), - ), + return Container( + alignment: Alignment.bottomCenter, + padding: const EdgeInsets.all(16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (_currentStep != 0) + ElevatedButton( + onPressed: () { + controls + .onStepCancel!(); // Call onStepCancel function + }, + child: Text( + 'Cancel', + style: TextStyle(color: Color(0xFFE26728)), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + side: + BorderSide(color: Color(0xFFE26728)), ), ), - SizedBox(width: 10), - if (_currentStep != 2) - ElevatedButton( - onPressed: controls.onStepContinue, - child: const Text( - 'NEXT', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - ), + ), + SizedBox(width: 10), + if (_currentStep != 2) + ElevatedButton( + onPressed: () { + controls + .onStepContinue!(); // Call onStepContinue function + }, + child: const Text( + 'NEXT', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), ), ), - SizedBox(width: 10), - if (_currentStep == 2) - ElevatedButton( - onPressed: () { - _retrieveAndUploadFile(); - }, - child: Text( - 'Submit', - style: TextStyle(color: Colors.white), - ), - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFFE26728), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - ), + ), + SizedBox(width: 10), + if (_currentStep == 2) + ElevatedButton( + onPressed: () { + _retrieveAndUploadFile(); + }, + child: Text( + 'Submit', + style: TextStyle(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), ), ), - ], - ), + ), + ], ), ); }, @@ -478,7 +513,7 @@ class _excelVerifyState extends State { children: [ Expanded( child: Text( - importPolicyName ?? '', + policy_name ?? '', textAlign: TextAlign.center, style: TextStyle( fontSize: 20, @@ -788,14 +823,18 @@ class _DependenceDataSource0 extends DataTableSource { @override DataRow getRow(int index) { final row = _data[index]; + + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A'; + return DataRow(cells: [ - DataCell(Text(row['SNo'].toString())), - DataCell(Text(row['EmpCode'].toString())), + DataCell(Text(row['Sno'].toString())), + DataCell(Text(row['emp_code'].toString())), DataCell(Text(row['Name'].toString())), DataCell(Text(row['DOJ']?.toString() ?? 'N/A')), DataCell(Text(row['Gender']?.toString() ?? 'N/A')), DataCell(Text(row['Relation']?.toString() ?? 'N/A')), - DataCell(Text(row['DOB']?.toString() ?? 'N/A')), + DataCell(Text(dob)), DataCell(Text(row['Mail']?.toString() ?? 'N/A')), DataCell(Text(row['Mobile']?.toString() ?? 'N/A')), DataCell(Text(row['SI']?.toString() ?? 'N/A')), @@ -810,4 +849,13 @@ class _DependenceDataSource0 extends DataTableSource { @override int get selectedRowCount => 0; + + String formatDateString(String dateString) { + // Parse the date string to DateTime object + DateTime dateTime = DateTime.parse(dateString); + // Format the DateTime object to "July 03, 2024" + String formattedDate = DateFormat.yMMMMd().format(dateTime); + + return formattedDate; + } } diff --git a/lib/hrHome.dart b/lib/hrHome.dart index f96b9be..d2d91df 100644 --- a/lib/hrHome.dart +++ b/lib/hrHome.dart @@ -7,7 +7,6 @@ import 'package:jwt_decode/jwt_decode.dart'; import 'dart:convert'; import 'dart:async'; import 'package:http/http.dart' as http; -import 'package:file_picker/file_picker.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart'; // import 'dart:html' as html; import 'package:universal_html/html.dart' as html; @@ -15,6 +14,7 @@ import 'dart:typed_data'; import 'dart:io'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:excel/excel.dart'; +import 'package:intl/intl.dart'; class MyHrHome extends StatefulWidget { const MyHrHome({Key? key}) : super(key: key); @@ -24,28 +24,33 @@ class MyHrHome extends StatefulWidget { } class _MyHrHomeState extends State with TickerProviderStateMixin { - Uint8List? _fileBytes; Uint8List? fileBytes; late String _token; List> getEmpDependenceByClintIdGMC = []; List> getEmpDependenceByClintIdGPA = []; + List> getEmpDependenceByClintIdAddOns = []; dynamic getPolicyNameDetails0; dynamic getPolicyNameDetails1; + dynamic getPolicyNameDetails2; dynamic getPolicyNo0; dynamic getPolicyNo1; + dynamic getPolicyNo2; bool _isLoading = false; dynamic clintID; late TabController _tabController; List dataPolicy = []; + List reversedDataPolicy = []; List> originalDataGpa = []; // Original data source List> filteredDataGpa = []; // Filtered data source List> originalDataGmc = []; // Original data source List> filteredDataGmc = []; // Filtered data source + List> originalDataAddOns = []; // Original data source + List> filteredDataAddOns = []; @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this); + _tabController = TabController(length: 3, vsync: this); _loadToken(); } @@ -57,17 +62,19 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { Future _loadToken() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - final token = prefs.getString('token'); - if (token != null) { + final token = prefs.getString('hrtoken'); + if (token != null && token.isNotEmpty) { setState(() { _token = token; }); Map? decodedToken = Jwt.parseJwt(token); clintID = decodedToken['client_id']; - await getPolicyName(clintID); + getPolicyName(clintID); } else { - _token = 'null'; - // Handle the case when token is not available + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'hrLogin'); } } @@ -91,22 +98,52 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { setState(() { dataPolicy = List>.from(data['data']); print(dataPolicy); - getPolicyNameDetails0 = dataPolicy[0]['policy_name']; - print(getPolicyNameDetails0); - getPolicyNameDetails1 = dataPolicy[1]['policy_name']; - print(getPolicyNameDetails1); - getPolicyNo0 = dataPolicy[0]['client_policy_id']; - print(getPolicyNameDetails1); - getPolicyNo1 = dataPolicy[1]['client_policy_id']; - print(getPolicyNameDetails1); + reversedDataPolicy = dataPolicy.reversed.toList(); + // getPolicyNameDetails0 = dataPolicy[0]['policy_name']; + // print(getPolicyNameDetails0); + // getPolicyNameDetails1 = dataPolicy[1]['policy_name']; + // print(getPolicyNameDetails1); + // getPolicyNameDetails2 = dataPolicy[2]['policy_name']; + // print(getPolicyNameDetails2); + // getPolicyNo0 = dataPolicy[0]['client_policy_id']; + // print(getPolicyNameDetails1); + // getPolicyNo1 = dataPolicy[1]['client_policy_id']; + // print(getPolicyNameDetails1); + // getPolicyNo2 = dataPolicy[2]['client_policy_id']; + // print(getPolicyNameDetails2); }); // Code to execute periodically every 2 seconds - getEmployeeAndDependenceGPA(clintID, getPolicyNo0); - getEmployeeAndDependenceGMC(clintID, getPolicyNo1); + reversedDataPolicy.forEach((policy) { + if (policy['type'] == 'GPA') { + String clientPolicyId = policy['client_policy_id']; + String clientId = policy['client_id']; + getEmployeeAndDependenceGPA(clientId, clientPolicyId); + } else if (policy['type'] == 'GMC') { + String clientPolicyId = policy['client_policy_id']; + String clientId = policy['client_id']; + getEmployeeAndDependenceGMC(clientId, clientPolicyId); + } else if (policy['type'] == 'AddOn') { + String clientPolicyId = policy['client_policy_id']; + String clientId = policy['client_id']; + getEmployeeAndDependenceAddOnsSi(clientId, clientPolicyId); + } else if (policy['type'] == 'AddOn-DEPENDENT') { + String clientPolicyId = policy['client_policy_id']; + String clientId = policy['client_id']; + getEmployeeAndDependenceAddOnsDependent(clientId, clientPolicyId); + } + // Extract client_policy_id from the policy object + }); + // getEmployeeAndDependenceGPA(clintID, getPolicyNo2); + // getEmployeeAndDependenceGMC(clintID, getPolicyNo1); + // getEmployeeAndDependenceAddOns(clintID, getPolicyNo0); } else { + ToastHelper.showWarningToast( + context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + ToastHelper.showWarningToast( + context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -118,12 +155,12 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { } } - Future getEmployeeAndDependenceGPA(clintID, getPolicyNo0) async { + Future getEmployeeAndDependenceGPA(clintID, getPolicyNo) async { setState(() { _isLoading = true; }); var url = Uri.parse(Environment.apiUrl + - 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo0'); + 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo'); try { var response = await http.get( url, @@ -141,9 +178,13 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { filteredDataGpa = List.from(originalDataGpa); }); } else { + ToastHelper.showWarningToast( + context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + ToastHelper.showWarningToast( + context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -155,12 +196,12 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { } } - Future getEmployeeAndDependenceGMC(clintID, getPolicyNo1) async { + Future getEmployeeAndDependenceGMC(clintID, getPolicyNo) async { setState(() { _isLoading = true; }); var url = Uri.parse(Environment.apiUrl + - 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo1'); + 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo'); try { var response = await http.get( url, @@ -178,9 +219,96 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { filteredDataGmc = List.from(originalDataGmc); }); } else { + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}'); } } else { + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + print('Exception occurred: $e'); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + Future getEmployeeAndDependenceAddOnsSi(clintID, getPolicyNo) async { + setState(() { + _isLoading = true; + }); + var url = Uri.parse(Environment.apiUrl + + 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + setState(() { + getEmpDependenceByClintIdAddOns = + List>.from(data['data']); + originalDataAddOns = getEmpDependenceByClintIdAddOns; + filteredDataAddOns = List.from(originalDataAddOns); + }); + } else { + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.statusCode}'); + } + } catch (e) { + print('Exception occurred: $e'); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + Future getEmployeeAndDependenceAddOnsDependent( + clintID, getPolicyNo) async { + setState(() { + _isLoading = true; + }); + var url = Uri.parse(Environment.apiUrl + + 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo'); + try { + var response = await http.get( + url, + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + if (response.statusCode == 200) { + Map data = json.decode(response.body); + if (data['status'] == 'success') { + setState(() { + getEmpDependenceByClintIdAddOns = + List>.from(data['data']); + originalDataAddOns = getEmpDependenceByClintIdAddOns; + filteredDataAddOns = List.from(originalDataAddOns); + }); + } else { + ToastHelper.showErrorToast( + context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${data['status']}'); + } + } else { + ToastHelper.showErrorToast( + context, 'Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}'); } } catch (e) { @@ -195,9 +323,14 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { void _uploadFile(importPolicyName) async { var argumentDetails; if (importPolicyName == 'GPA') { - argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails2; + argumentDetails = 'GPA'; + } else if (importPolicyName == 'GMC') { + // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1; + argumentDetails = 'GMC'; } else { - argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1; + // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; + argumentDetails = 'ADDONS'; } Navigator.pushNamed(context, 'excelVerify', arguments: argumentDetails); @@ -250,273 +383,433 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { }); } - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: CustomAppBar(), - body: Container( - padding: const EdgeInsets.all(20), - color: Color(0xFFEFF3F6), - child: Card( - elevation: 0, - child: Column( - children: [ - TabBar( - labelColor: Colors.white, // Selected tab color - unselectedLabelColor: Colors.grey, // Unselected tab color - indicator: BoxDecoration( - color: Color(0xFFE26728), // Background color of selected tab - ), - indicatorSize: TabBarIndicatorSize.label, - controller: _tabController, - tabs: [ - Tab( - child: Container( - width: double.maxFinite, - alignment: Alignment.center, - padding: EdgeInsets.symmetric(vertical: 0), - child: Text('GPA-' + (getPolicyNameDetails0 ?? '')), - ), - ), - Tab( - child: Container( - width: double.infinity, - alignment: Alignment.center, - padding: EdgeInsets.symmetric(vertical: 0), - child: Text('GMC-' + (getPolicyNameDetails1 ?? '')), - ), - ), - ], - ), - Expanded( - child: TabBarView( - controller: _tabController, - children: [ - Center( - child: Padding( - padding: const EdgeInsets.all(20), - child: _isLoading - ? Center(child: CircularProgressIndicator()) - : Column( - children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, - child: Container( - width: - 350, // Set your desired width here - height: - 40, // Set your desired height here - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 255, - 255, - 255, - 0.5), // Shadow color with opacity - offset: Offset(5, - 5), // Shadow position (horizontal, vertical) - blurRadius: - 10, // Blur radius - spreadRadius: - 0, // Spread radius - ), - ], - borderRadius: - BorderRadius.circular(5), - ), - child: TextField( - textAlignVertical: TextAlignVertical - .center, // Center the text vertically - decoration: InputDecoration( - hintText: 'Search', - suffixIcon: - Icon(Icons.search), - contentPadding: EdgeInsets.all( - 10), // Adjust the horizontal padding - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color( - 0xFFf5f5f7)), // Set border color to gray - ), - ), - onChanged: - searchGpa, // Call the search method on text change - ), - )), - ), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.centerRight, - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () => - _uploadFile('GPA'), - child: Text( - 'Import Data', - style: TextStyle( - color: Colors.white), - ), - style: - ElevatedButton.styleFrom( - backgroundColor: - Color(0xFFE26728), - shape: - RoundedRectangleBorder( - borderRadius: - BorderRadius.circular( - 5), - ), - ), - ), - ), - ], - ), - ), - ), - ], - ), - SizedBox(height: 20), - Row( - children: [ - Expanded( - child: SingleChildScrollView( - child: _buildDataTableGPA(), - ), - ) - ], - ), - ], - ), - ), - ), - Center( - child: Padding( - padding: const EdgeInsets.all(20), - child: _isLoading - ? Center(child: CircularProgressIndicator()) - : Column( - children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Container( - alignment: Alignment.centerLeft, - child: Container( - width: - 350, // Set your desired width here - height: - 40, // Set your desired height here - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 255, - 255, - 255, - 0.5), // Shadow color with opacity - offset: Offset(5, - 5), // Shadow position (horizontal, vertical) - blurRadius: - 10, // Blur radius - spreadRadius: - 0, // Spread radius - ), - ], - borderRadius: - BorderRadius.circular(5), - ), - child: TextField( - textAlignVertical: TextAlignVertical - .center, // Center the text vertically - decoration: InputDecoration( - hintText: 'Search', - suffixIcon: - Icon(Icons.search), - contentPadding: EdgeInsets.all( - 10), // Adjust the horizontal padding - border: OutlineInputBorder( - borderSide: BorderSide( - color: Color( - 0xFFf5f5f7)), // Set border color to gray - ), - ), - onChanged: - searchGmc, // Call the search method on text change - ), - )), - ), - Expanded( - flex: 2, - child: Container( - alignment: Alignment.centerRight, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: ElevatedButton( - onPressed: () => - _uploadFile('GMC'), - child: Text( - 'Import', - style: TextStyle( - color: Colors.white), - ), - style: - ElevatedButton.styleFrom( - backgroundColor: - Color(0xFFE26728), - shape: - RoundedRectangleBorder( - borderRadius: - BorderRadius.circular( - 5), - ), - ), - ), - ) - ], - ), - ), - ), - ], - ), - SizedBox(height: 20), - Row( - children: [ - Expanded( - child: SingleChildScrollView( - child: _buildDataTableGMC(), - ), - ) - ], - ), - ], - ), - ), - ), - ], - ), - ), - ], - ), - ), - ), - ); + void searchAddOns(String query) { + setState(() { + if (query.isEmpty) { + // If search query is empty, show all data + filteredDataAddOns = List.from(originalDataAddOns); + } else { + // Filter the data based on the search query + filteredDataAddOns = originalDataAddOns.where((item) { + // Implement your filter logic here, for example: + return item['emp_code'].toLowerCase().contains(query.toLowerCase()); + }).toList(); + } + }); } - Widget _buildDataTableGPA() { + @override + Widget build(BuildContext context) { + if (dataPolicy == []) { + return Scaffold( + appBar: CustomAppBar(), + body: SingleChildScrollView( + child: Container( + color: Color(0xFFEFF3F6), + child: Column( + children: [ + Center( + child: Text('No Data Available'), + ) + ], + ), + ), + )); + } else { + return Scaffold( + appBar: CustomAppBar(), + body: Container( + padding: const EdgeInsets.all(20), + color: Color(0xFFEFF3F6), + child: Card( + elevation: 0, + child: Column( + children: [ + TabBar( + labelColor: Colors.white, // Selected tab color + unselectedLabelColor: Colors.grey, // Unselected tab color + indicator: BoxDecoration( + color: + Color(0xFFE26728), // Background color of selected tab + ), + indicatorSize: TabBarIndicatorSize.label, + controller: _tabController, + tabs: reversedDataPolicy != null && + reversedDataPolicy.isNotEmpty + ? reversedDataPolicy.map((policy) { + return Tab( + child: Container( + width: double.infinity, + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 0), + child: Text( + '${policy['type']}-${policy['policy_name']}'), + ), + ); + }).toList() + : [ + Tab(text: 'Loading...') + ], // Display a loading tab if dataPolicy is null or empty + // tabs: [ + // Tab( + // child: Container( + // width: double.maxFinite, + // alignment: Alignment.center, + // padding: EdgeInsets.symmetric(vertical: 0), + // child: Text('GPA-' + (getPolicyNameDetails0 ?? '')), + // ), + // ), + // Tab( + // child: Container( + // width: double.infinity, + // alignment: Alignment.center, + // padding: EdgeInsets.symmetric(vertical: 0), + // child: Text('GMC-' + (getPolicyNameDetails1 ?? '')), + // ), + // ), + // ], + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: [ + Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius.circular(5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: InputDecoration( + hintText: 'Search', + suffixIcon: + Icon(Icons.search), + contentPadding: EdgeInsets.all( + 10), // Adjust the horizontal padding + border: OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchGpa, // Call the search method on text change + ), + )), + ), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + _uploadFile('GPA'), + child: Text( + 'Import Data', + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular(5), + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: _buildDataTableGPA(context), + ), + ) + ], + ), + ], + ), + ), + ), + Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius.circular(5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: InputDecoration( + hintText: 'Search', + suffixIcon: + Icon(Icons.search), + contentPadding: EdgeInsets.all( + 10), // Adjust the horizontal padding + border: OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchGmc, // Call the search method on text change + ), + )), + ), + Expanded( + flex: 2, + child: Container( + alignment: Alignment.centerRight, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => + _uploadFile('GMC'), + child: Text( + 'Import', + style: TextStyle( + color: Colors.white), + ), + style: ElevatedButton + .styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: + RoundedRectangleBorder( + borderRadius: + BorderRadius + .circular(5), + ), + ), + ), + ) + ], + ), + ), + ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: _buildDataTableGMC(context), + ), + ) + ], + ), + ], + ), + ), + ), + Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : Column( + children: [ + Row( + children: [ + Expanded( + flex: 10, + child: Container( + alignment: Alignment.centerLeft, + child: Container( + width: + 350, // Set your desired width here + height: + 40, // Set your desired height here + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 255, + 255, + 255, + 0.5), // Shadow color with opacity + offset: Offset(5, + 5), // Shadow position (horizontal, vertical) + blurRadius: + 10, // Blur radius + spreadRadius: + 0, // Spread radius + ), + ], + borderRadius: + BorderRadius.circular(5), + ), + child: TextField( + textAlignVertical: + TextAlignVertical + .center, // Center the text vertically + decoration: InputDecoration( + hintText: 'Search', + suffixIcon: + Icon(Icons.search), + contentPadding: EdgeInsets.all( + 10), // Adjust the horizontal padding + border: OutlineInputBorder( + borderSide: BorderSide( + color: Color( + 0xFFf5f5f7)), // Set border color to gray + ), + ), + onChanged: + searchAddOns, // Call the search method on text change + ), + )), + ), + // Expanded( + // flex: 2, + // child: Container( + // alignment: Alignment.centerRight, + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceEvenly, + // children: [ + // Expanded( + // child: ElevatedButton( + // onPressed: () => + // _uploadFile('ADDONS'), + // child: Text( + // 'Import', + // style: TextStyle( + // color: Colors.white), + // ), + // style: ElevatedButton + // .styleFrom( + // backgroundColor: + // Color(0xFFE26728), + // shape: + // RoundedRectangleBorder( + // borderRadius: + // BorderRadius + // .circular(5), + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // ), + ], + ), + SizedBox(height: 20), + Row( + children: [ + Expanded( + child: SingleChildScrollView( + child: + _buildDataTableAddOns(context), + ), + ) + ], + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } + } + + Widget _buildDataTableGPA(context) { if (filteredDataGpa.isEmpty) { SizedBox(height: 25); return Text('No available data'); @@ -533,13 +826,13 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { DataColumn(label: Text('Gender')), DataColumn(label: Text('Mobile No')), ], - source: _DependenceDataSource0(filteredDataGpa), + source: _DependenceDataSource0(filteredDataGpa, context), ), ); } } - Widget _buildDataTableGMC() { + Widget _buildDataTableGMC(context) { if (filteredDataGmc.isEmpty) { SizedBox(height: 25); return Text('No available data'); @@ -556,7 +849,30 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { DataColumn(label: Text('Gender')), DataColumn(label: Text('Mobile No')), ], - source: _DependenceDataSource1(filteredDataGmc), + source: _DependenceDataSource1(filteredDataGmc, context), + ), + ); + } + } + + Widget _buildDataTableAddOns(context) { + if (filteredDataAddOns.isEmpty) { + SizedBox(height: 25); + return Text('No available data'); + } else { + return Card( + elevation: 0, // Set elevation to 0 for no shadow + child: PaginatedDataTable( + rowsPerPage: 5, // Adjust rows per page as needed + columns: [ + DataColumn(label: Text('Employee ID')), + DataColumn(label: Text('Name')), + DataColumn(label: Text('Relationship')), + DataColumn(label: Text('Date of Birth')), + DataColumn(label: Text('Gender')), + DataColumn(label: Text('Mobile No')), + ], + source: _DependenceDataSource2(filteredDataAddOns, context), ), ); } @@ -565,19 +881,41 @@ class _MyHrHomeState extends State with TickerProviderStateMixin { class _DependenceDataSource0 extends DataTableSource { final List> _data; - _DependenceDataSource0(this._data); + final BuildContext context; + _DependenceDataSource0(this._data, this.context); @override DataRow getRow(int index) { final row = _data[index]; - return DataRow(cells: [ - DataCell(Text(row['emp_code'].toString())), - DataCell(Text(row['name'].toString())), - DataCell(Text(row['relationship'].toString())), - DataCell(Text(row['dob'] ?? 'N/A')), - DataCell(Text(row['gender'] ?? 'N/A')), - DataCell(Text(row['mobile'] ?? 'N/A')), - ]); + Color rowColor = Colors.transparent; + TextStyle textStyle = TextStyle(color: Colors.black); + bool isClickable = false; + + if (row['relationship'] == 'Self') { + rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows + textStyle = TextStyle(color: Colors.black); + isClickable = true; // Making 'Self' rows clickable + } + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + + return DataRow( + color: MaterialStateColor.resolveWith( + (states) => rowColor), // Setting row background color + cells: [ + DataCell( + Text(row['emp_code'].toString(), style: textStyle), + onTap: isClickable + ? () => _navigateToAnotherPage(row) + : null, // Navigation only for 'Self' rows + ), + DataCell(Text(row['name'].toString(), style: textStyle)), + DataCell(Text(row['relationship'].toString(), style: textStyle)), + DataCell(Text(dob, style: textStyle)), + DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)), + DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)), + ], + ); } @override @@ -588,23 +926,57 @@ class _DependenceDataSource0 extends DataTableSource { @override int get selectedRowCount => 0; + + void _navigateToAnotherPage(row) { + print(row['mobile']); + // Navigation logic here + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': row['mobile']}); + } + + String _formatDate(String date) { + DateTime parsedDate = DateTime.parse(date); + String formattedDate = DateFormat.yMMMMd().format(parsedDate); + return formattedDate; + } } class _DependenceDataSource1 extends DataTableSource { final List> _data; - _DependenceDataSource1(this._data); + final BuildContext context; + _DependenceDataSource1(this._data, this.context); @override DataRow getRow(int index) { final row = _data[index]; - return DataRow(cells: [ - DataCell(Text(row['emp_code'].toString())), - DataCell(Text(row['name'].toString())), - DataCell(Text(row['relationship'].toString())), - DataCell(Text(row['dob'] ?? 'N/A')), - DataCell(Text(row['gender'] ?? 'N/A')), - DataCell(Text(row['mobile'] ?? 'N/A')), - ]); + Color rowColor = Colors.transparent; + TextStyle textStyle = TextStyle(color: Colors.black); + bool isClickable = false; + + if (row['relationship'] == 'Self') { + rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows + textStyle = TextStyle(color: Colors.black); + isClickable = true; // Making 'Self' rows clickable + } + + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + + return DataRow( + color: MaterialStateColor.resolveWith((states) => rowColor), + cells: [ + DataCell( + Text(row['emp_code'].toString(), style: textStyle), + onTap: isClickable + ? () => _navigateToAnotherPage(row) + : null, // Navigation only for 'Self' rows + ), + DataCell(Text(row['name'].toString(), style: textStyle)), + DataCell(Text(row['relationship'].toString(), style: textStyle)), + DataCell(Text(dob, style: textStyle)), + DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)), + DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)), + ]); } @override @@ -615,6 +987,78 @@ class _DependenceDataSource1 extends DataTableSource { @override int get selectedRowCount => 0; + + void _navigateToAnotherPage(row) { + print(row); + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': row['mobile']}); + } + + String _formatDate(String date) { + DateTime parsedDate = DateTime.parse(date); + String formattedDate = DateFormat.yMMMMd().format(parsedDate); + return formattedDate; + } +} + +class _DependenceDataSource2 extends DataTableSource { + final List> _data; + final BuildContext context; + _DependenceDataSource2(this._data, this.context); + + @override + DataRow getRow(int index) { + final row = _data[index]; + Color rowColor = Colors.transparent; + TextStyle textStyle = TextStyle(color: Colors.black); + bool isClickable = false; + + if (row['relationship'] == 'Self') { + rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows + textStyle = TextStyle(color: Colors.black); + isClickable = true; // Making 'Self' rows clickable + } + + // Format date of birth to "July 10, 1996" + String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A'; + + return DataRow( + color: MaterialStateColor.resolveWith((states) => rowColor), + cells: [ + DataCell( + Text(row['emp_code'].toString(), style: textStyle), + onTap: isClickable + ? () => _navigateToAnotherPage(row) + : null, // Navigation only for 'Self' rows + ), + DataCell(Text(row['name'].toString(), style: textStyle)), + DataCell(Text(row['relationship'].toString(), style: textStyle)), + DataCell(Text(dob, style: textStyle)), + DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)), + DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)), + ]); + } + + @override + bool get isRowCountApproximate => false; + + @override + int get rowCount => _data.length; + + @override + int get selectedRowCount => 0; + + void _navigateToAnotherPage(row) { + print(row); + Navigator.pushNamed(context, 'empDetails', + arguments: {'mobile': row['mobile']}); + } + + String _formatDate(String date) { + DateTime parsedDate = DateTime.parse(date); + String formattedDate = DateFormat.yMMMMd().format(parsedDate); + return formattedDate; + } } // Sample Data class representing each element in the array diff --git a/lib/hrLogin.dart b/lib/hrLogin.dart index 7ea5d2d..d256f19 100644 --- a/lib/hrLogin.dart +++ b/lib/hrLogin.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'dart:convert'; import 'dart:io'; @@ -44,10 +45,12 @@ class _MyPhoneState extends State { bool userVerification = data['data']['user_verification']; return userVerification; } else { + ToastHelper.showErrorToast(context, 'Failed to verify mobile number'); throw Exception('Failed to verify mobile number'); } } catch (e) { print('Error: $e'); + ToastHelper.showErrorToast(context, 'Error: $e'); return false; } } @@ -60,14 +63,11 @@ class _MyPhoneState extends State { bool isValid = await verifyMobileNumber(enteredMobileNumber); if (isValid) { + ToastHelper.showSuccessToast(context, 'Mobile No Verified...'); Navigator.pushNamed(context, 'hrVerify', arguments: enteredMobileNumber); } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Invalid mobile number'), - ), - ); + ToastHelper.showErrorToast(context, 'Invalid mobile number'); } } } @@ -118,6 +118,109 @@ class _MyPhoneState extends State { height: _size.height / 3, width: double.infinity, color: Color(0xFF00989E), + child: Stack( + children: [ + Positioned( + top: 40, // Adjust top position as needed + left: 10, // Align to the right + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed(context, 'phone'); + }, + child: Row( + children: [ + Icon( + Icons.west, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + SizedBox(width: 5), + Text( + 'Customer Login', + style: TextStyle( + color: Color(0xFF000000), // Text color + // Add other text styles as needed + ), + ), + ], + ), + ), + ), + ), + ), + Column( + children: [ + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 10 : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + _size.width <= 1100 + ? 'assets/mobileViewLogo.png' + : 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + ), + ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) + children: [ + Text( + 'HR Login', + style: TextStyle( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + ], + ), + ), + ), + ), + ], + ), + ], + ), + ], + ), ), ), ), @@ -154,77 +257,81 @@ class _MyPhoneState extends State { child: Container( margin: _size.width > 1100 ? EdgeInsets.only(left: 20, right: 20) - : null, + : EdgeInsets.only(left: 0, right: 0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( - children: [ - Expanded( - flex: 4, - child: Align( - alignment: Alignment.centerLeft, - child: MouseRegion( - cursor: - SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'phone'); - }, - child: Row( - children: [ - Icon( - Icons - .west, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - SizedBox(width: 5), - Text( - 'Customer Login', - style: TextStyle( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 4, + child: Align( + alignment: Alignment.centerLeft, + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'phone'); + }, + child: Row( + children: [ + Icon( + Icons + .west, // Icon for customer login + color: Colors + .black, // Adjust color as needed ), - ), - ], + SizedBox(width: 5), + Text( + 'Customer Login', + style: TextStyle( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + ], + ), ), ), - ), - )), - Expanded( - flex: 8, - child: Align( - alignment: Alignment - .centerRight, // Align to the start - child: _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final-mobile.png', - width: 150, - height: 150, - ) - : _size.width > 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ), - )), - ], - ), + )), + Expanded( + flex: 8, + child: Align( + alignment: Alignment + .centerRight, // Align to the start + child: _size.width <= 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final-mobile.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ) + : Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + )), + ], + ), SizedBox(height: 15), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -243,8 +350,10 @@ class _MyPhoneState extends State { height: 15, ), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -266,8 +375,10 @@ class _MyPhoneState extends State { ), Container( height: 55, - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), decoration: BoxDecoration( border: Border.all( width: 1, color: Colors.grey), @@ -334,8 +445,10 @@ class _MyPhoneState extends State { height: 20, ), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: SizedBox( width: double.infinity, height: 45, @@ -455,7 +568,10 @@ class _MyPhoneState extends State { ), ) : SizedBox( - height: _size.height * 0.2, + height: + Responsive.isDesktop(context) + ? _size.height * 0.1 + : _size.height * 0.2, ), SizedBox( height: _size.height * 0.1, diff --git a/lib/hrVerify.dart b/lib/hrVerify.dart index e68ae4a..3b914fb 100644 --- a/lib/hrVerify.dart +++ b/lib/hrVerify.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/models/environment.dart'; import 'package:pinput/pinput.dart'; import 'dart:async'; @@ -70,23 +71,27 @@ class _MyVerifyState extends State { if (response.statusCode == 200) { // Handle successful response - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('OTP resent successfully.'), - ), - ); + ToastHelper.showSuccessToast(context, 'OTP resent successfully.'); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text('OTP resent successfully.'), + // ), + // ); } else { // Handle other response status codes + ToastHelper.showErrorToast(context, 'Failed to resend OTP'); throw Exception('Failed to resend OTP'); } } catch (e) { // Handle API call errors print('Error: $e'); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to resend OTP. Please try again.'), - ), - ); + ToastHelper.showErrorToast( + context, 'Failed to resend OTP. Please try again.'); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text('Failed to resend OTP. Please try again.'), + // ), + // ); } } @@ -110,32 +115,41 @@ class _MyVerifyState extends State { print(status); if (status == 'success') { final SharedPreferences prefs = await SharedPreferences.getInstance(); - prefs.setString('token', data['data']); - // Store data in local storage (if needed) - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // await prefs.setString('userData', json.encode(data['data'])); - + prefs.setString('hrtoken', data['data']); + final hrtoken = prefs.getString('hrtoken'); + if (hrtoken != null && hrtoken.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + Navigator.pushNamed(context, 'hrHome'); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'hrLogin'); + } // Redirect to another page - Navigator.pushNamed(context, 'hrHome'); } else { + ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again.'); // Show a Snackbar if the OTP is invalid - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Invalid OTP. Please try again.'), - ), - ); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text('Invalid OTP. Please try again.'), + // ), + // ); } } else { + ToastHelper.showErrorToast(context, 'Failed to verify OTP'); throw Exception('Failed to verify OTP'); } } catch (e) { print('Error: $e'); + ToastHelper.showErrorToast( + context, 'Failed to verify OTP. Please try again.'); // Show a Snackbar if there's an error while verifying OTP - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to verify OTP. Please try again.'), - ), - ); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text('Failed to verify OTP. Please try again.'), + // ), + // ); } } @@ -194,347 +208,451 @@ class _MyVerifyState extends State { ); return Scaffold( - // extendBodyBehindAppBar: true, - // appBar: AppBar( - // backgroundColor: Colors.transparent, - // leading: IconButton( - // onPressed: () { - // Navigator.pop(context); - // }, - // icon: Icon( - // Icons.arrow_back_ios_rounded, - // color: Colors.black, - // ), - // ), - // elevation: 0, - // ), - body: Stack(children: [ - // First half of the screen with background color - Visibility( - visible: _size.width <= - 1100, // Show only for screen width less than or equal to 1100 (mobile view) - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), // Adjust border radius as needed - bottomRight: - Radius.circular(30), // Adjust border radius as needed - ), - child: Container( - height: _size.height / 3, // One-third of the screen height - width: double.infinity, // Full width - color: Color(0xFF00989E), // Your desired background color - ), - ), - ), - // Second half of the screen with the content - Container( - margin: marginInsets, // Adjust bottom margin - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column(children: [ - Row(children: [ - if (_size.width > - 1100) // Render Expanded column only if screen width is greater than 600 (tablet or larger) - Expanded( - flex: _size.width < 1100 - ? 6 - : 12, // Take 6 parts out of 12 - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - // Only show the image column if screen width is greater than 600 (tablet or larger) - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/hrLogin.jpg', - height: _size.height, - fit: BoxFit.fill, - ); - } else { - return SizedBox(); // If screen width is smaller, return an empty SizedBox - } - }, - ), - ), - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 150, right: 150) - : null, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final-mobile.png', - width: 150, - height: 150, - ) - : _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ), - SizedBox( - height: _size.width <= 1100 ? 50 : 0, - ), - Text( - "Welcome to Nhance", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - SizedBox(height: 10), - RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - "Please enter the one-time usage code sent to your mobile number $mobileNumber", - style: TextStyle( - fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Number)", - style: TextStyle( - fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: TapGestureRecognizer() - ..onTap = () { - // Navigate to the page where the user can change the phone number - Navigator.pushNamed( - context, 'hrLogin'); - }, - ), - ], + body: SingleChildScrollView( + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + child: Container( + height: _size.height, + color: Colors.white, + child: Stack( + children: [ + Visibility( + visible: _size.width <= 1100, + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(30), + ), + child: Container( + height: _size.height / 3, + width: double.infinity, + color: Color(0xFF00989E), + child: Stack( + children: [ + Column( + children: [ + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 10 : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + _size.width <= 1100 + ? 'assets/mobileViewLogo.png' + : 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, ), ), - SizedBox(height: 30), - Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - SizedBox(height: 15), - SizedBox(height: 0), - Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: TextStyle( - color: Colors.black), - ) - : InkWell( - onTap: () { - resendOTP(mobileNumber); - }, - child: Text( - "Resend OTP", - style: TextStyle( - color: Colors.blue), - ), - ), - ], - ), - SizedBox(height: 10), - SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), - ), - ), - onPressed: () { - if (_formKey.currentState!.validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP(_otpController.text); - } - }, - child: Text( - "Submit", - style: - TextStyle(color: Color(0xFFFFFFFF)), - ), - ), - ), - - // Row( - // children: [ - // TextButton( - // onPressed: () { - // Navigator.pushNamedAndRemoveUntil( - // context, - // 'phone', - // (route) => false, - // ); - // }, - // child: Text("Edit Phone Number?", - // style: TextStyle( - // color: Color(0xFFE26728))), - // ), - // ], - // ), - SizedBox( - height: _size.width <= 1100 ? 0 : 0, - ), // Added SizedBox - _size.width > 1100 - ? // Conditionally rendering based on screen width - Column( + ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) children: [ - SizedBox( - height: 15), // Added SizedBox Text( - "Benefits of Login", + 'HR Login', style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed ), ), - SizedBox(height: 15), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), ], - ) - : SizedBox(), // Added SizedBox - _size.width > 1100 - ? Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 8), - // color: Colors.grey[200], - child: Row( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Expanded( - child: Container( - padding: EdgeInsets - .symmetric( - vertical: 12), - decoration: - BoxDecoration( - border: Border( - right: BorderSide( - width: 1, - color: Colors - .black, - ), - ), - ), - child: Column( - children: [ - Icon(Icons.policy, - color: Color( - 0xFFE26728)), - SizedBox( - height: 10), - Text( - "View Policy"), - ], - ), - ), - ), - Expanded( - child: Container( - padding: EdgeInsets - .symmetric( - vertical: 12), - child: Column( - children: [ - Icon(Icons.edit, - color: Color( - 0xFFE26728)), - SizedBox( - height: 10), - Text( - "Manage Claims"), - ], - ), - ), - ), - ], - ), - ), - ), - ], - ), - ) - : SizedBox( - height: _size.height * 0.2, ), - SizedBox( - height: _size.height * 0.1, + ), + ), ), - Container( - alignment: Alignment.bottomCenter, - padding: EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - 'By continuing, you agree with our ', - style: TextStyle( - color: Colors.black, - fontSize: 9, - ), - children: [ - TextSpan( - text: 'privacy policy ', + ], + ), + ], + ), + ], + ), + ), + ), + ), + Container( + margin: marginInsets, + alignment: Alignment.bottomCenter, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( + children: [ + Row( + children: [ + if (_size.width > 1100) + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return Image.asset( + 'assets/hrLogin.jpg', + height: _size.height, + fit: BoxFit.fill, + ); + } else { + return SizedBox(); + } + }, + ), + ), + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: Container( + margin: _size.width > 1100 + ? EdgeInsets.only(left: 20, right: 20) + : EdgeInsets.only(left: 0, right: 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 8, + child: Align( + alignment: Alignment + .centerRight, // Align to the start + child: _size.width <= 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final-mobile.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ) + : Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + )), + ], + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Welcome to Nhance", style: TextStyle( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - TextSpan( - text: 'and ', - style: TextStyle( - color: Colors.black, - fontSize: 9, - ), - ), - TextSpan( - text: 'terms of use', - style: TextStyle( - color: Color(0xFF00989E), - fontSize: 9, + fontSize: 16, + fontWeight: FontWeight.bold, ), ), ], ), ), - ), - ], + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + "Please enter the one-time usage code sent to your mobile number $mobileNumber", + style: TextStyle( + fontSize: 12, + height: 1.5, + color: Color(0xFF000000)), + children: [ + TextSpan( + text: " (Change Number)", + style: TextStyle( + fontSize: 12, + color: Color( + 0xFFE26728)), // Change color as desired + recognizer: TapGestureRecognizer() + ..onTap = () { + // Navigate to the page where the user can change the phone number + Navigator.pushNamed( + context, 'hrLogin'); + }, + ), + ], + ), + ), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Pinput( + length: 6, + // defaultPinTheme: defaultPinTheme, + // focusedPinTheme: focusedPinTheme, + // submittedPinTheme: submittedPinTheme, + showCursor: true, + controller: _otpController, + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align text to the right + children: [ + _isTimerRunning + ? Text( + "Resend OTP in $_secondsRemaining seconds", + style: TextStyle( + color: Colors.black), + ) + : InkWell( + onTap: () { + resendOTP(mobileNumber); + }, + child: Text( + "Resend OTP", + style: TextStyle( + color: Colors.blue), + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF00989E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), + ), + ), + onPressed: () { + if (_formKey.currentState! + .validate()) { + _formKey.currentState! + .save(); // Save form fields before calling verifyOTP + verifyOTP(_otpController.text); + } + }, + child: Text( + "Submit", + style: TextStyle( + color: Color(0xFFFFFFFF)), + ), + ), + ), + ), + SizedBox( + height: _size.width <= 1100 ? 0 : 0, + ), + _size.width > 1100 + ? Container( + margin: EdgeInsets.symmetric( + horizontal: 150), + child: Column( + children: [ + SizedBox(height: 30), + Text( + "Benefits of Login", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 15), + ], + )) + : SizedBox(), + _size.width > 1100 + ? Container( + margin: EdgeInsets.symmetric( + horizontal: 150), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + padding: + EdgeInsets.symmetric( + vertical: 8), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Expanded( + child: Container( + padding: EdgeInsets + .symmetric( + vertical: + 12), + decoration: + BoxDecoration( + border: Border( + right: + BorderSide( + width: 1, + color: Colors + .black, + ), + ), + ), + child: Column( + children: [ + Icon( + Icons + .policy, + color: Color( + 0xFFE26728)), + SizedBox( + height: 10), + Text( + "View Policy"), + ], + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets + .symmetric( + vertical: + 12), + child: Column( + children: [ + Icon(Icons.edit, + color: Color( + 0xFFE26728)), + SizedBox( + height: 10), + Text( + "Manage Claims"), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ) + : SizedBox( + height: + Responsive.isDesktop(context) + ? _size.height * 0.1 + : _size.height * 0.2, + ), + SizedBox( + height: _size.height * 0.1, + ), + Container( + alignment: Alignment.bottomCenter, + padding: + EdgeInsets.symmetric(vertical: 8), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + 'By continuing, you agree with our ', + style: TextStyle( + color: Colors.black, + fontSize: 9, + ), + children: [ + TextSpan( + text: 'privacy policy ', + style: TextStyle( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + TextSpan( + text: 'and ', + style: TextStyle( + color: Colors.black, + fontSize: 9, + ), + ), + TextSpan( + text: 'terms of use', + style: TextStyle( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], + ), + ), + ), + ], + ), ), - )), - ]) - ])))) - ]), - ); + ), + ], + ), + ], + ), + ), + ), + ), + ], + )), + )); } } diff --git a/lib/main.dart b/lib/main.dart index 1e8d517..a63c4fb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,3 @@ -import 'dart:js'; - -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:nhancepolicy/addons.dart'; import 'package:nhancepolicy/empReview.dart'; diff --git a/lib/phone.dart b/lib/phone.dart index d0c18eb..24049e5 100644 --- a/lib/phone.dart +++ b/lib/phone.dart @@ -45,9 +45,11 @@ class _MyPhoneState extends State { bool userVerification = data['data']['user_verification']; return userVerification; } else { + ToastHelper.showErrorToast(context, 'Failed to verify mobile number'); throw Exception('Failed to verify mobile number'); } } catch (e) { + ToastHelper.showErrorToast(context, '$e'); print('Error: $e'); return false; } @@ -61,9 +63,10 @@ class _MyPhoneState extends State { bool isValid = await verifyMobileNumber(enteredMobileNumber); if (isValid) { + ToastHelper.showSuccessToast(context, 'Mobile No Verified..'); Navigator.pushNamed(context, 'verify', arguments: enteredMobileNumber); } else { - // ToastHelper.showErrorToast(context, 'Invalid mobile number'); + ToastHelper.showErrorToast(context, 'Invalid mobile number..'); print('Invalid mobile number'); } } @@ -115,6 +118,106 @@ class _MyPhoneState extends State { height: _size.height / 3, width: double.infinity, color: Color(0xFF00989E), + child: Stack( + children: [ + // Positioned( + // top: 40, // Adjust top position as needed + // right: 10, // Align to the right + // child: MouseRegion( + // cursor: SystemMouseCursors.click, + // child: GestureDetector( + // onTap: () { + // // Add your navigation logic here + // // For example, you can use Navigator.push to navigate to another page + // Navigator.pushNamed(context, 'hrLogin'); + // }, + // child: Row( + // children: [ + // Text( + // 'HR Login', + // style: TextStyle( + // color: Color(0xFF000000), // Text color + // // Add other text styles as needed + // ), + // ), + // SizedBox(width: 5), + // Icon( + // Icons.east, // Icon for customer login + // color: + // Colors.black, // Adjust color as needed + // ), + // ], + // ), + // ), + // ), + // ), + Column( + children: [ + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 10 : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + _size.width <= 1100 + ? 'assets/mobileViewLogo.png' + : 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + ), + ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) + children: [ + Text( + 'HR Login', + style: TextStyle( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + ], + ), + ), + ), + ), + ], + ), + ], + ), + ], + ), ), ), ), @@ -133,77 +236,85 @@ class _MyPhoneState extends State { child: Container( margin: _size.width > 1100 ? EdgeInsets.only(left: 20, right: 20) - : null, + : EdgeInsets.only(left: 0, right: 0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( - children: [ - Expanded( - flex: 10, - child: Align( - alignment: Alignment - .centerLeft, // Align to the start - child: _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final-mobile.png', - width: 150, - height: 150, - ) - : _size.width > 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 10, + child: Align( + alignment: Responsive.isDesktop( + context) + ? Alignment.centerLeft + : Alignment + .bottomCenter, // Align to the start + child: _size.width <= 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final-mobile.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ) + : Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + )), + Expanded( + flex: 2, + child: Align( + alignment: + Alignment.centerRight, + child: MouseRegion( + cursor: + SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + children: [ + Text( + 'HR Login', + style: TextStyle( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), ), - )), - Expanded( - flex: 2, - child: Align( - alignment: Alignment.centerRight, - child: MouseRegion( - cursor: - SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - children: [ - Text( - 'HR Login', - style: TextStyle( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], + ], + ), ), ), - ), - )), - ], - ), + )), + ], + ), SizedBox(height: 15), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -222,8 +333,10 @@ class _MyPhoneState extends State { height: 15, ), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -245,8 +358,10 @@ class _MyPhoneState extends State { ), Container( height: 55, - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), decoration: BoxDecoration( border: Border.all( width: 1, color: Colors.grey), @@ -313,8 +428,10 @@ class _MyPhoneState extends State { height: 20, ), Container( - margin: - EdgeInsets.symmetric(horizontal: 150), + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), child: SizedBox( width: double.infinity, height: 45, @@ -434,7 +551,10 @@ class _MyPhoneState extends State { ), ) : SizedBox( - height: _size.height * 0.2, + height: + Responsive.isDesktop(context) + ? _size.height * 0.1 + : _size.height * 0.2, ), SizedBox( height: _size.height * 0.1, diff --git a/lib/verify.dart b/lib/verify.dart index 7086a77..a8f5f46 100644 --- a/lib/verify.dart +++ b/lib/verify.dart @@ -24,6 +24,10 @@ class _MyVerifyState extends State { late Timer _timer; int _secondsRemaining = 30; bool _isTimerRunning = false; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic gpaEmpName; + dynamic client_id; @override void initState() { @@ -74,6 +78,7 @@ class _MyVerifyState extends State { ToastHelper.showSuccessToast(context, 'OTP resent successfully'); } else { // Handle other response status codes + ToastHelper.showErrorToast(context, 'Failed to resend OTP'); throw Exception('Failed to resend OTP'); } } catch (e) { @@ -105,23 +110,47 @@ class _MyVerifyState extends State { if (status == 'success') { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('token', data['data']); - // Store data in local storage (if needed) - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // await prefs.setString('userData', json.encode(data['data'])); - // ToastHelper.showSuccessToast(context, 'Successfully Login'); + + // Decode the JWT token received from the API response + Map? decodedToken = Jwt.parseJwt(data['data']); + print(decodedToken); + empCodeString = decodedToken['emp_code'].toString(); + prefs.setString('empCode', empCodeString); + empPrimaryId = decodedToken['id']; + prefs.setString('empPrimaryId', empPrimaryId); + gpaEmpName = decodedToken['name'].toString(); + prefs.setString('gpaEmpName', gpaEmpName); + client_id = decodedToken['client_id']; + prefs.setString('client_id', client_id); + print('Successfully Login'); + // Redirect to another page - Navigator.pushNamed(context, 'empDetails'); + final token = prefs.getString('token'); + if (token != null && token.isNotEmpty) { + ToastHelper.showSuccessToast(context, 'Successfully Login'); + Navigator.pushReplacementNamed(context, 'empDetails', + arguments: {'mobile': ''}); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + // For now, let's navigate to the login screen + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'phone'); + } } else { + ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); // Show a Snackbar if the OTP is invalid // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); print('Invalid OTP. Please try again'); } } else { + ToastHelper.showErrorToast(context, 'Failed to verify OTP'); throw Exception('Failed to verify OTP'); } } catch (e) { print('Error: $e'); + ToastHelper.showErrorToast( + context, 'Failed to verify OTP. Please try again.'); // Show a Snackbar if there's an error while verifying OTP // ToastHelper.showErrorToast( // context, 'Failed to verify OTP. Please try again.'); @@ -184,347 +213,451 @@ class _MyVerifyState extends State { ); return Scaffold( - // extendBodyBehindAppBar: true, - // appBar: AppBar( - // backgroundColor: Colors.transparent, - // leading: IconButton( - // onPressed: () { - // Navigator.pop(context); - // }, - // icon: Icon( - // Icons.arrow_back_ios_rounded, - // color: Colors.black, - // ), - // ), - // elevation: 0, - // ), - body: Stack(children: [ - // First half of the screen with background color - Visibility( - visible: _size.width <= - 1100, // Show only for screen width less than or equal to 1100 (mobile view) - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), // Adjust border radius as needed - bottomRight: - Radius.circular(30), // Adjust border radius as needed - ), - child: Container( - height: _size.height / 3, // One-third of the screen height - width: double.infinity, // Full width - color: Color(0xFF00989E), // Your desired background color - ), - ), - ), - // Second half of the screen with the content - Container( - margin: marginInsets, // Adjust bottom margin - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column(children: [ - Row(children: [ - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 150, right: 150) - : null, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final-mobile.png', - width: 150, - height: 150, - ) - : _size.width <= 1100 - ? Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ) - : Image.asset( - 'assets/Nhance-Logo-Final 1.png', - width: 150, - height: 150, - ), - SizedBox( - height: _size.width <= 1100 ? 50 : 0, - ), - Text( - "Welcome to Nhance", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - SizedBox(height: 10), - RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - "Please enter the one-time usage code sent to your mobile number $mobileNumber", - style: TextStyle( - fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Number)", - style: TextStyle( - fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: TapGestureRecognizer() - ..onTap = () { - // Navigate to the page where the user can change the phone number - Navigator.pushNamed( - context, 'phone'); - }, - ), - ], + body: SingleChildScrollView( + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + child: Container( + height: _size.height, + color: Colors.white, + child: Stack( + children: [ + Visibility( + visible: _size.width <= 1100, + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(30), + ), + child: Container( + height: _size.height / 3, + width: double.infinity, + color: Color(0xFF00989E), + child: Stack( + children: [ + Column( + children: [ + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) ? 10 : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + _size.width <= 1100 + ? 'assets/mobileViewLogo.png' + : 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, ), ), - SizedBox(height: 30), - Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - SizedBox(height: 15), - SizedBox(height: 0), - Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: TextStyle( - color: Colors.black), - ) - : InkWell( - onTap: () { - resendOTP(mobileNumber); - }, - child: Text( - "Resend OTP", - style: TextStyle( - color: Colors.blue), - ), - ), - ], - ), - SizedBox(height: 10), - SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), - ), - ), - onPressed: () { - if (_formKey.currentState!.validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP(_otpController.text); - } - }, - child: Text( - "Submit", - style: - TextStyle(color: Color(0xFFFFFFFF)), - ), - ), - ), - - // Row( - // children: [ - // TextButton( - // onPressed: () { - // Navigator.pushNamedAndRemoveUntil( - // context, - // 'phone', - // (route) => false, - // ); - // }, - // child: Text("Edit Phone Number?", - // style: TextStyle( - // color: Color(0xFFE26728))), - // ), - // ], - // ), - SizedBox( - height: _size.width <= 1100 ? 0 : 0, - ), // Added SizedBox - _size.width > 1100 - ? // Conditionally rendering based on screen width - Column( + ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) children: [ - SizedBox( - height: 15), // Added SizedBox Text( - "Benefits of Login", + 'HR Login', style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed ), ), - SizedBox(height: 15), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), ], - ) - : SizedBox(), // Added SizedBox - _size.width > 1100 - ? Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 8), - // color: Colors.grey[200], - child: Row( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Expanded( - child: Container( - padding: EdgeInsets - .symmetric( - vertical: 12), - decoration: - BoxDecoration( - border: Border( - right: BorderSide( - width: 1, - color: Colors - .black, - ), - ), - ), - child: Column( - children: [ - Icon(Icons.policy, - color: Color( - 0xFFE26728)), - SizedBox( - height: 10), - Text( - "View Policy"), - ], - ), - ), - ), - Expanded( - child: Container( - padding: EdgeInsets - .symmetric( - vertical: 12), - child: Column( - children: [ - Icon(Icons.edit, - color: Color( - 0xFFE26728)), - SizedBox( - height: 10), - Text( - "Manage Claims"), - ], - ), - ), - ), - ], - ), - ), - ), - ], - ), - ) - : SizedBox( - height: _size.height * 0.2, ), - SizedBox( - height: _size.height * 0.1, + ), + ), ), - Container( - alignment: Alignment.bottomCenter, - padding: EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - 'By continuing, you agree with our ', - style: TextStyle( - color: Colors.black, - fontSize: 9, - ), - children: [ - TextSpan( - text: 'privacy policy ', + ], + ), + ], + ), + ], + ), + ), + ), + ), + Container( + margin: marginInsets, + alignment: Alignment.bottomCenter, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: Container( + margin: _size.width > 1100 + ? EdgeInsets.only(left: 20, right: 20) + : EdgeInsets.only(left: 0, right: 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 10, + child: Align( + alignment: Responsive.isDesktop( + context) + ? Alignment.centerLeft + : Alignment + .bottomCenter, // Align to the start + child: _size.width <= 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final-mobile.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ) + : Image.asset( + 'assets/Nhance-Logo-Final 1.png', + width: 150, + height: 150, + ), + )), + ], + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Welcome to Nhance", style: TextStyle( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - TextSpan( - text: 'and ', - style: TextStyle( - color: Colors.black, - fontSize: 9, - ), - ), - TextSpan( - text: 'terms of use', - style: TextStyle( - color: Color(0xFF00989E), - fontSize: 9, + fontSize: 16, + fontWeight: FontWeight.bold, ), ), ], ), ), - ), - ], + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + "Please enter the one-time usage code sent to your mobile number $mobileNumber", + style: TextStyle( + fontSize: 12, + height: 1.5, + color: Color(0xFF000000)), + children: [ + TextSpan( + text: " (Change Number)", + style: TextStyle( + fontSize: 12, + color: Color( + 0xFFE26728)), // Change color as desired + recognizer: TapGestureRecognizer() + ..onTap = () { + // Navigate to the page where the user can change the phone number + Navigator.pushNamed( + context, 'phone'); + }, + ), + ], + ), + ), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Pinput( + length: 6, + // defaultPinTheme: defaultPinTheme, + // focusedPinTheme: focusedPinTheme, + // submittedPinTheme: submittedPinTheme, + showCursor: true, + controller: _otpController, + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align text to the right + children: [ + _isTimerRunning + ? Text( + "Resend OTP in $_secondsRemaining seconds", + style: TextStyle( + color: Colors.black), + ) + : InkWell( + onTap: () { + resendOTP(mobileNumber); + }, + child: Text( + "Resend OTP", + style: TextStyle( + color: Colors.blue), + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric(horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFF00989E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), + ), + ), + onPressed: () { + if (_formKey.currentState! + .validate()) { + _formKey.currentState! + .save(); // Save form fields before calling verifyOTP + verifyOTP(_otpController.text); + } + }, + child: Text( + "Submit", + style: TextStyle( + color: Color(0xFFFFFFFF)), + ), + ), + ), + ), + _size.width > 1100 + ? Container( + margin: EdgeInsets.symmetric( + horizontal: 150), + child: Column( + children: [ + SizedBox(height: 30), + Text( + "Benefits of Login", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 15), + ], + )) + : SizedBox(), + _size.width > 1100 + ? Container( + margin: EdgeInsets.symmetric( + horizontal: 150), + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + padding: + EdgeInsets.symmetric( + vertical: 8), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Expanded( + child: Container( + padding: EdgeInsets + .symmetric( + vertical: + 12), + decoration: + BoxDecoration( + border: Border( + right: + BorderSide( + width: 1, + color: Colors + .black, + ), + ), + ), + child: Column( + children: [ + Icon( + Icons + .policy, + color: Color( + 0xFFE26728)), + SizedBox( + height: 10), + Text( + "View Policy"), + ], + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets + .symmetric( + vertical: + 12), + child: Column( + children: [ + Icon(Icons.edit, + color: Color( + 0xFFE26728)), + SizedBox( + height: 10), + Text( + "Manage Claims"), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ) + : SizedBox( + height: + Responsive.isDesktop(context) + ? _size.height * 0.1 + : _size.height * 0.2, + ), + SizedBox( + height: _size.height * 0.1, + ), + Container( + alignment: Alignment.bottomCenter, + padding: + EdgeInsets.symmetric(vertical: 8), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + 'By continuing, you agree with our ', + style: TextStyle( + color: Colors.black, + fontSize: 9, + ), + children: [ + TextSpan( + text: 'privacy policy ', + style: TextStyle( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + TextSpan( + text: 'and ', + style: TextStyle( + color: Colors.black, + fontSize: 9, + ), + ), + TextSpan( + text: 'terms of use', + style: TextStyle( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], + ), + ), + ), + ], + ), ), - )), - if (_size.width > - 1100) // Render Expanded column only if screen width is greater than 600 (tablet or larger) - Expanded( - flex: _size.width < 1100 - ? 6 - : 12, // Take 6 parts out of 12 - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - // Only show the image column if screen width is greater than 600 (tablet or larger) - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/login_web.jpg', - height: _size.height, - fit: BoxFit.fill, - ); - } else { - return SizedBox(); // If screen width is smaller, return an empty SizedBox - } - }, ), - ), - ]) - ])))) - ]), - ); + if (_size.width > 1100) + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return Image.asset( + 'assets/login_web.jpg', + height: _size.height, + fit: BoxFit.fill, + ); + } else { + return SizedBox(); + } + }, + ), + ), + ], + ), + ], + ), + ), + ), + ), + ], + )), + )); } } diff --git a/pubspec.yaml b/pubspec.yaml index 1c9cd10..e61a388 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,8 @@ dependencies: data_tables: ^1.4.0 universal_html: ^2.2.4 excel: ^4.0.3 + intl: ^0.19.0 + toastification: ^1.2.1 dev_dependencies: diff --git a/web/assets/nhance-loader.gif b/web/assets/nhance-loader.gif new file mode 100644 index 0000000..ed96c65 Binary files /dev/null and b/web/assets/nhance-loader.gif differ diff --git a/web/favicon.png b/web/favicon.png index 8aaa46a..6917ff7 100644 Binary files a/web/favicon.png and b/web/favicon.png differ diff --git a/web/index.html b/web/index.html index 07a196f..003c4c7 100644 --- a/web/index.html +++ b/web/index.html @@ -32,14 +32,47 @@ nhancepolicy + + + - + +
+ +
+