From 810647da406b5d80ef5ee026dc4ef66523ee6377 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Sat, 5 Jul 2025 10:26:36 +0530 Subject: [PATCH] UI_HR_POLICY_CLAIMS_MODULE --- lib/hrDashboard.dart | 16 +- lib/service/api_service.dart | 34 + lib/service/hrDashboardTabs/cd.dart | 72 +- lib/service/hrDashboardTabs/claims.dart | 1052 ++++++++++++++++++++++- pubspec.yaml | 1 + 5 files changed, 1125 insertions(+), 50 deletions(-) diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index 1e86484..0fb7761 100755 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -228,6 +228,7 @@ class _hrDashboardState extends State empClientId: empClientId, empClientBranchId: empClientBranchId, empHrId: empHrId, + postToken: _postToken, )); } } @@ -422,7 +423,8 @@ class _hrDashboardState extends State appBar: CustomAppBar(), body: Stack(children: [ Container( - padding: const EdgeInsets.all(40), + padding: const EdgeInsets.only( + top: 20, bottom: 40, left: 40, right: 40), // padding: const EdgeInsets.only( // top: 20, bottom: 20, left: 50, right: 50), @@ -438,8 +440,8 @@ class _hrDashboardState extends State ? const EdgeInsets.only( top: 10, bottom: 10, left: 20, right: 20) : EdgeInsets.only( - top: 12, - bottom: 12, + top: 10, + bottom: 10, left: 10, right: 10), // Add padding to the container child: Row( @@ -448,12 +450,12 @@ class _hrDashboardState extends State flex: 6, child: Container( width: 150, - height: 150, + height: 80, alignment: Alignment.centerLeft, child: Image.network( clientLogo ?? '', width: 80, // Set the width here - height: 80, // Set the height here + height: 60, // Set the height here loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { @@ -474,7 +476,7 @@ class _hrDashboardState extends State return Image.asset( 'assets/Solid_gray.png', // Replace 'default_image.png' with your default image asset path width: 80, - height: 80, + height: 60, fit: BoxFit.cover, ); }, @@ -496,7 +498,7 @@ class _hrDashboardState extends State ), ), - SizedBox(height: 16), + SizedBox(height: 8), Container( padding: const EdgeInsets.all(5), height: MediaQuery.of(context).size.height * 0.08, diff --git a/lib/service/api_service.dart b/lib/service/api_service.dart index 67df1a0..5bf7c9f 100755 --- a/lib/service/api_service.dart +++ b/lib/service/api_service.dart @@ -460,6 +460,40 @@ class ApiService { return response; } + Future> getClaimPoliciesToApi(String token) async { + print("getgetClaimPoliciesToApii1"); + final url = Uri.parse('${Environment.apiUrlPost}claimsSearch'); + + final headers = { + 'Authorization': 'Bearer $token' ?? '', + }; + final response = await _makeGetRequest(url, headers); + return response; + } + + Future> getClaimPoliciesListDataToApi( + String token, Map body) async { + print("getgetClaimPoliciesToApii1"); + final url = Uri.parse('${Environment.apiUrlPost}claimsSearch'); + + final headers = { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }; + + final response = await http.post( + url, + headers: headers, + body: jsonEncode(body), + ); + if (response.statusCode == 200) { + return jsonDecode(response.body); + } else { + throw Exception( + 'Failed to load claims list: ${response.statusCode} ${response.body}'); + } + } + Future> getCdTransactionData( String clintID, String insurerId, String cd_ac_pk, String token) async { print("getCashDepositDetailsToApi1"); diff --git a/lib/service/hrDashboardTabs/cd.dart b/lib/service/hrDashboardTabs/cd.dart index f8d902d..0db1ca3 100644 --- a/lib/service/hrDashboardTabs/cd.dart +++ b/lib/service/hrDashboardTabs/cd.dart @@ -40,17 +40,17 @@ class _CdPolicieState extends State { // List dataPolicy = []; List reversedDataPolicy = []; List> originalData = []; // Original data source - // List> filteredData = []; // Filtered data source - List> filteredData = [ - { - "client_id": "58", - "insurer_id": "2", - "cd_ac_pk": "94", - "insurer_name": "ICICI Prudential Life Insurance Co. Ltd", - "cd_master_account_no": "CD-IOCL-887744559966", - "balance": "10000000.00" - } - ]; // Filtered data source + List> filteredData = []; // Filtered data source + // List> filteredData = [ + // { + // "client_id": "58", + // "insurer_id": "2", + // "cd_ac_pk": "94", + // "insurer_name": "ICICI Prudential Life Insurance Co. Ltd", + // "cd_master_account_no": "CD-IOCL-887744559966", + // "balance": "10000000.00" + // } + // ]; // Filtered data source dynamic argumentsData; dynamic policyType; dynamic policyName; @@ -245,7 +245,11 @@ class _CdPolicieState extends State { ), child: Text( 'Export', - style: GoogleFonts.poppins(fontSize: 16,color: Color(0xFFFFFFFF),fontWeight: FontWeight.w700,letterSpacing: 1), + style: GoogleFonts.poppins( + fontSize: 16, + color: Color(0xFFFFFFFF), + fontWeight: FontWeight.w700, + letterSpacing: 1), ), ), ), @@ -293,21 +297,24 @@ class _CdPolicieState extends State { flex: 4, child: Text( 'Insurer Name', - style: GoogleFonts.poppins(color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), ), ), Expanded( flex: 3, child: Text( 'CD Account number', - style: GoogleFonts.poppins(color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), ), ), Expanded( flex: 2, child: Text( 'Current Balance', - style: GoogleFonts.poppins(color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), ), ), Expanded( @@ -315,7 +322,8 @@ class _CdPolicieState extends State { child: Text( 'Action', textAlign: TextAlign.center, - style: GoogleFonts.poppins(color: Colors.white, fontWeight: FontWeight.bold), + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), ), ), ], @@ -338,28 +346,22 @@ class _CdPolicieState extends State { Expanded( flex: 4, child: Text( - item['insurer_name'] ?? '-', - style: GoogleFonts.poppins( - color: Color(0xFF000000) - ), + item['insurer_name'] ?? '-', + style: GoogleFonts.poppins(color: Color(0xFF000000)), ), ), Expanded( flex: 3, child: Text( - item['cd_master_account_no'] ?? '-', - style: GoogleFonts.poppins( - color: Color(0xFF000000) - ), + item['cd_master_account_no'] ?? '-', + style: GoogleFonts.poppins(color: Color(0xFF000000)), ), ), Expanded( flex: 2, child: Text( - "₹${item['balance'] ?? '0'}", - style: GoogleFonts.poppins( - color: Color(0xFF000000) - ), + "₹${item['balance'] ?? '0'}", + style: GoogleFonts.poppins(color: Color(0xFF000000)), ), ), Expanded( @@ -372,16 +374,14 @@ class _CdPolicieState extends State { context, MaterialPageRoute( builder: (context) => cdTransactionDetails( - insurerName: item['insurer_name'], - cdMasterAccountNo: item['cd_master_account_no'], - insurerId: item['insurer_id'], - cd_ac_pk: item['cd_ac_pk'], - empClientId: widget.empClientId, - postToken:widget.postToken - ), + insurerName: item['insurer_name'], + cdMasterAccountNo: item['cd_master_account_no'], + insurerId: item['insurer_id'], + cd_ac_pk: item['cd_ac_pk'], + empClientId: widget.empClientId, + postToken: widget.postToken), ), ); - }, ), ), diff --git a/lib/service/hrDashboardTabs/claims.dart b/lib/service/hrDashboardTabs/claims.dart index 1ce88ca..951f254 100644 --- a/lib/service/hrDashboardTabs/claims.dart +++ b/lib/service/hrDashboardTabs/claims.dart @@ -1,25 +1,189 @@ +import 'package:dropdown_search/dropdown_search.dart'; 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 'package:collection/collection.dart'; +import 'package:jwt_decode/jwt_decode.dart'; + +import '../../models/environment.dart'; +import '../api_service.dart'; class ClaimsPolicies extends StatefulWidget { final String empClientId; final String empClientBranchId; final String empHrId; + final String postToken; const ClaimsPolicies( {Key? key, required this.empClientId, required this.empClientBranchId, - required this.empHrId}); + required this.empHrId, + required this.postToken}); @override State createState() => _ClaimsPolicieState(); } class _ClaimsPolicieState extends State { + List tabHeader = ['name', 'empCode', 'from', 'to', 'claimNum']; + + List> filteredData = []; // Filtered data source + // List> filteredData = [ + // { + // "client_id": "58", + // "insurer_id": "2", + // "cd_ac_pk": "94", + // "insurer_name": "ICICI Prudential Life Insurance Co. Ltd", + // "cd_master_account_no": "CD-IOCL-887744559966", + // "balance": "10000000.00" + // } + // ]; + + Map controllers = {}; + List reversedDataPolicy = []; + List> originalData = []; + String? selectedPolicyType; + // int? selectedPolicyType; + String? selectedClaimStatus; + dynamic empClientId; + List> getClaimPolicies = []; + Map getClaimPoliciesApi = {}; + bool isLoading = false; + late ApiService apiService; + int _currentPage = 1; + int _rowsPerPage = 5; + + List get _paginatedData { + final startIndex = (_currentPage - 1) * _rowsPerPage; + final endIndex = + (_currentPage * _rowsPerPage).clamp(0, filteredData.length); + return filteredData.sublist(startIndex, endIndex); + } + + Map claim_Detials() { + final data = { + "client_id": empClientId, + "emp_code": controllers["empCode"]?.text ?? '', + "from_date": controllers["from"]?.text ?? '', + "to_date": controllers["to"]?.text ?? '', + "ticket_type_id": selectedPolicyType ?? '', + "claim_status_id": selectedClaimStatus ?? '', + "claim_number": controllers["claimNum"]?.text ?? '', + "emp_name": controllers["name"]?.text ?? '', + }; + return data; + } + + @override + void initState() { + super.initState(); + apiService = ApiService(context); + + if (widget.postToken != null && widget.postToken.isNotEmpty) { + Map? postdecodedToken = Jwt.parseJwt(widget.postToken); + + empClientId = postdecodedToken['client_id'].toString(); + getClaimList(); + } + for (String field in tabHeader) { + controllers[field] = TextEditingController(); + } + + print("TextCXOnte - $controllers"); + + getCDPoliciesDetails(); + // getApiData(); + } + + @override + void dispose() { + for (var controller in controllers.values) { + controller.dispose(); + } + super.dispose(); + } + + Future getCDPoliciesDetails() async { + print('9'); + setState(() { + isLoading = true; + }); + try { + print('10'); + final response = await apiService.getClaimPoliciesToApi(widget.postToken); + if (response['status'] == 'success') { + setState(() { + // isLoading = false; + }); + setState(() { + getClaimPoliciesApi = Map.from(response['data']); + }); + } else { + setState(() { + // isLoading = false; + }); + + // ToastHelper.showWarningToast( + // context, 'Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response['code']}'); + } + } catch (e) { + setState(() { + // isLoading = false; + }); + print('Exception occurred: $e'); + } finally { + setState(() { + // _isLoading = false; + }); + } + } + + Future getClaimList() async { + print('getClaimList called'); + setState(() { + isLoading = true; + }); + + final requestData = claim_Detials(); + print("Request Body: $requestData"); + + try { + final response = await apiService.getClaimPoliciesListDataToApi( + widget.postToken, + requestData, + ); + + if (response['status'] == 'success') { + setState(() { + getClaimPolicies = List>.from(response['data']); + print('API Data - $getClaimPolicies'); + + originalData = getClaimPolicies; + filteredData = List.from(originalData); + print('originalData - $getClaimPolicies'); + }); + } else { + print('Request failed: ${response['code']}'); + } + } catch (e) { + print('Exception occurred: $e'); + } finally { + setState(() { + isLoading = false; + }); + } + } + + void applyFilter() { + final data = claim_Detials(); + print("data -- $data"); + } + @override Widget build(BuildContext context) { // TODO: implement build @@ -29,13 +193,887 @@ class _ClaimsPolicieState extends State { borderRadius: BorderRadius.circular(10), // 👈 set your desired radius ), padding: const EdgeInsets.all(16.0), - child: Text("Claims policy data"), + child: Column( + children: [ + _buildInputFields(context), + SizedBox( + height: 10, + ), + Expanded( + child: Container( + child: Column( + children: [ + // Text("DAer"), + // _buildClaimsDataTable(context), + SingleChildScrollView( + child: _buildClaimsDataTable(context), + ), + ], + ), + ), + ), + ], + ), ); } - // Widget _buildName(context){ - // return TextField( - // - // ) - // } + Widget _buildInputFields(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _buildName(context), + _buildEmpCode(context), + _buildFrom(context), + _buildTo(context), + ], + ), + const SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _buildPolicyType(context), + _buildClaimStatus(context), + _buildClaimNumber(context), + _buildActions(context), + ], + ) + ], + ); + } + + Widget _buildClaimsDataTable(BuildContext context) { + if (filteredData.isEmpty) { + return const SizedBox( + height: 50, + child: Center(child: Text('No available data')), + ); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Header row + Container( + decoration: BoxDecoration( + color: Color(0xFF00A6A6), + borderRadius: BorderRadius.circular(6), + ), + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + child: Row( + children: [ + Expanded( + flex: 4, + child: Text( + 'Name', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 4, + child: Text( + 'Policy Name', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 3, + child: Text( + 'Claim Number', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 2, + child: Text( + 'Status', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 3, + child: Text( + 'Claim Amount', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 3, + child: Text( + 'Record Date', + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + Expanded( + flex: 2, + child: Text( + 'Action', + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + ], + ), + ), + + const SizedBox(height: 6), + + SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: _paginatedData.mapIndexed((index, item) { + return Container( + // margin: const EdgeInsets.only(bottom: 8), + padding: + const EdgeInsets.symmetric(vertical: 5, horizontal: 16), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + bottom: BorderSide( + // color: Color(0xFFA1A1A1), + color: Color(0xFFD7E9EB), + width: 1, + ), + ), + // color: index % 2 == 0 ? Color(0xFFE6FAFB) : Colors.white, + borderRadius: BorderRadius.circular(6), + ), + child: Row( + children: [ + Expanded( + flex: 4, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item['emp_name'] ?? '-', + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 12), + ), + Text( + item['emp_code'] ?? '-', + style: GoogleFonts.poppins( + color: Color(0xFF585757), + fontWeight: FontWeight.w300, + fontSize: 10), + ), + ], + ), + ), + Expanded( + flex: 4, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item['emp_name'] ?? '-', + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 12), + ), + Text( + item['policy_no'] ?? '-', + style: GoogleFonts.poppins( + color: Color(0xFF585757), + fontWeight: FontWeight.w300, + fontSize: 10), + ), + ], + ), + ), + Expanded( + flex: 3, + child: Text( + "${item['claim_no'] ?? ''}", + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 12), + ), + ), + Expanded( + flex: 2, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 4, vertical: 4), + decoration: BoxDecoration( + color: Color(0xFF7BD9B6), + // color: (item['emp_is_active'] == "1") + // ? Color(0xFF7BD9B6) + // : Color(0xFFFFA6A6), + borderRadius: BorderRadius.circular(6), + ), + child: Align( + alignment: Alignment.center, + child: Text( + "${item['status'] ?? ''}", + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w500, + fontSize: 12, + ), + ), + ), + ), + ), + Expanded( + flex: 3, + child: Text( + "${item['claim_amount'] ?? ''}", + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 12), + ), + ), + Expanded( + flex: 3, + child: Text( + "${item['ticket_created_date'] ?? ''}", + style: GoogleFonts.poppins( + color: Color(0xFF000000), + fontWeight: FontWeight.w400, + fontSize: 12), + ), + ), + Expanded( + flex: 2, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () {}, + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + color: Color(0xFFE6F5F6), + borderRadius: BorderRadius.circular(12)), + child: Icon(Icons.credit_card, + color: Color(0xFF3D3D3D)), + // child: Image.asset( + // 'assets/ecard.jpg', + // height: 20, + // fit: BoxFit.cover, + // ), + ), + ), + ], + ), + ), + ], + ), + ); + }).toList(), + ), + ), + + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DropdownButton( + value: _rowsPerPage, + items: [5, 10, 15, 20, 50].map((int value) { + return DropdownMenuItem( + value: value, + child: Text( + ' $value ', + style: GoogleFonts.poppins(fontSize: 15), + ), + ); + }).toList(), + onChanged: (newValue) { + setState(() { + _rowsPerPage = newValue!; + _currentPage = + 1; // Reset to first page when rows per page changes + }); + }, + ), + IconButton( + onPressed: _currentPage > 1 + ? () { + setState(() { + _currentPage--; + }); + } + : null, + icon: Icon(Icons.chevron_left), + ), + for (int i = 1; + i <= (filteredData.length / _rowsPerPage).ceil(); + i++) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: _currentPage == i + ? Color(0xFF00A6A6) + : Colors.grey[300], + foregroundColor: + _currentPage == i ? Colors.white : Colors.black, + minimumSize: Size(36, 36), + padding: EdgeInsets.zero, + ), + onPressed: () { + setState(() { + _currentPage = i; + }); + }, + child: Text(i.toString()), + ), + ), + IconButton( + onPressed: _currentPage < + (filteredData.length / _rowsPerPage).ceil() + ? () { + setState(() { + _currentPage++; + }); + } + : null, + icon: Icon(Icons.chevron_right), + ), + ], + ), + ), + ], + ), + ], + ); + } + + Widget _buildName(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Name", + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500), + ), + const SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: TextField( + controller: controllers['name'], + style: const TextStyle( + fontSize: 12, + ), + decoration: InputDecoration( + floatingLabelBehavior: FloatingLabelBehavior.never, + + hintText: 'Enter your name', + filled: true, + fillColor: Color(0xFFD5F5F6), + + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.teal, width: 2.0), + borderRadius: BorderRadius.circular(8.0), + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), + contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10), + ), + ), + ), + ], + ), + ); + } + + Widget _buildEmpCode(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Emp Code", + style: TextStyle(fontSize: 12), + ), + SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: TextField( + controller: controllers['empCode'], + style: TextStyle( + fontSize: 12, + ), + decoration: InputDecoration( + floatingLabelBehavior: FloatingLabelBehavior.never, + + hintText: 'Enter your Emp Code', + filled: true, + fillColor: Color(0xFFD5F5F6), + + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.teal, width: 2.0), + borderRadius: BorderRadius.circular(8.0), + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), + contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10), + ), + ), + ), + ], + ), + ); + } + + Widget _buildFrom(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "From", + style: TextStyle(fontSize: 12), + ), + const SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: TextField( + controller: controllers['from'], + readOnly: true, + onTap: () async { + FocusScope.of(context) + .requestFocus(FocusNode()); // hide keyboard + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100), + ); + + if (pickedDate != null) { + String formattedDate = + "${pickedDate.day.toString().padLeft(2, '0')}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.year}"; + + print("FomatedFromDAta - $formattedDate"); + setState(() { + controllers['from']?.text = formattedDate; + }); + } + }, + style: const TextStyle( + fontSize: 12, + ), + decoration: InputDecoration( + floatingLabelBehavior: FloatingLabelBehavior.never, + + hintText: 'Select', + filled: true, + fillColor: Color(0xFFD5F5F6), + + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.teal, width: 2.0), + borderRadius: BorderRadius.circular(8.0), + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), + contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10), + suffixIcon: const Icon(Icons.calendar_today, size: 16), + ), + ), + ), + ], + ), + ); + } + + Widget _buildTo(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "To", + style: TextStyle(fontSize: 12), + ), + const SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: TextField( + controller: controllers['to'], + readOnly: true, + onTap: () async { + FocusScope.of(context) + .requestFocus(FocusNode()); // hide keyboard + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(2100), + ); + + if (pickedDate != null) { + String formattedDate = + "${pickedDate.day.toString().padLeft(2, '0')}-${pickedDate.month.toString().padLeft(2, '0')}-${pickedDate.year}"; + + print("FomatedFromDAta - $formattedDate"); + setState(() { + controllers['to']?.text = formattedDate; + }); + } + }, + style: const TextStyle( + fontSize: 12, + ), + decoration: InputDecoration( + floatingLabelBehavior: FloatingLabelBehavior.never, + + hintText: 'Select', + + filled: true, + fillColor: Color(0xFFD5F5F6), + + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.teal, width: 2.0), + borderRadius: BorderRadius.circular(8.0), + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), + contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10), + suffixIcon: const Icon(Icons.calendar_today, size: 16), + ), + ), + ), + ], + ), + ); + } + + Widget _buildPolicyType(BuildContext context) { + List ticketTypeList = getClaimPoliciesApi['ticket_type'] ?? []; + + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Policy Type", + style: TextStyle(fontSize: 12), + ), + const SizedBox(height: 3), + SizedBox( + height: 40, + child: DropdownSearch( + selectedItem: selectedPolicyType, + items: (String? filter, _) { + List allItems = ticketTypeList + .map((item) => item['type_name'].toString()) + .toList(); + + if (filter == null || filter.isEmpty) return allItems; + + return allItems + .where((element) => + element.toLowerCase().contains(filter.toLowerCase())) + .toList(); + }, + onChanged: (value) { + setState(() { + // Find corresponding ticket_type ID + var selectedItem = ticketTypeList.firstWhere( + (e) => e['type_name'] == value, + orElse: () => null, + ); + if (selectedItem != null) { + print( + "Selected ticket_type: ${selectedItem['ticket_type']}"); + selectedPolicyType = selectedItem['ticket_type']; + } + }); + }, + decoratorProps: DropDownDecoratorProps( + decoration: InputDecoration( + constraints: BoxConstraints(maxHeight: 200), + hintText: "Select Policy Type", + hintStyle: TextStyle(fontSize: 12), + filled: true, + fillColor: Color(0xFFD5F5F6), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: Colors.teal, width: 2), + ), + contentPadding: + EdgeInsets.symmetric(horizontal: 12, vertical: 10), + ), + ), + popupProps: PopupProps.menu( + showSearchBox: true, + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search Policy Type", + hintStyle: TextStyle(fontSize: 12), + contentPadding: + EdgeInsets.symmetric(horizontal: 12, vertical: 10), + ), + ), + ), + ), + ), + ], + ), + ); + } + + Widget _buildClaimStatus(BuildContext context) { + List claimStatusList = getClaimPoliciesApi['claim_status'] ?? []; + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Claim Status", + style: TextStyle(fontSize: 12), + ), + SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: DropdownSearch( + selectedItem: selectedClaimStatus, + items: (String? filter, _) { + List allItems = claimStatusList + .map((item) => item['claim_status'].toString()) + .toList(); + + if (filter == null || filter.isEmpty) return allItems; + + return allItems + .where((element) => + element.toLowerCase().contains(filter.toLowerCase())) + .toList(); + }, + onChanged: (value) { + setState(() { + // Find corresponding ticket_type ID + var selectedItem = claimStatusList.firstWhere( + (e) => e['claim_status'] == value, + orElse: () => null, + ); + if (selectedItem != null) { + print( + "Selected ticket_type: ${selectedItem['ticket_type']}"); + selectedClaimStatus = selectedItem['ticket_type']; + } + }); + }, + decoratorProps: DropDownDecoratorProps( + decoration: InputDecoration( + constraints: BoxConstraints(maxHeight: 200), + hintText: "Select Policy Type", + hintStyle: TextStyle(fontSize: 12), + filled: true, + fillColor: Color(0xFFD5F5F6), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: Colors.teal, width: 2), + ), + contentPadding: + EdgeInsets.symmetric(horizontal: 12, vertical: 10), + ), + ), + popupProps: PopupProps.menu( + showSearchBox: true, + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search Claim Status", + hintStyle: TextStyle(fontSize: 12), + contentPadding: + EdgeInsets.symmetric(horizontal: 12, vertical: 10), + ), + ), + ), + ), + ), + ], + ), + ); + } + + Widget _buildClaimNumber(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Claim Number", + style: TextStyle(fontSize: 12), + ), + const SizedBox( + height: 3, + ), + SizedBox( + height: 40, + child: TextField( + controller: controllers['claimNum'], + style: const TextStyle( + fontSize: 12, + ), + decoration: InputDecoration( + floatingLabelBehavior: FloatingLabelBehavior.never, + + hintText: 'Enter Claim Number', + + filled: true, + fillColor: Color(0xFFD5F5F6), + + border: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.transparent), + borderRadius: BorderRadius.circular(8.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.teal, width: 2.0), + borderRadius: BorderRadius.circular(8.0), + ), + // contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), + contentPadding: EdgeInsets.fromLTRB(12, 20, 12, 10), + ), + ), + ), + ], + ), + ); + } + + Widget _buildActions(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width * 0.22, + height: 50, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + ElevatedButton.icon( + onPressed: () { + applyFilter(); + }, + icon: const Icon(Icons.filter_alt_outlined, + color: Colors.white, size: 18), + label: const Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w500), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + padding: EdgeInsets.symmetric(horizontal: 34, vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + ), + ElevatedButton.icon( + onPressed: () {}, + icon: const Icon(Icons.refresh_outlined, + color: Colors.white, size: 18), + label: const Text( + 'Reset', + style: TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w500), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + padding: EdgeInsets.symmetric(horizontal: 34, vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + ), + ], + ), + ); + } } diff --git a/pubspec.yaml b/pubspec.yaml index 4eac9ff..2567081 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,6 +58,7 @@ dependencies: google_sign_in: ^6.2.1 firebase_auth_web: ^5.12.4 archive: ^3.4.9 + dropdown_search: ^6.0.2 dev_dependencies: