UI_FILTER
This commit is contained in:
parent
af081f73b3
commit
88e65c0923
@ -609,7 +609,12 @@ class ApiService {
|
|||||||
|
|
||||||
// ----------------------------------- POLICY -------------------------------------------------
|
// ----------------------------------- POLICY -------------------------------------------------
|
||||||
|
|
||||||
Future<Map<String, dynamic>> fetchPolicyList(int id, role) async {
|
Future<Map<String, dynamic>> fetchPolicyList(
|
||||||
|
int id,
|
||||||
|
role, {
|
||||||
|
String? fromDate,
|
||||||
|
String? toDate,
|
||||||
|
}) async {
|
||||||
// print(_token);
|
// print(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
@ -618,11 +623,25 @@ class ApiService {
|
|||||||
final userId = '1';
|
final userId = '1';
|
||||||
final url;
|
final url;
|
||||||
|
|
||||||
|
final String query;
|
||||||
|
|
||||||
if (role == 'manager') {
|
if (role == 'manager') {
|
||||||
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?manager_id=$id');
|
query = 'manager_id=$id';
|
||||||
|
} else if (role == 'staff') {
|
||||||
|
query = 'staff_id=$id';
|
||||||
} else {
|
} else {
|
||||||
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?staff_id=$id');
|
query = 'agent_id=$id';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url = Uri.parse(
|
||||||
|
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}',
|
||||||
|
);
|
||||||
|
|
||||||
|
// if (role == 'manager') {
|
||||||
|
// url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?manager_id=$id');
|
||||||
|
// } else {
|
||||||
|
// url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?staff_id=$id');
|
||||||
|
// }
|
||||||
// else {
|
// else {
|
||||||
// url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id');
|
// url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id');
|
||||||
// }
|
// }
|
||||||
@ -637,28 +656,47 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> fetchPolicyDataOnlyList(int id, role) async {
|
Future<Map<String, dynamic>> fetchPolicyDataOnlyList(
|
||||||
|
int id,
|
||||||
|
role, {
|
||||||
|
String? fromDate,
|
||||||
|
String? toDate,
|
||||||
|
}) async {
|
||||||
// print(_token);
|
// print(_token);
|
||||||
if (_token == null) {
|
if (_token == null) {
|
||||||
await _initializeToken();
|
await _initializeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
final userId = '1';
|
final userId = '1';
|
||||||
final url;
|
|
||||||
|
final String query;
|
||||||
|
|
||||||
if (role == 'manager') {
|
if (role == 'manager') {
|
||||||
url = Uri.parse(
|
query = 'manager_id=$id';
|
||||||
'${Env.apiUrl}enquiry/enquiryList?manager_id=$id&only_policy_data=true',
|
|
||||||
);
|
|
||||||
} else if (role == 'staff') {
|
} else if (role == 'staff') {
|
||||||
url = Uri.parse(
|
query = 'staff_id=$id';
|
||||||
'${Env.apiUrl}enquiry/enquiryList?staff_id=$id&only_policy_data=true',
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
url = Uri.parse(
|
query = 'agent_id=$id';
|
||||||
'${Env.apiUrl}enquiry/enquiryList?agent_id=$id&only_policy_data=true',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final url = Uri.parse(
|
||||||
|
'${Env.apiUrl}enquiry/enquiryList?$query&only_policy_data=true&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}',
|
||||||
|
);
|
||||||
|
|
||||||
|
// if (role == 'manager') {
|
||||||
|
// url = Uri.parse(
|
||||||
|
// '${Env.apiUrl}enquiry/enquiryList?manager_id=$id&only_policy_data=true',
|
||||||
|
// );
|
||||||
|
// } else if (role == 'staff') {
|
||||||
|
// url = Uri.parse(
|
||||||
|
// '${Env.apiUrl}enquiry/enquiryList?staff_id=$id&only_policy_data=true',
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// url = Uri.parse(
|
||||||
|
// '${Env.apiUrl}enquiry/enquiryList?agent_id=$id&only_policy_data=true',
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
// final url = Uri.parse(
|
// final url = Uri.parse(
|
||||||
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',
|
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',
|
||||||
// );
|
// );
|
||||||
|
|||||||
@ -27,9 +27,9 @@ class MainLayout extends StatelessWidget {
|
|||||||
appBar: TopBar(
|
appBar: TopBar(
|
||||||
title: title,
|
title: title,
|
||||||
isMobile: true,
|
isMobile: true,
|
||||||
onBack: () {
|
// onBack: () {
|
||||||
// Navigator.pop(context);
|
// // Navigator.pop(context);
|
||||||
},
|
// },
|
||||||
onNotifications: () {
|
onNotifications: () {
|
||||||
debugPrint("Notifications tapped");
|
debugPrint("Notifications tapped");
|
||||||
},
|
},
|
||||||
|
|||||||
@ -38,9 +38,9 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
|||||||
List<Map<String, dynamic>> getStaffData = [];
|
List<Map<String, dynamic>> getStaffData = [];
|
||||||
List<Map<String, dynamic>> originalData = [];
|
List<Map<String, dynamic>> originalData = [];
|
||||||
List<Map<String, dynamic>> filteredData = [];
|
List<Map<String, dynamic>> filteredData = [];
|
||||||
Map<String, TextEditingController> controllers = {};
|
|
||||||
bool isLoading = false;
|
|
||||||
|
|
||||||
|
bool isLoading = false;
|
||||||
|
Map<String, TextEditingController> controllers = {};
|
||||||
List<String> tabHeader = ['startDate', 'endDate'];
|
List<String> tabHeader = ['startDate', 'endDate'];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -378,240 +378,23 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: ResponsiveLayout.isMobile(context) ? 5 : 10),
|
SizedBox(height: ResponsiveLayout.isMobile(context) ? 5 : 10),
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
Expanded(
|
? Container(
|
||||||
child: Container(
|
height: MediaQuery.of(context).size.height * 0.7,
|
||||||
// color: Colors.green,
|
child: SingleChildScrollView(
|
||||||
// color: Colors.green.shade50,
|
child: Padding(
|
||||||
width: MediaQuery.of(context).size.width,
|
padding: EdgeInsets.all(8),
|
||||||
|
child: _buildContent(context),
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
if (ResponsiveLayout.isMobile(context)) ...[
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
color: Color(0xffD9EBE8),
|
|
||||||
child: DateFilterRow(
|
|
||||||
startController: controllers['startDate']!,
|
|
||||||
endController: controllers['endDate']!,
|
|
||||||
formKey: _formKey,
|
|
||||||
isMobile: ResponsiveLayout.isMobile(context),
|
|
||||||
onFilter: () {
|
|
||||||
// call your filter logic
|
|
||||||
filterDateRange();
|
|
||||||
},
|
|
||||||
onRefresh: () {
|
|
||||||
// call your refresh logic
|
|
||||||
refrshfilterDateRange();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
|
|
||||||
Container(
|
|
||||||
// height: 40,
|
|
||||||
// color: Colors.pink,
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
if (!ResponsiveLayout.isMobile(context)) ...[
|
|
||||||
DateFilterRow(
|
|
||||||
startController: controllers['startDate']!,
|
|
||||||
endController: controllers['endDate']!,
|
|
||||||
formKey: _formKey,
|
|
||||||
isMobile: ResponsiveLayout.isMobile(context),
|
|
||||||
onFilter: () {
|
|
||||||
// call your filter logic
|
|
||||||
filterDateRange();
|
|
||||||
},
|
|
||||||
onRefresh: () {
|
|
||||||
// call your refresh logic
|
|
||||||
refrshfilterDateRange();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
// Form(
|
|
||||||
// key: _formKey,
|
|
||||||
// child: Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
// children: [
|
|
||||||
// buildStartDate(context),
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
// buildEndDate(context),
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
//
|
|
||||||
// Padding(
|
|
||||||
// padding: const EdgeInsets.symmetric(
|
|
||||||
// vertical: 8.0,
|
|
||||||
// ),
|
|
||||||
// child: GestureDetector(
|
|
||||||
// // onTap: filterDateRange,
|
|
||||||
// onTap: () {
|
|
||||||
// if (_formKey.currentState!.validate()) {
|
|
||||||
// filterDateRange(); // only runs if valid
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: Icon(Icons.filter_alt_outlined),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
//
|
|
||||||
// Padding(
|
|
||||||
// padding: const EdgeInsets.all(8.0),
|
|
||||||
// child: GestureDetector(
|
|
||||||
// onTap: refrshfilterDateRange,
|
|
||||||
// child: Icon(Icons.refresh),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
Spacer(),
|
|
||||||
],
|
|
||||||
ThemedSearchField(
|
|
||||||
hintText: 'Search',
|
|
||||||
backgroundColor: Color(0xFFF6F8F8),
|
|
||||||
onChanged: filterData,
|
|
||||||
controller: _searchStaffController,
|
|
||||||
txtwidth: ResponsiveLayout.isMobile(context)
|
|
||||||
? MediaQuery.of(context).size.width * 0.6
|
|
||||||
: MediaQuery.of(context).size.width * 0.2,
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(width: 10),
|
|
||||||
|
|
||||||
ExportBtn(
|
|
||||||
sheetName: "Enquiry",
|
|
||||||
fileName: "enquiry_list",
|
|
||||||
data: filteredData,
|
|
||||||
txt: !ResponsiveLayout.isMobile(context)
|
|
||||||
? true
|
|
||||||
: false,
|
|
||||||
headers: [
|
|
||||||
"id",
|
|
||||||
"created_on",
|
|
||||||
"updated_on",
|
|
||||||
"reg_no",
|
|
||||||
"insurer_name",
|
|
||||||
"status",
|
|
||||||
"remarks",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(width: 10),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () async {
|
|
||||||
final prefs =
|
|
||||||
await SharedPreferences.getInstance();
|
|
||||||
|
|
||||||
await prefs.remove('enqAgentDataId');
|
|
||||||
context.go(AppRoutes.tabEnquiry);
|
|
||||||
// print('Export');
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Color(0xFF425B5B),
|
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.add, color: Colors.white),
|
|
||||||
|
|
||||||
if (!ResponsiveLayout.isMobile(context)) ...[
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text(
|
|
||||||
'Create New Enquiry',
|
|
||||||
style: GoogleFonts.inter(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// GestureDetector(
|
|
||||||
// onTap: () {
|
|
||||||
// ref
|
|
||||||
// .read(
|
|
||||||
// enquiryIdProvider.notifier,
|
|
||||||
// )
|
|
||||||
// .state =
|
|
||||||
// null;
|
|
||||||
// context.go(AppRoutes.tabEnquiry);
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// 'Create New Enquiry',
|
|
||||||
// style: GoogleFonts.inter(
|
|
||||||
// color: Colors.white,
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// fontSize: 14,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
)
|
||||||
|
: Expanded(
|
||||||
if (!ResponsiveLayout.isMobile(context))
|
child: Container(
|
||||||
Container(
|
width: MediaQuery.of(context).size.width,
|
||||||
decoration: BoxDecoration(
|
padding: EdgeInsets.all(8.0),
|
||||||
color: Color(0xFFEDF6F5),
|
child: _buildContent(context),
|
||||||
borderRadius: BorderRadius.circular(6),
|
),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 12,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Text('S.No.', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Created Date', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Updated Date', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Text('Reg.No.', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Company', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Status', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Remarks', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Text('Action', style: _headerStyle),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(child: _buildDataTable(context)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
// height: 20,
|
// height: 20,
|
||||||
@ -642,6 +425,243 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
if (ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
color: Color(0xffD9EBE8),
|
||||||
|
child: DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
Container(
|
||||||
|
// height: 40,
|
||||||
|
// color: Colors.pink,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Form(
|
||||||
|
// key: _formKey,
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// buildStartDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
// buildEndDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 8.0,
|
||||||
|
// ),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// // onTap: filterDateRange,
|
||||||
|
// onTap: () {
|
||||||
|
// if (_formKey.currentState!.validate()) {
|
||||||
|
// filterDateRange(); // only runs if valid
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Icon(Icons.filter_alt_outlined),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.all(8.0),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// onTap: refrshfilterDateRange,
|
||||||
|
// child: Icon(Icons.refresh),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
Spacer(),
|
||||||
|
],
|
||||||
|
ThemedSearchField(
|
||||||
|
hintText: 'Search',
|
||||||
|
backgroundColor: Color(0xFFF6F8F8),
|
||||||
|
onChanged: filterData,
|
||||||
|
controller: _searchStaffController,
|
||||||
|
txtwidth: ResponsiveLayout.isMobile(context)
|
||||||
|
? MediaQuery.of(context).size.width * 0.6
|
||||||
|
: MediaQuery.of(context).size.width * 0.2,
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(width: 10),
|
||||||
|
|
||||||
|
ExportBtn(
|
||||||
|
sheetName: "Enquiry",
|
||||||
|
fileName: "enquiry_list",
|
||||||
|
data: filteredData,
|
||||||
|
txt: !ResponsiveLayout.isMobile(context) ? true : false,
|
||||||
|
headers: [
|
||||||
|
"id",
|
||||||
|
"created_on",
|
||||||
|
"updated_on",
|
||||||
|
"reg_no",
|
||||||
|
"insurer_name",
|
||||||
|
"status",
|
||||||
|
"remarks",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(width: 10),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
await prefs.remove('enqAgentDataId');
|
||||||
|
context.go(AppRoutes.tabEnquiry);
|
||||||
|
// print('Export');
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFF425B5B),
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.add, color: Colors.white),
|
||||||
|
|
||||||
|
if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
'Raise Enquiry',
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// ref
|
||||||
|
// .read(
|
||||||
|
// enquiryIdProvider.notifier,
|
||||||
|
// )
|
||||||
|
// .state =
|
||||||
|
// null;
|
||||||
|
// context.go(AppRoutes.tabEnquiry);
|
||||||
|
// },
|
||||||
|
// child: Text(
|
||||||
|
// 'Create New Enquiry',
|
||||||
|
// style: GoogleFonts.inter(
|
||||||
|
// color: Colors.white,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// fontSize: 14,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
|
||||||
|
if (!ResponsiveLayout.isMobile(context))
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFFEDF6F5),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(flex: 1, child: Text('S.No.', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text('Created Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text('Updated Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 1, child: Text('Reg.No.', style: _headerStyle)),
|
||||||
|
Expanded(flex: 3, child: Text('Company', style: _headerStyle)),
|
||||||
|
Expanded(flex: 2, child: Text('Status', style: _headerStyle)),
|
||||||
|
Expanded(flex: 2, child: Text('Remarks', style: _headerStyle)),
|
||||||
|
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? _buildDataTable(context)
|
||||||
|
: Expanded(child: _buildDataTable(context)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Widget _buildDataTable1(BuildContext context) {
|
||||||
|
// if (filteredData.isEmpty) {
|
||||||
|
// return const SizedBox(
|
||||||
|
// height: 50,
|
||||||
|
// child: Center(child: Text('No available data')),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final sortedData = [..._paginatedData];
|
||||||
|
// return ListView.builder(
|
||||||
|
// itemCount: ResponsiveLayout.isMobile(context)
|
||||||
|
// ? sortedData
|
||||||
|
// .length // only cards for mobile
|
||||||
|
// : sortedData.length + 1, // +1 for header in desktop
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
||||||
|
// return _buildHeader();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
// final item =
|
||||||
|
// sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
||||||
|
// final sno = startIndex + index;
|
||||||
|
//
|
||||||
|
// return !ResponsiveLayout.isMobile(context)
|
||||||
|
// ? _buildDataRow(item, sno)
|
||||||
|
// : _buildDataCard(item, sno);
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
Widget _buildDataTable(BuildContext context) {
|
Widget _buildDataTable(BuildContext context) {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
@ -651,24 +671,28 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final sortedData = [..._paginatedData];
|
final sortedData = [..._paginatedData];
|
||||||
|
|
||||||
|
if (ResponsiveLayout.isMobile(context)) {
|
||||||
|
// Use Column instead of ListView
|
||||||
|
return Column(
|
||||||
|
children: List.generate(sortedData.length, (index) {
|
||||||
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
final item = sortedData[index];
|
||||||
|
final sno = startIndex + index;
|
||||||
|
return _buildDataCard(item, sno);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop: keep ListView.builder
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: ResponsiveLayout.isMobile(context)
|
itemCount: sortedData.length + 1,
|
||||||
? sortedData
|
|
||||||
.length // only cards for mobile
|
|
||||||
: sortedData.length + 1, // +1 for header in desktop
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
if (index == 0) return _buildHeader();
|
||||||
return _buildHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
final item =
|
final item = sortedData[index - 1];
|
||||||
sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
|
||||||
final sno = startIndex + index;
|
final sno = startIndex + index;
|
||||||
|
return _buildDataRow(item, sno);
|
||||||
return !ResponsiveLayout.isMobile(context)
|
|
||||||
? _buildDataRow(item, sno)
|
|
||||||
: _buildDataCard(item, sno);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -251,10 +251,10 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
|||||||
// if (switcherStatus == 1) {
|
// if (switcherStatus == 1) {
|
||||||
// _verifyPhoneNumber();
|
// _verifyPhoneNumber();
|
||||||
// } else {
|
// } else {
|
||||||
setState(() {
|
setState(() {
|
||||||
enteredEmailOrMobile = true;
|
enteredEmailOrMobile = true;
|
||||||
});
|
});
|
||||||
ToastHelper.showSuccessToast(context, 'OTP sent successfully');
|
ToastHelper.showSuccessToast(context, 'OTP sent successfully');
|
||||||
// }
|
// }
|
||||||
return true; // ✅ success
|
return true; // ✅ success
|
||||||
} else {
|
} else {
|
||||||
@ -1308,9 +1308,9 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
|||||||
// if (switcherStatus == 1) {
|
// if (switcherStatus == 1) {
|
||||||
// await verifyFirebaseMobileOTP();
|
// await verifyFirebaseMobileOTP();
|
||||||
// } else {
|
// } else {
|
||||||
await verifyMobileOrMailOTP(
|
await verifyMobileOrMailOTP(
|
||||||
_otpController.text,
|
_otpController.text,
|
||||||
);
|
);
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import '../../../themes/indicators/text_field_theme.dart';
|
|||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
|
||||||
|
import '../../../widgets/custom_Stdate_EnDate_Filter.dart';
|
||||||
import '../../../widgets/custom_action_popup.dart';
|
import '../../../widgets/custom_action_popup.dart';
|
||||||
import '../assignStaff.dart';
|
import '../assignStaff.dart';
|
||||||
|
|
||||||
@ -50,6 +51,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
int itemsPerPage = 10;
|
int itemsPerPage = 10;
|
||||||
late ApiService apiService;
|
late ApiService apiService;
|
||||||
|
dynamic userId;
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
// List<Map<String, dynamic>> dataVal = [];
|
// List<Map<String, dynamic>> dataVal = [];
|
||||||
List<Map<String, dynamic>> getStaffData = [];
|
List<Map<String, dynamic>> getStaffData = [];
|
||||||
@ -58,19 +61,28 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
dynamic roleId;
|
dynamic roleId;
|
||||||
|
|
||||||
|
Map<String, TextEditingController> controllers = {};
|
||||||
|
List<String> tabHeader = ['startDate', 'endDate'];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
apiService = ApiService();
|
apiService = ApiService();
|
||||||
|
|
||||||
|
for (String field in tabHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
Future.microtask(() {
|
Future.microtask(() {
|
||||||
final id = ref.read(managerIdProvider);
|
final id = ref.read(managerIdProvider);
|
||||||
roleId = ref.read(userRoleProvider);
|
roleId = ref.read(userRoleProvider);
|
||||||
final userId = ref.read(userIdProvider);
|
userId = ref.read(userIdProvider);
|
||||||
|
|
||||||
print("C72 => r : $roleId | mId: $id | uId: $userId ");
|
print("C72 => r : $roleId | mId: $id | uId: $userId ");
|
||||||
if (userId != null) { getStaffList(userId, roleId); }
|
if (userId != null) {
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,24 +92,84 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
final userId = ref.read(userIdProvider);
|
final userId = ref.read(userIdProvider);
|
||||||
|
|
||||||
print("C82 => r : $roleId | mId: $id | uId: $userId ");
|
print("C82 => r : $roleId | mId: $id | uId: $userId ");
|
||||||
if (userId != null) { getStaffList(userId, roleId); }
|
if (userId != null) {
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getStaffList(int managerId, role) async {
|
void filterDateRange() {
|
||||||
|
// ✅ Validate the form first
|
||||||
|
if (!_formKey.currentState!.validate()) {
|
||||||
|
// stop execution if validation fails
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final fromDateText = controllers['startDate']?.text ?? '';
|
||||||
|
final toDateText = controllers['endDate']?.text ?? '';
|
||||||
|
|
||||||
|
// Optional: double-check End >= Start
|
||||||
|
final fromDate = DateFormat('dd-MM-yyyy').parse(fromDateText);
|
||||||
|
final toDate = DateFormat('dd-MM-yyyy').parse(toDateText);
|
||||||
|
|
||||||
|
if (toDate.isBefore(fromDate)) {
|
||||||
|
// This is already caught by the validator, but extra safety
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text("End Date cannot be earlier than Start Date")),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Call your API
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void refrshfilterDateRange() {
|
||||||
|
setState(() {
|
||||||
|
controllers['startDate']!.clear();
|
||||||
|
controllers['endDate']!.clear();
|
||||||
|
|
||||||
|
controllers['startDate']?.text = '';
|
||||||
|
controllers['endDate']?.text = '';
|
||||||
|
// Reset the FormField validation
|
||||||
|
_formKey.currentState?.reset();
|
||||||
|
});
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> getStaffList(
|
||||||
|
int managerId,
|
||||||
|
role, {
|
||||||
|
String fromDate = '',
|
||||||
|
String toDate = '',
|
||||||
|
}) async {
|
||||||
print('C89 => Fns called => $managerId | $role');
|
print('C89 => Fns called => $managerId | $role');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await apiService.fetchPolicyList(managerId, role);
|
final response = await apiService.fetchPolicyList(
|
||||||
|
managerId,
|
||||||
|
role,
|
||||||
|
fromDate: controllers['startDate']?.text ?? '',
|
||||||
|
toDate: controllers['endDate']?.text ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
|
print('FromDate : $fromDate');
|
||||||
|
print('ToDate : $toDate');
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
final data = response['data'];
|
final data = response['data'];
|
||||||
print('C99 => getStaffListData => ${response['data']}');
|
print('C99 => getStaffListData => ${response['data']}');
|
||||||
|
final fromDate = response['from_date'] ?? '';
|
||||||
|
final toDate = response['to_date'] ?? '';
|
||||||
|
|
||||||
|
print('FromDate : $fromDate');
|
||||||
|
print('ToDate : $toDate');
|
||||||
setState(() {
|
setState(() {
|
||||||
|
controllers['startDate']?.text = fromDate;
|
||||||
|
controllers['endDate']?.text = toDate;
|
||||||
|
|
||||||
if (data is List) {
|
if (data is List) {
|
||||||
// Already a list of maps
|
// Already a list of maps
|
||||||
getStaffData = List<Map<String, dynamic>>.from(data);
|
getStaffData = List<Map<String, dynamic>>.from(data);
|
||||||
@ -391,175 +463,34 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
Expanded(
|
? Container(
|
||||||
child: Container(
|
height: MediaQuery.of(context).size.height * 0.69,
|
||||||
// color: Colors.green,
|
child: SingleChildScrollView(
|
||||||
// color: Colors.green.shade50,
|
child: Padding(
|
||||||
width: MediaQuery.of(context).size.width,
|
padding: EdgeInsets.all(8),
|
||||||
|
child: _buildContent(context),
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
// height: 40,
|
|
||||||
// color: Colors.pink,
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
ThemedSearchField(
|
|
||||||
hintText: 'Search',
|
|
||||||
backgroundColor: Color(0xFFF6F8F8),
|
|
||||||
onChanged: filterData,
|
|
||||||
controller: _searchStaffController,
|
|
||||||
txtwidth: ResponsiveLayout.isMobile(context)
|
|
||||||
? MediaQuery.of(context).size.width * 0.6
|
|
||||||
: MediaQuery.of(context).size.width * 0.2,
|
|
||||||
),
|
|
||||||
|
|
||||||
Spacer(),
|
|
||||||
|
|
||||||
ExportBtn(
|
|
||||||
sheetName: "Enquiry",
|
|
||||||
fileName: "Enquiry_list",
|
|
||||||
data: filteredData,
|
|
||||||
txt: !ResponsiveLayout.isMobile(context)
|
|
||||||
? true
|
|
||||||
: false,
|
|
||||||
headers: [
|
|
||||||
"created_on",
|
|
||||||
"updated_on",
|
|
||||||
"reg_no",
|
|
||||||
"agent_name",
|
|
||||||
"assigned_to_name",
|
|
||||||
"insurer_name",
|
|
||||||
"insured_name",
|
|
||||||
"premium_amount",
|
|
||||||
"payment_mode",
|
|
||||||
"policy_number",
|
|
||||||
"status",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
// GestureDetector(
|
|
||||||
// onTap: () {
|
|
||||||
// // print('Export');
|
|
||||||
// },
|
|
||||||
// child: Container(
|
|
||||||
// padding: EdgeInsets.all(8.0),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: Color(0xFF425B5B),
|
|
||||||
// borderRadius: BorderRadius.circular(8.0),
|
|
||||||
// ),
|
|
||||||
// child: Row(
|
|
||||||
// mainAxisSize: MainAxisSize.min,
|
|
||||||
// children: [
|
|
||||||
// Icon(Icons.add, color: Colors.white),
|
|
||||||
//
|
|
||||||
// if (!ResponsiveLayout.isMobile(context)) ...[
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
//
|
|
||||||
// GestureDetector(
|
|
||||||
// onTap: () {
|
|
||||||
// // context.go(AppRoutes.agent / create);
|
|
||||||
// context.go('/staff/create');
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// 'Create New Staff',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: Colors.white,
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// fontSize: 14,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
)
|
||||||
if (!ResponsiveLayout.isMobile(context))
|
: Expanded(
|
||||||
Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
width: MediaQuery.of(context).size.width,
|
||||||
color: Color(0xFFEDF6F5),
|
padding: EdgeInsets.all(8.0),
|
||||||
borderRadius: BorderRadius.circular(6),
|
child: _buildContent(context),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
),
|
||||||
vertical: 12,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
child: const Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Created Date', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Updated Date', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Reg.No', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Agents', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Assigned To', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Insurer', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(left: 8.0),
|
|
||||||
child: Text(
|
|
||||||
'Insured Name',
|
|
||||||
style: _headerStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Premium', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Payment Mode', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Text('Policy Number', style: _headerStyle),
|
|
||||||
),
|
|
||||||
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Status', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Text('Action', style: _headerStyle),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(child: _buildDataTable(context)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
|
// Expanded(
|
||||||
|
// child: Container(
|
||||||
|
// // color: Colors.green,
|
||||||
|
// // color: Colors.green.shade50,
|
||||||
|
// width: MediaQuery.of(context).size.width,
|
||||||
|
//
|
||||||
|
// padding: EdgeInsets.all(8.0),
|
||||||
|
// child:
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
Container(
|
Container(
|
||||||
// height: 20,
|
// height: 20,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
@ -589,6 +520,221 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
if (ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
color: Color(0xffD9EBE8),
|
||||||
|
child: DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
Container(
|
||||||
|
// height: 40,
|
||||||
|
// color: Colors.pink,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Form(
|
||||||
|
// key: _formKey,
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// buildStartDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
// buildEndDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 8.0,
|
||||||
|
// ),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// // onTap: filterDateRange,
|
||||||
|
// onTap: () {
|
||||||
|
// if (_formKey.currentState!.validate()) {
|
||||||
|
// filterDateRange(); // only runs if valid
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Icon(Icons.filter_alt_outlined),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.all(8.0),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// onTap: refrshfilterDateRange,
|
||||||
|
// child: Icon(Icons.refresh),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
Spacer(),
|
||||||
|
],
|
||||||
|
|
||||||
|
ThemedSearchField(
|
||||||
|
hintText: 'Search',
|
||||||
|
backgroundColor: Color(0xFFF6F8F8),
|
||||||
|
onChanged: filterData,
|
||||||
|
controller: _searchStaffController,
|
||||||
|
txtwidth: ResponsiveLayout.isMobile(context)
|
||||||
|
? MediaQuery.of(context).size.width * 0.7
|
||||||
|
: MediaQuery.of(context).size.width * 0.2,
|
||||||
|
),
|
||||||
|
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? Spacer()
|
||||||
|
: SizedBox(width: 10),
|
||||||
|
|
||||||
|
ExportBtn(
|
||||||
|
sheetName: "Enquiry",
|
||||||
|
fileName: "Enquiry_list",
|
||||||
|
data: filteredData,
|
||||||
|
txt: !ResponsiveLayout.isMobile(context) ? true : false,
|
||||||
|
headers: [
|
||||||
|
"created_on",
|
||||||
|
"updated_on",
|
||||||
|
"reg_no",
|
||||||
|
"agent_name",
|
||||||
|
"assigned_to_name",
|
||||||
|
"insurer_name",
|
||||||
|
"insured_name",
|
||||||
|
"premium_amount",
|
||||||
|
"payment_mode",
|
||||||
|
"policy_number",
|
||||||
|
"status",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// // print('Export');
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(8.0),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Color(0xFF425B5B),
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// ),
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// children: [
|
||||||
|
// Icon(Icons.add, color: Colors.white),
|
||||||
|
//
|
||||||
|
// if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
//
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// // context.go(AppRoutes.agent / create);
|
||||||
|
// context.go('/staff/create');
|
||||||
|
// },
|
||||||
|
// child: Text(
|
||||||
|
// 'Create New Staff',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.white,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// fontSize: 14,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
if (!ResponsiveLayout.isMobile(context))
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFFEDF6F5),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Created Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Updated Date', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 2, child: Text('Reg.No', style: _headerStyle)),
|
||||||
|
Expanded(flex: 2, child: Text('Agents', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text('Assigned To', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 3, child: Text('Insurer', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Text('Insured Name', style: _headerStyle),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(flex: 2, child: Text('Premium', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text('Payment Mode', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Text('Policy Number', style: _headerStyle),
|
||||||
|
),
|
||||||
|
|
||||||
|
Expanded(flex: 3, child: Text('Status', style: _headerStyle)),
|
||||||
|
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? _buildDataTable(context)
|
||||||
|
: Expanded(child: _buildDataTable(context)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildDataTable(BuildContext context) {
|
Widget _buildDataTable(BuildContext context) {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
@ -598,28 +744,63 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final sortedData = [..._paginatedData];
|
final sortedData = [..._paginatedData];
|
||||||
|
|
||||||
|
if (ResponsiveLayout.isMobile(context)) {
|
||||||
|
// Use Column instead of ListView
|
||||||
|
return Column(
|
||||||
|
children: List.generate(sortedData.length, (index) {
|
||||||
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
final item = sortedData[index];
|
||||||
|
final sno = startIndex + index;
|
||||||
|
return _buildDataCard(item, sno);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop: keep ListView.builder
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: ResponsiveLayout.isMobile(context)
|
itemCount: sortedData.length + 1,
|
||||||
? sortedData
|
|
||||||
.length // only cards for mobile
|
|
||||||
: sortedData.length + 1, // +1 for header in desktop
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
if (index == 0) return _buildHeader();
|
||||||
return _buildHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
final item =
|
final item = sortedData[index - 1];
|
||||||
sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
|
||||||
final sno = startIndex + index;
|
final sno = startIndex + index;
|
||||||
|
return _buildDataRow(item, sno);
|
||||||
return !ResponsiveLayout.isMobile(context)
|
|
||||||
? _buildDataRow(item, sno)
|
|
||||||
: _buildDataCard(item, sno);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Widget _buildDataTable(BuildContext context) {
|
||||||
|
// if (filteredData.isEmpty) {
|
||||||
|
// return const SizedBox(
|
||||||
|
// height: 50,
|
||||||
|
// child: Center(child: Text('No available data')),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final sortedData = [..._paginatedData];
|
||||||
|
// return ListView.builder(
|
||||||
|
// itemCount: ResponsiveLayout.isMobile(context)
|
||||||
|
// ? sortedData
|
||||||
|
// .length // only cards for mobile
|
||||||
|
// : sortedData.length + 1, // +1 for header in desktop
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
||||||
|
// return _buildHeader();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
// final item =
|
||||||
|
// sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
||||||
|
// final sno = startIndex + index;
|
||||||
|
//
|
||||||
|
// return !ResponsiveLayout.isMobile(context)
|
||||||
|
// ? _buildDataRow(item, sno)
|
||||||
|
// : _buildDataCard(item, sno);
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
Widget _buildHeader() {
|
Widget _buildHeader() {
|
||||||
return SizedBox.shrink();
|
return SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import '../../../providers/manager_provider.dart';
|
|||||||
import '../../../providers/quotation_staff_proivder.dart';
|
import '../../../providers/quotation_staff_proivder.dart';
|
||||||
import '../../../themes/indicators/export_btn.dart';
|
import '../../../themes/indicators/export_btn.dart';
|
||||||
import '../../../themes/indicators/search_field_theme.dart';
|
import '../../../themes/indicators/search_field_theme.dart';
|
||||||
|
import '../../../widgets/custom_Stdate_EnDate_Filter.dart';
|
||||||
import '../../../widgets/custom_action_popup.dart';
|
import '../../../widgets/custom_action_popup.dart';
|
||||||
|
|
||||||
class policylist extends ConsumerStatefulWidget {
|
class policylist extends ConsumerStatefulWidget {
|
||||||
@ -27,13 +28,16 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
int itemsPerPage = 10;
|
int itemsPerPage = 10;
|
||||||
late ApiService apiService;
|
late ApiService apiService;
|
||||||
|
dynamic userId;
|
||||||
// List<Map<String, dynamic>> dataVal = [];
|
// List<Map<String, dynamic>> dataVal = [];
|
||||||
List<Map<String, dynamic>> getStaffData = [];
|
List<Map<String, dynamic>> getStaffData = [];
|
||||||
List<Map<String, dynamic>> originalData = [];
|
List<Map<String, dynamic>> originalData = [];
|
||||||
List<Map<String, dynamic>> filteredData = [];
|
List<Map<String, dynamic>> filteredData = [];
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
dynamic roleId;
|
dynamic roleId;
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
Map<String, TextEditingController> controllers = {};
|
||||||
|
List<String> tabHeader = ['startDate', 'endDate'];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -41,10 +45,14 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
|
|
||||||
apiService = ApiService();
|
apiService = ApiService();
|
||||||
|
|
||||||
|
for (String field in tabHeader) {
|
||||||
|
controllers[field] = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
Future.microtask(() {
|
Future.microtask(() {
|
||||||
final id = ref.read(managerIdProvider);
|
final id = ref.read(managerIdProvider);
|
||||||
roleId = ref.read(userRoleProvider);
|
roleId = ref.read(userRoleProvider);
|
||||||
final userId = ref.read(userIdProvider);
|
userId = ref.read(userIdProvider);
|
||||||
|
|
||||||
print("D49 => r : $roleId | mId: $id | uId: $userId ");
|
print("D49 => r : $roleId | mId: $id | uId: $userId ");
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
@ -64,7 +72,12 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getStaffList(int managerId, role) async {
|
Future<void> getStaffList(
|
||||||
|
int managerId,
|
||||||
|
role, {
|
||||||
|
String fromDate = '',
|
||||||
|
String toDate = '',
|
||||||
|
}) async {
|
||||||
print('D68 => Fns called => $managerId | $role');
|
print('D68 => Fns called => $managerId | $role');
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@ -74,12 +87,22 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
final response = await apiService.fetchPolicyDataOnlyList(
|
final response = await apiService.fetchPolicyDataOnlyList(
|
||||||
managerId,
|
managerId,
|
||||||
role,
|
role,
|
||||||
|
fromDate: controllers['startDate']?.text ?? '',
|
||||||
|
toDate: controllers['endDate']?.text ?? '',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
final data = response['data'];
|
final data = response['data'];
|
||||||
print('D81 => getStaffListData => ${response['data']}');
|
print('D81 => getStaffListData => ${response['data']}');
|
||||||
|
|
||||||
|
final fromDate = response['from_date'] ?? '';
|
||||||
|
final toDate = response['to_date'] ?? '';
|
||||||
|
|
||||||
|
print('FromDate : $fromDate');
|
||||||
|
print('ToDate : $toDate');
|
||||||
setState(() {
|
setState(() {
|
||||||
|
controllers['startDate']?.text = fromDate;
|
||||||
|
controllers['endDate']?.text = toDate;
|
||||||
if (data is List) {
|
if (data is List) {
|
||||||
// Already a list of maps
|
// Already a list of maps
|
||||||
getStaffData = List<Map<String, dynamic>>.from(data);
|
getStaffData = List<Map<String, dynamic>>.from(data);
|
||||||
@ -124,6 +147,45 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
return sortedData.sublist(startIndex, endIndex);
|
return sortedData.sublist(startIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void filterDateRange() {
|
||||||
|
// ✅ Validate the form first
|
||||||
|
if (!_formKey.currentState!.validate()) {
|
||||||
|
// stop execution if validation fails
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final fromDateText = controllers['startDate']?.text ?? '';
|
||||||
|
final toDateText = controllers['endDate']?.text ?? '';
|
||||||
|
|
||||||
|
// Optional: double-check End >= Start
|
||||||
|
final fromDate = DateFormat('dd-MM-yyyy').parse(fromDateText);
|
||||||
|
final toDate = DateFormat('dd-MM-yyyy').parse(toDateText);
|
||||||
|
|
||||||
|
if (toDate.isBefore(fromDate)) {
|
||||||
|
// This is already caught by the validator, but extra safety
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text("End Date cannot be earlier than Start Date")),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Call your API
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void refrshfilterDateRange() {
|
||||||
|
setState(() {
|
||||||
|
controllers['startDate']!.clear();
|
||||||
|
controllers['endDate']!.clear();
|
||||||
|
|
||||||
|
controllers['startDate']?.text = '';
|
||||||
|
controllers['endDate']?.text = '';
|
||||||
|
// Reset the FormField validation
|
||||||
|
_formKey.currentState?.reset();
|
||||||
|
});
|
||||||
|
getStaffList(userId, roleId);
|
||||||
|
}
|
||||||
|
|
||||||
void filterData(String query) {
|
void filterData(String query) {
|
||||||
print("FilterDAta - $query");
|
print("FilterDAta - $query");
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -334,157 +396,23 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
|
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
|
|
||||||
Expanded(
|
ResponsiveLayout.isMobile(context)
|
||||||
child: Container(
|
? Container(
|
||||||
// color: Colors.green,
|
height: MediaQuery.of(context).size.height * 0.69,
|
||||||
// color: Colors.green.shade50,
|
child: SingleChildScrollView(
|
||||||
width: MediaQuery.of(context).size.width,
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
padding: EdgeInsets.all(8.0),
|
child: _buildContent(context),
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
// height: 40,
|
|
||||||
// color: Colors.pink,
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
ThemedSearchField(
|
|
||||||
hintText: 'Search',
|
|
||||||
backgroundColor: Color(0xFFF6F8F8),
|
|
||||||
onChanged: filterData,
|
|
||||||
controller: _searchStaffController,
|
|
||||||
txtwidth: ResponsiveLayout.isMobile(context)
|
|
||||||
? MediaQuery.of(context).size.width * 0.6
|
|
||||||
: MediaQuery.of(context).size.width * 0.2,
|
|
||||||
),
|
|
||||||
|
|
||||||
Spacer(),
|
|
||||||
|
|
||||||
ExportBtn(
|
|
||||||
sheetName: "Policy",
|
|
||||||
fileName: "Policy_list",
|
|
||||||
data: filteredData,
|
|
||||||
txt: !ResponsiveLayout.isMobile(context)
|
|
||||||
? true
|
|
||||||
: false,
|
|
||||||
headers: [
|
|
||||||
"reg_no",
|
|
||||||
"agent_name",
|
|
||||||
"assigned_to_name",
|
|
||||||
"insurer_name",
|
|
||||||
"insured_name",
|
|
||||||
"premium_amount",
|
|
||||||
"payment_mode",
|
|
||||||
"updated_on",
|
|
||||||
"policy_number",
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
// GestureDetector(
|
|
||||||
// onTap: () {
|
|
||||||
// // print('Export');
|
|
||||||
// },
|
|
||||||
// child: Container(
|
|
||||||
// padding: EdgeInsets.all(8.0),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: Color(0xFF425B5B),
|
|
||||||
// borderRadius: BorderRadius.circular(8.0),
|
|
||||||
// ),
|
|
||||||
// child: Row(
|
|
||||||
// mainAxisSize: MainAxisSize.min,
|
|
||||||
// children: [
|
|
||||||
// Icon(Icons.add, color: Colors.white),
|
|
||||||
//
|
|
||||||
// if (!ResponsiveLayout.isMobile(context)) ...[
|
|
||||||
// SizedBox(width: 10),
|
|
||||||
//
|
|
||||||
// GestureDetector(
|
|
||||||
// onTap: () {
|
|
||||||
// // context.go(AppRoutes.agent / create);
|
|
||||||
// context.go('/staff/create');
|
|
||||||
// },
|
|
||||||
// child: Text(
|
|
||||||
// 'Create New Staff',
|
|
||||||
// style: GoogleFonts.inter(
|
|
||||||
// color: Colors.white,
|
|
||||||
// fontWeight: FontWeight.w600,
|
|
||||||
// fontSize: 14,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
)
|
||||||
if (!ResponsiveLayout.isMobile(context))
|
: Expanded(
|
||||||
Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
width: MediaQuery.of(context).size.width,
|
||||||
color: Color(0xFFEDF6F5),
|
padding: EdgeInsets.all(8.0),
|
||||||
borderRadius: BorderRadius.circular(6),
|
child: _buildContent(context),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
),
|
||||||
vertical: 12,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: Text('Date', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Reg.No', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Agents', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Assigned To', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Insurer', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Insured Name', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Premium', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Payment Mode', style: _headerStyle),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Text('Policy Number', style: _headerStyle),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Expanded(
|
|
||||||
// flex: 1,
|
|
||||||
// child: Text('Action', style: _headerStyle),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(child: _buildDataTable(context)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
// height: 20,
|
// height: 20,
|
||||||
@ -515,6 +443,244 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
if (ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
color: Color(0xffD9EBE8),
|
||||||
|
child: DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
Container(
|
||||||
|
// height: 40,
|
||||||
|
// color: Colors.pink,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
DateFilterRow(
|
||||||
|
startController: controllers['startDate']!,
|
||||||
|
endController: controllers['endDate']!,
|
||||||
|
formKey: _formKey,
|
||||||
|
isMobile: ResponsiveLayout.isMobile(context),
|
||||||
|
onFilter: () {
|
||||||
|
// call your filter logic
|
||||||
|
filterDateRange();
|
||||||
|
},
|
||||||
|
onRefresh: () {
|
||||||
|
// call your refresh logic
|
||||||
|
refrshfilterDateRange();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
// Form(
|
||||||
|
// key: _formKey,
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
// children: [
|
||||||
|
// buildStartDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
// buildEndDate(context),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 8.0,
|
||||||
|
// ),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// // onTap: filterDateRange,
|
||||||
|
// onTap: () {
|
||||||
|
// if (_formKey.currentState!.validate()) {
|
||||||
|
// filterDateRange(); // only runs if valid
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Icon(Icons.filter_alt_outlined),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.all(8.0),
|
||||||
|
// child: GestureDetector(
|
||||||
|
// onTap: refrshfilterDateRange,
|
||||||
|
// child: Icon(Icons.refresh),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
Spacer(),
|
||||||
|
],
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? SizedBox(height: 10)
|
||||||
|
: SizedBox.shrink(),
|
||||||
|
ThemedSearchField(
|
||||||
|
hintText: 'Search',
|
||||||
|
backgroundColor: Color(0xFFF6F8F8),
|
||||||
|
onChanged: filterData,
|
||||||
|
controller: _searchStaffController,
|
||||||
|
txtwidth: ResponsiveLayout.isMobile(context)
|
||||||
|
? MediaQuery.of(context).size.width * 0.7
|
||||||
|
: MediaQuery.of(context).size.width * 0.2,
|
||||||
|
),
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? Spacer()
|
||||||
|
: SizedBox(width: 10),
|
||||||
|
ExportBtn(
|
||||||
|
sheetName: "Policy",
|
||||||
|
fileName: "Policy_list",
|
||||||
|
data: filteredData,
|
||||||
|
txt: !ResponsiveLayout.isMobile(context) ? true : false,
|
||||||
|
headers: [
|
||||||
|
"reg_no",
|
||||||
|
"agent_name",
|
||||||
|
"assigned_to_name",
|
||||||
|
"insurer_name",
|
||||||
|
"insured_name",
|
||||||
|
"premium_amount",
|
||||||
|
"payment_mode",
|
||||||
|
"updated_on",
|
||||||
|
"policy_number",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// // print('Export');
|
||||||
|
// },
|
||||||
|
// child: Container(
|
||||||
|
// padding: EdgeInsets.all(8.0),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Color(0xFF425B5B),
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// ),
|
||||||
|
// child: Row(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// children: [
|
||||||
|
// Icon(Icons.add, color: Colors.white),
|
||||||
|
//
|
||||||
|
// if (!ResponsiveLayout.isMobile(context)) ...[
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
//
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// // context.go(AppRoutes.agent / create);
|
||||||
|
// context.go('/staff/create');
|
||||||
|
// },
|
||||||
|
// child: Text(
|
||||||
|
// 'Create New Staff',
|
||||||
|
// style: GoogleFonts.inter(
|
||||||
|
// color: Colors.white,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// fontSize: 14,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
if (!ResponsiveLayout.isMobile(context))
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFFEDF6F5),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(flex: 4, child: Text('Date', style: _headerStyle)),
|
||||||
|
Expanded(flex: 3, child: Text('Reg.No', style: _headerStyle)),
|
||||||
|
Expanded(flex: 3, child: Text('Agents', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Assigned To', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 3, child: Text('Insurer', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Insured Name', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(flex: 3, child: Text('Premium', style: _headerStyle)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Payment Mode', style: _headerStyle),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Text('Policy Number', style: _headerStyle),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Expanded(
|
||||||
|
// flex: 1,
|
||||||
|
// child: Text('Action', style: _headerStyle),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Expanded(child: _buildDataTable(context)),
|
||||||
|
ResponsiveLayout.isMobile(context)
|
||||||
|
? _buildDataTable(context)
|
||||||
|
: Expanded(child: _buildDataTable(context)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Widget _buildDataTable(BuildContext context) {
|
||||||
|
// if (filteredData.isEmpty) {
|
||||||
|
// return const SizedBox(
|
||||||
|
// height: 50,
|
||||||
|
// child: Center(child: Text('No available data')),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final sortedData = [..._paginatedData];
|
||||||
|
// return ListView.builder(
|
||||||
|
// itemCount: ResponsiveLayout.isMobile(context)
|
||||||
|
// ? sortedData
|
||||||
|
// .length // only cards for mobile
|
||||||
|
// : sortedData.length + 1, // +1 for header in desktop
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
||||||
|
// return _buildHeader();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
// final item =
|
||||||
|
// sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
||||||
|
// final sno = startIndex + index;
|
||||||
|
//
|
||||||
|
// return !ResponsiveLayout.isMobile(context)
|
||||||
|
// ? _buildDataRow(item, sno)
|
||||||
|
// : _buildDataCard(item, sno);
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
Widget _buildDataTable(BuildContext context) {
|
Widget _buildDataTable(BuildContext context) {
|
||||||
if (filteredData.isEmpty) {
|
if (filteredData.isEmpty) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
@ -524,24 +690,28 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final sortedData = [..._paginatedData];
|
final sortedData = [..._paginatedData];
|
||||||
|
|
||||||
|
if (ResponsiveLayout.isMobile(context)) {
|
||||||
|
// Use Column instead of ListView
|
||||||
|
return Column(
|
||||||
|
children: List.generate(sortedData.length, (index) {
|
||||||
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
|
final item = sortedData[index];
|
||||||
|
final sno = startIndex + index;
|
||||||
|
return _buildDataCard(item, sno);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop: keep ListView.builder
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: ResponsiveLayout.isMobile(context)
|
itemCount: sortedData.length + 1,
|
||||||
? sortedData
|
|
||||||
.length // only cards for mobile
|
|
||||||
: sortedData.length + 1, // +1 for header in desktop
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (!ResponsiveLayout.isMobile(context) && index == 0) {
|
if (index == 0) return _buildHeader();
|
||||||
return _buildHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
final item =
|
final item = sortedData[index - 1];
|
||||||
sortedData[index - (ResponsiveLayout.isMobile(context) ? 0 : 1)];
|
|
||||||
final sno = startIndex + index;
|
final sno = startIndex + index;
|
||||||
|
return _buildDataRow(item, sno);
|
||||||
return !ResponsiveLayout.isMobile(context)
|
|
||||||
? _buildDataRow(item, sno)
|
|
||||||
: _buildDataCard(item, sno);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,44 +1,72 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:http/http.dart' as ref;
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:nhance_partner/presentation/providers/userRoleProvider.dart';
|
||||||
|
|
||||||
class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
import '../../core/routing/routes.dart';
|
||||||
|
import '../layouts/responsive_layout.dart';
|
||||||
|
import '../providers/userRoleProvider.dart';
|
||||||
|
|
||||||
|
class TopBar extends StatefulWidget implements PreferredSizeWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final bool isMobile;
|
final bool isMobile;
|
||||||
final VoidCallback? onBack;
|
|
||||||
final VoidCallback? onMenuPressed;
|
|
||||||
final VoidCallback? onLogout;
|
final VoidCallback? onLogout;
|
||||||
// final VoidCallback? onProfile;
|
|
||||||
final void Function(TapDownDetails details)? onProfile;
|
final void Function(TapDownDetails details)? onProfile;
|
||||||
|
final VoidCallback? onMenuPressed;
|
||||||
final VoidCallback? onNotifications;
|
final VoidCallback? onNotifications;
|
||||||
final int notificationCount;
|
|
||||||
|
|
||||||
const TopBar({
|
const TopBar({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
this.isMobile = false,
|
this.isMobile = false,
|
||||||
this.onBack,
|
|
||||||
this.onMenuPressed,
|
|
||||||
this.onLogout,
|
this.onLogout,
|
||||||
this.onProfile,
|
this.onProfile,
|
||||||
this.onNotifications,
|
this.onNotifications,
|
||||||
this.notificationCount = 0,
|
this.onMenuPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TopBar> createState() => _TopBarState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TopBarState extends State<TopBar> {
|
||||||
|
String? role;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadUser() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
setState(() {
|
||||||
|
role = prefs.getString('userRole') ?? "Guest";
|
||||||
|
});
|
||||||
|
print('Tpbn - $role');
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
backgroundColor: const Color(0xFFD6F6F4), // light cyan
|
backgroundColor: const Color(0xFFD6F6F4), // light cyan
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
titleSpacing: isMobile ? 0 : 30,
|
titleSpacing: widget.isMobile ? 0 : 30,
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
if (!isMobile)
|
if (!widget.isMobile)
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/login/nhance-partner-logo.png",
|
"assets/login/nhance-partner-logo.png",
|
||||||
height: 60,
|
height: 60,
|
||||||
width: 120,
|
width: 120,
|
||||||
),
|
),
|
||||||
if (isMobile) ...[
|
if (widget.isMobile) ...[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
@ -75,6 +103,38 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
// icon: const Icon(Icons.menu, color: Colors.black87),
|
// icon: const Icon(Icons.menu, color: Colors.black87),
|
||||||
// onPressed: onMenuPressed,
|
// onPressed: onMenuPressed,
|
||||||
// ),
|
// ),
|
||||||
|
if (role == 'agent') ...[
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
await prefs.remove('enqAgentDataId');
|
||||||
|
context.go(AppRoutes.tabEnquiry);
|
||||||
|
// print('Export');
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(8.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(0xFF425B5B),
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Raise Enquiry',
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
SizedBox(width: 10),
|
||||||
Container(
|
Container(
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
@ -84,10 +144,10 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.notifications_none, color: Colors.black87),
|
icon: const Icon(Icons.notifications_none, color: Colors.black87),
|
||||||
onPressed: onNotifications,
|
onPressed: widget.onNotifications,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isMobile) ...[
|
if (!widget.isMobile) ...[
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
Container(
|
Container(
|
||||||
width: 40,
|
width: 40,
|
||||||
@ -97,7 +157,7 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
borderRadius: BorderRadius.circular(50.0),
|
borderRadius: BorderRadius.circular(50.0),
|
||||||
),
|
),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTapDown: (details) => onProfile!(details),
|
onTapDown: (details) => widget.onProfile!(details),
|
||||||
child: const Icon(Icons.person_outline, color: Colors.black87),
|
child: const Icon(Icons.person_outline, color: Colors.black87),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -106,21 +166,20 @@ class TopBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
// icon: const Icon(Icons.person_outline, color: Colors.black87),
|
// icon: const Icon(Icons.person_outline, color: Colors.black87),
|
||||||
// onPressed: onProfile,
|
// onPressed: onProfile,
|
||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
Container(
|
Container(
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(50.0),
|
borderRadius: BorderRadius.circular(50.0),
|
||||||
),
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.logout, color: Colors.black87),
|
|
||||||
onPressed: onLogout,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(Icons.logout, color: Colors.black87),
|
||||||
|
onPressed: widget.onLogout,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user