Claims History Added

This commit is contained in:
Surendiran 2025-07-08 12:25:58 +05:30
parent b7b17c928d
commit d532f9150d

View File

@ -31,6 +31,8 @@ class ClaimHistoryPopup extends StatefulWidget {
class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> { class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
late ApiService apiService; late ApiService apiService;
List<Map<String, dynamic>> getClaimsHistoryList = []; List<Map<String, dynamic>> getClaimsHistoryList = [];
List<String> stepKeys =[];
late Map<String, dynamic> stepMap;
int _index = 4; int _index = 4;
@override @override
@ -44,7 +46,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
print(widget.empCode); print(widget.empCode);
print(widget.policyType); print(widget.policyType);
print(widget.ticket_id); print(widget.ticket_id);
// getClaimsHistoryDetails(); getClaimsHistoryDetails();
} }
@override @override
@ -58,10 +60,10 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
}); });
try { try {
print('10'); print('10');
final ticketID = widget.ticket_id; // final ticketID = widget.ticket_id;
if (ticketID != '' || ticketID != null) { // if (ticketID != '' || ticketID != null) {
return; // return;
} // }
final response = await apiService.getClaimsHistoryToApi( final response = await apiService.getClaimsHistoryToApi(
widget.ticket_id, widget.postToken); widget.ticket_id, widget.postToken);
if (response['status'] == 'success') { if (response['status'] == 'success') {
@ -69,8 +71,10 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
// isLoading = false; // isLoading = false;
}); });
setState(() { setState(() {
getClaimsHistoryList = getClaimsHistoryList = [Map<String, dynamic>.from(response['data']['ticket_data'])];
List<Map<String, dynamic>>.from(response['data']); stepMap = getClaimsHistoryList[0];
stepKeys = stepMap.keys.toList();
print('Claims History List $getClaimsHistoryList');
// originalData = getCDPolicies; // originalData = getCDPolicies;
// filteredData = List.from(originalData); // filteredData = List.from(originalData);
// print('filteredData'); // print('filteredData');
@ -99,12 +103,12 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (getClaimsHistoryList.isEmpty) { // if (getClaimsHistoryList.isEmpty) {
return SizedBox( // return SizedBox(
height: 50, // height: 50,
child: Center(child: Text('No available Claims')), // child: Center(child: Text('No available Claims')),
); // );
} // }
return Container( return Container(
constraints: BoxConstraints(maxWidth: 800, maxHeight: 800), constraints: BoxConstraints(maxWidth: 800, maxHeight: 800),
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
@ -154,123 +158,124 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
], ],
), ),
SizedBox(height: 10), SizedBox(height: 10),
Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
decoration: BoxDecoration(
color: Color(0xFFFFFFFF), // White background
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Color(0xFFEBEBEB), // Shadow color
blurRadius: 14, // How soft the shadow is
spreadRadius: 2, // How much it spreads
offset: Offset(0, 1), // X and Y offset
),
],
),
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: _buildKeyValue(
'Name', '${widget.empName ?? ''} (${widget.empCode ?? ''})'),
),
SizedBox(width: 16),
Expanded(
child: _buildKeyValue('Policy Name',
'${widget.policyType ?? ''} - ${widget.clientPolicyNo ?? ''}')),
],
),
SizedBox(height: 16),
Row(
children: [
Expanded(
child: _buildKeyValue(
'Claim Amount', '${widget.claimAmount ?? ''}'),
),
SizedBox(width: 16),
Expanded(
child: _buildKeyValue('Claim Number', widget.claimNo ?? ''),
),
],
),
],
),
),
SizedBox(height: 10),
// Container( // Container(
// decoration: BoxDecoration(
// color: Color(0xFFFFFFFF), // White background
// borderRadius: BorderRadius.circular(12),
// boxShadow: [
// BoxShadow(
// color: Color(0xFFEBEBEB), // Shadow color
// blurRadius: 14, // How soft the shadow is
// spreadRadius: 2, // How much it spreads
// offset: Offset(0, 1), // X and Y offset
// ),
// ],
// ),
// padding: const EdgeInsets.all(16), // padding: const EdgeInsets.all(16),
// child: Column( // child: Stepper(
// crossAxisAlignment: CrossAxisAlignment.start, // currentStep: _index,
// children: [ // onStepCancel: () {
// Row( // if (_index > 0) {
// children: [ // setState(() {
// Expanded( // _index -= 1;
// child: _buildKeyValue( // });
// 'Name', '${widget.empName ?? ''} (${widget.empCode ?? ''})'), // }
// ), // },
// SizedBox(width: 16), // onStepContinue: () {
// Expanded( // if (_index < 4) {
// child: _buildKeyValue('Policy Name', // setState(() {
// '${widget.policyType ?? ''} - ${widget.clientPolicyNo ?? ''}')), // _index += 1;
// ], // });
// }
// },
// onStepTapped: (int index) {
// setState(() {
// _index = index;
// });
// },
// steps: <Step>[
// Step(
// title: Text('Step 1: PAYMENT INITIATED'),
// content: Text('Pay Initiate Date: 05-05-2025'),
// isActive: true,
// state: StepState.complete,
// ), // ),
// SizedBox(height: 16), // Step(
// Row( // title: Text('Step 2: INFORMATION REQUIRED'),
// children: [ // content: Text('Raised Date: 05-05-2025'),
// Expanded( // isActive: true,
// child: _buildKeyValue( // state: StepState.complete,
// 'Claim Amount', '${widget.claimAmount ?? ''}'), // ),
// ), // Step(
// SizedBox(width: 16), // title: Text('Step 3: CLAIM NO. UPDATION'),
// Expanded( // content: Column(
// child: _buildKeyValue('Claim Number', widget.claimNo ?? ''), // crossAxisAlignment: CrossAxisAlignment.start,
// ), // children: [
// ], // Text('Claim Number: 4315440'),
// Text('Registration Date: 05-05-2025'),
// ],
// ),
// isActive: true,
// state: StepState.complete,
// ),
// Step(
// title: Text('Step 4: QUERY DOCUMENT REQUIRED'),
// content: Text('Query Received Date: 05-05-2025'),
// isActive: true,
// state: StepState.complete,
// ),
// Step(
// title: Text('Step 5: APPROVED'),
// content: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text('Approved Amount: 4315440'),
// Text('Approved Date: 05-05-2025'),
// Text('Approved Letter: Lorem ipsum...'),
// Text('Description: Lorem ipsum...'),
// ],
// ),
// isActive: true,
// state: StepState.complete,
// ), // ),
// ], // ],
// ), // ),
// ), // )
// SizedBox(height: 10),
// // Container(
// // padding: const EdgeInsets.all(16),
// // child: Stepper(
// // currentStep: _index,
// // onStepCancel: () {
// // if (_index > 0) {
// // setState(() {
// // _index -= 1;
// // });
// // }
// // },
// // onStepContinue: () {
// // if (_index < 4) {
// // setState(() {
// // _index += 1;
// // });
// // }
// // },
// // onStepTapped: (int index) {
// // setState(() {
// // _index = index;
// // });
// // },
// // steps: <Step>[
// // Step(
// // title: Text('Step 1: PAYMENT INITIATED'),
// // content: Text('Pay Initiate Date: 05-05-2025'),
// // isActive: true,
// // state: StepState.complete,
// // ),
// // Step(
// // title: Text('Step 2: INFORMATION REQUIRED'),
// // content: Text('Raised Date: 05-05-2025'),
// // isActive: true,
// // state: StepState.complete,
// // ),
// // Step(
// // title: Text('Step 3: CLAIM NO. UPDATION'),
// // content: Column(
// // crossAxisAlignment: CrossAxisAlignment.start,
// // children: [
// // Text('Claim Number: 4315440'),
// // Text('Registration Date: 05-05-2025'),
// // ],
// // ),
// // isActive: true,
// // state: StepState.complete,
// // ),
// // Step(
// // title: Text('Step 4: QUERY DOCUMENT REQUIRED'),
// // content: Text('Query Received Date: 05-05-2025'),
// // isActive: true,
// // state: StepState.complete,
// // ),
// // Step(
// // title: Text('Step 5: APPROVED'),
// // content: Column(
// // crossAxisAlignment: CrossAxisAlignment.start,
// // children: [
// // Text('Approved Amount: 4315440'),
// // Text('Approved Date: 05-05-2025'),
// // Text('Approved Letter: Lorem ipsum...'),
// // Text('Description: Lorem ipsum...'),
// // ],
// // ),
// // isActive: true,
// // state: StepState.complete,
// // ),
// // ],
// // ),
// // )
// Column( // Column(
// crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
// children: List.generate(5, (index) { // children: List.generate(5, (index) {
@ -282,6 +287,25 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
// ); // );
// }), // }),
// ) // )
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(stepKeys.length, (index) {
String stepTitleKey = stepKeys[index];
Map<String, dynamic> stepData = stepMap[stepTitleKey];
print('stepTitleKey');
print(stepTitleKey);
print('stepData');
print(stepData);
return _buildStep(
stepNumber: index + 1,
title: _getStepTitleFromApi(stepTitleKey, stepData),
content: _getStepContentFromApi(stepData),
isLast: index == stepKeys.length - 1,
);
}),
)
], ],
), ),
), ),
@ -290,10 +314,12 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
Widget _buildStep({ Widget _buildStep({
required int stepNumber, required int stepNumber,
required String title, // required String title,
required Widget title,
required Widget content, required Widget content,
bool isLast = false, bool isLast = false,
}) { }) {
print(title);
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -342,13 +368,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( title,
title,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
SizedBox(height: 8), SizedBox(height: 8),
Container( Container(
width: double.infinity, width: double.infinity,
@ -368,52 +388,60 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
); );
} }
String _getStepTitle(int index) { // String _getStepTitleFromApi(String status, Map<String, dynamic> data) {
switch (index) { // final modifiedBy = data['modified_by'] ?? '';
case 0: // final modifiedAt = data['modified_at'] ?? '';
return 'PAYMENT INITIATED (Nalini 21062025 / 11:20:02 AM)'; // return '$status ($modifiedBy $modifiedAt)';
case 1: // }
return 'INFORMATION REQUIRED (Nalini 21062025 / 11:20:02 AM)';
case 2:
return 'UNDER PROCESS CLAIM NO. UPDATION (Nalini 21062025 / 11:20:02 AM)'; Widget _getStepTitleFromApi(String status, Map<String, dynamic> data) {
case 3: final modifiedBy = data['modified_by'] ?? '';
return 'UNDER PROCESS QUERY DOCUMENT REQUIRED (Nalini 21062025 / 11:20:02 AM)'; final modifiedAt = data['modified_at'] ?? '';
case 4:
return 'APPROVED (Nalini 21062025 / 11:20:02 AM)'; return RichText(
default: text: TextSpan(
return ''; children: [
} TextSpan(
text: status,
style: GoogleFonts.poppins(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Color(0xFF212120), // Status color
),
),
TextSpan(
text: ' ($modifiedBy $modifiedAt)',
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFF565656), // Subtitle color
),
),
],
),
);
} }
Widget _getStepContent(int index) {
switch (index) { Widget _getStepContentFromApi(Map<String, dynamic> data) {
case 0: List<Widget> rows = [];
return Text('Pay Initiate Date: 05-05-2025');
case 1: data.forEach((key, value) {
return Text('Raised Date: 05-05-2025'); // Skip metadata fields
case 2: if (key == 'modified_by' || key == 'modified_at') return;
return Column(
crossAxisAlignment: CrossAxisAlignment.start, String displayName = value['display_name'] ?? key;
children: [ String displayValue = value['display_value'] ?? 'N/A';
Text('Claim Number: 4315440'),
Text('Registration Date: 05-05-2025'), rows.add(_buildHistoryListData(displayName, displayValue));
], rows.add(SizedBox(height: 6));
); });
case 3:
return Text('Query Received Date: 05-05-2025'); return Column(
case 4: crossAxisAlignment: CrossAxisAlignment.start,
return Column( children: rows,
crossAxisAlignment: CrossAxisAlignment.start, );
children: [
Text('Approved Amount: 4315440'),
Text('Approved Date: 05-05-2025'),
Text('Approved Letter: Lorem ipsum...'),
Text('Description: Lorem ipsum...'),
],
);
default:
return SizedBox.shrink();
}
} }
Widget _buildKeyValue(String title, String value) { Widget _buildKeyValue(String title, String value) {
@ -424,29 +452,75 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
children: [ children: [
Text( Text(
title, title,
style: TextStyle( style: GoogleFonts.poppins(
color: Colors.grey[600], color: Color(0xFF747474),
fontSize: 14, fontWeight: FontWeight.w400,
fontSize: 16,
), ),
), ),
SizedBox(height: 4), SizedBox(height: 4),
Text( Text(
displayValue, displayValue,
style: TextStyle( style: GoogleFonts.poppins(
color: Colors.black, color: Color(0xFF000000),
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontSize: 15, fontSize: 16,
), ),
), ),
], ],
); );
} }
Widget _buildHistoryListData(String title, String value) {
final displayValue =
(value == null || value.trim().isEmpty) ? 'N/A' : value;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6), // optional spacing
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Title - Align to center left
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Text(
title,
style: GoogleFonts.poppins(
color: const Color(0xFF747474),
fontWeight: FontWeight.w400,
fontSize: 14,
),
),
),
),
// Value - Align to center right
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Text(
displayValue,
style: GoogleFonts.poppins(
color: const Color(0xFF000000),
fontWeight: FontWeight.w400,
fontSize: 14,
),
),
),
),
],
),
);
}
} }
class DottedLinePainter extends CustomPainter { class DottedLinePainter extends CustomPainter {
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
const dashHeight = 4.0; const dashHeight = 2.0;
const dashSpace = 3.0; const dashSpace = 3.0;
double startY = 0; double startY = 0;
final paint = Paint() final paint = Paint()