375 lines
14 KiB
Dart
Executable File
375 lines
14 KiB
Dart
Executable File
// import 'package:firebase_auth/firebase_auth.dart';
|
|
// import 'package:flutter/cupertino.dart';
|
|
// import 'package:flutter/material.dart';
|
|
// import 'package:flutter/services.dart';
|
|
// import 'package:google_fonts/google_fonts.dart';
|
|
// import 'package:http/http.dart' as http;
|
|
//
|
|
// import '../../presentation/hrPolicyDetails.dart';
|
|
// import '../api_service.dart';
|
|
//
|
|
// class PreEnrollment extends StatefulWidget {
|
|
// final String enrollmentClientId;
|
|
// final String enrollmentClientBranchId;
|
|
// final String enrollmentHrId;
|
|
// final String enrollToken;
|
|
//
|
|
// const PreEnrollment(
|
|
// {Key? key,
|
|
// required this.enrollmentClientId,
|
|
// required this.enrollmentClientBranchId,
|
|
// required this.enrollmentHrId,
|
|
// required this.enrollToken});
|
|
//
|
|
// @override
|
|
// State<PreEnrollment> createState() => _PreEnrollmentState();
|
|
// }
|
|
//
|
|
// class _PreEnrollmentState extends State<PreEnrollment> {
|
|
// late ApiService apiService;
|
|
// dynamic getCardArrays = [];
|
|
// int selectedIndex = 0;
|
|
// bool isLoading = false;
|
|
// // List<Map<String, dynamic>> getCardArrays = [
|
|
// // {
|
|
// // "client_policy_id": "415",
|
|
// // "client_id": "187",
|
|
// // "policy_type_id": "2",
|
|
// // "is_addon": "1",
|
|
// // "OpenForEnrollment": "0",
|
|
// // "inception_type": "1",
|
|
// // "policy_no": "GMC-2002/2022/2005",
|
|
// // "insurer_id": null,
|
|
// // "policy_expiry_date": "06-07-2026",
|
|
// // "type": "GMC",
|
|
// // "policy_name": "Group Medical Coverage",
|
|
// // "insurer_name": null,
|
|
// // "insurer_short_name": null,
|
|
// // "totalMembersCount": 17,
|
|
// // "membersCountOfEnrolled": 0,
|
|
// // "membersCountOfDraft": 17
|
|
// // },
|
|
// // {
|
|
// // "client_policy_id": 396,
|
|
// // "client_id": 58,
|
|
// // "policy_type_id": 4,
|
|
// // "is_addon": 2,
|
|
// // "OpenForEnrollment": 1,
|
|
// // "inception_type": 2,
|
|
// // "policy_no": "GMC-MA8596745566998855885",
|
|
// // "insurer_id": 1,
|
|
// // "type": "GMC - Topup",
|
|
// // "policy_name": "Group Medical Coverage Topup",
|
|
// // "insurer_name": "Life Insurance Corporation of India (LIC)",
|
|
// // "insurer_short_name": "LIC",
|
|
// // "totalMembersCount": 7,
|
|
// // "membersCountOfEnrolled": 0,
|
|
// // "membersCountOfDraft": 7
|
|
// // },
|
|
// //
|
|
// // ];
|
|
//
|
|
// @override
|
|
// void initState() {
|
|
// super.initState();
|
|
// apiService = ApiService(context);
|
|
// _loadData();
|
|
//
|
|
// logDebug("_PreEnrollmentState 1");
|
|
// }
|
|
//
|
|
// Future<void> _loadData() async {
|
|
// await getCashDepositDetails(widget.enrollmentClientBranchId,
|
|
// widget.enrollmentClientId, widget.enrollmentHrId, widget.enrollToken);
|
|
// }
|
|
//
|
|
// Future<void> getCashDepositDetails(
|
|
// clintBranchId, clintID, hr_id, token) async {
|
|
// logDebug("_PreEnrollmentState 2");
|
|
// logDebug('IN');
|
|
// logDebug("clintBranchId -$clintBranchId");
|
|
// logDebug("clintID -$clintID");
|
|
// logDebug("hr_id -$hr_id");
|
|
// logDebug("token -$token");
|
|
//
|
|
// // isLoading = true;
|
|
// setState(() {
|
|
// isLoading = true;
|
|
// });
|
|
// try {
|
|
// if (clintBranchId == null || clintID == null) {
|
|
// return;
|
|
// }
|
|
// final response = await apiService.getCashDepositDetailsToApi(
|
|
// clintID!, clintBranchId!, hr_id, token);
|
|
//
|
|
// // final response = await apiService.getCashDepositDetailsToApi(
|
|
// // clintID!, clintBranchId!, hr_id, token);
|
|
// logDebug('IN1');
|
|
// if (response['status'] == 'success') {
|
|
//
|
|
// setState(() {
|
|
// isLoading = false;
|
|
// logDebug('response');
|
|
// logDebug(response['data']);
|
|
//
|
|
// logDebug("_PreEnrollmentState 3");
|
|
// // getCardArrays = [];
|
|
// getCardArrays = List<Map<String, dynamic>>.from(response['data']);
|
|
// logDebug('getCardArrays');
|
|
// logDebug(getCardArrays);
|
|
// });
|
|
//
|
|
// logDebug('IN2');
|
|
// logDebug("getCardArrays9 - $getCardArrays");
|
|
// } else {
|
|
// setState(() {
|
|
// isLoading = false;
|
|
// });
|
|
//
|
|
// logDebug('API request failed with status');
|
|
// }
|
|
// } catch (e) {
|
|
// logDebug('Exception occurred: $e');
|
|
// }
|
|
// }
|
|
//
|
|
// @override
|
|
// Widget build(BuildContext context) {
|
|
// final screenWidth = MediaQuery.of(context).size.width;
|
|
// final screenHeight = MediaQuery.of(context).size.height;
|
|
//
|
|
// final crossAxisCount = 4;
|
|
// final spacing = 20.0; // crossAxisSpacing
|
|
// final totalSpacing = (crossAxisCount - 1) * spacing;
|
|
// final itemWidth = (screenWidth - totalSpacing) / crossAxisCount;
|
|
//
|
|
// // Example: target card height
|
|
// final itemHeight = screenHeight * 0.2;
|
|
//
|
|
// // Dynamic aspect ratio:
|
|
// final aspectRatio = screenWidth / screenHeight;
|
|
//
|
|
// logDebug("_PreEnrollmentState 4");
|
|
// // TODO: implement build
|
|
// return Container(
|
|
// // height: MediaQuery.of(context).size.height * 0.2,
|
|
//
|
|
// // height: 400,
|
|
// padding: const EdgeInsets.all(16.0),
|
|
// decoration: BoxDecoration(
|
|
// color: Colors.white,
|
|
// // color: Colors.yellow.shade100,
|
|
// borderRadius: BorderRadius.circular(16),
|
|
// ),
|
|
// //
|
|
// child: Column(
|
|
// mainAxisAlignment: MainAxisAlignment.start,
|
|
// children: [
|
|
// 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
|
|
// ),
|
|
// )
|
|
// : Flexible(
|
|
// child: Container(
|
|
// // color: Colors.redAccent.shade100,
|
|
// // color: Colors.white,
|
|
// // color: Colors.white,
|
|
// // padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
// // height: MediaQuery.of(context).size.height * 0.45,
|
|
// // height: 400,
|
|
//
|
|
// child: Container(
|
|
// child: getCardArrays.isEmpty
|
|
// ? Center(
|
|
// child: Column(
|
|
// mainAxisSize: MainAxisSize.min,
|
|
// children: [
|
|
// Image.asset(
|
|
// 'assets/searchData.jpg', // Replace 'default_image.png' with your default image asset path
|
|
// width: 200,
|
|
// height: 200,
|
|
// fit: BoxFit.cover,
|
|
// ),
|
|
// Text(
|
|
// 'No Policy Mapping Found',
|
|
// style: TextStyle(
|
|
// fontSize: 16,
|
|
// color: Colors.grey.shade600,
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// )
|
|
// : GridView.builder(
|
|
// itemCount: getCardArrays.length,
|
|
// gridDelegate:
|
|
// const SliverGridDelegateWithFixedCrossAxisCount(
|
|
// crossAxisCount: 4,
|
|
// crossAxisSpacing: 20,
|
|
// mainAxisSpacing: 20,
|
|
// childAspectRatio: 2.4,
|
|
// // childAspectRatio: aspectRatio,
|
|
// // childAspectRatio: 2.1,
|
|
// ),
|
|
// itemBuilder: (context, index) {
|
|
// return buildPolicyCard(getCardArrays[index]);
|
|
// },
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// );
|
|
// }
|
|
//
|
|
// Widget buildPolicyCard(Map<String, dynamic> policy) {
|
|
// final mediaQuery = MediaQuery.of(context);
|
|
// final devicePixelRatio = mediaQuery.devicePixelRatio;
|
|
// final logicalWidth = 230 / devicePixelRatio;
|
|
// final logicalHeight = 189 / devicePixelRatio;
|
|
//
|
|
// logDebug("logicalWidth - $logicalWidth");
|
|
// logDebug("logicalHeight - $logicalHeight");
|
|
// return InkWell(
|
|
// onTap: () {
|
|
// setState(() {
|
|
// logDebug("policytab - $policy");
|
|
// Navigator.push(
|
|
// context,
|
|
// MaterialPageRoute(
|
|
// builder: (context) => hrPolicyDetails(
|
|
// ClientId: widget.enrollmentClientId, // <-- from map
|
|
// policyTypeId:
|
|
// policy['policy_type_id'].toString(), // <-- from map
|
|
// ClientPoliyId: policy['client_policy_id'].toString(),
|
|
// clientBranchId: widget.enrollmentClientBranchId,
|
|
// Token: widget.enrollToken,
|
|
// TokenType: "pre",
|
|
// cardType: policy['type'].toString(),
|
|
// cardPolicyNo: policy['policy_no'].toString(),
|
|
// cardInsurer_name: policy['insurer_short_name'].toString(),
|
|
// cardPolicy_name: policy['policy_name'].toString(),
|
|
// cardPolicy_ExpDate: policy['policy_expiry_date'].toString(),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// });
|
|
// },
|
|
//
|
|
// // height: MediaQuery.of(context).size.height * 0.1,
|
|
// // width: MediaQuery.of(context).size.height * 0.1,
|
|
// // width: logicalWidth,
|
|
// // height: logicalHeight,
|
|
// child: Container(
|
|
// margin: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
|
|
// // height: MediaQuery.of(context).size.height * 1,
|
|
// // width: MediaQuery.of(context).size.height * 0.1,
|
|
// // margin: EdgeInsets.only(bottom: 10.0),
|
|
// decoration: BoxDecoration(
|
|
// // color: Colors.yellow.shade50,
|
|
// color: Colors.white,
|
|
// borderRadius: BorderRadius.circular(12),
|
|
// boxShadow: const [
|
|
// BoxShadow(
|
|
// color: Colors.black12,
|
|
// blurRadius: 6,
|
|
// spreadRadius: 1,
|
|
// offset: Offset(0, 0), // Equal shadow in all directions
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
// child: Padding(
|
|
// padding: const EdgeInsets.all(12),
|
|
// child: Column(
|
|
// mainAxisSize: MainAxisSize.min,
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
// children: [
|
|
// Container(
|
|
// height: MediaQuery.of(context).size.height * 0.03,
|
|
// // color: Colors.green.shade100,
|
|
// child: Row(
|
|
// children: [
|
|
// Column(
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
// children: [
|
|
// Text(
|
|
// "${policy['type']} - ${policy['policy_no']} " ?? '',
|
|
// style: const TextStyle(
|
|
// fontFamily: "Inter",
|
|
// fontWeight: FontWeight.w600,
|
|
// fontSize: 12,
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// // Spacer(),
|
|
// SizedBox(
|
|
// height: 5,
|
|
// ),
|
|
// Container(
|
|
// // color: Colors.pink.shade50,
|
|
// height: MediaQuery.of(context).size.height * 0.09,
|
|
// child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.start,
|
|
// children: [
|
|
// _buildCountBox(
|
|
// policy['membersCountOfDraft'].toString(), "Draft"),
|
|
// Spacer(),
|
|
// _buildCountBox(policy['membersCountOfEnrolled'].toString(),
|
|
// "Enrolled"),
|
|
// Spacer(),
|
|
// _buildCountBox(
|
|
// policy['totalMembersCount'].toString(), "Total"),
|
|
// // Spacer(),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// }
|
|
//
|
|
// Widget _buildCountBox(String count, String label) {
|
|
// return Column(
|
|
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
// children: [
|
|
// Container(
|
|
// // width: 70,
|
|
// // height: 40,
|
|
// height: MediaQuery.of(context).size.height * 0.05,
|
|
// width: MediaQuery.of(context).size.height * 0.1,
|
|
// alignment: Alignment.center,
|
|
// decoration: BoxDecoration(
|
|
// color: const Color(0xFFDFF1F3),
|
|
// borderRadius: BorderRadius.circular(8),
|
|
// ),
|
|
// child: Text(
|
|
// count,
|
|
// style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
|
|
// ),
|
|
// ),
|
|
// // Spacer(),
|
|
// const SizedBox(height: 8),
|
|
// Text(label,
|
|
// style: const TextStyle(fontSize: 10, color: Color(0xFF848484))),
|
|
// ],
|
|
// );
|
|
// }
|
|
// }
|