pre and post bug fix
This commit is contained in:
parent
3ec22aa137
commit
a2d1480b5a
98
lib/presentation/claims_overview/claims_overview_cache.dart
Normal file
98
lib/presentation/claims_overview/claims_overview_cache.dart
Normal file
@ -0,0 +1,98 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class ClaimsOverviewCacheEntry {
|
||||
final String policyId;
|
||||
final Map<String, dynamic> claimsKpiBySlug;
|
||||
final Map<String, dynamic> enrollmentKpiBySlug;
|
||||
final DateTime generatedAt;
|
||||
final String? claimsLoadError;
|
||||
final String? enrollmentLoadError;
|
||||
|
||||
const ClaimsOverviewCacheEntry({
|
||||
required this.policyId,
|
||||
required this.claimsKpiBySlug,
|
||||
required this.enrollmentKpiBySlug,
|
||||
required this.generatedAt,
|
||||
this.claimsLoadError,
|
||||
this.enrollmentLoadError,
|
||||
});
|
||||
|
||||
factory ClaimsOverviewCacheEntry.fromJson(Map<String, dynamic> json) {
|
||||
return ClaimsOverviewCacheEntry(
|
||||
policyId: json['policyId']?.toString() ?? '',
|
||||
claimsKpiBySlug: Map<String, dynamic>.from(json['claimsKpiBySlug'] ?? {}),
|
||||
enrollmentKpiBySlug:
|
||||
Map<String, dynamic>.from(json['enrollmentKpiBySlug'] ?? {}),
|
||||
generatedAt: DateTime.tryParse(json['generatedAt']?.toString() ?? '') ??
|
||||
DateTime.now(),
|
||||
claimsLoadError: json['claimsLoadError']?.toString(),
|
||||
enrollmentLoadError: json['enrollmentLoadError']?.toString(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'policyId': policyId,
|
||||
'claimsKpiBySlug': claimsKpiBySlug,
|
||||
'enrollmentKpiBySlug': enrollmentKpiBySlug,
|
||||
'generatedAt': generatedAt.toIso8601String(),
|
||||
'claimsLoadError': claimsLoadError,
|
||||
'enrollmentLoadError': enrollmentLoadError,
|
||||
};
|
||||
}
|
||||
|
||||
abstract final class ClaimsOverviewCache {
|
||||
static const _keyPrefix = 'claims_overview_cache_v1_';
|
||||
|
||||
static String _key(String branchId, String policyId) =>
|
||||
'$_keyPrefix${branchId}_$policyId';
|
||||
|
||||
static Future<ClaimsOverviewCacheEntry?> read(
|
||||
String branchId,
|
||||
String policyId,
|
||||
) async {
|
||||
if (branchId.isEmpty || policyId.isEmpty) return null;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final raw = prefs.getString(_key(branchId, policyId));
|
||||
if (raw == null || raw.isEmpty) return null;
|
||||
try {
|
||||
final decoded = jsonDecode(raw);
|
||||
if (decoded is! Map) return null;
|
||||
return ClaimsOverviewCacheEntry.fromJson(
|
||||
Map<String, dynamic>.from(decoded),
|
||||
);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> write(
|
||||
String branchId,
|
||||
ClaimsOverviewCacheEntry entry,
|
||||
) async {
|
||||
if (branchId.isEmpty || entry.policyId.isEmpty) return;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(
|
||||
_key(branchId, entry.policyId),
|
||||
jsonEncode(entry.toJson()),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> clear(String branchId, String policyId) async {
|
||||
if (branchId.isEmpty || policyId.isEmpty) return;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(_key(branchId, policyId));
|
||||
}
|
||||
|
||||
static Future<void> clearAll() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final keys = prefs
|
||||
.getKeys()
|
||||
.where((key) => key.startsWith(_keyPrefix))
|
||||
.toList();
|
||||
for (final key in keys) {
|
||||
await prefs.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../customAppBar/base_layout.dart';
|
||||
import '../../customAppBar/toastHelper.dart';
|
||||
@ -10,6 +11,7 @@ import '../../service/api_service.dart';
|
||||
import '../../service/secure_pop_scope.dart';
|
||||
import '../../service/token_storage_service.dart';
|
||||
import 'claims_collection_kpi.dart';
|
||||
import 'claims_overview_cache.dart';
|
||||
import 'enrollment_collection_kpi.dart';
|
||||
import 'claims_overview_animations.dart';
|
||||
import 'claims_overview_pdf_export.dart';
|
||||
@ -50,6 +52,13 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
String? _selectedPolicyId;
|
||||
List<Map<String, dynamic>> _activePolicies = [];
|
||||
Uint8List? _clientLogoBytes;
|
||||
DateTime? _dataGeneratedAt;
|
||||
|
||||
String? get _formattedGeneratedAt {
|
||||
final generatedAt = _dataGeneratedAt;
|
||||
if (generatedAt == null) return null;
|
||||
return DateFormat('d MMM yyyy, h:mm a').format(generatedAt.toLocal());
|
||||
}
|
||||
|
||||
static const _tabs = [
|
||||
(Icons.dashboard_outlined, 'Overview'),
|
||||
@ -105,7 +114,10 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadDashboard({bool reloadPolicies = false}) async {
|
||||
Future<void> _loadDashboard({
|
||||
bool reloadPolicies = false,
|
||||
bool forceRefresh = false,
|
||||
}) async {
|
||||
final isInitialLoad = _replayToken == 0;
|
||||
setState(() {
|
||||
if (isInitialLoad) {
|
||||
@ -116,8 +128,8 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
});
|
||||
|
||||
try {
|
||||
_clientId ??= await _tokenService.readValue('empClientId');
|
||||
_clientBranchId ??= await _tokenService.readValue('empClientBranchId');
|
||||
_clientId = await _tokenService.readValue('empClientId');
|
||||
_clientBranchId = await _tokenService.readValue('empClientBranchId');
|
||||
final hrId = await _tokenService.readValue('empHrId');
|
||||
final token = await _tokenService.getCurrentToken();
|
||||
if (token != null && token.isNotEmpty) {
|
||||
@ -141,6 +153,7 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
error: 'No active policy found',
|
||||
);
|
||||
_enrollmentViewData = EnrollmentOverviewViewData.empty();
|
||||
_dataGeneratedAt = null;
|
||||
_isLoading = false;
|
||||
_isRefreshing = false;
|
||||
});
|
||||
@ -148,6 +161,28 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
}
|
||||
|
||||
final policyId = _selectedPolicyId!;
|
||||
final branchId = _clientBranchId ?? '';
|
||||
|
||||
if (forceRefresh) {
|
||||
await ClaimsOverviewCache.clear(branchId, policyId);
|
||||
}
|
||||
|
||||
if (!forceRefresh) {
|
||||
final cached = await ClaimsOverviewCache.read(branchId, policyId);
|
||||
if (cached != null) {
|
||||
_applyCacheEntry(cached);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_isRefreshing = false;
|
||||
if (_replayToken == 0) {
|
||||
_replayToken++;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final response = await _apiService.getClaimsCollectionV2All(
|
||||
clientPolicyId: policyId,
|
||||
);
|
||||
@ -186,6 +221,7 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
setState(() {
|
||||
_viewData = claimsData;
|
||||
_enrollmentViewData = enrollmentData;
|
||||
_dataGeneratedAt = DateTime.now();
|
||||
_isLoading = false;
|
||||
_isRefreshing = false;
|
||||
_replayToken++;
|
||||
@ -195,10 +231,24 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
}
|
||||
}
|
||||
|
||||
final generatedAt = DateTime.now();
|
||||
await ClaimsOverviewCache.write(
|
||||
branchId,
|
||||
ClaimsOverviewCacheEntry(
|
||||
policyId: policyId,
|
||||
claimsKpiBySlug: claimsData.kpiBySlug,
|
||||
enrollmentKpiBySlug: enrollmentData.kpiBySlug,
|
||||
generatedAt: generatedAt,
|
||||
claimsLoadError: claimsData.loadError,
|
||||
enrollmentLoadError: enrollmentData.loadError,
|
||||
),
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_viewData = claimsData;
|
||||
_enrollmentViewData = enrollmentData;
|
||||
_dataGeneratedAt = generatedAt;
|
||||
_isLoading = false;
|
||||
_isRefreshing = false;
|
||||
_replayToken++;
|
||||
@ -209,6 +259,7 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
_viewData = ClaimsOverviewViewData.empty(error: e.toString());
|
||||
_enrollmentViewData =
|
||||
EnrollmentOverviewViewData.empty(error: e.toString());
|
||||
_dataGeneratedAt = null;
|
||||
_isLoading = false;
|
||||
_isRefreshing = false;
|
||||
});
|
||||
@ -216,9 +267,21 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
}
|
||||
}
|
||||
|
||||
void _applyCacheEntry(ClaimsOverviewCacheEntry entry) {
|
||||
_viewData = ClaimsOverviewViewData(
|
||||
kpiBySlug: Map<String, dynamic>.from(entry.claimsKpiBySlug),
|
||||
loadError: entry.claimsLoadError,
|
||||
);
|
||||
_enrollmentViewData = EnrollmentOverviewViewData(
|
||||
kpiBySlug: Map<String, dynamic>.from(entry.enrollmentKpiBySlug),
|
||||
loadError: entry.enrollmentLoadError,
|
||||
);
|
||||
_dataGeneratedAt = entry.generatedAt;
|
||||
}
|
||||
|
||||
Future<void> _loadPolicyList(String token, String hrId) async {
|
||||
_clientId ??= await _tokenService.readValue('empClientId');
|
||||
_clientBranchId ??= await _tokenService.readValue('empClientBranchId');
|
||||
_clientId = await _tokenService.readValue('empClientId');
|
||||
_clientBranchId = await _tokenService.readValue('empClientBranchId');
|
||||
|
||||
if (_clientId == null || _clientBranchId == null) return;
|
||||
|
||||
@ -386,7 +449,7 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
policyId: _selectedPolicyId ?? '',
|
||||
dashboardInfo: ClaimsPdfDashboardInfo(
|
||||
policyLabel: _selectedPolicyLabel(),
|
||||
misCreationDate: _viewData.liveUpdatedAt,
|
||||
misCreationDate: _formattedGeneratedAt,
|
||||
),
|
||||
clientLogoBytes: _clientLogoBytes,
|
||||
onProgress: (_, __, label) {
|
||||
@ -550,13 +613,17 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
color: ClaimsOverviewTheme.textSecondary,
|
||||
),
|
||||
),
|
||||
if (_viewData.liveUpdatedAt != null &&
|
||||
_viewData.liveUpdatedAt!.isNotEmpty) ...[
|
||||
if (_formattedGeneratedAt != null) ...[
|
||||
const SizedBox(width: 12),
|
||||
ClaimsLiveIndicator(
|
||||
createdAt: _viewData.liveUpdatedAt,
|
||||
createdAt: _formattedGeneratedAt,
|
||||
),
|
||||
],
|
||||
ClaimsRefreshIcon(
|
||||
isRefreshing: _isRefreshing,
|
||||
onPressed: () =>
|
||||
_loadDashboard(forceRefresh: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -593,11 +660,6 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
ClaimsRefreshIcon(
|
||||
isRefreshing: _isRefreshing,
|
||||
onPressed: _loadDashboard,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -639,10 +701,6 @@ class _ClaimsOverviewDashboardState extends State<ClaimsOverviewDashboard>
|
||||
Icons.arrow_drop_down,
|
||||
color: ClaimsOverviewTheme.textSecondary,
|
||||
),
|
||||
ClaimsRefreshIcon(
|
||||
isRefreshing: _isRefreshing,
|
||||
onPressed: _loadDashboard,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -41,7 +41,7 @@ class ClaimsTabPanelRow extends StatelessWidget {
|
||||
panels.map((p) {
|
||||
return SizedBox(
|
||||
width: available * p.flex / totalFlex,
|
||||
child: ClipRect(child: p.child),
|
||||
child: p.child,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
@ -5,6 +5,15 @@ import 'claims_overview_animations.dart';
|
||||
import 'claims_overview_scope.dart';
|
||||
import 'claims_overview_theme.dart';
|
||||
|
||||
bool _overviewUsesWideLayout(
|
||||
BuildContext context,
|
||||
BoxConstraints constraints, {
|
||||
double minWidth = 520,
|
||||
}) {
|
||||
if (ClaimsPdfExportScope.of(context)) return true;
|
||||
return constraints.maxWidth >= minWidth;
|
||||
}
|
||||
|
||||
/// Hover / tap focus wrapper for dashboard tiles.
|
||||
class ClaimsFocusCard extends StatefulWidget {
|
||||
final Widget child;
|
||||
@ -163,9 +172,9 @@ class ClaimsPolicyInformationBody extends StatelessWidget {
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 520;
|
||||
final wide = _overviewUsesWideLayout(context, constraints);
|
||||
|
||||
if (narrow) {
|
||||
if (!wide) {
|
||||
return Column(
|
||||
children: [
|
||||
startTile,
|
||||
@ -218,7 +227,7 @@ class ClaimsExperienceBody extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final wide = constraints.maxWidth >= 520;
|
||||
final wide = _overviewUsesWideLayout(context, constraints);
|
||||
final incurredTile = _OverviewInnerTile(
|
||||
label: 'Incurred Claims',
|
||||
icon: Icons.gps_fixed,
|
||||
@ -283,7 +292,11 @@ class ClaimsInceptionBody extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final wide = constraints.maxWidth >= 400;
|
||||
final wide = _overviewUsesWideLayout(
|
||||
context,
|
||||
constraints,
|
||||
minWidth: 400,
|
||||
);
|
||||
final valueStyle = GoogleFonts.poppins(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
@ -519,7 +532,7 @@ class ClaimsPremiumMembershipBody extends StatelessWidget {
|
||||
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (constraints.maxWidth < 520) {
|
||||
if (!_overviewUsesWideLayout(context, constraints)) {
|
||||
return Column(
|
||||
children: [
|
||||
premiumTile,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -566,7 +566,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
case 'emp_count':
|
||||
return relationship == 'self';
|
||||
case 'enrolled':
|
||||
return _isEnrolledStatus(status);
|
||||
return _isSelfRow(row) && _isEnrolledStatus(status);
|
||||
case 'not_enrolled':
|
||||
return !_isEnrolledStatus(status);
|
||||
case 'logged_in':
|
||||
@ -574,7 +574,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
case 'not_logged_in':
|
||||
return _isSelfRow(row) && !_isLoggedInRow(row);
|
||||
case 'draft':
|
||||
return status == 'draft';
|
||||
return _isSelfRow(row) && status == 'draft';
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@ -1934,9 +1934,9 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
item['relationship']?.toString().toLowerCase().trim() ?? '';
|
||||
|
||||
if (relationship == 'self') empCount++;
|
||||
if (_isEnrolledStatus(status)) {
|
||||
if (_isSelfRow(item) && _isEnrolledStatus(status)) {
|
||||
enrolled++;
|
||||
} else {
|
||||
} else if (!_isEnrolledStatus(status)) {
|
||||
notEnrolled++;
|
||||
}
|
||||
if (_isSelfRow(item)) {
|
||||
@ -1946,7 +1946,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
notLoggedIn++;
|
||||
}
|
||||
}
|
||||
if (status == 'draft') draft++;
|
||||
if (status == 'draft' && _isSelfRow(item)) draft++;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -900,125 +900,138 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// Select File Action
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: buildStyledDropdown(
|
||||
label: 'Select File Action',
|
||||
value: selectedKey,
|
||||
items: getFileUploadMasterList,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
selectedKey = val;
|
||||
final selectedItem = getFileUploadMasterList
|
||||
.firstWhere((e) => e['key'] == val);
|
||||
selectedValue = selectedItem['value'];
|
||||
currentApiValue = selectedItem['key'];
|
||||
showSampleButton = true;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
/// Upload Box
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// ✅ LABEL
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Upload File',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 640;
|
||||
final fileActionDropdown = buildStyledDropdown(
|
||||
label: 'Select File Action',
|
||||
value: selectedKey,
|
||||
items: getFileUploadMasterList,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
selectedKey = val;
|
||||
final selectedItem =
|
||||
getFileUploadMasterList.firstWhere(
|
||||
(e) => e['key'] == val,
|
||||
);
|
||||
selectedValue = selectedItem['value'];
|
||||
currentApiValue = selectedItem['key'];
|
||||
showSampleButton = true;
|
||||
});
|
||||
},
|
||||
);
|
||||
final uploadField = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Upload File',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black,
|
||||
),
|
||||
children: const [
|
||||
TextSpan(
|
||||
text: '(Supported Formats: XLSX)',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
children: const [
|
||||
TextSpan(
|
||||
text: '(Supported Formats: XLSX)',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w400,
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
DragTarget<html.File>(
|
||||
onAccept: (html.File droppedFile) {
|
||||
setState(() {
|
||||
fileName = droppedFile.name;
|
||||
});
|
||||
_dragAndDropFile(droppedFile);
|
||||
},
|
||||
builder:
|
||||
(context, candidateData, rejectedData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (selectedValue != null) {
|
||||
_uploadFile();
|
||||
} else {
|
||||
ToastHelper.showErrorToast(
|
||||
context,
|
||||
'Please select file action',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF00A6A6),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
/// ✅ DOTTED UPLOAD BOX
|
||||
DragTarget<html.File>(
|
||||
onAccept: (html.File droppedFile) {
|
||||
setState(() {
|
||||
fileName = droppedFile.name;
|
||||
});
|
||||
_dragAndDropFile(droppedFile);
|
||||
},
|
||||
builder:
|
||||
(context, candidateData, rejectedData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (selectedValue != null) {
|
||||
_uploadFile();
|
||||
} else {
|
||||
ToastHelper.showErrorToast(
|
||||
context,
|
||||
'Please select file action',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF00A6A6),
|
||||
width: 1,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
fileName ??
|
||||
'Upload Your Documents',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: fileName == null
|
||||
? Colors.grey
|
||||
: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
fileName ??
|
||||
'Upload Your Documents',
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: fileName == null
|
||||
? Colors.grey
|
||||
: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.file_upload_outlined,
|
||||
size: 18,
|
||||
color: Colors.black,
|
||||
),
|
||||
],
|
||||
const Icon(
|
||||
Icons.file_upload_outlined,
|
||||
size: 18,
|
||||
color: Colors.black,
|
||||
),
|
||||
));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (narrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
fileActionDropdown,
|
||||
const SizedBox(height: 16),
|
||||
uploadField,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: fileActionDropdown,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: uploadField,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Column(
|
||||
@ -1146,27 +1159,35 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true, // ✅ IMPORTANT
|
||||
physics: const NeverScrollableScrollPhysics(), // ✅ Disable inner scroll
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
childAspectRatio: 10,
|
||||
),
|
||||
itemCount: _paginatedData.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _paginatedData[index];
|
||||
return _buildFileCard(item);
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final crossAxisCount = width < 640 ? 1 : 2;
|
||||
const mainAxisExtent = 88.0;
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
mainAxisExtent: mainAxisExtent,
|
||||
),
|
||||
itemCount: _paginatedData.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _paginatedData[index];
|
||||
return _buildFileCard(item);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFileCard(Map<String, dynamic> item) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEFF9FA),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@ -1175,10 +1196,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
/// 📄 File Icon
|
||||
Container(
|
||||
height: 44,
|
||||
width: 44,
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
@ -1187,18 +1207,16 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
child: const Icon(
|
||||
Icons.description_outlined,
|
||||
color: Color(0xFF00A6A6),
|
||||
size: 22,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 12),
|
||||
|
||||
/// 📑 LEFT CONTENT
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// Row 1 → File name
|
||||
Text(
|
||||
item['file_name'] ?? '-',
|
||||
maxLines: 1,
|
||||
@ -1209,12 +1227,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
color: const Color(0xFF101010),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
/// Row 2 → Action - Date
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
const SizedBox(height: 2),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
children: [
|
||||
TextSpan(
|
||||
@ -1234,106 +1249,82 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
),
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
/// 👉 RIGHT SIDE (ICON + STATUS + DOWNLOAD)
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
const SizedBox(width: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// 🔴 Error + Status
|
||||
Row(
|
||||
children: [],
|
||||
),
|
||||
if (item['file_error_status'] == '1')
|
||||
Tooltip(
|
||||
message: 'Info',
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final String? token =
|
||||
await tokenService.getCurrentToken();
|
||||
final String? empClientId =
|
||||
await tokenService.readValue('empClientId');
|
||||
final String? empBranchId =
|
||||
await tokenService.readValue('empClientBranchId');
|
||||
|
||||
const SizedBox(height: 8),
|
||||
if (token == null ||
|
||||
empClientId == null ||
|
||||
empBranchId == null) {
|
||||
debugPrint(
|
||||
'❌ Missing required data for navigation $token');
|
||||
return;
|
||||
}
|
||||
|
||||
Row(
|
||||
children: [
|
||||
if (item['file_error_status'] == '1')
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
logDebug(item);
|
||||
// return;
|
||||
final String? token =
|
||||
await tokenService.getCurrentToken();
|
||||
final String? empClientId =
|
||||
await tokenService.readValue('empClientId');
|
||||
final String? empBranchId =
|
||||
await tokenService.readValue('empClientBranchId');
|
||||
|
||||
logDebug(item);
|
||||
logDebug(empClientId);
|
||||
logDebug(localPolicyTypeId);
|
||||
logDebug(empBranchId);
|
||||
logDebug(token);
|
||||
logDebug('post');
|
||||
logDebug(localCardType);
|
||||
logDebug(localCardPolicyNo);
|
||||
logDebug(localCardInsurerName);
|
||||
logDebug(localCardPolicyName);
|
||||
logDebug(localCardPolicyExpDate);
|
||||
logDebug(item['id']);
|
||||
|
||||
// ✅ SAFETY CHECK
|
||||
if (token == null ||
|
||||
empClientId == null ||
|
||||
empBranchId == null) {
|
||||
debugPrint(
|
||||
'❌ Missing required data for navigation ${token}');
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => excelErrorScreen(
|
||||
ClientId: empClientId,
|
||||
policy_no: item['policy_no'],
|
||||
action: item['file_action'],
|
||||
created_at: item['created_at'],
|
||||
clientBranchId: empBranchId,
|
||||
Token: token,
|
||||
TokenType: 'post',
|
||||
id: item['id']),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
_buildStatusChip(item['status']),
|
||||
SizedBox(width: 10),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
getHrFileDownload(item['id'], item['file_name']);
|
||||
if (!context.mounted) return;
|
||||
await openExcelErrorScreenIfAvailable(
|
||||
context: context,
|
||||
apiService: apiService,
|
||||
fileId: item['id'].toString(),
|
||||
tokenType: 'post',
|
||||
clientId: empClientId,
|
||||
policyNo: item['policy_no']?.toString() ?? '',
|
||||
action: item['file_action']?.toString() ?? '',
|
||||
createdAt: item['created_at']?.toString() ?? '',
|
||||
clientBranchId: empBranchId,
|
||||
token: token,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 30,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFC5F2F4),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFF76CED2)),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.file_download_outlined,
|
||||
color: Color(0xFF1D1B20),
|
||||
size: 22,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildStatusChip(item['status']),
|
||||
const SizedBox(width: 8),
|
||||
Tooltip(
|
||||
message: 'Download',
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
getHrFileDownload(item['id'], item['file_name']);
|
||||
},
|
||||
child: Container(
|
||||
height: 28,
|
||||
width: 28,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFC5F2F4),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFF76CED2)),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.file_download_outlined,
|
||||
color: Color(0xFF1D1B20),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/// ⬇ Download
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -1428,75 +1419,109 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
Widget paginationControls = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
DropdownButton<int>(
|
||||
value: _rowsPerPage,
|
||||
items: [6, 10, 15, 20, 50].map((int value) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: value,
|
||||
child: Text(
|
||||
' $value ',
|
||||
style: GoogleFonts.poppins(fontSize: 15),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_rowsPerPage = newValue!;
|
||||
_currentPage = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Previous Page',
|
||||
onPressed:
|
||||
_currentPage > 1 ? () => setState(() => _currentPage--) : null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
if (!visiblePages.contains(1))
|
||||
Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
DropdownButton<int>(
|
||||
value: _rowsPerPage,
|
||||
items: [6, 10, 15, 20, 50].map((int value) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: value,
|
||||
child: Text(' $value ',
|
||||
style: GoogleFonts.poppins(fontSize: 15)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_rowsPerPage = newValue!;
|
||||
_currentPage = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
tooltip: 'Previous Page',
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
if (!visiblePages.contains(1))
|
||||
Row(children: [
|
||||
_buildPageButton(1),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text("..."),
|
||||
),
|
||||
]),
|
||||
|
||||
// Visible page buttons
|
||||
for (int page in visiblePages) _buildPageButton(page),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages))
|
||||
Row(children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text("..."),
|
||||
),
|
||||
_buildPageButton(totalPages),
|
||||
]),
|
||||
|
||||
// Next button
|
||||
IconButton(
|
||||
onPressed: _currentPage < totalPages
|
||||
? () => setState(() => _currentPage++)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
_buildPageButton(1),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text('...'),
|
||||
),
|
||||
],
|
||||
),
|
||||
for (int page in visiblePages) _buildPageButton(page),
|
||||
if (!visiblePages.contains(totalPages) && totalPages > 0)
|
||||
Row(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text('...'),
|
||||
),
|
||||
_buildPageButton(totalPages),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage < totalPages
|
||||
? () => setState(() => _currentPage++)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final showingText = Text(
|
||||
'Showing $startEntry to $endEntry of $totalItems entries',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: const Color(0xFF585757),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 720;
|
||||
if (narrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
showingText,
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: paginationControls,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
showingText,
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: paginationControls,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPageButton(int page) {
|
||||
|
||||
@ -930,66 +930,140 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 260, // 👈 set your required width
|
||||
child: _dateField(
|
||||
label: 'Enrolment Open Date',
|
||||
controller: openDateController,
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime.now(),
|
||||
initialDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
final formatted =
|
||||
DateFormat('dd-MM-yyyy').format(picked);
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 580;
|
||||
if (narrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_dateField(
|
||||
label: 'Enrolment Open Date',
|
||||
controller: openDateController,
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime.now(),
|
||||
initialDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
final formatted =
|
||||
DateFormat('dd-MM-yyyy')
|
||||
.format(picked);
|
||||
|
||||
// ✅ If open date changed, clear close date
|
||||
if (openDateController.text != formatted) {
|
||||
closeDateController.clear();
|
||||
}
|
||||
if (openDateController.text !=
|
||||
formatted) {
|
||||
closeDateController.clear();
|
||||
}
|
||||
|
||||
openDateController.text = formatted;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
SizedBox(
|
||||
width: 260, // 👈 same width
|
||||
child: _dateField(
|
||||
label: 'Enrolment Close Date',
|
||||
controller: closeDateController,
|
||||
onTap: () async {
|
||||
if (openDateController.text.isEmpty) {
|
||||
ToastHelper.showErrorToast(context,
|
||||
'Please select Enrolment Open Date first');
|
||||
return;
|
||||
}
|
||||
openDateController.text = formatted;
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_dateField(
|
||||
label: 'Enrolment Close Date',
|
||||
controller: closeDateController,
|
||||
onTap: () async {
|
||||
if (openDateController.text.isEmpty) {
|
||||
ToastHelper.showErrorToast(
|
||||
context,
|
||||
'Please select Enrolment Open Date first',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final openDate = DateFormat('dd-MM-yyyy')
|
||||
.parse(openDateController.text);
|
||||
final openDate =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
openDateController.text,
|
||||
);
|
||||
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate:
|
||||
openDate, // ✅ Cannot select before open date
|
||||
lastDate: DateTime(2100),
|
||||
initialDate: openDate,
|
||||
);
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: openDate,
|
||||
lastDate: DateTime(2100),
|
||||
initialDate: openDate,
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
closeDateController.text =
|
||||
DateFormat('dd-MM-yyyy').format(picked);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
if (picked != null) {
|
||||
closeDateController.text =
|
||||
DateFormat('dd-MM-yyyy')
|
||||
.format(picked);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: _dateField(
|
||||
label: 'Enrolment Open Date',
|
||||
controller: openDateController,
|
||||
onTap: () async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime.now(),
|
||||
initialDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
final formatted =
|
||||
DateFormat('dd-MM-yyyy')
|
||||
.format(picked);
|
||||
|
||||
if (openDateController.text !=
|
||||
formatted) {
|
||||
closeDateController.clear();
|
||||
}
|
||||
|
||||
openDateController.text = formatted;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: _dateField(
|
||||
label: 'Enrolment Close Date',
|
||||
controller: closeDateController,
|
||||
onTap: () async {
|
||||
if (openDateController.text.isEmpty) {
|
||||
ToastHelper.showErrorToast(
|
||||
context,
|
||||
'Please select Enrolment Open Date first',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final openDate =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
openDateController.text,
|
||||
);
|
||||
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
firstDate: openDate,
|
||||
lastDate: DateTime(2100),
|
||||
initialDate: openDate,
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
closeDateController.text =
|
||||
DateFormat('dd-MM-yyyy')
|
||||
.format(picked);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Row(
|
||||
@ -1288,20 +1362,28 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
return const Center(child: Text('No uploaded files'));
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true, // ✅ IMPORTANT
|
||||
physics: const NeverScrollableScrollPhysics(), // ✅ Disable inner scroll
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
childAspectRatio: 10,
|
||||
),
|
||||
itemCount: _paginatedData.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _paginatedData[index];
|
||||
return _buildFileCard(item);
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final crossAxisCount = width < 640 ? 1 : 2;
|
||||
const mainAxisExtent = 88.0;
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
mainAxisExtent: mainAxisExtent,
|
||||
),
|
||||
itemCount: _paginatedData.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _paginatedData[index];
|
||||
return _buildFileCard(item);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -1333,7 +1415,7 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
|
||||
Widget _buildFileCard(Map<String, dynamic> item) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEFF9FA),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@ -1342,10 +1424,9 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
/// 📄 File Icon
|
||||
Container(
|
||||
height: 44,
|
||||
width: 44,
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
@ -1354,18 +1435,16 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
child: const Icon(
|
||||
Icons.description_outlined,
|
||||
color: Color(0xFF00A6A6),
|
||||
size: 22,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 12),
|
||||
|
||||
/// 📑 LEFT CONTENT
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// Row 1 → File name
|
||||
Text(
|
||||
item['file_name'] ?? '-',
|
||||
maxLines: 1,
|
||||
@ -1376,12 +1455,9 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
color: const Color(0xFF101010),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
|
||||
/// Row 2 → Action - Date
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
const SizedBox(height: 2),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
children: [
|
||||
TextSpan(
|
||||
@ -1401,113 +1477,83 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
),
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
/// 👉 RIGHT SIDE (ICON + STATUS + DOWNLOAD)
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
const SizedBox(width: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
/// 🔴 Error + Status
|
||||
Row(
|
||||
children: [],
|
||||
),
|
||||
if (item['file_error_status'] == '1')
|
||||
Tooltip(
|
||||
message: 'Info',
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
final String? token =
|
||||
await tokenService.getCurrentToken();
|
||||
final String? enrollmentClient_id = await tokenService
|
||||
.readValue('enrollmentClient_id');
|
||||
final String? enrollmentEmpClientBranchId =
|
||||
await tokenService
|
||||
.readValue('enrollmentEmpClientBranchId');
|
||||
|
||||
const SizedBox(height: 8),
|
||||
if (token == null ||
|
||||
enrollmentClient_id == null ||
|
||||
enrollmentEmpClientBranchId == null) {
|
||||
debugPrint(
|
||||
'❌ Missing required data for navigation $token');
|
||||
return;
|
||||
}
|
||||
|
||||
Row(
|
||||
children: [
|
||||
if (item['file_error_status'] == '1')
|
||||
Tooltip(
|
||||
message: 'Info', // Added tooltip name
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
logDebug(item);
|
||||
// return;
|
||||
final String? token =
|
||||
await tokenService.getCurrentToken();
|
||||
final String? enrollmentClient_id = await tokenService
|
||||
.readValue('enrollmentClient_id');
|
||||
final String? enrollmentEmpClientBranchId =
|
||||
await tokenService
|
||||
.readValue('enrollmentEmpClientBranchId');
|
||||
|
||||
logDebug(item);
|
||||
logDebug(enrollmentClient_id);
|
||||
logDebug(localPolicyTypeId);
|
||||
logDebug(enrollmentEmpClientBranchId);
|
||||
logDebug(token);
|
||||
logDebug('post');
|
||||
logDebug(localCardType);
|
||||
logDebug(localCardPolicyNo);
|
||||
logDebug(localCardInsurerName);
|
||||
logDebug(localCardPolicyName);
|
||||
logDebug(localCardPolicyExpDate);
|
||||
logDebug(item['id']);
|
||||
|
||||
// ✅ SAFETY CHECK
|
||||
if (token == null ||
|
||||
enrollmentClient_id == null ||
|
||||
enrollmentEmpClientBranchId == null) {
|
||||
debugPrint(
|
||||
'❌ Missing required data for navigation ${token}');
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => excelErrorScreen(
|
||||
ClientId: enrollmentClient_id,
|
||||
policy_no: item['policy_no'],
|
||||
action: item['file_action'],
|
||||
created_at: item['created_at'],
|
||||
clientBranchId: enrollmentEmpClientBranchId,
|
||||
Token: token,
|
||||
TokenType: 'pre',
|
||||
id: item['id']),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
_buildStatusChip(item['status']),
|
||||
SizedBox(width: 10),
|
||||
Tooltip(
|
||||
message: 'Download', // Added tooltip name
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
getHrFileDownload(item['id'], item['file_name']);
|
||||
},
|
||||
child: Container(
|
||||
height: 30,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFC5F2F4),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFF76CED2)),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.file_download_outlined,
|
||||
color: Color(0xFF1D1B20),
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
if (!context.mounted) return;
|
||||
await openExcelErrorScreenIfAvailable(
|
||||
context: context,
|
||||
apiService: apiService,
|
||||
fileId: item['id'].toString(),
|
||||
tokenType: 'pre',
|
||||
clientId: enrollmentClient_id,
|
||||
policyNo: item['policy_no']?.toString() ?? '',
|
||||
action: item['file_action']?.toString() ?? '',
|
||||
createdAt: item['created_at']?.toString() ?? '',
|
||||
clientBranchId: enrollmentEmpClientBranchId,
|
||||
token: token,
|
||||
);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.error,
|
||||
size: 16,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildStatusChip(item['status']),
|
||||
const SizedBox(width: 8),
|
||||
Tooltip(
|
||||
message: 'Download',
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
getHrFileDownload(item['id'], item['file_name']);
|
||||
},
|
||||
child: Container(
|
||||
height: 28,
|
||||
width: 28,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFC5F2F4),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFF76CED2)),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.file_download_outlined,
|
||||
color: Color(0xFF1D1B20),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/// ⬇ Download
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -1586,86 +1632,106 @@ class _excelVerifyState extends State<preFileUpload> {
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Padding(
|
||||
// Match this horizontal padding (16) to your Table Header padding for perfect alignment
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment
|
||||
.spaceBetween, // Pushes text to left, buttons to right
|
||||
children: [
|
||||
// --- LEFT SIDE: Showing Text ---
|
||||
Text(
|
||||
"Showing $startEntry to $endEntry of $totalItems entries",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: const Color(0xFF585757),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
|
||||
// --- RIGHT SIDE: Controls ---
|
||||
Widget paginationControls = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DropdownButton<int>(
|
||||
value: _rowsPerPage,
|
||||
items: [6, 10, 15, 20, 50].map((int value) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: value,
|
||||
child: Text(
|
||||
' $value ',
|
||||
style: GoogleFonts.poppins(fontSize: 15),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_rowsPerPage = newValue!;
|
||||
_currentPage = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed:
|
||||
_currentPage > 1 ? () => setState(() => _currentPage--) : null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
if (!visiblePages.contains(1))
|
||||
Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
DropdownButton<int>(
|
||||
value: _rowsPerPage,
|
||||
// focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
|
||||
items: [6, 10, 15, 20, 50].map((int value) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: value,
|
||||
child: Text(' $value ',
|
||||
style: GoogleFonts.poppins(fontSize: 15)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_rowsPerPage = newValue!;
|
||||
_currentPage = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
if (!visiblePages.contains(1))
|
||||
Row(children: [
|
||||
_buildPageButton(1),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text("..."),
|
||||
),
|
||||
]),
|
||||
|
||||
// Visible page buttons
|
||||
for (int page in visiblePages) _buildPageButton(page),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages) && totalPages > 0)
|
||||
Row(children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text("..."),
|
||||
),
|
||||
_buildPageButton(totalPages),
|
||||
]),
|
||||
|
||||
// Next button
|
||||
IconButton(
|
||||
onPressed: _currentPage < totalPages
|
||||
? () => setState(() => _currentPage++)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
_buildPageButton(1),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text('...'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
for (int page in visiblePages) _buildPageButton(page),
|
||||
if (!visiblePages.contains(totalPages) && totalPages > 0)
|
||||
Row(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text('...'),
|
||||
),
|
||||
_buildPageButton(totalPages),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage < totalPages
|
||||
? () => setState(() => _currentPage++)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final showingText = Text(
|
||||
'Showing $startEntry to $endEntry of $totalItems entries',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 13,
|
||||
color: const Color(0xFF585757),
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 720;
|
||||
if (narrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
showingText,
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: paginationControls,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
showingText,
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: paginationControls,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import '../presentation/claims_overview/claims_overview_cache.dart';
|
||||
import 'package:nhancepolicy/logger.dart';
|
||||
|
||||
class TokenStorageService {
|
||||
@ -268,7 +270,10 @@ class TokenStorageService {
|
||||
// 1️⃣ Clear ONLY branch/session related keys
|
||||
await clearBranchSession();
|
||||
|
||||
// 2️⃣ Save selected branch
|
||||
// 2️⃣ Clear claims overview cache so the dashboard fetches fresh data
|
||||
await ClaimsOverviewCache.clearAll();
|
||||
|
||||
// 3️⃣ Save selected branch
|
||||
await saveSelectedBranch(newBranch);
|
||||
|
||||
// 3️⃣ Rebuild decoded session data from token
|
||||
|
||||
Loading…
Reference in New Issue
Block a user