bug fix
This commit is contained in:
parent
12daf54cb7
commit
17caf82191
File diff suppressed because one or more lines are too long
@ -206,7 +206,7 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
||||
Spacer(),
|
||||
|
||||
// Dashboard
|
||||
if (roleId != 'staff') ...[
|
||||
if (roleId != 'staff' && role != 'admin') ...[
|
||||
_buildMenuItem(
|
||||
icon: Icons.dashboard,
|
||||
label: "Dashboard",
|
||||
@ -221,6 +221,7 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
||||
],
|
||||
|
||||
// Enquiry
|
||||
if (role != 'admin') ...[
|
||||
_buildMenuItem(
|
||||
icon: Icons.list_alt_rounded,
|
||||
label: "Enquiry",
|
||||
@ -234,11 +235,12 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// User (Manager Only) - with hover popup
|
||||
if (roleId == 'manager') ...[
|
||||
if (roleId == 'manager' || role == 'admin') ...[
|
||||
_buildHoverMenuItem(
|
||||
icon: Icons.person_add_alt,
|
||||
label: "User",
|
||||
|
||||
@ -180,45 +180,45 @@ class BrokerState extends ConsumerState<Broker> {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseBody = jsonDecode(response.body);
|
||||
final message = responseBody['message'];
|
||||
print("Broker submitted successfully!");
|
||||
print("Response: ${response.body}");
|
||||
|
||||
refresh();
|
||||
isUpdating
|
||||
? ToastHelper.showSuccessToast(
|
||||
context,
|
||||
'Broker Updated Successfully',
|
||||
)
|
||||
: ToastHelper.showSuccessToast(
|
||||
context,
|
||||
'Broker Created Successfully',
|
||||
if(responseBody['status'] == 200){
|
||||
refresh();
|
||||
isUpdating
|
||||
? ToastHelper.showSuccessToast(
|
||||
context,message
|
||||
)
|
||||
: ToastHelper.showSuccessToast(
|
||||
context,message,
|
||||
);
|
||||
} else {
|
||||
|
||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Broker Creation Failed"),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if (response.statusCode == 403) {
|
||||
await apiService.clearLocalStorageAndRedirect();
|
||||
} else {
|
||||
final responseBody = jsonDecode(response.body);
|
||||
dynamic msg = responseBody['data'];
|
||||
|
||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Broker Creation Failed"),
|
||||
content: Text(msg),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print(" Error submitting Staff: $e");
|
||||
|
||||
@ -188,45 +188,46 @@ class PaymentState extends ConsumerState<Payment> {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseBody = jsonDecode(response.body);
|
||||
final message = responseBody['message'];
|
||||
print("Payment submitted successfully!");
|
||||
print("Response: ${response.body}");
|
||||
print(message);
|
||||
|
||||
if(responseBody['status'] == 200){
|
||||
refresh();
|
||||
isUpdating
|
||||
? ToastHelper.showSuccessToast(
|
||||
context,message,
|
||||
)
|
||||
: ToastHelper.showSuccessToast(
|
||||
context,message,
|
||||
);
|
||||
} else {
|
||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Payment Creation Failed"),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
refresh();
|
||||
isUpdating
|
||||
? ToastHelper.showSuccessToast(
|
||||
context,
|
||||
'Payment Updated Successfully',
|
||||
)
|
||||
: ToastHelper.showSuccessToast(
|
||||
context,
|
||||
'Payment Created Successfully',
|
||||
);
|
||||
} else if (response.statusCode == 403) {
|
||||
await apiService.clearLocalStorageAndRedirect();
|
||||
} else {
|
||||
final responseBody = jsonDecode(response.body);
|
||||
dynamic msg = responseBody['data'];
|
||||
|
||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Payment Creation Failed"),
|
||||
content: Text(msg),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print(" Error submitting Staff: $e");
|
||||
|
||||
@ -342,6 +342,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
||||
print('userRole -- $userRole');
|
||||
if (userRole == 'staff') {
|
||||
context.go(AppRoutes.enquiryForStaff);
|
||||
} if (userRole == 'admin') {
|
||||
context.go(AppRoutes.payout);
|
||||
} else {
|
||||
context.go(AppRoutes.dashboard);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
managerId = ref.watch(managerIdProvider);
|
||||
userId = ref.watch(userIdProvider);
|
||||
if (managerId != null) {
|
||||
await getAgentList(managerId);
|
||||
await getAgentList(managerId);
|
||||
}
|
||||
await getBroker();
|
||||
});
|
||||
@ -181,7 +181,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
// -----------------------------
|
||||
setState(() {
|
||||
selectedBrokerID = int.tryParse(invoice['broker_id'].toString());
|
||||
selectedAgentId = int.tryParse(invoice['agent_id'].toString());
|
||||
selectedAgentId = int.tryParse(invoice['agent_id'].toString());
|
||||
|
||||
invoiceNoController.text = invoice['invoice_no'];
|
||||
invoiceDate = DateTime.parse(invoice['invoice_date']);
|
||||
@ -217,10 +217,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
setState(() {
|
||||
filteredPolicies = filteredPolicies.map((p) {
|
||||
final policyId = int.parse(p['policy_id']);
|
||||
return {
|
||||
...p,
|
||||
'is_selected': selectedPolicies.contains(policyId),
|
||||
};
|
||||
return {...p, 'is_selected': selectedPolicies.contains(policyId)};
|
||||
}).toList();
|
||||
});
|
||||
}
|
||||
@ -228,8 +225,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
setState(() => isLoading = false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
String formatDate(String date) {
|
||||
final d = DateTime.parse(date);
|
||||
return DateFormat('dd-MM-yyyy').format(d);
|
||||
@ -319,7 +314,9 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
// Load policies (simulate API)
|
||||
Future<void> loadPolicies() async {
|
||||
try {
|
||||
String formattedTillDate = DateFormat( 'yyyy-MM-dd').format(policyTillDate!);
|
||||
String formattedTillDate = DateFormat(
|
||||
'yyyy-MM-dd',
|
||||
).format(policyTillDate!);
|
||||
final jsondata = {
|
||||
"broker_id": selectedBrokerID,
|
||||
"agent_id": selectedAgentId,
|
||||
@ -370,76 +367,81 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
}
|
||||
|
||||
// Save invoice (simulation)
|
||||
Future<void> saveInvoice() async{
|
||||
Future<void> saveInvoice() async {
|
||||
try {
|
||||
if (selectedAgentId == null) {
|
||||
ToastHelper.showWarningToast(context, "Please select an agent");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (selectedAgentId == null) {
|
||||
ToastHelper.showWarningToast(context,"Please select an agent");
|
||||
return;
|
||||
}
|
||||
if (selectedPolicies.isEmpty) {
|
||||
ToastHelper.showWarningToast(
|
||||
context,
|
||||
"Please select at least 1 policy",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedPolicies.isEmpty) {
|
||||
ToastHelper.showWarningToast(context,"Please select at least 1 policy");
|
||||
return;
|
||||
}
|
||||
// Format dates for API
|
||||
final String formattedInvoiceDate = DateFormat(
|
||||
'yyyy-MM-dd',
|
||||
).format(invoiceDate);
|
||||
final String formattedTillDate = DateFormat(
|
||||
'yyyy-MM-dd',
|
||||
).format(policyTillDate!);
|
||||
|
||||
// Format dates for API
|
||||
final String formattedInvoiceDate = DateFormat('yyyy-MM-dd').format(invoiceDate);
|
||||
final String formattedTillDate = DateFormat('yyyy-MM-dd').format(policyTillDate!);
|
||||
// Total Commission
|
||||
final double totalCommission = filteredPolicies
|
||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||
.fold(0.0, (sum, p) => sum + double.parse(p["commission_amount"]));
|
||||
|
||||
// Total Commission
|
||||
final double totalCommission = filteredPolicies
|
||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||
.fold(0.0, (sum, p) => sum + double.parse(p["commission_amount"]));
|
||||
// Build items array
|
||||
final List<Map<String, dynamic>> items = filteredPolicies
|
||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||
.map(
|
||||
(p) => {
|
||||
"policy_id": int.parse(p["policy_id"]),
|
||||
"policy_no": p["policy_no"],
|
||||
"commission_amount": double.parse(p["commission_amount"]),
|
||||
},
|
||||
)
|
||||
.toList();
|
||||
|
||||
// Build items array
|
||||
final List<Map<String, dynamic>> items = filteredPolicies
|
||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||
.map((p) => {
|
||||
"policy_id": int.parse(p["policy_id"]),
|
||||
"policy_no": p["policy_no"],
|
||||
"commission_amount": double.parse(p["commission_amount"]),
|
||||
}).toList();
|
||||
final jsondata = {
|
||||
"invoice_no": invoiceNoController.text,
|
||||
"invoice_amount": totalCommission,
|
||||
"agent_id": selectedAgentId,
|
||||
"broker_id": selectedBrokerID,
|
||||
"invoice_date": formattedInvoiceDate,
|
||||
"till_date": formattedTillDate,
|
||||
"payout_status": 0,
|
||||
"created_by": userId,
|
||||
"updated_by": userId,
|
||||
"items": items,
|
||||
};
|
||||
print('Commissions $jsondata');
|
||||
final response = await apiService.getCreateOrUpdate(jsondata);
|
||||
|
||||
final jsondata = {
|
||||
"invoice_no": invoiceNoController.text,
|
||||
"invoice_amount": totalCommission,
|
||||
"agent_id": selectedAgentId,
|
||||
"broker_id": selectedBrokerID,
|
||||
"invoice_date": formattedInvoiceDate,
|
||||
"till_date": formattedTillDate,
|
||||
"payout_status": 0,
|
||||
"created_by": userId,
|
||||
"updated_by": userId,
|
||||
"items": items,
|
||||
};
|
||||
print('Commissions $jsondata');
|
||||
final response = await apiService.getCreateOrUpdate(jsondata);
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
|
||||
setState(() {
|
||||
print('API Data response - $response');
|
||||
selectedPolicies.clear();
|
||||
invoiceNoController.clear();
|
||||
invoiceDate = DateTime.now();
|
||||
policyTillDate = DateTime.now();
|
||||
if (response['status'] == 'success') {
|
||||
setState(() {
|
||||
print('API Data response - $response');
|
||||
selectedPolicies.clear();
|
||||
invoiceNoController.clear();
|
||||
invoiceDate = DateTime.now();
|
||||
policyTillDate = DateTime.now();
|
||||
filteredPolicies = [];
|
||||
});
|
||||
context.go(AppRoutes.invoiceList);
|
||||
} else {
|
||||
filteredPolicies = [];
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
} finally {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
context.go(AppRoutes.invoiceList);
|
||||
} else {
|
||||
filteredPolicies = [];
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
} finally {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// showDialog(
|
||||
// context: context,
|
||||
@ -684,6 +686,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
policyTillDate =
|
||||
DateTime.now();
|
||||
filteredPolicies = [];
|
||||
selectedPolicies.clear();
|
||||
});
|
||||
},
|
||||
child: const Icon(
|
||||
@ -886,20 +889,31 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
if (filteredPolicies.isNotEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 16,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: filteredPolicies.isNotEmpty &&
|
||||
value:
|
||||
filteredPolicies.isNotEmpty &&
|
||||
filteredPolicies.every(
|
||||
(p) => selectedPolicies.contains(int.parse(p["policy_id"])),
|
||||
(p) => selectedPolicies.contains(
|
||||
int.parse(p["policy_id"]),
|
||||
),
|
||||
),
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
if (v == true) {
|
||||
selectedPolicies = filteredPolicies
|
||||
.map((p) => int.parse(p["policy_id"]))
|
||||
.toSet();
|
||||
selectedPolicies =
|
||||
filteredPolicies
|
||||
.map(
|
||||
(p) => int.parse(
|
||||
p["policy_id"],
|
||||
),
|
||||
)
|
||||
.toSet();
|
||||
} else {
|
||||
selectedPolicies.clear();
|
||||
}
|
||||
@ -923,8 +937,32 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
)
|
||||
else
|
||||
...filteredPolicies.map((p) {
|
||||
final int id = int.parse(p["policy_id"]);
|
||||
final bool isSelected = selectedPolicies.contains(id);
|
||||
// final int id = int.parse(p["policy_id"]);
|
||||
// final bool isSelected = selectedPolicies.contains(id);
|
||||
|
||||
// ---- SAFE ID PARSING ----
|
||||
final String policyIdStr =
|
||||
p["policy_id"]?.toString() ?? "0";
|
||||
final int id = int.tryParse(policyIdStr) ?? 0;
|
||||
|
||||
final bool isSelected = selectedPolicies
|
||||
.contains(id);
|
||||
|
||||
// ---- SAFE FIELDS ----
|
||||
final String policyNo =
|
||||
p["policy_no"]?.toString() ?? "-";
|
||||
final String customer =
|
||||
p["customer_name"]?.toString() ?? "-";
|
||||
|
||||
final String premiumStr =
|
||||
p["premium_amount"]?.toString() ?? "0";
|
||||
final double premium =
|
||||
double.tryParse(premiumStr) ?? 0;
|
||||
|
||||
final String commissionStr =
|
||||
p["commission_amount"]?.toString() ?? "0";
|
||||
final double commission =
|
||||
double.tryParse(commissionStr) ?? 0;
|
||||
|
||||
return ListTile(
|
||||
tileColor: isSelected
|
||||
@ -943,15 +981,15 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
},
|
||||
),
|
||||
|
||||
title: Text(p["policy_no"]),
|
||||
title: Text(policyNo),
|
||||
|
||||
subtitle: Text(
|
||||
"Customer: ${p["customer_name"]} | "
|
||||
"Premium: ₹${p["premium_amount"]}",
|
||||
"Customer: ${customer} | "
|
||||
"Premium: ₹${premium}",
|
||||
),
|
||||
|
||||
trailing: Text(
|
||||
"₹${p["commission_amount"]}",
|
||||
"₹${commission}",
|
||||
style: const TextStyle(
|
||||
color: Colors.teal,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -998,7 +1036,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Selected Count + Total
|
||||
// ---------------- SELECTED COUNT ----------------
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -1016,6 +1054,8 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// ---------------- TOTAL COMMISSION ----------------
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -1024,10 +1064,10 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
/// NULL-SAFE TOTAL COMMISSION CALCULATION
|
||||
Text(
|
||||
"₹${filteredPolicies
|
||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||
.fold(0.0, (s, p) => s + double.parse(p["commission_amount"]))}",
|
||||
"₹${_calculateTotalCommission()}",
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -1037,6 +1077,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
],
|
||||
),
|
||||
|
||||
// ---------------- BUTTONS ----------------
|
||||
Row(
|
||||
children: [
|
||||
TextButton(
|
||||
@ -1064,6 +1105,27 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
double _calculateTotalCommission() {
|
||||
double total = 0.0;
|
||||
|
||||
for (var p in filteredPolicies) {
|
||||
// Safe policy_id parsing
|
||||
final String idStr = p["policy_id"]?.toString() ?? "0";
|
||||
final int id = int.tryParse(idStr) ?? 0;
|
||||
|
||||
if (!selectedPolicies.contains(id)) continue;
|
||||
|
||||
// Safe commission amount
|
||||
final String commStr = p["commission_amount"]?.toString() ?? "0";
|
||||
final double comm = double.tryParse(commStr) ?? 0;
|
||||
|
||||
total += comm;
|
||||
}
|
||||
|
||||
// Remove decimal points (.00)
|
||||
return total.roundToDouble();
|
||||
}
|
||||
|
||||
InputDecoration commonInputDecoration({required String hint}) {
|
||||
return InputDecoration(
|
||||
hintText: hint,
|
||||
|
||||
@ -2509,6 +2509,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
RaiseEnqForm(
|
||||
key: raiseEnqKey,
|
||||
onSubmit: (dataSet) async {
|
||||
print('Check checking dataSet $dataSet');
|
||||
try {
|
||||
await createUserData(dataSet); // <-- API call here
|
||||
print("Enquiry saved successfully");
|
||||
|
||||
@ -92,6 +92,8 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
|
||||
bool isLoading = false;
|
||||
|
||||
Map<String, dynamic> dataDetails() {
|
||||
print('checking agent id $selectedAgent');
|
||||
|
||||
final data = {
|
||||
"agent_id": ((roleId == 'handler') || (roleId == 'manager'))
|
||||
? selectedAgent
|
||||
@ -931,6 +933,8 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
|
||||
|
||||
final dataSet = dataDetails();
|
||||
|
||||
print('checking dataSet $dataSet');
|
||||
|
||||
widget.onSubmit(dataSet);
|
||||
resetFields();
|
||||
},
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -40,6 +41,9 @@ class policylistState extends ConsumerState<policylist> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
Map<String, TextEditingController> controllers = {};
|
||||
List<String> tabHeader = ['startDate', 'endDate'];
|
||||
dynamic choosedPolcyId;
|
||||
PlatformFile? docPDFUploadedFile;
|
||||
String? selectedPDFFileNames;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -693,10 +697,7 @@ class policylistState extends ConsumerState<policylist> {
|
||||
child: Text('Policy Number', style: _headerStyle),
|
||||
),
|
||||
|
||||
// Expanded(
|
||||
// flex: 1,
|
||||
// child: Text('Action', style: _headerStyle),
|
||||
// ),
|
||||
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -780,6 +781,12 @@ class policylistState extends ConsumerState<policylist> {
|
||||
}
|
||||
|
||||
Widget _buildDataRow(Map<String, dynamic> item, sno) {
|
||||
print('ITEMS $item');
|
||||
final String policyId = item['policy_id']?.toString() ?? '';
|
||||
final String? pdfPath = item["policy_pdf_file_name"];
|
||||
String? fileName = pdfPath != null && pdfPath.isNotEmpty
|
||||
? pdfPath.split('/').last
|
||||
: null;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
// margin: const EdgeInsets.only(top: 10),
|
||||
@ -802,13 +809,9 @@ class policylistState extends ConsumerState<policylist> {
|
||||
maxLines: 3,
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
_formatDate(item['agent_name']) ?? '-',
|
||||
style: _dataBold,
|
||||
),
|
||||
child: Text(item['agent_name'] ?? '-', style: _dataBold),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
@ -863,6 +866,45 @@ class policylistState extends ConsumerState<policylist> {
|
||||
maxLines: 3,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Tooltip(
|
||||
message: 'Download',
|
||||
// color: Colors.white,
|
||||
child:
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () => apiService.downloadFile(
|
||||
apiUrl: 'api/policy/downloadPolicyFile?policy_id=$policyId&file_type=policy_pdf',
|
||||
apiId: policyId,
|
||||
localFile: null,
|
||||
fileName: fileName,
|
||||
),
|
||||
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Color(0xFF425B5B),
|
||||
// color: Colors.green.shade300,
|
||||
),
|
||||
child: Row(
|
||||
children: const [
|
||||
Icon(Icons.download, size: 13, color: Colors.white),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user