policy_pdf

This commit is contained in:
venbaittech 2025-11-21 16:13:20 +05:30
parent ef21a4883c
commit 3233093da9
3 changed files with 173 additions and 161 deletions

View File

@ -452,8 +452,9 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
print("Response: ${response.body}");
widget.onSubmit('Success');
// ToastHelper.showErrorToast(context, 'Proposal Created');
reset();
// Navigator.of(context).pop();
Navigator.of(context).pop();
} else if (response.statusCode == 403) {
await apiService.clearLocalStorageAndRedirect();
} else {
@ -967,7 +968,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
decoratorProps: DropDownDecoratorProps(
decoration:
AppInputDecorations.dropdownDecoration(
label: "Select Staff Member",
label: "Select Broker",
).copyWith(
filled: true,
fillColor:

View File

@ -377,10 +377,11 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
);
quotationAcceptedData = acceptedItem;
print('AcceptedData - $quotationAcceptedData');
print('AcceptedData YYY - $quotationAcceptedData');
if (quotationAcceptedData != null) {
if (!mounted) return;
print('AcceptedData YYY2');
setState(() {
controllers["insurer"]?.text = quotationAcceptedData?['insurer_name'];
acceptedQuotationId = quotationAcceptedData?['id']?.toString() ?? '';
@ -391,6 +392,10 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
quotationAcceptedData?['premium_amount']?.toString() ?? '';
controllers["planType"]?.text =
quotationAcceptedData?['insurance_plan_type']?.toString() ?? '';
controllers["policyPaymentMode"]?.text =
quotationAcceptedData?['payment_mode_value']?.toString() ?? '';
selectedBroker = quotationAcceptedData?['broker_id'] ?? '';
selectedBrokerName = quotationAcceptedData?['broker_name'] ?? '';
});
}
} catch (e) {
@ -485,6 +490,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
policyData['policy_number']?.toString() ?? '';
controllers["policyPaymentMode"]?.text =
policyData['payment_mode']?.toString() ?? '';
controllers["issueDate"]?.text =
_formatDate(policyData['issued_date']!.toString()) ?? '';
controllers["startDate"]?.text =
@ -531,15 +537,16 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
final bool isUpdating = choosedPolcyId != null;
if (!isUpdating && selectedBrokerName == 'Nhance') {
// if (!isUpdating && enqBrokerName == 'Nhance') {
ToastHelper.showErrorToast(context, "Policy PDF is required");
return;
}
// if (!isUpdating && selectedBrokerName == 'Nhance') {
// // if (!isUpdating && enqBrokerName == 'Nhance') {
// ToastHelper.showErrorToast(context, "Policy PDF is required");
// return;
// }
// (enqBrokerName != 'Nhance')
// File validations
if ((selectedBrokerName != 'Nhance') &&
(docPDFUploadedFile == null || docPDFUploadedFile?.bytes == null) &&
if (
// (selectedBrokerName != 'Nhance') &&
(docPDFUploadedFile == null || docPDFUploadedFile?.bytes == null) &&
(docUploadedPDFFileUrlFromApi == null ||
docUploadedPDFFileUrlFromApi!.isEmpty)) {
ToastHelper.showErrorToast(context, "Policy PDF is required");
@ -1067,10 +1074,10 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Paymentmode(context),
SizedBox(width: 20),
buildBroker(context),
if (selectedBrokerName != null) ...[
Paymentmode(context),
SizedBox(width: 20),
buildBroker(context),
SizedBox(width: 20),
buildUploadPolicyPdf(context),
@ -1412,149 +1419,150 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
return Row(
children: [
Text('Broker *', style: _textStyle),
SizedBox(width: 15),
SizedBox(
width: MediaQuery.of(context).size.width * 0.095,
child: Text(
'$selectedBrokerName',
style: GoogleFonts.inter(fontSize: 12),
),
),
SizedBox(width: 10),
// SizedBox(
// height: 30,
// width: MediaQuery.of(context).size.width * 0.1,
// child: DropdownSearch<Map<String, dynamic>>(
// key: dropDownKeyBroker,
// selectedItem: selectedBrokers.isNotEmpty ? selectedBrokers : null,
// items: (filter, infiniteScrollProps) {
// return filteredBrokerData;
// },
//
// itemAsString: (val) => val['name'].toString(), // what to show
// compareFn: (item, selectedItem) =>
// item['id'] == selectedItem['id'], // compare by id
// validator: (val) {
// if (val == null) {
// return "Required"; // error message
// }
// return null;
// },
// suffixProps: DropdownSuffixProps(
// // make sure the dropdown button is visible
// dropdownButtonProps: DropdownButtonProps(
// isVisible: true,
// padding: EdgeInsets.zero, // remove default padding
// constraints: const BoxConstraints(
// // shrink icon tap area
// minWidth: 12,
// minHeight: 12,
// ),
// iconSize: 15, // smaller icon
// // icon: const Icon(Icons.arrow_drop_down),
// ),
// ),
// dropdownBuilder: (context, selectedItem) => Align(
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem != null ? selectedItem['name'].toString() : "",
// style: GoogleFonts.poppins(fontSize: 11, color: Colors.black),
// overflow: TextOverflow.ellipsis,
// maxLines: 1,
// softWrap: false,
// ),
// ),
// decoratorProps: DropDownDecoratorProps(
// decoration:
// AppInputDecorations.dropdownDecoration(
// label: "Select Broker",
// ).copyWith(
// filled: true,
// fillColor:
// Colors.white, // 👈 makes the dropdown input white
// isDense: true,
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5),
// borderSide: const BorderSide(
// color: Colors.black,
// width: 0.1,
// ),
// ),
// enabledBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5),
// borderSide: const BorderSide(
// color: Colors.black,
// width: 0.1,
// ),
// ),
// contentPadding: EdgeInsets.symmetric(
// horizontal: 8,
// vertical: 6,
// ),
// ),
// ),
//
// popupProps: PopupProps.menu(
// fit: FlexFit.loose,
// constraints: BoxConstraints(maxHeight: 250),
// menuProps: MenuProps(
// backgroundColor:
// Colors.white, // 👈 sets dropdown background to white
// ),
// showSearchBox: true,
// searchFieldProps: TextFieldProps(
// decoration: InputDecoration(
// filled: true,
// fillColor: Colors.white,
// hintText: "Search Broker...",
// hintStyle: GoogleFonts.inter(
// fontSize: 12,
// color: Colors.black,
// ),
// enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: Colors.white,
// ), // 👈 Normal border
// ),
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: Colors.white,
// width: 1.5,
// ), // 👈 Focused border
// ),
// ),
// ),
//
// itemBuilder: (context, item, isDisabled, isSelected) {
// return Container(
// // color: isSelected ? Colors.blue.withOpacity(0.1) : null,
// padding: const EdgeInsets.symmetric(
// horizontal: 8,
// vertical: 3,
// ),
// child: Text(
// item['name'].toString(),
// style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
// ),
// );
// },
// // constraints: BoxConstraints(),
// ),
//
// onChanged: (val) {
// if (val != null) {
// print("Selected Broker : ${val['name']}");
// print("Id: ${val['id']}");
// selectedBroker = val['id'];
// setState(() {
// selectedBrokerName = val['name'];
// print('selectedBrokerName - $selectedBrokerName');
// });
// // controllers['agentId']?.text = val['agent_code'];
// // agentId = agent['id'];
// }
// },
// width: MediaQuery.of(context).size.width * 0.095,
// child: Text(
// '$selectedBrokerName',
// style: GoogleFonts.inter(fontSize: 12),
// ),
// ),
SizedBox(
height: 30,
width: MediaQuery.of(context).size.width * 0.1,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyBroker,
selectedItem: selectedBrokers.isNotEmpty ? selectedBrokers : null,
items: (filter, infiniteScrollProps) {
return filteredBrokerData;
},
itemAsString: (val) => val['name'].toString(), // what to show
compareFn: (item, selectedItem) =>
item['id'] == selectedItem['id'], // compare by id
validator: (val) {
if (val == null) {
return "Required"; // error message
}
return null;
},
suffixProps: DropdownSuffixProps(
// make sure the dropdown button is visible
dropdownButtonProps: DropdownButtonProps(
isVisible: true,
padding: EdgeInsets.zero, // remove default padding
constraints: const BoxConstraints(
// shrink icon tap area
minWidth: 12,
minHeight: 12,
),
iconSize: 15, // smaller icon
// icon: const Icon(Icons.arrow_drop_down),
),
),
dropdownBuilder: (context, selectedItem) => Align(
alignment: Alignment.centerLeft,
child: Text(
selectedItem != null ? selectedItem['name'].toString() : "",
style: GoogleFonts.poppins(fontSize: 11, color: Colors.black),
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
),
),
decoratorProps: DropDownDecoratorProps(
decoration:
AppInputDecorations.dropdownDecoration(
label: "Select Broker",
).copyWith(
filled: true,
fillColor: Color(0xffEDF6F5),
// fillColor:
// Colors.white, // 👈 makes the dropdown input white
isDense: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(
color: Color(0xffEDF6F5),
width: 0.1,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(
color: Color(0xffEDF6F5),
width: 0.1,
),
),
contentPadding: EdgeInsets.symmetric(
horizontal: 8,
vertical: 6,
),
),
),
popupProps: PopupProps.menu(
fit: FlexFit.loose,
constraints: BoxConstraints(maxHeight: 250),
menuProps: MenuProps(
backgroundColor:
Colors.white, // 👈 sets dropdown background to white
),
showSearchBox: true,
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: "Search Broker...",
hintStyle: GoogleFonts.inter(
fontSize: 12,
color: Colors.black,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
), // 👈 Normal border
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1.5,
), // 👈 Focused border
),
),
),
itemBuilder: (context, item, isDisabled, isSelected) {
return Container(
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
child: Text(
item['name'].toString(),
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
),
);
},
// constraints: BoxConstraints(),
),
onChanged: (val) {
if (val != null) {
print("Selected Broker : ${val['name']}");
print("Id: ${val['id']}");
selectedBroker = val['id'];
setState(() {
selectedBrokerName = val['name'];
print('selectedBrokerName - $selectedBrokerName');
});
// controllers['agentId']?.text = val['agent_code'];
// agentId = agent['id'];
}
},
),
),
],
);
}
@ -1569,7 +1577,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
SizedBox(
width: MediaQuery.of(context).size.width * 0.075,
child: Text(
'${controllers['policyPaymentMode']?.text}',
controllers['policyPaymentMode']?.text ?? 'Online',
style: GoogleFonts.inter(fontSize: 12),
),
),
@ -1757,7 +1765,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.12,
width: MediaQuery.of(context).size.width * 0.15,
child: Text('Upload Policy PDF * ', style: _textStyle),
),
// const SizedBox(height: 10),
@ -1771,12 +1779,15 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
allowedExtensions: ['pdf'],
// backgroundColor: Colors.white,
backgroundColor: Color(0xffEDF6F5),
txtheight: 35,
txtwidth: ResponsiveLayout.isMobile(context)
? null
: (docUploadedPDFFileUrlFromApi != null)
? MediaQuery.of(context).size.width * 0.135
? MediaQuery.of(context).size.width * 0.117
// ? MediaQuery.of(context).size.width * 0.135
// ? MediaQuery.of(context).size.width * 0.12
: MediaQuery.of(context).size.width * 0.15,
: MediaQuery.of(context).size.width * 0.14,
// : MediaQuery.of(context).size.width * 0.15,
// backgroundColor: Color(0xFFEDF6F5),
onFileSelected: (fileName, file) async {
print("Picked file: $fileName (${file.size} bytes)");
@ -1800,9 +1811,9 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
docPDFUploadedFile = file;
});
if (selectedBrokerName == 'Nhance') {
handleUploadPolicy();
}
// if (selectedBrokerName == 'Nhance') {
// handleUploadPolicy();
// }
},
),

View File

@ -105,7 +105,7 @@ class TabEnquiryStaffListState extends ConsumerState<TabEnquiryStaffList> {
selectedVehicleType = data['enquiry']?['vehicle_type'];
selectedBrokerName = data['enquiry']?['broker_name'];
selectedAgentName = data['enquiry']?['agent_name'];
selectedInsurer = data['enquiry']?['insurer_short_name'];
selectedInsurer = data['enquiry']?['short_name'];
print(
'loadQuotationTab 4s -$selectedBrokerName $selectedInsuredName - $selectedVehicleNum - $selectedVehicleType',
);