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(),
|
Spacer(),
|
||||||
|
|
||||||
// Dashboard
|
// Dashboard
|
||||||
if (roleId != 'staff') ...[
|
if (roleId != 'staff' && role != 'admin') ...[
|
||||||
_buildMenuItem(
|
_buildMenuItem(
|
||||||
icon: Icons.dashboard,
|
icon: Icons.dashboard,
|
||||||
label: "Dashboard",
|
label: "Dashboard",
|
||||||
@ -221,6 +221,7 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Enquiry
|
// Enquiry
|
||||||
|
if (role != 'admin') ...[
|
||||||
_buildMenuItem(
|
_buildMenuItem(
|
||||||
icon: Icons.list_alt_rounded,
|
icon: Icons.list_alt_rounded,
|
||||||
label: "Enquiry",
|
label: "Enquiry",
|
||||||
@ -234,11 +235,12 @@ class _AppHeaderState extends ConsumerState<AppHeader> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
|
|
||||||
// User (Manager Only) - with hover popup
|
// User (Manager Only) - with hover popup
|
||||||
if (roleId == 'manager') ...[
|
if (roleId == 'manager' || role == 'admin') ...[
|
||||||
_buildHoverMenuItem(
|
_buildHoverMenuItem(
|
||||||
icon: Icons.person_add_alt,
|
icon: Icons.person_add_alt,
|
||||||
label: "User",
|
label: "User",
|
||||||
|
|||||||
@ -180,24 +180,21 @@ class BrokerState extends ConsumerState<Broker> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
final responseBody = jsonDecode(response.body);
|
||||||
|
final message = responseBody['message'];
|
||||||
print("Broker submitted successfully!");
|
print("Broker submitted successfully!");
|
||||||
print("Response: ${response.body}");
|
print("Response: ${response.body}");
|
||||||
|
|
||||||
|
if(responseBody['status'] == 200){
|
||||||
refresh();
|
refresh();
|
||||||
isUpdating
|
isUpdating
|
||||||
? ToastHelper.showSuccessToast(
|
? ToastHelper.showSuccessToast(
|
||||||
context,
|
context,message
|
||||||
'Broker Updated Successfully',
|
|
||||||
)
|
)
|
||||||
: ToastHelper.showSuccessToast(
|
: ToastHelper.showSuccessToast(
|
||||||
context,
|
context,message,
|
||||||
'Broker Created Successfully',
|
|
||||||
);
|
);
|
||||||
} else if (response.statusCode == 403) {
|
|
||||||
await apiService.clearLocalStorageAndRedirect();
|
|
||||||
} else {
|
} else {
|
||||||
final responseBody = jsonDecode(response.body);
|
|
||||||
dynamic msg = responseBody['data'];
|
|
||||||
|
|
||||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||||
print("Error: ${response.body}");
|
print("Error: ${response.body}");
|
||||||
@ -207,7 +204,7 @@ class BrokerState extends ConsumerState<Broker> {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text("Broker Creation Failed"),
|
title: Text("Broker Creation Failed"),
|
||||||
content: Text(msg),
|
content: Text(message),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
child: Text("OK"),
|
child: Text("OK"),
|
||||||
@ -220,6 +217,9 @@ class BrokerState extends ConsumerState<Broker> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await apiService.clearLocalStorageAndRedirect();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(" Error submitting Staff: $e");
|
print(" Error submitting Staff: $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,25 +188,22 @@ class PaymentState extends ConsumerState<Payment> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
final responseBody = jsonDecode(response.body);
|
||||||
|
final message = responseBody['message'];
|
||||||
print("Payment submitted successfully!");
|
print("Payment submitted successfully!");
|
||||||
print("Response: ${response.body}");
|
print("Response: ${response.body}");
|
||||||
|
print(message);
|
||||||
|
|
||||||
|
if(responseBody['status'] == 200){
|
||||||
refresh();
|
refresh();
|
||||||
isUpdating
|
isUpdating
|
||||||
? ToastHelper.showSuccessToast(
|
? ToastHelper.showSuccessToast(
|
||||||
context,
|
context,message,
|
||||||
'Payment Updated Successfully',
|
|
||||||
)
|
)
|
||||||
: ToastHelper.showSuccessToast(
|
: ToastHelper.showSuccessToast(
|
||||||
context,
|
context,message,
|
||||||
'Payment Created Successfully',
|
|
||||||
);
|
);
|
||||||
} else if (response.statusCode == 403) {
|
|
||||||
await apiService.clearLocalStorageAndRedirect();
|
|
||||||
} else {
|
} else {
|
||||||
final responseBody = jsonDecode(response.body);
|
|
||||||
dynamic msg = responseBody['data'];
|
|
||||||
|
|
||||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||||
print("Error: ${response.body}");
|
print("Error: ${response.body}");
|
||||||
|
|
||||||
@ -215,7 +212,7 @@ class PaymentState extends ConsumerState<Payment> {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text("Payment Creation Failed"),
|
title: Text("Payment Creation Failed"),
|
||||||
content: Text(msg),
|
content: Text(message),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
child: Text("OK"),
|
child: Text("OK"),
|
||||||
@ -228,6 +225,10 @@ class PaymentState extends ConsumerState<Payment> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (response.statusCode == 403) {
|
||||||
|
await apiService.clearLocalStorageAndRedirect();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(" Error submitting Staff: $e");
|
print(" Error submitting Staff: $e");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -342,6 +342,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
|
|||||||
print('userRole -- $userRole');
|
print('userRole -- $userRole');
|
||||||
if (userRole == 'staff') {
|
if (userRole == 'staff') {
|
||||||
context.go(AppRoutes.enquiryForStaff);
|
context.go(AppRoutes.enquiryForStaff);
|
||||||
|
} if (userRole == 'admin') {
|
||||||
|
context.go(AppRoutes.payout);
|
||||||
} else {
|
} else {
|
||||||
context.go(AppRoutes.dashboard);
|
context.go(AppRoutes.dashboard);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -217,10 +217,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
filteredPolicies = filteredPolicies.map((p) {
|
filteredPolicies = filteredPolicies.map((p) {
|
||||||
final policyId = int.parse(p['policy_id']);
|
final policyId = int.parse(p['policy_id']);
|
||||||
return {
|
return {...p, 'is_selected': selectedPolicies.contains(policyId)};
|
||||||
...p,
|
|
||||||
'is_selected': selectedPolicies.contains(policyId),
|
|
||||||
};
|
|
||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -228,8 +225,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String formatDate(String date) {
|
String formatDate(String date) {
|
||||||
final d = DateTime.parse(date);
|
final d = DateTime.parse(date);
|
||||||
return DateFormat('dd-MM-yyyy').format(d);
|
return DateFormat('dd-MM-yyyy').format(d);
|
||||||
@ -319,7 +314,9 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
// Load policies (simulate API)
|
// Load policies (simulate API)
|
||||||
Future<void> loadPolicies() async {
|
Future<void> loadPolicies() async {
|
||||||
try {
|
try {
|
||||||
String formattedTillDate = DateFormat( 'yyyy-MM-dd').format(policyTillDate!);
|
String formattedTillDate = DateFormat(
|
||||||
|
'yyyy-MM-dd',
|
||||||
|
).format(policyTillDate!);
|
||||||
final jsondata = {
|
final jsondata = {
|
||||||
"broker_id": selectedBrokerID,
|
"broker_id": selectedBrokerID,
|
||||||
"agent_id": selectedAgentId,
|
"agent_id": selectedAgentId,
|
||||||
@ -371,7 +368,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
|
|
||||||
// Save invoice (simulation)
|
// Save invoice (simulation)
|
||||||
Future<void> saveInvoice() async {
|
Future<void> saveInvoice() async {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (selectedAgentId == null) {
|
if (selectedAgentId == null) {
|
||||||
ToastHelper.showWarningToast(context, "Please select an agent");
|
ToastHelper.showWarningToast(context, "Please select an agent");
|
||||||
@ -379,13 +375,20 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedPolicies.isEmpty) {
|
if (selectedPolicies.isEmpty) {
|
||||||
ToastHelper.showWarningToast(context,"Please select at least 1 policy");
|
ToastHelper.showWarningToast(
|
||||||
|
context,
|
||||||
|
"Please select at least 1 policy",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format dates for API
|
// Format dates for API
|
||||||
final String formattedInvoiceDate = DateFormat('yyyy-MM-dd').format(invoiceDate);
|
final String formattedInvoiceDate = DateFormat(
|
||||||
final String formattedTillDate = DateFormat('yyyy-MM-dd').format(policyTillDate!);
|
'yyyy-MM-dd',
|
||||||
|
).format(invoiceDate);
|
||||||
|
final String formattedTillDate = DateFormat(
|
||||||
|
'yyyy-MM-dd',
|
||||||
|
).format(policyTillDate!);
|
||||||
|
|
||||||
// Total Commission
|
// Total Commission
|
||||||
final double totalCommission = filteredPolicies
|
final double totalCommission = filteredPolicies
|
||||||
@ -395,11 +398,14 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
// Build items array
|
// Build items array
|
||||||
final List<Map<String, dynamic>> items = filteredPolicies
|
final List<Map<String, dynamic>> items = filteredPolicies
|
||||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
||||||
.map((p) => {
|
.map(
|
||||||
|
(p) => {
|
||||||
"policy_id": int.parse(p["policy_id"]),
|
"policy_id": int.parse(p["policy_id"]),
|
||||||
"policy_no": p["policy_no"],
|
"policy_no": p["policy_no"],
|
||||||
"commission_amount": double.parse(p["commission_amount"]),
|
"commission_amount": double.parse(p["commission_amount"]),
|
||||||
}).toList();
|
},
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
final jsondata = {
|
final jsondata = {
|
||||||
"invoice_no": invoiceNoController.text,
|
"invoice_no": invoiceNoController.text,
|
||||||
@ -417,7 +423,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
final response = await apiService.getCreateOrUpdate(jsondata);
|
final response = await apiService.getCreateOrUpdate(jsondata);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
print('API Data response - $response');
|
print('API Data response - $response');
|
||||||
selectedPolicies.clear();
|
selectedPolicies.clear();
|
||||||
@ -425,7 +430,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
invoiceDate = DateTime.now();
|
invoiceDate = DateTime.now();
|
||||||
policyTillDate = DateTime.now();
|
policyTillDate = DateTime.now();
|
||||||
filteredPolicies = [];
|
filteredPolicies = [];
|
||||||
|
|
||||||
});
|
});
|
||||||
context.go(AppRoutes.invoiceList);
|
context.go(AppRoutes.invoiceList);
|
||||||
} else {
|
} else {
|
||||||
@ -439,8 +443,6 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// showDialog(
|
// showDialog(
|
||||||
// context: context,
|
// context: context,
|
||||||
// builder: (_) => AlertDialog(
|
// builder: (_) => AlertDialog(
|
||||||
@ -684,6 +686,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
policyTillDate =
|
policyTillDate =
|
||||||
DateTime.now();
|
DateTime.now();
|
||||||
filteredPolicies = [];
|
filteredPolicies = [];
|
||||||
|
selectedPolicies.clear();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
@ -886,19 +889,30 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
if (filteredPolicies.isNotEmpty)
|
if (filteredPolicies.isNotEmpty)
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: filteredPolicies.isNotEmpty &&
|
value:
|
||||||
|
filteredPolicies.isNotEmpty &&
|
||||||
filteredPolicies.every(
|
filteredPolicies.every(
|
||||||
(p) => selectedPolicies.contains(int.parse(p["policy_id"])),
|
(p) => selectedPolicies.contains(
|
||||||
|
int.parse(p["policy_id"]),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (v == true) {
|
if (v == true) {
|
||||||
selectedPolicies = filteredPolicies
|
selectedPolicies =
|
||||||
.map((p) => int.parse(p["policy_id"]))
|
filteredPolicies
|
||||||
|
.map(
|
||||||
|
(p) => int.parse(
|
||||||
|
p["policy_id"],
|
||||||
|
),
|
||||||
|
)
|
||||||
.toSet();
|
.toSet();
|
||||||
} else {
|
} else {
|
||||||
selectedPolicies.clear();
|
selectedPolicies.clear();
|
||||||
@ -923,8 +937,32 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
...filteredPolicies.map((p) {
|
...filteredPolicies.map((p) {
|
||||||
final int id = int.parse(p["policy_id"]);
|
// final int id = int.parse(p["policy_id"]);
|
||||||
final bool isSelected = selectedPolicies.contains(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(
|
return ListTile(
|
||||||
tileColor: isSelected
|
tileColor: isSelected
|
||||||
@ -943,15 +981,15 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
title: Text(p["policy_no"]),
|
title: Text(policyNo),
|
||||||
|
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
"Customer: ${p["customer_name"]} | "
|
"Customer: ${customer} | "
|
||||||
"Premium: ₹${p["premium_amount"]}",
|
"Premium: ₹${premium}",
|
||||||
),
|
),
|
||||||
|
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
"₹${p["commission_amount"]}",
|
"₹${commission}",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.teal,
|
color: Colors.teal,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -998,7 +1036,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
// Selected Count + Total
|
// ---------------- SELECTED COUNT ----------------
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -1016,6 +1054,8 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ---------------- TOTAL COMMISSION ----------------
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -1024,10 +1064,10 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
|
|
||||||
|
/// NULL-SAFE TOTAL COMMISSION CALCULATION
|
||||||
Text(
|
Text(
|
||||||
"₹${filteredPolicies
|
"₹${_calculateTotalCommission()}",
|
||||||
.where((p) => selectedPolicies.contains(int.parse(p["policy_id"])))
|
|
||||||
.fold(0.0, (s, p) => s + double.parse(p["commission_amount"]))}",
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -1037,6 +1077,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ---------------- BUTTONS ----------------
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
TextButton(
|
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}) {
|
InputDecoration commonInputDecoration({required String hint}) {
|
||||||
return InputDecoration(
|
return InputDecoration(
|
||||||
hintText: hint,
|
hintText: hint,
|
||||||
|
|||||||
@ -2509,6 +2509,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
|||||||
RaiseEnqForm(
|
RaiseEnqForm(
|
||||||
key: raiseEnqKey,
|
key: raiseEnqKey,
|
||||||
onSubmit: (dataSet) async {
|
onSubmit: (dataSet) async {
|
||||||
|
print('Check checking dataSet $dataSet');
|
||||||
try {
|
try {
|
||||||
await createUserData(dataSet); // <-- API call here
|
await createUserData(dataSet); // <-- API call here
|
||||||
print("Enquiry saved successfully");
|
print("Enquiry saved successfully");
|
||||||
|
|||||||
@ -92,6 +92,8 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
|
|||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
Map<String, dynamic> dataDetails() {
|
Map<String, dynamic> dataDetails() {
|
||||||
|
print('checking agent id $selectedAgent');
|
||||||
|
|
||||||
final data = {
|
final data = {
|
||||||
"agent_id": ((roleId == 'handler') || (roleId == 'manager'))
|
"agent_id": ((roleId == 'handler') || (roleId == 'manager'))
|
||||||
? selectedAgent
|
? selectedAgent
|
||||||
@ -931,6 +933,8 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
|
|||||||
|
|
||||||
final dataSet = dataDetails();
|
final dataSet = dataDetails();
|
||||||
|
|
||||||
|
print('checking dataSet $dataSet');
|
||||||
|
|
||||||
widget.onSubmit(dataSet);
|
widget.onSubmit(dataSet);
|
||||||
resetFields();
|
resetFields();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
@ -40,6 +41,9 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
Map<String, TextEditingController> controllers = {};
|
Map<String, TextEditingController> controllers = {};
|
||||||
List<String> tabHeader = ['startDate', 'endDate'];
|
List<String> tabHeader = ['startDate', 'endDate'];
|
||||||
|
dynamic choosedPolcyId;
|
||||||
|
PlatformFile? docPDFUploadedFile;
|
||||||
|
String? selectedPDFFileNames;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -693,10 +697,7 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
child: Text('Policy Number', style: _headerStyle),
|
child: Text('Policy Number', style: _headerStyle),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Expanded(
|
Expanded(flex: 1, child: Text('Action', style: _headerStyle)),
|
||||||
// flex: 1,
|
|
||||||
// child: Text('Action', style: _headerStyle),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -780,6 +781,12 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDataRow(Map<String, dynamic> item, sno) {
|
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(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||||
// margin: const EdgeInsets.only(top: 10),
|
// margin: const EdgeInsets.only(top: 10),
|
||||||
@ -802,13 +809,9 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(item['agent_name'] ?? '-', style: _dataBold),
|
||||||
_formatDate(item['agent_name']) ?? '-',
|
|
||||||
style: _dataBold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
@ -863,6 +866,45 @@ class policylistState extends ConsumerState<policylist> {
|
|||||||
maxLines: 3,
|
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