2454 lines
104 KiB
Dart
Executable File
2454 lines
104 KiB
Dart
Executable File
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:nhancepolicy/customAppBar/customAppBar.dart';
|
|
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
|
|
import 'package:nhancepolicy/service/api_service.dart';
|
|
import 'package:shared_preferences/shared_preferences.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';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import 'config/environment.dart';
|
|
import 'customAppBar/customFooter.dart';
|
|
import 'package:nhancepolicy/logger.dart';
|
|
|
|
class empDetails extends StatefulWidget {
|
|
const empDetails({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<empDetails> createState() => _empDetailsState();
|
|
}
|
|
|
|
class _empDetailsState extends State<empDetails> {
|
|
late ApiService apiService;
|
|
bool isLoading = true;
|
|
bool login_by_hr = false;
|
|
dynamic _token;
|
|
dynamic empCodeString;
|
|
dynamic empPrimaryId;
|
|
dynamic gpaEmpName;
|
|
dynamic client_id;
|
|
dynamic gpaPolicies;
|
|
dynamic gpaPolicyName;
|
|
dynamic gpaGridMaster;
|
|
dynamic gpasumInsured;
|
|
dynamic gpaClintPolicyId;
|
|
dynamic gpaSlabRates = [];
|
|
dynamic gpaMappedFamilyFloaters;
|
|
dynamic gpaSelfName;
|
|
dynamic gpaSelfDob;
|
|
dynamic gpaSelfRelationship;
|
|
dynamic gpaSelfDetails;
|
|
dynamic gpaOpenForEnrollment;
|
|
dynamic gpaECardDownload;
|
|
dynamic gpaSumInsured;
|
|
dynamic gmcECardDownload;
|
|
int gmcOpenForEnrollment = 0;
|
|
dynamic gmcPolicies;
|
|
dynamic gmcSlabRates = [];
|
|
dynamic gmcMappedFamilyFloaters = [];
|
|
dynamic gmcSelfName;
|
|
dynamic gmcSelfDob;
|
|
dynamic gmcSelfRelationship;
|
|
dynamic gmcSelfDetails;
|
|
dynamic gmcPolicyName;
|
|
dynamic gmc_client_policy_id;
|
|
dynamic gmcPolicyType;
|
|
dynamic gmcNotes;
|
|
dynamic gmcGridMaster;
|
|
dynamic gmcSumInsured;
|
|
dynamic gmcFloaterTextDescription;
|
|
dynamic gmcFloaterTextHeading;
|
|
dynamic gmcTypeName;
|
|
dynamic clientName;
|
|
dynamic clientLogo;
|
|
late TextEditingController _relationShipController;
|
|
late TextEditingController _dobController;
|
|
late TextEditingController _memberNameController;
|
|
late DateTime? selectedDate;
|
|
List<Map<String, String>> relationshipOptions = [];
|
|
List<Map<String, String>> selectedRelationships = [];
|
|
List<Map<String, dynamic>> 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;
|
|
dynamic selfEmpStatus;
|
|
dynamic selfUnit;
|
|
dynamic gmcDataIsEmpty = 1;
|
|
dynamic gpaDataIsEmpty = 1;
|
|
dynamic hrPrimaryId;
|
|
dynamic empRefId;
|
|
dynamic empClientBranchId;
|
|
dynamic token;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
apiService = ApiService(context); // Initialize ApiService here
|
|
_dobController = TextEditingController();
|
|
_memberNameController = TextEditingController();
|
|
_relationShipController = TextEditingController();
|
|
// _loadToken();
|
|
|
|
Timer(Duration(seconds: 2), tokenAPI);
|
|
|
|
Future.delayed(Duration(seconds: 3), () {
|
|
setState(() {
|
|
isLoading = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_dobController.dispose();
|
|
_memberNameController.dispose();
|
|
_relationShipController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void tokenAPI() async {
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
if (prefs.containsKey('hrtoken')) {
|
|
String? getHrToken = prefs.getString('hrtoken');
|
|
String? empID = prefs.getString('employee_id');
|
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(getHrToken!);
|
|
logDebug(decodedToken);
|
|
hrPrimaryId = decodedToken['id'];
|
|
logDebug('hrPrimaryId');
|
|
logDebug(hrPrimaryId);
|
|
_hrLoadToken(empID);
|
|
} else {
|
|
_loadToken();
|
|
}
|
|
}
|
|
|
|
Future<void> _hrLoadToken(empID) async {
|
|
logDebug('_hrLoadToken');
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
prefs.setString('fromHrLoginMobileNo', mobileNumber);
|
|
|
|
// Retrieve the passed mobile number value
|
|
|
|
setState(() {
|
|
login_by_hr = true;
|
|
});
|
|
try {
|
|
final response = await http.post(
|
|
Uri.parse(Environment.apiUrl + 'getVerifiedUserData'),
|
|
body: json.encode({
|
|
'mobile_number': mobileNumber,
|
|
'otp_verification': 0,
|
|
'login_by_hr': login_by_hr,
|
|
'employee_id': empID
|
|
}),
|
|
headers: {
|
|
'APP-SIGNATURE':
|
|
'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
|
|
HttpHeaders.contentTypeHeader: 'application/json',
|
|
},
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
logDebug('API Success');
|
|
Map<String, dynamic> data = json.decode(response.body);
|
|
logDebug(data);
|
|
String status = data['status'];
|
|
|
|
if (status == 'success') {
|
|
logDebug(status);
|
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
setState(() {
|
|
prefs.setString('token', data['data']);
|
|
});
|
|
|
|
// Decode the JWT token received from the API response
|
|
Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
|
|
logDebug('decodedTokenssss $decodedToken');
|
|
empClientBranchId = decodedToken['client_branch_id'];
|
|
prefs.setString('empClientBranchId', empClientBranchId);
|
|
logDebug(empClientBranchId);
|
|
empCodeString = decodedToken['emp_code'];
|
|
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);
|
|
|
|
logDebug('Successfully Login');
|
|
|
|
// Redirect to another page
|
|
token = prefs.getString('token');
|
|
logDebug('final $token');
|
|
if (token != null && token.isNotEmpty) {
|
|
// ToastHelper.showSuccessToast(context, 'Successfully Login');
|
|
await getTokenLoad(token);
|
|
if (prefs.containsKey('clientLogo') &&
|
|
prefs.containsKey('clientName')) {
|
|
clientLogo = prefs.getString('clientLogo');
|
|
clientName = prefs.getString('clientName');
|
|
} else {
|
|
getClientLogoAndDetails();
|
|
}
|
|
await getGpaEmpPolicyDetails(empPrimaryId);
|
|
await 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');
|
|
logDebug('Invalid OTP. Please try again');
|
|
}
|
|
} else {
|
|
// ToastHelper.showErrorToast(context, 'Failed to verify OTP');
|
|
throw Exception('Failed to verify OTP');
|
|
}
|
|
} catch (e) {
|
|
logDebug('Error: $e');
|
|
ToastHelper.showErrorToast(context, 'Something went wrong');
|
|
// Show a Snackbar if there's an error while verifying OTP
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'Failed to verify OTP. Please try again.');
|
|
logDebug('Failed to verify OTP. Please try again.');
|
|
}
|
|
}
|
|
|
|
Future<void> _loadToken() async {
|
|
logDebug('_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<String, dynamic>? decodedToken = Jwt.parseJwt(token);
|
|
logDebug(decodedToken);
|
|
empClientBranchId = prefs.getString('empClientBranchId');
|
|
empCodeString = prefs.getString('empCode');
|
|
logDebug(empCodeString); // Check if emp_code is correct
|
|
empPrimaryId = prefs.getString('empPrimaryId');
|
|
gpaEmpName = prefs.getString('gpaEmpName');
|
|
client_id = prefs.getString('client_id');
|
|
logDebug(client_id);
|
|
|
|
// logDebug(empPrimaryId);
|
|
// Call the API when the page enters
|
|
// getSelfEmployeeProfile('');
|
|
if (prefs.containsKey('clientLogo') && prefs.containsKey('clientName')) {
|
|
clientLogo = prefs.getString('clientLogo');
|
|
clientName = prefs.getString('clientName');
|
|
} else {
|
|
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<void> getClientLogoAndDetails() async {
|
|
try {
|
|
if (client_id == null ||
|
|
empCodeString == null ||
|
|
empClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getClientLogoAndDetailsToApi(
|
|
client_id!, empCodeString!, empClientBranchId!);
|
|
logDebug('check 1');
|
|
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
dynamic clientDetails = response['data'];
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
prefs.setString('clientLogo', clientDetails['client']['client_logo']);
|
|
prefs.setString('clientName', clientDetails['client']['client_name']);
|
|
setState(() {
|
|
// dynamic clientDetails = data['data'];
|
|
// logDebug(clientDetails);
|
|
clientName = clientDetails['client']['client_name'];
|
|
logDebug(clientName);
|
|
clientLogo = clientDetails['client']['client_logo'];
|
|
logDebug(clientLogo);
|
|
});
|
|
} else {
|
|
// Handle other status messages if needed
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'API request failed with status: ${data['status']}');
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'Request failed with status: ${response.statusCode}');
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getTokenLoad(token) async {
|
|
try {
|
|
final response = await apiService.getTokenLoadAPI(token);
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getSelfEmployeeProfile(token, client_policy_id) async {
|
|
try {
|
|
if (client_id == null ||
|
|
empCodeString == null ||
|
|
empClientBranchId == null) {
|
|
return;
|
|
}
|
|
final response = await apiService.getSelfEmployeeProfileToApi(token,
|
|
client_id!, empCodeString!, empClientBranchId!, client_policy_id);
|
|
|
|
if (response['status'] == 'success') {
|
|
if (response.containsKey('data')) {
|
|
setState(() {
|
|
dynamic selfDetails = response['data'];
|
|
logDebug(selfDetails);
|
|
mobileNumber = selfDetails['relationship'];
|
|
selfRelationship = selfDetails['relationship'];
|
|
selfName = selfDetails['name'];
|
|
selfMobile = selfDetails['mobile'];
|
|
selfDesignation = selfDetails['designation'];
|
|
selfDob = convertDateFormat(selfDetails['dob']);
|
|
// selfDoj = convertDateFormat(selfDetails['doj']);
|
|
selfDoj = convertDateFormat(selfDetails['date_coverage']);
|
|
selfGender = selfDetails['gender'];
|
|
selfEmailCorporate = selfDetails['email_corporate'];
|
|
selfEmailPersonal = selfDetails['email_personal'];
|
|
selfEmpCode = selfDetails['emp_code'];
|
|
selfFamilyFloaterKey = selfDetails['family_floater_key'];
|
|
// logDebug(clientDetails);
|
|
selfEmpStatus = selfDetails['emp_status'];
|
|
selfUnit = selfDetails['unit'];
|
|
});
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
prefs.setString('selfEmpStatus', selfEmpStatus);
|
|
} else {
|
|
// Handle other status messages if needed
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'API request failed with status: ${data['status']}');
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} else {
|
|
// Handle other status codes
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'Request failed with status: ${response.statusCode}');
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
String convertDateFormat(String? date) {
|
|
if (date == null || date.isEmpty)
|
|
return ''; // Return empty string if date is null or empty
|
|
|
|
// Parse the date string to DateTime
|
|
DateTime dateTime = DateTime.parse(date);
|
|
|
|
// Format the DateTime object to the desired format (DD-MM-YYYY)
|
|
String formattedDate =
|
|
'${dateTime.day.toString().padLeft(2, '0')}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.year}';
|
|
|
|
return formattedDate;
|
|
}
|
|
|
|
Future<void> getGpaEmpPolicyDetails(empPrimaryId) async {
|
|
try {
|
|
if (client_id == null ||
|
|
empCodeString == null ||
|
|
empClientBranchId == null) {
|
|
return;
|
|
}
|
|
|
|
final response = await apiService.getGpaEmpPolicyDetailsToApi(
|
|
empPrimaryId,
|
|
empCodeString!,
|
|
client_id!,
|
|
'GPA',
|
|
empClientBranchId!,
|
|
login_by_hr);
|
|
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
gpaPolicies = response['data'];
|
|
logDebug('gpaPolicies');
|
|
});
|
|
} else {
|
|
setState(() {
|
|
gpaDataIsEmpty = 0;
|
|
});
|
|
// Handle other status codes
|
|
ToastHelper.showWarningToast(context, 'Something went wrong');
|
|
logDebug('Request failed with status: ${response['code']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> getGmcEmpPolicyDetails(empPrimaryId) async {
|
|
try {
|
|
if (client_id == null ||
|
|
empCodeString == null ||
|
|
empClientBranchId == null) {
|
|
return;
|
|
}
|
|
|
|
final response = await apiService.getGmcEmpPolicyDetailsToApi(
|
|
empPrimaryId,
|
|
empCodeString!,
|
|
client_id!,
|
|
'GMC',
|
|
empClientBranchId!,
|
|
login_by_hr);
|
|
if (response['status'] == 'success') {
|
|
setState(() {
|
|
gmcPolicies = response['data'];
|
|
logDebug('gmcPolicies');
|
|
});
|
|
// Assuming data is a List
|
|
logDebug(gmcPolicies);
|
|
} else {
|
|
setState(() {
|
|
gmcDataIsEmpty = 0;
|
|
});
|
|
// Handle other status messages if needed
|
|
// ToastHelper.showErrorToast(
|
|
// context, 'API request failed with status: ${data['status']}');
|
|
logDebug('API request failed with status: ${response['status']}');
|
|
}
|
|
} catch (e) {
|
|
// Handle exceptions
|
|
logDebug('Exception occurred: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> fetchRelationshipList() async {
|
|
// Replace the URL with your API endpoint
|
|
try {
|
|
final response = await apiService.fetchRelationshipListToApi();
|
|
if (response['status'] == 'success') {
|
|
for (var item in response['data']) {
|
|
String relationshipName = item['relationship_name'];
|
|
String dependent = item['dependent'];
|
|
|
|
relationshipOptions.add({
|
|
'relationship_name': relationshipName,
|
|
'dependent': dependent,
|
|
});
|
|
}
|
|
// final List<String> relationships =
|
|
// List<String>.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');
|
|
logDebug('Error fetching relationship list: $error');
|
|
// Handle error accordingly, e.g., show a snackbar with an error message
|
|
}
|
|
}
|
|
|
|
Future<void> _selectDate(BuildContext context, formType) async {
|
|
logDebug(formType);
|
|
var ageValidation = formType['age_validation'];
|
|
logDebug(ageValidation);
|
|
// Ensure ageValidation is a Map and contains the expected values
|
|
if (ageValidation is Map<String, dynamic>) {
|
|
int min = ageValidation.containsKey('min')
|
|
? int.tryParse(ageValidation['min'].toString()) ?? 0
|
|
: 0;
|
|
int max = ageValidation.containsKey('max')
|
|
? int.tryParse(ageValidation['max'].toString()) ?? 100
|
|
: 100;
|
|
|
|
logDebug('Min age: $min');
|
|
logDebug('Max age: $max');
|
|
late DateTime minDate;
|
|
late DateTime maxDate;
|
|
|
|
final DateTime now = DateTime.now();
|
|
|
|
maxDate = DateTime(now.year - min, now.month, now.day);
|
|
logDebug(maxDate);
|
|
minDate = DateTime(now.year - max, now.month, now.day);
|
|
logDebug(minDate);
|
|
|
|
// if (formType['form_type'] == 'child') {
|
|
// // For 'child' form type, allow 0-25 age
|
|
// minDate = DateTime(now.year - 25, now.month, now.day);
|
|
// maxDate = now;
|
|
// } else {
|
|
// // For other form types, allow 18-100 age
|
|
// minDate = DateTime(1900);
|
|
// maxDate = DateTime(now.year - 18, now.month, now.day);
|
|
// }
|
|
|
|
// Ensure initialDate is within the range of minDate and maxDate
|
|
DateTime initialDate =
|
|
_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)));
|
|
},
|
|
builder: (BuildContext context, Widget? child) {
|
|
return Theme(
|
|
data: ThemeData.light().copyWith(
|
|
primaryColor: Color(0xFFE26728), // Header background color
|
|
colorScheme: ColorScheme.light(
|
|
primary: Color(0xFFE26728), secondary: Color(0xFFE26728)),
|
|
buttonTheme: ButtonThemeData(textTheme: ButtonTextTheme.primary),
|
|
// dialogBackgroundColor:
|
|
// Colors.white, // Background color of the dialog
|
|
iconTheme: IconThemeData(color: Color(0xFFE26728)),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: Color(0xFFE26728)), // Button color
|
|
),
|
|
),
|
|
child: child!,
|
|
);
|
|
},
|
|
);
|
|
|
|
if (picked != null && picked != _selectedDate) {
|
|
setState(() {
|
|
_selectedDate = picked;
|
|
_dobController.text = DateFormat('dd-MM-yyyy').format(_selectedDate);
|
|
});
|
|
}
|
|
} else {
|
|
logDebug('Invalid age validation data');
|
|
}
|
|
}
|
|
|
|
Future<void> deleteItem(Map<String, dynamic> deletedItem) async {
|
|
logDebug(deletedItem);
|
|
try {
|
|
var id = deletedItem['employee_id'];
|
|
final response = await apiService.deleteItemToApi(id);
|
|
|
|
// Check if the request was successful (status code 200)
|
|
if (response['status'] == 'success') {
|
|
formDataList.clear();
|
|
selectedRelationships.clear();
|
|
_relationShipController.clear();
|
|
_memberNameController.clear();
|
|
_dobController.clear();
|
|
relationshipOptions.clear();
|
|
getGpaEmpPolicyDetails(empPrimaryId);
|
|
getGmcEmpPolicyDetails(empPrimaryId);
|
|
fetchRelationshipList();
|
|
ToastHelper.showSuccessToast(context, 'Item deleted successfully');
|
|
logDebug('Item deleted successfully');
|
|
} else {
|
|
// Handle errors
|
|
ToastHelper.showErrorToast(context, 'Failed to delete item');
|
|
logDebug('Failed to delete item. Status code: ${response['code']}');
|
|
logDebug('Response body: ${response}');
|
|
}
|
|
} catch (error) {
|
|
// Handle network errors
|
|
logDebug('Error deleting item: $error');
|
|
}
|
|
}
|
|
|
|
void saveFamilyMemberDetails(Map<String, dynamic> formData,
|
|
Map<String, dynamic> floatedData, action, gmcSumInsured) async {
|
|
// Construct the array of objects
|
|
logDebug(formData);
|
|
logDebug('floatedData $floatedData');
|
|
logDebug(action);
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
dynamic primaryId;
|
|
dynamic is_createdby_hr;
|
|
if (prefs.containsKey('hrtoken')) {
|
|
primaryId = hrPrimaryId;
|
|
is_createdby_hr = 1;
|
|
} else {
|
|
primaryId = empPrimaryId;
|
|
is_createdby_hr = 0;
|
|
}
|
|
|
|
formDataList.add({
|
|
'client_branch_id': empClientBranchId,
|
|
'relationship': formData['relationship'],
|
|
'name': formData['memberName'],
|
|
'dob': formData['dateOfBirth'],
|
|
'emp_code': empCodeString,
|
|
'client_id': client_id,
|
|
'client_policy_id': floatedData['client_policy_id'],
|
|
'created_by': primaryId,
|
|
'is_createdby_hr': is_createdby_hr,
|
|
'unit': selfUnit,
|
|
'basic_cover_si': gmcSumInsured,
|
|
// 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
|
|
final response =
|
|
await apiService.saveFamilyMemberDetailsToApi(formDataList);
|
|
|
|
// Check the response
|
|
if (response['status'] == 'success') {
|
|
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.');
|
|
logDebug('Form data sent successfully.');
|
|
} else {
|
|
// Request failed, handle error
|
|
ToastHelper.showErrorToast(context, 'Failed');
|
|
logDebug('Failed to send form data. Error: ${response}');
|
|
}
|
|
}
|
|
|
|
void cancelPopUp() {
|
|
formDataList.clear();
|
|
selectedRelationships.clear();
|
|
_relationShipController.clear();
|
|
_memberNameController.clear();
|
|
_dobController.clear();
|
|
}
|
|
|
|
Future<void> backFunction() async {
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final String? hrtoken = prefs.getString('hrtoken');
|
|
|
|
if (hrtoken != null && hrtoken.isNotEmpty) {
|
|
prefs.setBool('showBackToHR', false);
|
|
prefs.remove('token');
|
|
|
|
// Retrieve and decode `hrSelectArgumentsData`
|
|
final String? detailsString = prefs.getString('hrSelectArgumentsData');
|
|
if (detailsString != null) {
|
|
final dynamic details = jsonDecode(detailsString);
|
|
logDebug('Decoded details:');
|
|
logDebug(details);
|
|
|
|
// Ensure that details is a Map<String, dynamic> before passing it
|
|
if (details is Map<String, dynamic>) {
|
|
Navigator.pushNamed(context, 'hrPolicyDetails', arguments: details);
|
|
} else {
|
|
logDebug('Error: Decoded details is not a Map<String, dynamic>.');
|
|
}
|
|
} else {
|
|
logDebug('hrSelectArgumentsData is null.');
|
|
}
|
|
} else {
|
|
logDebug('hrtoken is null or empty.');
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
dynamic arguments = ModalRoute.of(context)!.settings.arguments;
|
|
|
|
if (arguments != null && arguments is Map<String, dynamic>) {
|
|
if (arguments.containsKey('mobile')) {
|
|
mobileNumber = arguments["mobile"];
|
|
// Call your tokenAPI or _loadToken function here
|
|
logDebug("_hrLoadToken");
|
|
logDebug(mobileNumber);
|
|
// _hrLoadToken();
|
|
}
|
|
} else {
|
|
logDebug("Arguments are null or not in the expected format");
|
|
// _loadToken();
|
|
mobileNumber = '';
|
|
}
|
|
if (gpaDataIsEmpty == 0 && gmcDataIsEmpty == 0) {
|
|
logDebug('body if');
|
|
logDebug(gpaPolicies);
|
|
return Scaffold(
|
|
appBar: CustomAppBar(),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.symmetric(
|
|
horizontal: MediaQuery.of(context).size.width *
|
|
0.2, // 30% of screen width as horizontal padding
|
|
vertical: MediaQuery.of(context).size.height *
|
|
0.03, // 5% of screen height as vertical padding
|
|
)
|
|
: EdgeInsets.all(10),
|
|
color: Color(0xFFEFF3F6),
|
|
child: Column(
|
|
children: [
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 75,
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 20, bottom: 20, left: 30, right: 30)
|
|
: EdgeInsets.only(
|
|
top: 12,
|
|
bottom: 12,
|
|
left: 10,
|
|
right: 10), // Add padding to the container
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
width: 150,
|
|
height: 150,
|
|
alignment: Alignment.centerLeft,
|
|
child: Image.network(
|
|
clientLogo ?? '',
|
|
width: 80, // Set the width here
|
|
height: 80, // Set the height here
|
|
loadingBuilder: (BuildContext context,
|
|
Widget child,
|
|
ImageChunkEvent? loadingProgress) {
|
|
if (loadingProgress == null) return child;
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
value:
|
|
loadingProgress.expectedTotalBytes !=
|
|
null
|
|
? loadingProgress
|
|
.cumulativeBytesLoaded /
|
|
loadingProgress
|
|
.expectedTotalBytes!
|
|
: null,
|
|
),
|
|
);
|
|
},
|
|
errorBuilder: (BuildContext context,
|
|
Object error, StackTrace? stackTrace) {
|
|
return Image.asset(
|
|
'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path
|
|
width: 80,
|
|
height: 80,
|
|
fit: BoxFit.cover,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 9,
|
|
child: Text(
|
|
clientName ?? '',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 16),
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height,
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 20, bottom: 20, left: 30, right: 30)
|
|
: EdgeInsets.only(
|
|
top: 12, bottom: 12, left: 10, right: 10),
|
|
child: Center(
|
|
child: Text(
|
|
'No Active Current policies ',
|
|
textAlign: TextAlign
|
|
.center, // Align text center within the Card
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
height: 5,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
} else {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(),
|
|
body: Stack(children: [
|
|
SingleChildScrollView(
|
|
child: Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.symmetric(
|
|
horizontal: MediaQuery.of(context).size.width *
|
|
0.2, // 30% of screen width as horizontal padding
|
|
vertical: MediaQuery.of(context).size.height *
|
|
0.03, // 5% of screen height as vertical padding
|
|
)
|
|
: EdgeInsets.all(10),
|
|
color: Color(0xFFEFF3F6),
|
|
child: Column(
|
|
children: [
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 75,
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 20, bottom: 20, left: 30, right: 30)
|
|
: EdgeInsets.only(
|
|
top: 12,
|
|
bottom: 12,
|
|
left: 10,
|
|
right: 10), // Add padding to the container
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
width: 150,
|
|
height: 150,
|
|
alignment: Alignment.centerLeft,
|
|
child: Image.network(
|
|
clientLogo ?? '',
|
|
width: 80, // Set the width here
|
|
height: 80, // Set the height here
|
|
loadingBuilder: (BuildContext context,
|
|
Widget child,
|
|
ImageChunkEvent? loadingProgress) {
|
|
if (loadingProgress == null) return child;
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
value: loadingProgress
|
|
.expectedTotalBytes !=
|
|
null
|
|
? loadingProgress
|
|
.cumulativeBytesLoaded /
|
|
loadingProgress
|
|
.expectedTotalBytes!
|
|
: null,
|
|
),
|
|
);
|
|
},
|
|
errorBuilder: (BuildContext context,
|
|
Object error, StackTrace? stackTrace) {
|
|
return Image.asset(
|
|
'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path
|
|
width: 80,
|
|
height: 80,
|
|
fit: BoxFit.cover,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 9,
|
|
child: Text(
|
|
clientName ?? '',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 16),
|
|
if (gpaPolicies != null && gpaPolicies.length > 0)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...generateGpaCards(gpaPolicies),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
if (gmcPolicies != null && gmcPolicies.length > 0)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
...generateCards(gmcPolicies),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
if (gmcPolicies != null && gmcPolicies.length > 0)
|
|
Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 75,
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 20, bottom: 20, left: 30, right: 30)
|
|
: EdgeInsets.only(
|
|
top: 10,
|
|
bottom: 10,
|
|
left: 10,
|
|
right: 10), // Add padding to the container
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
width: 150,
|
|
height: 150,
|
|
alignment: Alignment.centerLeft,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
backFunction();
|
|
},
|
|
child: Text(
|
|
'Back',
|
|
style: GoogleFonts.poppins(
|
|
color: Color(0xFFE26728)),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(5),
|
|
side: BorderSide(
|
|
color: Color(0xFFE26728)),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
Expanded(
|
|
flex: 6,
|
|
child: Container(
|
|
width: 150,
|
|
height: 150,
|
|
alignment: Alignment.centerRight,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.pushNamed(
|
|
context, 'addOnsDetails');
|
|
},
|
|
child: Text(
|
|
'Continue',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFFE26728),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(5),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 30),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (isLoading)
|
|
Container(
|
|
color: Color(0x98FFFCE5), // Semi-transparent background
|
|
child: Center(
|
|
child: // Your GIF loader widget
|
|
Image.asset(
|
|
height: 60,
|
|
width: 60,
|
|
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
|
),
|
|
),
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Container(
|
|
width: double.infinity, // Make the footer full width
|
|
child: CustomFooter(),
|
|
),
|
|
),
|
|
]));
|
|
}
|
|
}
|
|
|
|
void openForm(Map<String, dynamic> floaterData, action, gmcSumInsured) {
|
|
logDebug(action);
|
|
logDebug(floaterData);
|
|
logDebug(relationshipOptions);
|
|
logDebug('test');
|
|
// Check if the action is 'Edit'
|
|
dynamic popupName = floaterData['button_name'];
|
|
|
|
selectedRelationships = relationshipOptions
|
|
.where(
|
|
(option) => option['dependent'] == floaterData['form_type'],
|
|
)
|
|
.toList();
|
|
|
|
// Set the dropdown value based on the form_type
|
|
String? dropdownValue;
|
|
if (floaterData['form_type'] == 'spouse') {
|
|
dropdownValue = 'Spouse';
|
|
_relationShipController.text = 'Spouse';
|
|
}
|
|
|
|
logDebug(selectedRelationships);
|
|
logDebug(gmcMappedFamilyFloaters);
|
|
if (action == 'Add') {
|
|
if (floaterData['form_type'] == 'parent_in_law' ||
|
|
floaterData['form_type'] == 'parent') {
|
|
logDebug('Add');
|
|
// Filter the addOnsDependentMappedFamilyFloatersDependent list to get only the objects where is_value_exist is true
|
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
logDebug(getTrueObjects);
|
|
|
|
List<Map<String, dynamic>> getTrueDataObjects = getTrueObjects
|
|
.map<Map<String, dynamic>>(
|
|
(element) => element['data'] as Map<String, dynamic>)
|
|
.toList();
|
|
|
|
logDebug(getTrueDataObjects);
|
|
|
|
selectedRelationships.removeWhere((relationship) =>
|
|
getTrueDataObjects.any((dataObject) =>
|
|
dataObject['relationship'] ==
|
|
relationship['relationship_name']));
|
|
|
|
logDebug(selectedRelationships);
|
|
}
|
|
} else {
|
|
// 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,
|
|
color: Colors.white,
|
|
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: GoogleFonts.poppins(
|
|
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<String>(
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
hintText: 'Relationship',
|
|
labelText: 'Relationship',
|
|
contentPadding: EdgeInsets.symmetric(
|
|
vertical: 10, horizontal: 15),
|
|
),
|
|
value: dropdownValue ??
|
|
(action == 'Edit'
|
|
? _relationShipController.text
|
|
: null),
|
|
onChanged: (value) {
|
|
_relationShipController.text = value!;
|
|
},
|
|
dropdownColor: Colors.white,
|
|
items: selectedRelationships
|
|
.map((relationship) {
|
|
final String relationshipName =
|
|
relationship[
|
|
'relationship_name'] ??
|
|
'';
|
|
return DropdownMenuItem<String>(
|
|
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);
|
|
},
|
|
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);
|
|
},
|
|
),
|
|
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: GoogleFonts.poppins(
|
|
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: () {
|
|
if (_relationShipController
|
|
.text.isEmpty ||
|
|
_memberNameController
|
|
.text.isEmpty ||
|
|
_dobController.text.isEmpty) {
|
|
ToastHelper.showWarningToast(
|
|
context,
|
|
'All fields are required');
|
|
} else {
|
|
Map<String, dynamic> 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,
|
|
gmcSumInsured);
|
|
|
|
// Close the dialog
|
|
Navigator.of(context).pop();
|
|
}
|
|
},
|
|
child: Text(
|
|
'Save',
|
|
style: GoogleFonts.poppins(
|
|
color: Colors.white),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFFE26728),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(5),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _launchURL(String url) async {
|
|
final Uri uri = Uri.parse(url); // Parse the URL properly
|
|
logDebug('_launchURL $uri');
|
|
if (uri != null) {
|
|
logDebug('If $uri');
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
} else {
|
|
logDebug('else $uri');
|
|
throw 'Could not launch $url';
|
|
}
|
|
}
|
|
|
|
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,
|
|
color: Colors.white,
|
|
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('Member Details',
|
|
style: GoogleFonts.poppins(
|
|
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 Coverage',
|
|
labelText: 'Date Coverage',
|
|
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 Coverage',
|
|
labelText: 'Date Coverage',
|
|
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: GoogleFonts.poppins(
|
|
color: Colors.white),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFFE26728),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(5),
|
|
),
|
|
),
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
List<Widget> generateGpaCards(List<dynamic> data) {
|
|
List<Widget> cards = [];
|
|
|
|
for (var item in data) {
|
|
logDebug('item');
|
|
logDebug(item);
|
|
|
|
String? gpaPolicyName = item['Policy_Name'];
|
|
String? gpaECardDownload = item['eCardDownload'];
|
|
String? client_policy_id = item['ClientPolicyId'];
|
|
String? gpaSumInsured = item['si_value'];
|
|
List<dynamic> gpaMappedFamilyFloaters = [];
|
|
|
|
if (item['mapped_family_floaters'] != null) {
|
|
gpaMappedFamilyFloaters = [item['mapped_family_floaters']];
|
|
}
|
|
|
|
dynamic getTrueObjects = gpaMappedFamilyFloaters
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
|
|
// if (getTrueObjects.length > 0) {
|
|
// gpaSumInsured = getTrueObjects[0]["data"]["basic_cover_si"];
|
|
// } else {
|
|
// gpaSumInsured = item['Policy_Terms']['sumInsured2'];
|
|
// }
|
|
|
|
int gpaOpenForEnrollment = int.parse(item['OpenForEnrollment']);
|
|
List<Widget> familyFloaterContainers = [];
|
|
|
|
for (var floater in gpaMappedFamilyFloaters) {
|
|
bool isValueExist = floater['is_value_exist'];
|
|
Map<String, dynamic> floaterData = floater['data'];
|
|
|
|
if (isValueExist) {
|
|
familyFloaterContainers.add(Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: Color(0xFF000000),
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(15)
|
|
: EdgeInsets.only(top: 8, bottom: 8, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 1 : 2,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(10)
|
|
: EdgeInsets.all(5),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF00989E),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
child: Icon(
|
|
Icons.account_circle,
|
|
color: Colors.white,
|
|
size: 32,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 8,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
floaterData['name'] ?? 'NA',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
'${floaterData['relationship']} - ${floaterData['dob']}' ??
|
|
'NA',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 2,
|
|
child: Container(
|
|
alignment: Alignment.topRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: GestureDetector(
|
|
onTap: () async {
|
|
await getSelfEmployeeProfile(
|
|
token, client_policy_id);
|
|
openSelfForm('View');
|
|
},
|
|
child: Text(
|
|
'View',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 16 : 15,
|
|
color: Color(0xFFE26728),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
familyFloaterContainers.add(SizedBox(height: 15));
|
|
}
|
|
|
|
Widget card = Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFFFFF1DD),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: EdgeInsets.all(10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 9,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 18 : 13,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
gpaPolicyName ?? 'NA',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
if (item['eCardDownload'] != null)
|
|
GestureDetector(
|
|
onTap: () async {
|
|
_launchURL(item['eCardDownload']);
|
|
},
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Icon(
|
|
Icons.file_download,
|
|
color: Color(0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 3,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
'Sum Insured',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 18 : 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${gpaSumInsured != null ? gpaSumInsured : 'NA'}',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 20 : 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
Column(
|
|
children: familyFloaterContainers,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
cards.add(card);
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
|
|
List<Widget> generateCards(List<dynamic> data) {
|
|
List<Widget> cards = [];
|
|
|
|
for (var item in data) {
|
|
logDebug('item');
|
|
logDebug(item);
|
|
setState(() {
|
|
gmcPolicyName = item['Policy_Name'];
|
|
gmc_client_policy_id = item['ClientPolicyId'];
|
|
gmcFloaterTextHeading = item['floter_text_heading'];
|
|
gmcFloaterTextDescription = item['floter_text_description'];
|
|
gmcNotes = item['notes'];
|
|
gmcECardDownload = item['eCardDownload'];
|
|
|
|
gmcMappedFamilyFloaters = item['mapped_family_floaters'];
|
|
dynamic getTrueObjects = gmcMappedFamilyFloaters
|
|
.where((element) => element['is_value_exist'] == true)
|
|
.toList();
|
|
logDebug('getTrueObjects');
|
|
logDebug(getTrueObjects);
|
|
if (getTrueObjects.length > 0) {
|
|
logDebug('true');
|
|
gmcSumInsured = gmcMappedFamilyFloaters[0]["data"]["basic_cover_si"];
|
|
} else {
|
|
logDebug('false');
|
|
gmcSumInsured = item['Policy_Terms']['sum_insured'];
|
|
}
|
|
String intOpenForEnrollment = item['OpenForEnrollment'];
|
|
gmcOpenForEnrollment = int.parse(intOpenForEnrollment);
|
|
gmcTypeName = item['type'];
|
|
});
|
|
|
|
List<Widget> familyFloaterContainers = [];
|
|
for (var floater in gmcMappedFamilyFloaters) {
|
|
bool isValueExist = floater['is_value_exist'];
|
|
Map<String, dynamic> floaterData = floater['data'];
|
|
|
|
if (isValueExist) {
|
|
familyFloaterContainers.add(
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: Color(0xFF000000),
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(15)
|
|
: EdgeInsets.only(top: 8, bottom: 8, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 1 : 2,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(10)
|
|
: EdgeInsets.all(5),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF00989E),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
child: Icon(
|
|
Icons.account_circle,
|
|
color: Colors.white,
|
|
size: 32,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: Responsive.isDesktop(context) ? 5 : 0),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 9 : 6,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
floaterData['name'] ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
'${floaterData['relationship']} - ${floaterData['dob']}',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (gmcOpenForEnrollment != 0)
|
|
if (gmcECardDownload == null)
|
|
if (isValueExist && floaterData['relationship'] != 'Self')
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 1 : 2,
|
|
child: Container(
|
|
alignment: Alignment.topRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
deleteItem(floaterData);
|
|
},
|
|
child: Text(
|
|
'Delete',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 16
|
|
: 15,
|
|
color: Color(
|
|
0xFFE26728), // Add underline decoration
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (gmcOpenForEnrollment != 0)
|
|
if (gmcECardDownload == null)
|
|
Expanded(
|
|
flex: (isValueExist &&
|
|
floaterData['relationship'] != 'Self')
|
|
? Responsive.isDesktop(context)
|
|
? 1
|
|
: 2
|
|
: Responsive.isDesktop(context)
|
|
? 2
|
|
: 4,
|
|
child: Container(
|
|
alignment: Alignment.topRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: GestureDetector(
|
|
onTap: () async {
|
|
if (floaterData['relationship'] == 'Self') {
|
|
await getSelfEmployeeProfile(
|
|
token, gmc_client_policy_id);
|
|
openSelfForm('View');
|
|
} else {
|
|
openForm(
|
|
floaterData, 'Edit', gmcSumInsured);
|
|
}
|
|
},
|
|
child: Text(
|
|
floaterData['relationship'] == 'Self'
|
|
? 'View'
|
|
: 'Edit',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 16
|
|
: 15,
|
|
color: Color(
|
|
0xFFE26728), // Add underline decoration
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
familyFloaterContainers.add(MouseRegion(
|
|
cursor: SystemMouseCursors.click, // Set cursor to pointer
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
// Handle the click event to open the form
|
|
if (gmcOpenForEnrollment != 0) {
|
|
if (gmcECardDownload == null) {
|
|
openForm(floaterData, 'Add', gmcSumInsured);
|
|
}
|
|
}
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
color: Color(0xFF000000),
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(12)
|
|
: EdgeInsets.all(10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 1 : 4,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.all(5),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF6A6A6A),
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
child: Icon(
|
|
Icons.person_add,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: Responsive.isDesktop(context) ? 5 : 10),
|
|
Expanded(
|
|
flex: Responsive.isDesktop(context) ? 11 : 8,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
floaterData['button_name'] ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context) ? 22 : 18,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
), // Replace YourChildWidget with the widget you want to wrap
|
|
),
|
|
));
|
|
}
|
|
familyFloaterContainers.add(SizedBox(height: 15));
|
|
}
|
|
|
|
Widget card = Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
child: Padding(
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.all(30)
|
|
: EdgeInsets.all(10),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(
|
|
0xFFFFF1DD), // Set background color for the container
|
|
borderRadius: BorderRadius.circular(
|
|
5), // Set border radius for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 25, right: 25)
|
|
: EdgeInsets.only(
|
|
top: 10, bottom: 10, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 9,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
gmcPolicyName ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize:
|
|
Responsive.isDesktop(context)
|
|
? 20
|
|
: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
if (item['eCardDownload'] != null)
|
|
GestureDetector(
|
|
onTap: () async {
|
|
_launchURL(item['eCardDownload']);
|
|
},
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: Icon(
|
|
Icons.file_download,
|
|
color: Color(0xFFE26728),
|
|
size: 25,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))),
|
|
Expanded(
|
|
flex: 3,
|
|
child: Container(
|
|
alignment: Alignment.centerRight,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
gmcFloaterTextHeading ?? '',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 13,
|
|
),
|
|
),
|
|
Text(
|
|
'₹ ${gmcSumInsured != null ? gmcSumInsured : 'NA'}',
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 20
|
|
: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
Container(
|
|
padding:
|
|
EdgeInsets.only(top: 0, bottom: 0, left: 10, right: 10),
|
|
child: Text(gmcFloaterTextDescription,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 14 : 11,
|
|
color: Color(0xFF727272),
|
|
)),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(
|
|
0xFFF9F9FB), // Set background color for the container
|
|
borderRadius: BorderRadius.circular(
|
|
5), // Set border radius for the container
|
|
),
|
|
padding: Responsive.isDesktop(context)
|
|
? EdgeInsets.only(
|
|
top: 15, bottom: 15, left: 25, right: 25)
|
|
: EdgeInsets.only(
|
|
top: 10, bottom: 10, left: 10, right: 10),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 12,
|
|
child: Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Please Note',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
gmcNotes ?? '',
|
|
textAlign: TextAlign.left,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context)
|
|
? 18
|
|
: 15,
|
|
),
|
|
),
|
|
],
|
|
))),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 15),
|
|
Container(
|
|
padding:
|
|
EdgeInsets.only(top: 0, bottom: 0, left: 15, right: 15),
|
|
child: Text('Please review your enrolled dependents.',
|
|
style: GoogleFonts.poppins(
|
|
fontSize: Responsive.isDesktop(context) ? 18 : 16,
|
|
color: Color(0xFF181818),
|
|
fontWeight: FontWeight.w500,
|
|
)),
|
|
),
|
|
SizedBox(height: 15),
|
|
Column(
|
|
children: familyFloaterContainers,
|
|
),
|
|
],
|
|
),
|
|
));
|
|
|
|
cards.add(card);
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
}
|