Non-EB
This commit is contained in:
parent
9a3367e802
commit
f940e53501
@ -886,6 +886,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
cardPolicy_ExpDate:
|
||||
widget.cardPolicy_ExpDate,
|
||||
total_premium: widget.total_premium,
|
||||
allocgType: 'EB',
|
||||
|
||||
// Token: localToken,
|
||||
// ClientId: widget.ClientId,
|
||||
|
||||
@ -10,6 +10,7 @@ import 'package:nhancepolicy/service/api_service.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/activePolicies.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/cd.dart';
|
||||
import 'package:nhancepolicy/presentation/claims.dart';
|
||||
import 'package:nhancepolicy/presentation/postFileUpload.dart';
|
||||
import 'package:nhancepolicy/service/hrDashboardTabs/preEnrollment.dart';
|
||||
import 'package:nhancepolicy/service/token_storage_service.dart';
|
||||
import 'package:nhancepolicy/service/_ResponsiveGridConfig.dart';
|
||||
@ -584,6 +585,11 @@ class _PolicyGrid extends StatelessWidget {
|
||||
this.onBulkDownload,
|
||||
});
|
||||
|
||||
bool _isNonEbPolicy(Map<String, dynamic> data) {
|
||||
final allocg = (data['allocg'] ?? '').toString().trim().toLowerCase();
|
||||
return allocg == 'non-eb';
|
||||
}
|
||||
|
||||
ResponsiveGridConfig _getGridConfig(
|
||||
BuildContext context,
|
||||
bool isEnrollment,
|
||||
@ -611,13 +617,80 @@ class _PolicyGrid extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokenService = TokenStorageService();
|
||||
final config = _getGridConfig(context, isEnrollment);
|
||||
|
||||
final int rowCount = (policies.length / config.crossAxisCount).ceil();
|
||||
/// ✅ Enrollment → No change
|
||||
if (isEnrollment) {
|
||||
return _buildGrid(
|
||||
context,
|
||||
policies,
|
||||
config,
|
||||
tokenService,
|
||||
);
|
||||
}
|
||||
|
||||
/// ✅ Active → Split EB / Non-EB
|
||||
final ebPolicies = policies.where((p) => p['allocg'] == 'EB').toList();
|
||||
|
||||
final nonEbPolicies =
|
||||
policies.where((p) => p['allocg'] == 'Non-EB').toList();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// ✅ EB section
|
||||
if (ebPolicies.isNotEmpty) ...[
|
||||
Text(
|
||||
'EB Policies',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: const Color(0xFF009195),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildGrid(
|
||||
context,
|
||||
ebPolicies,
|
||||
config,
|
||||
tokenService,
|
||||
),
|
||||
],
|
||||
|
||||
/// ✅ Non-EB section
|
||||
if (nonEbPolicies.isNotEmpty) ...[
|
||||
Text(
|
||||
'Non-EB Policies',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: const Color(0xFFD06A00),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildGrid(
|
||||
context,
|
||||
nonEbPolicies,
|
||||
config,
|
||||
tokenService,
|
||||
isNonEb: true,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGrid(
|
||||
BuildContext context,
|
||||
List<Map<String, dynamic>> list,
|
||||
ResponsiveGridConfig config,
|
||||
TokenStorageService tokenService, {
|
||||
bool isNonEb = false,
|
||||
}) {
|
||||
final int rowCount = (list.length / config.crossAxisCount).ceil();
|
||||
|
||||
double cardHeight;
|
||||
|
||||
@ -628,7 +701,6 @@ class _PolicyGrid extends StatelessWidget {
|
||||
}
|
||||
|
||||
final double totalHeight = rowCount * cardHeight + ((rowCount - 1) * 16);
|
||||
|
||||
return SizedBox(
|
||||
height: totalHeight,
|
||||
child: GridView.builder(
|
||||
@ -642,9 +714,9 @@ class _PolicyGrid extends StatelessWidget {
|
||||
mainAxisSpacing: 16,
|
||||
mainAxisExtent: isEnrollment ? 120 : 150, // fixed card height
|
||||
),
|
||||
itemCount: policies.length,
|
||||
itemCount: list.length,
|
||||
itemBuilder: (context, index) {
|
||||
final data = policies[index];
|
||||
final data = list[index];
|
||||
|
||||
return isEnrollment
|
||||
? _EnrollmentPolicyCardNew(
|
||||
@ -687,6 +759,7 @@ class _PolicyGrid extends StatelessWidget {
|
||||
)
|
||||
: _ActivePolicyCardNew(
|
||||
data: data,
|
||||
isNonEb: isNonEb,
|
||||
onBulkDownload: onBulkDownload,
|
||||
onTap: () async {
|
||||
final token = await tokenService.getCurrentToken();
|
||||
@ -704,6 +777,34 @@ class _PolicyGrid extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isNonEbPolicy(data)) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
settings: const RouteSettings(name: 'postFileUpload'),
|
||||
builder: (_) => postFileUpload(
|
||||
ClientId: clientId,
|
||||
policyTypeId: data['policy_type_id'].toString(),
|
||||
ClientPoliyId: data['client_policy_id'].toString(),
|
||||
clientBranchId: branchId,
|
||||
Token: token,
|
||||
TokenType: 'post',
|
||||
cardType: data['type'].toString(),
|
||||
cardPolicyNo: data['policy_no'].toString(),
|
||||
cardInsurer_name:
|
||||
data['insurer_short_name'].toString(),
|
||||
cardPolicy_name:
|
||||
data['policy_name']?.toString() ?? '',
|
||||
cardPolicy_ExpDate:
|
||||
data['policy_expiry_date'].toString(),
|
||||
total_premium: data['total_premium'].toString(),
|
||||
allocgType: 'NONEB',
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
@ -954,11 +1055,13 @@ class _ActivePolicyCardNew extends StatelessWidget {
|
||||
final Map<String, dynamic> data;
|
||||
final VoidCallback? onTap;
|
||||
final Function(String clientPolicyId)? onBulkDownload;
|
||||
final bool isNonEb;
|
||||
|
||||
const _ActivePolicyCardNew({
|
||||
required this.data,
|
||||
this.onTap,
|
||||
this.onBulkDownload,
|
||||
this.isNonEb = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -970,7 +1073,9 @@ class _ActivePolicyCardNew extends StatelessWidget {
|
||||
onTap: onTap, // 👈 card click
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE9F6FB),
|
||||
color: isNonEb
|
||||
? const Color(0xFFFFF3E0) // 🔥 Non-EB
|
||||
: const Color(0xFFE9F6FB), // EB
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.all(14),
|
||||
|
||||
@ -39,6 +39,7 @@ class postFileUpload extends StatefulWidget {
|
||||
final String cardPolicy_name;
|
||||
final String cardPolicy_ExpDate;
|
||||
final String total_premium;
|
||||
final String allocgType;
|
||||
const postFileUpload(
|
||||
{Key? key,
|
||||
required this.ClientId,
|
||||
@ -52,7 +53,8 @@ class postFileUpload extends StatefulWidget {
|
||||
required this.cardInsurer_name,
|
||||
required this.cardPolicy_name,
|
||||
required this.cardPolicy_ExpDate,
|
||||
required this.total_premium})
|
||||
required this.total_premium,
|
||||
this.allocgType = ''})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -74,6 +76,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
String localCardPolicyName = '';
|
||||
String localCardPolicyExpDate = '';
|
||||
String localTotalPremium = '';
|
||||
String localAllocgType = '';
|
||||
|
||||
Uint8List? fileBytes;
|
||||
Uint8List? fileBytes2;
|
||||
@ -214,6 +217,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
localTotalPremium = widget.total_premium.isNotEmpty
|
||||
? widget.total_premium
|
||||
: await tokenService.readValue('upload_total_premium') ?? '';
|
||||
|
||||
localAllocgType = widget.allocgType;
|
||||
}
|
||||
|
||||
Future<void> clearUploadStorage() async {
|
||||
@ -262,7 +267,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
Future<void> getFileUploadMasterDetails() async {
|
||||
logDebug('9');
|
||||
try {
|
||||
final response = await apiService.getFileUploadMastersToApi(localToken);
|
||||
final response = await apiService.getFileUploadMastersToApi(localToken,localAllocgType);
|
||||
|
||||
if (response['status'] == true) {
|
||||
logDebug('getFileUploadMasterList1');
|
||||
|
||||
@ -845,12 +845,12 @@ class ApiService {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getFileUploadMastersToApi(String token) async {
|
||||
Future<Map<String, dynamic>> getFileUploadMastersToApi(String token,localAllocgType) async {
|
||||
logDebug(_hrtoken);
|
||||
if (token == null) {
|
||||
await _initializeToken();
|
||||
}
|
||||
final url = Uri.parse('${Environment.apiUrlPost}hrFileUploadMasters');
|
||||
final url = Uri.parse('${Environment.apiUrlPost}hrFileUploadMasters?type=$localAllocgType');
|
||||
final headers = {
|
||||
'Authorization': 'Bearer $token' ?? '',
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user