Pagiantion
This commit is contained in:
parent
fc08f0a2d4
commit
7f6e79ceb8
File diff suppressed because one or more lines are too long
@ -595,14 +595,15 @@ class ApiService {
|
||||
url = Uri.parse(
|
||||
'${Env.apiUrl}enquiry/enquiryList?manager_id=$id&only_policy_data=true',
|
||||
);
|
||||
} else {
|
||||
} 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',
|
||||
);
|
||||
}
|
||||
// else {
|
||||
// url = Uri.parse('${Env.apiUrl}endorsement/endorsementList?agent_id=$id');
|
||||
// }
|
||||
// final url = Uri.parse(
|
||||
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',
|
||||
// );
|
||||
|
||||
@ -68,7 +68,7 @@ class Validators {
|
||||
|
||||
static String? number(String? value, String label) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return "$label is required";
|
||||
return "Required";
|
||||
}
|
||||
if (!RegExp(r'^[0-9]+$').hasMatch(value)) {
|
||||
return "$label must contain only numbers";
|
||||
@ -78,7 +78,7 @@ class Validators {
|
||||
|
||||
static String? doubleNumber(String? value, String label) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return "$label is required";
|
||||
return "Required";
|
||||
}
|
||||
// allow integers or decimals with optional fraction part
|
||||
if (!RegExp(r'^[0-9]+(\.[0-9]+)?$').hasMatch(value.trim())) {
|
||||
|
||||
@ -74,6 +74,8 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
String? selectedId;
|
||||
bool isLoading = false;
|
||||
|
||||
bool isSaving = false;
|
||||
|
||||
String? selectedVehicleType;
|
||||
// int? selectedVehicleTypeId;
|
||||
String? selectedInsurer;
|
||||
@ -284,6 +286,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
setState(() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
isSaving = true;
|
||||
dataDetails();
|
||||
final dataSet = dataDetails();
|
||||
print("dataSetAgent - $dataSet");
|
||||
@ -307,6 +310,8 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
createUserData(dataSet);
|
||||
} else {
|
||||
// isDisable = false;
|
||||
|
||||
setState(() => isSaving = false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -434,10 +439,13 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
ref.read(enquiryIdProvider.notifier).state = null;
|
||||
context.go(AppRoutes.enquiryLst);
|
||||
}
|
||||
|
||||
setState(() => isSaving = false);
|
||||
} else {
|
||||
print("❌ Submission failed. Status: ${response.statusCode}");
|
||||
print("Body: ${response.body}");
|
||||
|
||||
setState(() => isSaving = false);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -490,17 +498,22 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
handleSave();
|
||||
},
|
||||
// onTap: () {
|
||||
// handleSave();
|
||||
// },
|
||||
onTap: isSaving ? null : handleSave,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 45.0, vertical: 8),
|
||||
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
color: Color(0xFF425B5B),
|
||||
// color: Color(0xFF425B5B),
|
||||
color: isSaving ? Colors.grey : Color(0xFF425B5B),
|
||||
),
|
||||
child: Text(
|
||||
isSaving ? 'Saving...' : 'Save',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
child: Text('Save', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -732,7 +745,6 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
popupProps: PopupProps.menu(
|
||||
fit: FlexFit.loose,
|
||||
constraints: BoxConstraints(maxHeight: 250),
|
||||
|
||||
@ -10,9 +10,11 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../../core/routing/routes.dart';
|
||||
import '../../../../core/services/api_service.dart';
|
||||
import '../../../../data/utils/Pagination.dart';
|
||||
import '../../../data/utils/validators.dart';
|
||||
import '../../layouts/main_layout.dart';
|
||||
import '../../layouts/responsive_layout.dart';
|
||||
import '../../providers/manager_provider.dart';
|
||||
import '../../themes/indicators/date_field_theme.dart';
|
||||
import '../../themes/indicators/export_btn.dart';
|
||||
import '../../themes/indicators/search_field_theme.dart';
|
||||
import '../../widgets/custom_action_popup.dart';
|
||||
@ -32,13 +34,19 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
List<Map<String, dynamic>> getStaffData = [];
|
||||
List<Map<String, dynamic>> originalData = [];
|
||||
List<Map<String, dynamic>> filteredData = [];
|
||||
Map<String, TextEditingController> controllers = {};
|
||||
bool isLoading = false;
|
||||
|
||||
List<String> tabHeader = ['startDate', 'endDate'];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
apiService = ApiService();
|
||||
for (String field in tabHeader) {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
Future.microtask(() {
|
||||
final id = ref.read(managerIdProvider);
|
||||
@ -51,6 +59,9 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
});
|
||||
}
|
||||
|
||||
void filterDateRange() {}
|
||||
void refrshfilterDateRange() {}
|
||||
|
||||
Future<void> getStaffList(int managerId, role) async {
|
||||
print('getClaimList called MagId - $managerId - $role');
|
||||
setState(() {
|
||||
@ -91,7 +102,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> get _paginatedData {
|
||||
List<dynamic> get _paginatedData1 {
|
||||
// Sort descending by id first
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
@ -102,6 +113,23 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
List<dynamic> get _paginatedData {
|
||||
// Sort descending by id first
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
Future<void> handleEdit(item) async {
|
||||
// Navigator.pop(context);
|
||||
print('EDITStaff - ${item['id']}');
|
||||
@ -153,7 +181,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
String _formatDate(String rawDate) {
|
||||
try {
|
||||
final dateTime = DateTime.parse(rawDate);
|
||||
return DateFormat('dd/MM/yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
return DateFormat('dd-MM-yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
} catch (e) {
|
||||
return rawDate; // fallback if parsing fails
|
||||
}
|
||||
@ -241,9 +269,29 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
// height: 40,
|
||||
// color: Colors.pink,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
// buildStartDate(context),
|
||||
// SizedBox(width: 10),
|
||||
// buildEndDate(context),
|
||||
// SizedBox(width: 10),
|
||||
//
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: GestureDetector(
|
||||
// onTap: filterDateRange,
|
||||
// child: Icon(Icons.filter_list_outlined),
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: GestureDetector(
|
||||
// onTap: refrshfilterDateRange,
|
||||
// child: Icon(Icons.refresh),
|
||||
// ),
|
||||
// ),
|
||||
ThemedSearchField(
|
||||
hintText: 'Search',
|
||||
backgroundColor: Color(0xFFF6F8F8),
|
||||
@ -256,6 +304,8 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
|
||||
Spacer(),
|
||||
|
||||
SizedBox(width: 10),
|
||||
|
||||
ExportBtn(
|
||||
sheetName: "Enquiry",
|
||||
fileName: "enquiry_list",
|
||||
@ -276,7 +326,8 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
SizedBox(width: 10),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final prefs =
|
||||
await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.remove('enqAgentDataId');
|
||||
context.go(AppRoutes.tabEnquiry);
|
||||
@ -709,6 +760,61 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildStartDate(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Start Date', style: _textStyle),
|
||||
SizedBox(height: 5),
|
||||
ThemedDateField(
|
||||
hintText: "Select Date",
|
||||
txtwidth: ResponsiveLayout.isMobile(context)
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.16,
|
||||
txtheight: 50,
|
||||
// backgroundColor: const Color(0xFFECECEC),
|
||||
// validator: (value) => Validators.requiredField(value, "date"),
|
||||
controller: controllers['startDate']!,
|
||||
onDateSelected: (date) {
|
||||
print("Picked Date: $date");
|
||||
|
||||
controllers['startDate']?.text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(date);
|
||||
// controllers['date']?.text = date as String;
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildEndDate(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('End Date', style: _textStyle),
|
||||
SizedBox(height: 5),
|
||||
ThemedDateField(
|
||||
hintText: "Select Date",
|
||||
txtwidth: ResponsiveLayout.isMobile(context)
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.16,
|
||||
txtheight: 50,
|
||||
// backgroundColor: const Color(0xFFECECEC),
|
||||
// validator: (value) => Validators.requiredField(value, "date"),
|
||||
controller: controllers['endDate']!,
|
||||
onDateSelected: (date) {
|
||||
print("Picked Date: $date");
|
||||
controllers['endDate']?.text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(date);
|
||||
// controllers['date']?.text = date as String;
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
static final _dataBold = GoogleFonts.inter(
|
||||
fontSize: 14,
|
||||
|
||||
@ -741,4 +847,9 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static const _textStyle = TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
}
|
||||
|
||||
@ -96,8 +96,14 @@ class claimListState extends ConsumerState<claimList> {
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||
final endIndex = (currentPage * itemsPerPage).clamp(0, sortedData.length);
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
@ -133,7 +139,7 @@ class claimListState extends ConsumerState<claimList> {
|
||||
String _formatDate(String rawDate) {
|
||||
try {
|
||||
final dateTime = DateTime.parse(rawDate);
|
||||
return DateFormat('dd/MM/yyyy').format(dateTime); // date only
|
||||
return DateFormat('dd-MM-yyyy').format(dateTime); // date only
|
||||
} catch (e) {
|
||||
return rawDate; // fallback if parsing fails
|
||||
}
|
||||
|
||||
@ -94,8 +94,14 @@ class endosementState extends ConsumerState<endosement> {
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||
final endIndex = (currentPage * itemsPerPage).clamp(0, sortedData.length);
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
@ -130,7 +136,7 @@ class endosementState extends ConsumerState<endosement> {
|
||||
String _formatDate(String rawDate) {
|
||||
try {
|
||||
final dateTime = DateTime.parse(rawDate);
|
||||
return DateFormat('dd/MM/yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
return DateFormat('dd-MM-yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
} catch (e) {
|
||||
return rawDate; // fallback if parsing fails
|
||||
}
|
||||
@ -305,7 +311,7 @@ class endosementState extends ConsumerState<endosement> {
|
||||
child: Text('Reg.No.', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 4,
|
||||
child: Text('Company', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
@ -405,7 +411,7 @@ class endosementState extends ConsumerState<endosement> {
|
||||
|
||||
Widget _buildDataRow(Map<String, dynamic> item, sno) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
|
||||
// margin: const EdgeInsets.only(top: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
@ -426,7 +432,7 @@ class endosementState extends ConsumerState<endosement> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 4,
|
||||
child: Text(
|
||||
item['insurer_name'] ?? '-', // fallback
|
||||
style: _dataBold,
|
||||
|
||||
@ -102,27 +102,27 @@ class ClaimsSubListState extends ConsumerState<ClaimsSubList> {
|
||||
|
||||
List<Widget> _buildPopupMenuActions(BuildContext context, dynamic data) {
|
||||
return [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
print('EDITStaff - ${data['id']}');
|
||||
// dynamic id = data['id'];
|
||||
// context.go('/tabEnquiry/$id');
|
||||
|
||||
// update provider
|
||||
final id = data['id'].toString();
|
||||
ref.read(enquiryIdProvider.notifier).state = id;
|
||||
context.go(AppRoutes.tabEnquiry);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.edit_sharp, color: Color(0xFF319718), size: 18),
|
||||
SizedBox(width: 10),
|
||||
Text('Edit'),
|
||||
],
|
||||
),
|
||||
),
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// Navigator.pop(context);
|
||||
// print('EDITStaff - ${data['id']}');
|
||||
// // dynamic id = data['id'];
|
||||
// // context.go('/tabEnquiry/$id');
|
||||
//
|
||||
// // update provider
|
||||
// final id = data['id'].toString();
|
||||
// ref.read(enquiryIdProvider.notifier).state = id;
|
||||
// context.go(AppRoutes.tabEnquiry);
|
||||
// },
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Icon(Icons.edit_sharp, color: Color(0xFF319718), size: 18),
|
||||
// SizedBox(width: 10),
|
||||
// Text('Edit'),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -191,10 +191,10 @@ class EndrosmentSubListState extends ConsumerState<EndrosmentSubList> {
|
||||
child: Text('Status', style: _headerStyle),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text('Action', style: _headerStyle),
|
||||
),
|
||||
// Expanded(
|
||||
// flex: 1,
|
||||
// child: Text('Action', style: _headerStyle),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -319,38 +319,38 @@ class EndrosmentSubListState extends ConsumerState<EndrosmentSubList> {
|
||||
child: Text(item['status'] ?? '-', style: _dataBold),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Row(
|
||||
children: [
|
||||
PopupMenuButton<int>(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.zero,
|
||||
offset: Offset(0, 30),
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
color: Color(0xFF475569),
|
||||
size: 14,
|
||||
),
|
||||
itemBuilder: (context) => [
|
||||
CustomPopupMenuEntry(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 8,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: _buildPopupMenuActions(context, item),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Expanded(
|
||||
// flex: 1,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// PopupMenuButton<int>(
|
||||
// color: Colors.white,
|
||||
// padding: EdgeInsets.zero,
|
||||
// offset: Offset(0, 30),
|
||||
// icon: Icon(
|
||||
// Icons.more_vert,
|
||||
// color: Color(0xFF475569),
|
||||
// size: 14,
|
||||
// ),
|
||||
// itemBuilder: (context) => [
|
||||
// CustomPopupMenuEntry(
|
||||
// child: Container(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: 8,
|
||||
// vertical: 8,
|
||||
// ),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: _buildPopupMenuActions(context, item),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -378,25 +378,25 @@ class EndrosmentSubListState extends ConsumerState<EndrosmentSubList> {
|
||||
style: _headerStyle,
|
||||
),
|
||||
),
|
||||
PopupMenuButton<int>(
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.zero,
|
||||
offset: const Offset(0, 30),
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Color(0xFF475569),
|
||||
size: 16,
|
||||
),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem<int>(
|
||||
value: 1,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: _buildPopupMenuActions(context, item),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// PopupMenuButton<int>(
|
||||
// color: Colors.white,
|
||||
// padding: EdgeInsets.zero,
|
||||
// offset: const Offset(0, 30),
|
||||
// icon: const Icon(
|
||||
// Icons.more_vert,
|
||||
// color: Color(0xFF475569),
|
||||
// size: 16,
|
||||
// ),
|
||||
// itemBuilder: (context) => [
|
||||
// PopupMenuItem<int>(
|
||||
// value: 1,
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: _buildPopupMenuActions(context, item),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
// Description
|
||||
|
||||
@ -67,11 +67,15 @@ class AgentListState extends ConsumerState<AgentList> {
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
// Calculate pagination indices
|
||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||
final endIndex = (currentPage * itemsPerPage).clamp(0, sortedData.length);
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
// Return only the paginated slice
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
@ -259,6 +263,7 @@ class AgentListState extends ConsumerState<AgentList> {
|
||||
"agent_code",
|
||||
"email",
|
||||
"mobile",
|
||||
"address",
|
||||
"is_active",
|
||||
],
|
||||
),
|
||||
|
||||
@ -61,8 +61,14 @@ class StaffListState extends ConsumerState<StaffList> {
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||
final endIndex = (currentPage * itemsPerPage).clamp(0, sortedData.length);
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
@ -505,6 +505,40 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
// void _resendCode(String mobileNumber, int? resendToken) async {
|
||||
// await _auth.verifyPhoneNumber(
|
||||
// phoneNumber: '${_countryController.text + mobileNumber}',
|
||||
// timeout: const Duration(seconds: 60),
|
||||
// forceResendingToken: resendToken,
|
||||
// verificationCompleted: (PhoneAuthCredential credential) async {
|
||||
// await _auth.signInWithCredential(credential);
|
||||
// },
|
||||
// verificationFailed: (FirebaseAuthException e) {
|
||||
// if (e.code == 'invalid-phone-number') {
|
||||
// print('The provided phone number is not valid.');
|
||||
// }
|
||||
// },
|
||||
// codeSent: (String verificationId, int? resendToken) async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('verificationId', verificationId);
|
||||
// setState(() {
|
||||
// _verificationId = verificationId;
|
||||
// _resendToken = resendToken;
|
||||
// });
|
||||
// ToastHelper.showSuccessToast(
|
||||
// context,
|
||||
// 'Verification code resent to ${mobileNumber}',
|
||||
// );
|
||||
// },
|
||||
// codeAutoRetrievalTimeout: (String verificationId) async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('verificationId', verificationId);
|
||||
// setState(() {
|
||||
// _verificationId = verificationId;
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
void _resendCode(String mobileNumber, int? resendToken) async {
|
||||
await _auth.verifyPhoneNumber(
|
||||
phoneNumber: '${_countryController.text + mobileNumber}',
|
||||
@ -1210,7 +1244,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 15),
|
||||
Container(
|
||||
alignment: Alignment.center, // center the text
|
||||
child: RichText(
|
||||
|
||||
@ -124,7 +124,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
}
|
||||
}
|
||||
|
||||
List<dynamic> get _paginatedData {
|
||||
List<dynamic> get _paginatedData2 {
|
||||
// Sort descending by id first
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
@ -136,6 +136,23 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
List<dynamic> get _paginatedData {
|
||||
// Sort descending by id first
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
void filterData(String query) {
|
||||
print("FilterDAta - $query");
|
||||
setState(() {
|
||||
@ -179,7 +196,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
String _formatDate(String rawDate) {
|
||||
try {
|
||||
final dateTime = DateTime.parse(rawDate);
|
||||
return DateFormat('dd/MM/yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
return DateFormat(
|
||||
'dd-MM-yyyy HH:mm',
|
||||
).format(dateTime); // 24-hour format
|
||||
} catch (e) {
|
||||
return rawDate; // fallback if parsing fails
|
||||
}
|
||||
@ -490,12 +509,18 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
child: Text('Assigned To', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Insurer', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text('Insured Name', style: _headerStyle),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 8.0),
|
||||
child: Text(
|
||||
'Insured Name',
|
||||
style: _headerStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
@ -631,7 +656,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
child: Text(item['assigned_to_name'] ?? '-', style: _dataBold),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['insurer_name'] ?? '-',
|
||||
style: _dataBold,
|
||||
@ -641,11 +666,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['insured_name'] ?? '-',
|
||||
style: _dataBold,
|
||||
softWrap: true,
|
||||
maxLines: 3,
|
||||
child: Center(
|
||||
child: Text(
|
||||
item['insured_name'] ?? '-',
|
||||
style: _dataBold,
|
||||
softWrap: true,
|
||||
maxLines: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
|
||||
@ -1053,6 +1053,8 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
|
||||
ThemedFormField(
|
||||
controller: controllers['premium_amount']!,
|
||||
readOnly: true,
|
||||
validator: (value) =>
|
||||
Validators.doubleNumber(value, "Premium Amount"),
|
||||
txtwidth: ResponsiveLayout.isMobile(context)
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.26,
|
||||
|
||||
@ -109,9 +109,14 @@ class policylistState extends ConsumerState<policylist> {
|
||||
final sortedData = [...filteredData]
|
||||
..sort((a, b) => int.parse(b['id']) - int.parse(a['id']));
|
||||
|
||||
// final sortedData = [...filteredData];
|
||||
final startIndex = (currentPage - 1) * itemsPerPage;
|
||||
final endIndex = (currentPage * itemsPerPage).clamp(0, sortedData.length);
|
||||
if (sortedData.isEmpty) return [];
|
||||
|
||||
// Ensure currentPage is valid
|
||||
final maxPage = (sortedData.length / itemsPerPage).ceil();
|
||||
final safePage = currentPage.clamp(1, maxPage);
|
||||
|
||||
final startIndex = (safePage - 1) * itemsPerPage;
|
||||
final endIndex = (startIndex + itemsPerPage).clamp(0, sortedData.length);
|
||||
|
||||
return sortedData.sublist(startIndex, endIndex);
|
||||
}
|
||||
@ -160,7 +165,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
String _formatDate(String rawDate) {
|
||||
try {
|
||||
final dateTime = DateTime.parse(rawDate);
|
||||
return DateFormat('dd/MM/yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
return DateFormat('dd-MM-yyyy HH:mm').format(dateTime); // 24-hour format
|
||||
} catch (e) {
|
||||
return rawDate; // fallback if parsing fails
|
||||
}
|
||||
@ -428,39 +433,39 @@ class policylistState extends ConsumerState<policylist> {
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
flex: 4,
|
||||
child: Text('Date', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Reg.No', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Agents', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Assigned To', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Insurer', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Insured Name', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Premium', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Payment Mode', style: _headerStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text('Policy Number', style: _headerStyle),
|
||||
),
|
||||
|
||||
@ -560,7 +565,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
flex: 4,
|
||||
child: Text(
|
||||
_formatDate(item['updated_on']) ?? '-',
|
||||
style: _dataBold,
|
||||
@ -569,22 +574,22 @@ class policylistState extends ConsumerState<policylist> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(item['reg_no'] ?? '-', style: _dataBold),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
_formatDate(item['agent_name']) ?? '-',
|
||||
style: _dataBold,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(item['assigned_to_name'] ?? '-', style: _dataBold),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['insurer_name'] ?? '-',
|
||||
style: _dataBold,
|
||||
@ -593,7 +598,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['insured_name'] ?? '-',
|
||||
style: _dataBold,
|
||||
@ -602,7 +607,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['premium_amount'] ?? '-',
|
||||
style: _dataBold,
|
||||
@ -611,7 +616,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['payment_mode'] ?? '-',
|
||||
style: _dataBold,
|
||||
@ -620,7 +625,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['policy_number'] ?? '-',
|
||||
style: _dataBold,
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
This is a placeholder for base href that will be replaced by the value of
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
<!-- <base href="$FLUTTER_BASE_HREF">-->
|
||||
<base href="/nhance/partner/app/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user