UI_CHANGES

This commit is contained in:
venbaittech 2025-10-07 09:53:42 +05:30
parent 35ab0f994b
commit 4821c5f058
6 changed files with 342 additions and 188 deletions

View File

@ -154,7 +154,11 @@ class ApiService {
}
}
Future<void> getPdfDownload(BuildContext context,String path, String id) async {
Future<void> getPdfDownload(
BuildContext context,
String path,
String id,
) async {
print('getPdfDownload 1');
print('getPdfDownload 1 - $path');
@ -176,39 +180,40 @@ class ApiService {
final response = await _makeGethttpRequest(url, headers);
print('getPdfDownload 3');
if (response.statusCode == 200) {
final contentType = response.headers['content-type'] ?? '';
if (contentType.contains('application/json')) {
final jsonResponse = jsonDecode(response.body);
if (jsonResponse['code'] == 404 || jsonResponse['code'] == 500)
{ ToastHelper.showInfoToast(context, 'File Not Found'); }
else { ToastHelper.showInfoToast(context, 'No File Found'); }
if (jsonResponse['code'] == 404 || jsonResponse['code'] == 500) {
ToastHelper.showInfoToast(context, 'File Not Found');
} else {
ToastHelper.showInfoToast(context, 'No File Found');
}
return;
}else{
final blob = html.Blob([response.bodyBytes]);
final blobUrl = html.Url.createObjectUrlFromBlob(blob);
print('getPdfDownload $blobUrl');
// --- filename resolution ---
String fileName = 'download_$id';
print('getPdfDownloadfileName $fileName');
final contentDisp = response.headers['content-disposition'];
print('getPdfDownloadcontentDisp $contentDisp');
if (contentDisp != null && contentDisp.contains('filename=')) {
print('getPdfDownloadcontentDisp..1');
fileName = contentDisp.split('filename=')[1].replaceAll('"', '');
print('getPdfDownloadcontentDisp..2');
} else {
print('getPdfDownloadcontentDisp..3');
// fallback: URL or id
fileName = path.split('/').last;
if (id != null) fileName = '${id}_$fileName';
}
final anchor = html.AnchorElement(href: blobUrl)
..setAttribute('download', fileName)
..click();
print('getPdfDownloadcontentDisp..4');
html.Url.revokeObjectUrl(blobUrl);
final blob = html.Blob([response.bodyBytes]);
final blobUrl = html.Url.createObjectUrlFromBlob(blob);
print('getPdfDownload $blobUrl');
// --- filename resolution ---
String fileName = 'download_$id';
print('getPdfDownloadfileName $fileName');
final contentDisp = response.headers['content-disposition'];
print('getPdfDownloadcontentDisp $contentDisp');
if (contentDisp != null && contentDisp.contains('filename=')) {
print('getPdfDownloadcontentDisp..1');
fileName = contentDisp.split('filename=')[1].replaceAll('"', '');
print('getPdfDownloadcontentDisp..2');
} else {
print('getPdfDownloadcontentDisp..3');
// fallback: URL or id
fileName = path.split('/').last;
if (id != null) fileName = '${id}_$fileName';
}
final anchor = html.AnchorElement(href: blobUrl)
..setAttribute('download', fileName)
..click();
print('getPdfDownloadcontentDisp..4');
html.Url.revokeObjectUrl(blobUrl);
}
} else if (response.statusCode == 404) {
showDialog(
@ -256,7 +261,7 @@ class ApiService {
} else if (apiUrl != null) {
print("Download from API: $apiUrl");
print("Download from API: $apiId!");
await getPdfDownload(context,apiUrl, apiId!);
await getPdfDownload(context, apiUrl, apiId!);
} else {
print("⚠️ No file available to download");
}
@ -470,7 +475,7 @@ class ApiService {
// ----------------------------------- ENQUIRY -------------------------------------------------
Future<Map<String, dynamic>> fetchEnquiryList(int id, role) async {
Future<Map<String, dynamic>> fetchEnquiryList1(int id, role) async {
// print(_token);
if (_token == null) {
await _initializeToken();
@ -479,11 +484,17 @@ class ApiService {
final url;
if (role == 'manager') {
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?manager_id=$id');
url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?manager_id=$id&from_date=&to_date=',
);
} else if (role == 'staff') {
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?staff_id=$id');
url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?staff_id=$id&from_date=&to_date=',
);
} else {
url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?agent_id=$id');
url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?agent_id=$id&from_date=&to_date=',
);
}
// final url = Uri.parse(
// 'https://venbait.in/nhance/partner/dev/api/agent/agentList?manager_id=${managerId}',
@ -496,6 +507,39 @@ class ApiService {
return response;
}
Future<Map<String, dynamic>> fetchEnquiryList(
int id,
String role, {
String? fromDate,
String? toDate,
}) async {
if (_token == null) {
await _initializeToken();
}
final String query;
if (role == 'manager') {
query = 'manager_id=$id';
} else if (role == 'staff') {
query = 'staff_id=$id';
} else {
query = 'agent_id=$id';
}
final url = Uri.parse(
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}',
);
final headers = {
'Authorization': 'Bearer $_token' ?? '',
'App-Signature': 'nhance-partner-2025-signature-35468846JRhH551HK',
};
final response = await _makeGetRequest(url, headers);
return response;
}
Future<Map<String, dynamic>> findSingleEnquiryData(id) async {
// print(_token);
if (_token == null) {

View File

@ -326,24 +326,24 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
final dataSet = dataDetails();
// check RC file
if ((docUploadedRCFile == null ||
(docUploadedRCFile?.bytes == null &&
docUploadedRCFile?.path == null)) &&
(rcFileUrlFromApi == null || rcFileUrlFromApi!.isEmpty)) {
setState(() => isSaving = false); // reset button
ToastHelper.showErrorToast(context, "Please upload RC Document");
return;
}
// check ID proof
if ((docUploadedIDProof == null ||
(docUploadedIDProof?.bytes == null &&
docUploadedIDProof?.path == null)) &&
(idProofFileUrlFromApi == null || idProofFileUrlFromApi!.isEmpty)) {
setState(() => isSaving = false); // reset button
ToastHelper.showErrorToast(context, "Please upload ID Proof");
return;
}
// if ((docUploadedRCFile == null ||
// (docUploadedRCFile?.bytes == null &&
// docUploadedRCFile?.path == null)) &&
// (rcFileUrlFromApi == null || rcFileUrlFromApi!.isEmpty)) {
// setState(() => isSaving = false); // reset button
// ToastHelper.showErrorToast(context, "Please upload RC Document");
// return;
// }
//
// // check ID proof
// if ((docUploadedIDProof == null ||
// (docUploadedIDProof?.bytes == null &&
// docUploadedIDProof?.path == null)) &&
// (idProofFileUrlFromApi == null || idProofFileUrlFromApi!.isEmpty)) {
// setState(() => isSaving = false); // reset button
// ToastHelper.showErrorToast(context, "Please upload ID Proof");
// return;
// }
try {
await createUserData(dataSet); // API call
@ -358,7 +358,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('OK'),
)
),
],
),
);
@ -1032,7 +1032,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
Widget buildUploadRCDocument(BuildContext context) {
return buildResponsiveUploadField(
label: "Upload RC Document *",
label: "Upload RC Document ",
hintText: selectedRCFile,
onFileSelected: (fileName, file) {
setState(() {
@ -1063,7 +1063,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
Widget buildUploadIDDocument(BuildContext context) {
return buildResponsiveUploadField(
label: "Upload ID Proof *",
label: "Upload ID Proof",
hintText: selectedIdProof,
onFileSelected: (fileName, file) {
setState(() {

View File

@ -29,6 +29,9 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
int currentPage = 1;
int itemsPerPage = 10;
late ApiService apiService;
dynamic roleId;
dynamic userId;
final _formKey = GlobalKey<FormState>();
// List<Map<String, dynamic>> dataVal = [];
List<Map<String, dynamic>> getStaffData = [];
@ -50,8 +53,8 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
Future.microtask(() {
final id = ref.read(managerIdProvider);
final roleId = ref.read(userRoleProvider);
final userId = ref.read(userIdProvider);
roleId = ref.read(userRoleProvider);
userId = ref.read(userIdProvider);
print("A56 => r : $roleId | mId: $id | uId: $userId ");
@ -60,40 +63,120 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
// Agent - venba2026@gmail.com - T E S T A - 5 evarkku 8th id is manager
// so here i used userId
if (userId != null) { getStaffList(userId, roleId); }
if (userId != null) {
getStaffList(userId, roleId);
}
});
}
void filterDateRange() {}
void refrshfilterDateRange() {}
void filterDateRange() {
print("filterDateRange");
// if (!_formKey.currentState!.validate()) return;
Future<void> getStaffList(int managerId, role) async {
// final fromDate = controllers['startDate']?.text ?? '';
// final toDate = controllers['endDate']?.text ?? '';
print("filterDateRange1");
// Call with selected dates
getStaffList(userId, roleId);
}
void refrshfilterDateRange() {
setState(() {
controllers['startDate']!.clear();
controllers['endDate']!.clear();
controllers['startDate']?.text = '';
controllers['endDate']?.text = '';
});
getStaffList(userId, roleId);
}
// Future<void> getStaffList(int managerId, role) async {
// print('A72 => Fns called => $managerId | $role');
// setState(() {
// isLoading = true;
// });
//
// try {
// final response = await apiService.fetchEnquiryList(managerId, role);
//
// if (response['status'] == 'success') {
// final data = response['data'];
// final fromDate = response['from_date'] ?? '';
// final toDate = response['to_date'] ?? '';
// print('FromDAte : $fromDate');
// print('ToDAte : $toDate');
//
// print('A82 => getStaffListData => ${response['data']}');
// setState(() {
// controllers['startDate']?.text = fromDate;
// controllers['endDate']?.text = toDate;
// if (data is List) {
// // Already a list of maps
// getStaffData = List<Map<String, dynamic>>.from(data);
// } else if (data is Map) {
// // Single object, wrap in a list
// getStaffData = [Map<String, dynamic>.from(data)];
// } else {
// getStaffData = [];
// }
// // getStaffData = List<Map<String, dynamic>>.from(response['data']);
// originalData = getStaffData;
// filteredData = List.from(originalData);
// // print('originalData - $getClaimPolicies');
// });
// } else {
// getStaffData = [];
// originalData = [];
// }
// } catch (e) {
// print('Exception occurred: $e');
// } finally {
// setState(() {
// isLoading = false;
// });
// }
// }
Future<void> getStaffList(
int managerId,
role, {
String fromDate = '',
String toDate = '',
}) async {
print('A72 => Fns called => $managerId | $role');
setState(() {
isLoading = true;
});
try {
final response = await apiService.fetchEnquiryList(managerId, role);
final response = await apiService.fetchEnquiryList(
managerId,
role,
fromDate: controllers['startDate']?.text ?? '',
toDate: controllers['endDate']?.text ?? '',
);
if (response['status'] == 'success') {
final data = response['data'];
print('A82 => getStaffListData => ${response['data']}');
final fromDate = response['from_date'] ?? '';
final toDate = response['to_date'] ?? '';
print('FromDate : $fromDate');
print('ToDate : $toDate');
setState(() {
controllers['startDate']?.text = fromDate;
controllers['endDate']?.text = toDate;
if (data is List) {
// Already a list of maps
getStaffData = List<Map<String, dynamic>>.from(data);
} else if (data is Map) {
// Single object, wrap in a list
getStaffData = [Map<String, dynamic>.from(data)];
} else {
getStaffData = [];
}
// getStaffData = List<Map<String, dynamic>>.from(response['data']);
originalData = getStaffData;
filteredData = List.from(originalData);
// print('originalData - $getClaimPolicies');
});
} else {
getStaffData = [];
@ -180,7 +263,9 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
(item['status'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['remarks'] ?? '-').toLowerCase().contains(query.toLowerCase());
(item['remarks'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
);
}).toList();
});
}
@ -274,6 +359,50 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
padding: EdgeInsets.all(8.0),
child: Column(
children: [
if (ResponsiveLayout.isMobile(context)) ...[
Container(
padding: EdgeInsets.all(8.0),
color: Color(0xffD9EBE8),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
buildStartDate(context),
SizedBox(height: 10),
buildEndDate(context),
// SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: filterDateRange,
child: Icon(
Icons.filter_list_outlined,
size: 18,
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: refrshfilterDateRange,
child: Icon(Icons.refresh, size: 18),
),
),
],
),
],
),
),
),
],
Container(
// height: 40,
// color: Colors.pink,
@ -281,26 +410,29 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
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),
// ),
// ),
if (!ResponsiveLayout.isMobile(context)) ...[
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),
),
),
Spacer(),
],
ThemedSearchField(
hintText: 'Search',
backgroundColor: Color(0xFFF6F8F8),
@ -311,8 +443,6 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
: MediaQuery.of(context).size.width * 0.2,
),
Spacer(),
SizedBox(width: 10),
ExportBtn(
@ -411,17 +541,11 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
),
Expanded(
flex: 2,
child: Text(
'Created Date',
style: _headerStyle,
),
child: Text('Created Date', style: _headerStyle),
),
Expanded(
flex: 2,
child: Text(
'Updated Date',
style: _headerStyle,
),
child: Text('Updated Date', style: _headerStyle),
),
Expanded(
flex: 1,
@ -795,7 +919,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
txtwidth: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.16,
txtheight: 50,
// txtheight: 50,
// backgroundColor: const Color(0xFFECECEC),
// validator: (value) => Validators.requiredField(value, "date"),
controller: controllers['startDate']!,
@ -823,7 +947,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
txtwidth: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.16,
txtheight: 50,
// txtheight: 50,
// backgroundColor: const Color(0xFFECECEC),
// validator: (value) => Validators.requiredField(value, "date"),
controller: controllers['endDate']!,

View File

@ -45,8 +45,9 @@ class claimListState extends ConsumerState<claimList> {
final roleId = ref.read(userRoleProvider);
final userId = ref.read(userIdProvider);
print("G47 => r : $roleId | mId: $id | uId: $userId ");
if (userId != null) { getStaffList(userId, roleId); }
if (userId != null) {
getStaffList(userId, roleId);
}
});
}
@ -248,6 +249,7 @@ class claimListState extends ConsumerState<claimList> {
"policy_end_date",
"claim_number",
"claim_type_value",
'claim_status_value',
],
),
@ -336,10 +338,10 @@ class claimListState extends ConsumerState<claimList> {
flex: 2,
child: Text('Claim No.', style: _headerStyle),
),
// Expanded(
// flex: 1,
// child: Text('Action', style: _headerStyle),
// ),
Expanded(
flex: 2,
child: Text('Status', style: _headerStyle),
),
],
),
),
@ -470,6 +472,13 @@ class claimListState extends ConsumerState<claimList> {
style: _dataBold,
),
),
Expanded(
flex: 2,
child: Text(
item['claim_status_value'] ?? '-', // fallback
style: _dataBold,
),
),
// Expanded(
// flex: 1,
@ -528,6 +537,7 @@ class claimListState extends ConsumerState<claimList> {
item['reg_no'] != null ? _formatDate(item['reg_no']) : '-',
style: _headerStyle,
),
// PopupMenuButton<int>(
// color: Colors.white,
// padding: EdgeInsets.zero,
@ -627,6 +637,27 @@ class claimListState extends ConsumerState<claimList> {
),
],
),
const SizedBox(height: 15),
// Created On + Remarks
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//date and time
Text("Status", style: _cardheaderStyle),
Text(
item['claim_status_value'] ?? '-',
style: _cardBodyStyle,
),
],
),
),
],
),
],
),
);

View File

@ -156,8 +156,9 @@ class policylistState extends ConsumerState<policylist> {
) ||
(item['policy_number'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['status'] ?? '-').toLowerCase().contains(query.toLowerCase());
)
// ||
// (item['status'] ?? '-').toLowerCase().contains(query.toLowerCase());
;
}).toList();
});
@ -378,7 +379,6 @@ class policylistState extends ConsumerState<policylist> {
"payment_mode",
"updated_on",
"policy_number",
"status",
],
),
@ -473,10 +473,6 @@ class policylistState extends ConsumerState<policylist> {
child: Text('Policy Number', style: _headerStyle),
),
Expanded(
flex: 3,
child: Text('Status', style: _headerStyle),
),
// Expanded(
// flex: 1,
// child: Text('Action', style: _headerStyle),
@ -637,50 +633,6 @@ class policylistState extends ConsumerState<policylist> {
maxLines: 3,
),
),
Expanded(
flex: 3,
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.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: _buildPopupMenuActions(
// context,
// item,
// item['id'],
// item['reg_no'],
// ),
// ),
// ),
// ),
// ],
// ),
// ],
// ),
// ),
],
),
);
@ -741,16 +693,16 @@ class policylistState extends ConsumerState<policylist> {
],
),
),
const SizedBox(width: 5),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Status", style: _cardheaderStyle),
Text(item['status'] ?? '-', style: _cardBodyStyle),
],
),
),
// const SizedBox(width: 5),
// Expanded(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text("Status", style: _cardheaderStyle),
// Text(item['status'] ?? '-', style: _cardBodyStyle),
// ],
// ),
// ),
],
),
const SizedBox(height: 15),

View File

@ -268,29 +268,32 @@ class DrawerMenuState extends ConsumerState<DrawerMenu> {
DrawerLabel("User"),
],
Builder(
builder: (itemContext) {
return MouseRegion(
// onEnter: (_) => _showPopup(itemContext),
onEnter: (_) {
final renderBox = itemContext.findRenderObject() as RenderBox;
final offset = renderBox.localToGlobal(Offset.zero);
final size = renderBox.size;
final key = "Reports";
_showPopup(context, offset, size, key);
},
if (roleId != 'staff') ...[
Builder(
builder: (itemContext) {
return MouseRegion(
// onEnter: (_) => _showPopup(itemContext),
onEnter: (_) {
final renderBox =
itemContext.findRenderObject() as RenderBox;
final offset = renderBox.localToGlobal(Offset.zero);
final size = renderBox.size;
final key = "Reports";
_showPopup(context, offset, size, key);
},
child: DrawerContentWrapper(
child: Image.asset(
"assets/drawer/drawerImg2.png",
height: 25,
width: 25,
child: DrawerContentWrapper(
child: Image.asset(
"assets/drawer/drawerImg2.png",
height: 25,
width: 25,
),
),
),
);
},
),
DrawerLabel("Reports"),
);
},
),
DrawerLabel("Reports"),
],
],
),
);