diff --git a/assets/claimHistory.png b/assets/claimHistory.png new file mode 100644 index 0000000..9fac066 Binary files /dev/null and b/assets/claimHistory.png differ diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index d236ac6..2c3b967 100755 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -500,7 +500,7 @@ class _hrDashboardState extends State SizedBox(height: 8), Container( - padding: const EdgeInsets.all(5), + // padding: const EdgeInsets.all(5), // height: MediaQuery.of(context).size.height * 0.08, decoration: BoxDecoration( color: @@ -515,54 +515,62 @@ class _hrDashboardState extends State ), ], ), - child: TabBar( - controller: _tabController, - isScrollable: true, - labelPadding: const EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - // indicator: BoxDecoration( - // color: const Color(0xFF00999E), // Selected tab background - // borderRadius: BorderRadius.circular(12), - // boxShadow: [ - // BoxShadow( - // color: Colors.black.withOpacity(0.2), - // blurRadius: 4, - // offset: const Offset(0, 2), - // ) - // ], - // ), - dividerColor: Colors.transparent, - indicatorColor: Colors.transparent, - labelColor: Colors.white, - unselectedLabelColor: const Color(0xFF828282), - // tabs: visibleTabs, - tabs: List.generate(tabData.length, (index) { - final data = tabData[index]; - return CustomTab( - icon: data['icon'], - label: data['label'], - isSelected: selectedIndex == index, - ); - }), + child: Row( + // mainAxisAlignment: MainAxisAlignment.center, + // mainAxisSize: MainAxisSize.min, + children: [ + TabBar( + controller: _tabController, + isScrollable: true, + labelPadding: EdgeInsets.zero, + // labelPadding: const EdgeInsets.symmetric( + // horizontal: 0, vertical: 0), + // indicator: BoxDecoration( + // color: const Color(0xFF00999E), // Selected tab background + // borderRadius: BorderRadius.circular(12), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withOpacity(0.2), + // blurRadius: 4, + // offset: const Offset(0, 2), + // ) + // ], + // ), + dividerColor: Colors.transparent, + indicatorColor: Colors.transparent, + indicatorPadding: EdgeInsets.zero, + labelColor: Colors.white, + unselectedLabelColor: const Color(0xFF828282), + // tabs: visibleTabs, + tabs: List.generate(tabData.length, (index) { + final data = tabData[index]; + return CustomTab( + icon: data['icon'], + label: data['label'], + isSelected: selectedIndex == index, + ); + }), - // tabs: [ - // CustomTab( - // icon: Icons.grid_view, - // label: 'Pre Enrollment', - // isSelected: selectedIndex == 0), - // CustomTab( - // icon: Icons.verified_user, - // label: 'Active Policies', - // isSelected: selectedIndex == 1), - // CustomTab( - // icon: Icons.desktop_windows, - // label: 'CD', - // isSelected: selectedIndex == 2), - // CustomTab( - // icon: Icons.receipt_long, - // label: 'Claims', - // isSelected: selectedIndex == 3), - // ], + // tabs: [ + // CustomTab( + // icon: Icons.grid_view, + // label: 'Pre Enrollment', + // isSelected: selectedIndex == 0), + // CustomTab( + // icon: Icons.verified_user, + // label: 'Active Policies', + // isSelected: selectedIndex == 1), + // CustomTab( + // icon: Icons.desktop_windows, + // label: 'CD', + // isSelected: selectedIndex == 2), + // CustomTab( + // icon: Icons.receipt_long, + // label: 'Claims', + // isSelected: selectedIndex == 3), + // ], + ), + ], ), ), SizedBox(height: 16), @@ -695,7 +703,8 @@ class CustomTab extends StatelessWidget { Widget build(BuildContext context) { return Tab( child: Container( - margin: const EdgeInsets.symmetric(horizontal: 6), + // margin: const EdgeInsets.symmetric(horizontal: 6), + margin: const EdgeInsets.only(right: 6), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), decoration: BoxDecoration( color: isSelected ? const Color(0xFF00999E) : Colors.white, @@ -716,8 +725,8 @@ class CustomTab extends StatelessWidget { ], ), child: Row( - mainAxisAlignment: MainAxisAlignment.start, - // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ Icon(icon, size: 18, diff --git a/lib/service/hrDashboardTabs/claims.dart b/lib/service/hrDashboardTabs/claims.dart index 951f254..74f5bb7 100644 --- a/lib/service/hrDashboardTabs/claims.dart +++ b/lib/service/hrDashboardTabs/claims.dart @@ -46,9 +46,11 @@ class _ClaimsPolicieState extends State { Map controllers = {}; List reversedDataPolicy = []; List> originalData = []; - String? selectedPolicyType; - // int? selectedPolicyType; - String? selectedClaimStatus; + String? selectedPolicyTypeName; + String? selectedClaimStatusName; + int? selectedPolicyType; + int? selectedClaimStatus; + dynamic empClientId; List> getClaimPolicies = []; Map getClaimPoliciesApi = {}; @@ -95,7 +97,7 @@ class _ClaimsPolicieState extends State { print("TextCXOnte - $controllers"); - getCDPoliciesDetails(); + getClaimsPoliciesDetails(); // getApiData(); } @@ -107,7 +109,7 @@ class _ClaimsPolicieState extends State { super.dispose(); } - Future getCDPoliciesDetails() async { + Future getClaimsPoliciesDetails() async { print('9'); setState(() { isLoading = true; @@ -168,6 +170,10 @@ class _ClaimsPolicieState extends State { print('originalData - $getClaimPolicies'); }); } else { + getClaimPolicies = []; + originalData = getClaimPolicies; + filteredData = List.from(originalData); + print('originalData - $getClaimPolicies'); print('Request failed: ${response['code']}'); } } catch (e) { @@ -182,6 +188,26 @@ class _ClaimsPolicieState extends State { void applyFilter() { final data = claim_Detials(); print("data -- $data"); + getClaimList(); + } + + void reset() { + setState(() { + controllers.forEach((key, controller) { + controller.clear(); + }); + + selectedPolicyType = null; + selectedPolicyTypeName = null; + selectedClaimStatus = null; + selectedClaimStatusName = null; + _currentPage = 1; + + getClaimList(); + }); + + final data = claim_Detials(); + print("restdata -- $data"); } @override @@ -189,6 +215,7 @@ class _ClaimsPolicieState extends State { // TODO: implement build return Container( decoration: BoxDecoration( + // color: Colors.red.shade50, color: Colors.white, borderRadius: BorderRadius.circular(10), // 👈 set your desired radius ), @@ -199,19 +226,24 @@ class _ClaimsPolicieState extends State { SizedBox( height: 10, ), + Expanded( - child: Container( - child: Column( - children: [ - // Text("DAer"), - // _buildClaimsDataTable(context), - SingleChildScrollView( - child: _buildClaimsDataTable(context), - ), - ], - ), - ), + child: _buildClaimsDataTable(context), ), + // Expanded( + // child: Container( + // child: Column( + // children: [ + // // Text("DAer"), + // // _buildClaimsDataTable(context), + // SingleChildScrollView( + // scrollDirection: Axis.vertical, + // child: _buildClaimsDataTable(context), + // ), + // ], + // ), + // ), + // ), ], ), ); @@ -254,314 +286,533 @@ class _ClaimsPolicieState extends State { ); } - 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), - ), - ), - ], - ), + return ListView.builder( + itemCount: _paginatedData.length + 2, // +1 for header, +1 for pagination + itemBuilder: (context, index) { + if (index == 0) return _buildHeader(); + if (index == _paginatedData.length + 1) + return _buildPagination(context); + + final item = _paginatedData[index - 1]; + return _buildDataRow(item); + }, + ); + + // 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 _buildHeader() { + return Container( + decoration: BoxDecoration( + color: Color(0xFF00A6A6), + borderRadius: BorderRadius.circular(6), + ), + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + child: const Row( + children: [ + Expanded(flex: 4, child: Text('Name', style: _headerStyle)), + Expanded(flex: 4, child: Text('Policy Name', style: _headerStyle)), + Expanded(flex: 3, child: Text('Claim Number', style: _headerStyle)), + Expanded(flex: 4, child: Text('Status', style: _headerStyle)), + Expanded(flex: 3, child: Text('Claim Amount', style: _headerStyle)), + Expanded(flex: 3, child: Text('Record Date', style: _headerStyle)), + Expanded( + flex: 2, + child: Text('Action', + textAlign: TextAlign.center, style: _headerStyle)), + ], + ), + ); + } + + Widget _buildDataRow(Map item) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 16), + margin: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Color(0xFFE0F7F9), + border: const Border( + bottom: BorderSide(color: Color(0xFFD7E9EB), width: 1), ), - - 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, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + children: [ + Expanded( + flex: 4, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(item['emp_name'] ?? '-', style: _dataBold), + Text(item['emp_code'] ?? '-', style: _dataSub), + ], + ), + ), + Expanded( + flex: 4, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(item['policy_type'] ?? '-', style: _dataBold), + Text(item['client_policy_no'] ?? '-', style: _dataSub), + ], + ), + ), + Expanded( + flex: 3, + child: Text(item['claim_no'] ?? '-', style: _dataBold), + ), + Expanded( + flex: 4, + child: Align( + alignment: Alignment.bottomLeft, + child: Container( + padding: + const EdgeInsets.symmetric(horizontal: 14, vertical: 4), + decoration: BoxDecoration( + color: Color(0xFF7BD9B6), + borderRadius: BorderRadius.circular(6), + ), + child: Text(item['status'] ?? '-', style: _dataBold)), + ), + ), + Expanded( + flex: 3, + child: Text(item['claim_amount'] ?? '-', style: _dataBold), + ), + Expanded( + flex: 3, + child: Text(item['ticket_created_date'] ?? '-', style: _dataBold), + ), + Expanded( + flex: 2, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () {}, + child: Container( + height: 30, + width: 30, + decoration: BoxDecoration( + color: Color(0xFF86D1D4), + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: EdgeInsets.all(6), // You can adjust this value + child: Image.asset( + 'assets/claimHistory.png', + fit: BoxFit.contain, + ), ), ), - // 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, + static final _dataBold = GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + ); + + static final _dataSub = GoogleFonts.poppins( + fontSize: 10, + fontWeight: FontWeight.w300, + color: Color(0xFF585757), + ); + + static const _headerStyle = TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ); + + Widget _buildPagination(BuildContext context) { + return Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, 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) { + 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(() { - _rowsPerPage = newValue!; - _currentPage = - 1; // Reset to first page when rows per page changes + _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, ), - 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), - ), - ], + 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) { @@ -808,6 +1059,39 @@ class _ClaimsPolicieState extends State { Widget _buildPolicyType(BuildContext context) { List ticketTypeList = getClaimPoliciesApi['ticket_type'] ?? []; + // Get type_name from ticket_type id + String? getTypeNameById(int? id) { + if (id == null) return null; + final match = ticketTypeList.firstWhere( + (e) => e['ticket_type'] == id, + orElse: () => null, + ); + return match != null ? match['type_name'] : null; + } + + // Get id from type_name + int? getIdByTypeName(String? typeName) { + print("getIdByTypeName"); + print("getIdByTypeName - $typeName"); + final match = ticketTypeList.firstWhere( + (e) => e['type_name'] == typeName, + orElse: () => null, + ); + + print("match - $match"); + + if (match != null && match is Map) { + final map = match as Map; + final id = map['ticket_type']; + print("Returning ticket_type: $id"); + return id is int ? id : int.tryParse(id.toString()); + } + + print("no match or invalid map"); + + return null; + } + return Container( width: MediaQuery.of(context).size.width * 0.22, child: Column( @@ -821,32 +1105,21 @@ class _ClaimsPolicieState extends State { SizedBox( height: 40, child: DropdownSearch( - selectedItem: selectedPolicyType, + selectedItem: selectedPolicyTypeName, items: (String? filter, _) { - List allItems = ticketTypeList + return 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']; - } + selectedPolicyTypeName = value; + selectedPolicyType = getIdByTypeName(value); }); + + print( + "Selected selectedPolicyTypeName: $selectedPolicyTypeName"); + print("Selected selectedPolicyType: $selectedPolicyType"); }, decoratorProps: DropDownDecoratorProps( decoration: InputDecoration( @@ -871,7 +1144,7 @@ class _ClaimsPolicieState extends State { EdgeInsets.symmetric(horizontal: 12, vertical: 10), ), ), - popupProps: PopupProps.menu( + popupProps: const PopupProps.menu( showSearchBox: true, searchFieldProps: TextFieldProps( decoration: InputDecoration( @@ -891,12 +1164,46 @@ class _ClaimsPolicieState extends State { Widget _buildClaimStatus(BuildContext context) { List claimStatusList = getClaimPoliciesApi['claim_status'] ?? []; + + // Get type_name from ticket_type id + String? getTypeNameById(int? id) { + if (id == null) return null; + final match = claimStatusList.firstWhere( + (e) => e['id'] == id, + orElse: () => null, + ); + return match != null ? match['claim_status'] : null; + } + + // Get id from type_name + int? getIdByTypeName(String? typeName) { + print("getIdByTypeName"); + print("getIdByTypeName - $typeName"); + final match = claimStatusList.firstWhere( + (e) => e['claim_status'] == typeName, + orElse: () => null, + ); + + print("match - $match"); + + if (match != null && match is Map) { + final map = match as Map; + final id = map['id']; + print("Returning id: $id"); + return id is int ? id : int.tryParse(id.toString()); + } + + print("no match or invalid map"); + + return null; + } + return Container( width: MediaQuery.of(context).size.width * 0.22, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( + const Text( "Claim Status", style: TextStyle(fontSize: 12), ), @@ -906,33 +1213,55 @@ class _ClaimsPolicieState extends State { SizedBox( height: 40, child: DropdownSearch( - selectedItem: selectedClaimStatus, + selectedItem: selectedClaimStatusName, items: (String? filter, _) { - List allItems = claimStatusList + return 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']; - } + selectedClaimStatusName = value; + selectedClaimStatus = getIdByTypeName(value); }); + + print( + "Selected selectedClaimStatusName: $selectedClaimStatusName"); + print("Selected selectedClaimStatus: $selectedClaimStatus"); }, + + // selectedItem: selectedClaimStatus, + // selectedItem: getTypeNameById(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) { + // if (!mounted) return; + // print("Selected ticket_type11: $value"); + // + // final id = getIdByTypeName(value); + // print("getIdByTypeName returned: $id"); + // + // if (id != null) { + // setState(() { + // selectedClaimStatus = id; + // }); + // } else { + // print("No match found for $value"); + // } + // }, + decoratorProps: DropDownDecoratorProps( decoration: InputDecoration( constraints: BoxConstraints(maxHeight: 200), @@ -1032,43 +1361,52 @@ class _ClaimsPolicieState extends State { 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), + Expanded( + child: 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), + SizedBox( + width: 10, + ), + Expanded( + child: ElevatedButton.icon( + onPressed: () { + reset(); + }, + 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/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 2ce5852..ff40429 100755 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,7 @@ import FlutterMacOS import Foundation +import file_picker import firebase_auth import firebase_core import google_sign_in_ios @@ -14,6 +15,7 @@ import smart_auth import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))