This commit is contained in:
venbaittech 2025-11-21 19:00:16 +05:30
parent 3233093da9
commit cd201d608e
6 changed files with 199 additions and 126 deletions

View File

@ -326,7 +326,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
return Container(
// color: Color(0xFFFCFCFC),
// margin: const EdgeInsets.symmetric(vertical: 8),
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 25),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 25),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
@ -384,7 +384,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
// width: fromHeader
// ? MediaQuery.of(context).size.width * 0.11
// : MediaQuery.of(context).size.width * 0.08,
height: 30,
// height: 30,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyAgent,
selectedItem: selectedAgntName.isNotEmpty ? selectedAgntName : null,
@ -564,6 +564,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
// errorText: fieldErrors['name'],
borderColor: Color(0xFFE2E8F0),
highlightColor: Color(0xFF50A398),
padVertical: 13,
isdense: true,
validator: (value) => Validators.requiredField(value, "name"),
widthNone: true,
@ -585,7 +586,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
SizedBox(height: 5),
Container(
height: 30,
// height: 30,
width: MediaQuery.of(context).size.width * 0.12,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyInsurerEnqAsgn,
@ -746,6 +747,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
hintText: 'Vehicle Number',
borderColor: Color(0xFFE2E8F0),
highlightColor: Color(0xFF50A398),
padVertical: 13,
isdense: true,
inputFormatters: [
UpperCaseTextFormatter(), // 👈 custom formatter for uppercase
@ -777,7 +779,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
SizedBox(height: 5),
SizedBox(
height: 30,
// height: 30,
width: MediaQuery.of(context).size.width * 0.15,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownSelectStaffKey,

View File

@ -371,6 +371,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
// final bool isUpdating = widget.selectedQuotationFrmListId != null;
// final id = widget.selectedQuotationFrmListId!;
print("userDatauserData1 - $userData");
final bool isUpdating = widget.selectedQuotationFrmListId != null;
final id = widget.selectedQuotationFrmListId; // keep nullable
@ -396,6 +397,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
// request.fields['_method'] = 'PUT';
request.fields['id'] = id!;
request.fields['updated_by'] = widget.userId!.toString();
request.fields['created_by'] = widget.userId!.toString();
} else {
print('Not Updatrinf');
request.fields['created_by'] = widget.userId!.toString();
@ -591,6 +593,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
SizedBox(height: 10),
ThemedFormField(
controller: controllers['idv']!,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9.]')),
],
@ -603,7 +606,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
txtwidth: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
txtheight: 35,
// txtheight: 35,
),
],
);
@ -628,7 +631,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
txtwidth: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
txtheight: 35,
// txtheight: 35,
),
],
);
@ -650,7 +653,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
width: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
height: 35,
// height: 35,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKey,
selectedItem: selectedVehicle.isNotEmpty ? selectedVehicle : null,
@ -804,7 +807,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
width: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
height: 35,
// height: 35,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownSelectPaymentModeKey,
selectedItem: selectedVehicle.isNotEmpty ? selectedVehicle : null,
@ -938,7 +941,7 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
width: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
height: 35,
// height: 35,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyBroker,
selectedItem: selectedBrokers.isNotEmpty ? selectedBrokers : null,
@ -1066,19 +1069,46 @@ class CreateProposalFormState extends ConsumerState<CreateProposalForm> {
children: [
ThemedUploadField(
hintText: selectedFileNames ?? "Upload Document",
txtheight: 40,
// txtheight: 40,
txtwidth: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
borderColor: Color(0xFFE2E8F0),
// highlightColor: Color(0xFF50A398),
// backgroundColor: Color(0xFFEDF6F5),
onFileSelected: (fileName, file) {
onFileSelected: (fileName, file) async {
print("Picked file: $fileName (${file.size} bytes)");
if (!fileName.toLowerCase().endsWith('.pdf')) {
ToastHelper.showErrorToast(
context,
'Only PDF files are allowed.',
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Only PDF files are allowed.'),
backgroundColor: Colors.red,
),
);
return; // Stop here
}
print("Picked file: $fileName (${file.size} bytes)");
setState(() {
docUploadedFile = file;
});
// if (selectedBrokerName == 'Nhance') {
// handleUploadPolicy();
// }
},
// onFileSelected: (fileName, file) {
// print("Picked file: $fileName (${file.size} bytes)");
// setState(() {
// docUploadedFile = file;
// });
// },
),
// const SizedBox(height: 5),
//

View File

@ -404,7 +404,20 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
}
}
String fixInvalidDate(dynamic value) {
if (value == null) return '';
final str = value.toString();
// Check for your invalid date patterns
if (str.contains('--0001') || str == '30-11--0001' || str == '0000-00-00') {
return '';
}
return str;
}
void updatePolicyData(Map<String, dynamic> policyData) {
print("updatePolicyDataupdatePolicyData - $policyData");
if (!mounted || policyData.isEmpty) return;
setState(() {
@ -422,11 +435,18 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
policyData['policy_number']?.toString() ?? '';
controllers["policyPaymentMode"]?.text =
policyData['payment_mode']?.toString() ?? '';
controllers["issueDate"]?.text =
policyData['issued_date']?.toString() ?? '';
controllers["startDate"]?.text =
policyData['start_date']?.toString() ?? '';
controllers["endDate"]?.text = policyData['end_date']?.toString() ?? '';
controllers["issueDate"]?.text = fixInvalidDate(
policyData['issued_date'],
);
controllers["startDate"]?.text = fixInvalidDate(policyData['start_date']);
controllers["endDate"]?.text = fixInvalidDate(policyData['end_date']);
// controllers["issueDate"]?.text =
// policyData['issued_date']?.toString() ?? '';
// controllers["startDate"]?.text =
// policyData['start_date']?.toString() ?? '';
// controllers["endDate"]?.text = policyData['end_date']?.toString() ?? '';
controllers["tp"]?.text = policyData['tp']?.toString() ?? '';
controllers["od"]?.text = policyData['od']?.toString() ?? '';
@ -479,7 +499,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
}
void updateUploadPDFPolicyData(Map<String, dynamic> policyData) {
print('updateUploadPDFPolicyData - $policyData');
print('updateUploadPDFPolicyDataJJ - $policyData');
if (!mounted || policyData.isEmpty) return;
setState(() {
@ -527,35 +547,35 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
}
void handleSave() {
if (!_formKey.currentState!.validate()) return;
// if (!_formKey.currentState!.validate()) return;
setState(() {
if (_formKey.currentState!.validate()) {
calculateAmount();
dataDetails();
final dataSet = dataDetails();
print("dataSetPolicy - $dataSet");
// if (_formKey.currentState!.validate()) {
calculateAmount();
dataDetails();
final dataSet = dataDetails();
print("dataSetPolicy - $dataSet");
final bool isUpdating = choosedPolcyId != null;
final bool isUpdating = choosedPolcyId != null;
// 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) &&
(docUploadedPDFFileUrlFromApi == null ||
docUploadedPDFFileUrlFromApi!.isEmpty)) {
ToastHelper.showErrorToast(context, "Policy PDF is required");
return;
}
createUserData(dataSet);
} else {
// isDi sable = false;
// 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) &&
(docUploadedPDFFileUrlFromApi == null ||
docUploadedPDFFileUrlFromApi!.isEmpty)) {
ToastHelper.showErrorToast(context, "Policy PDF is required");
return;
}
createUserData(dataSet);
// } else {
// // isDi sable = false;
// }
});
}
@ -1070,66 +1090,75 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
key: _formKey,
child: Column(
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Paymentmode(context),
SizedBox(width: 20),
buildBroker(context),
if (selectedBrokerName != null) ...[
SizedBox(width: 20),
buildUploadPolicyPdf(context),
if (docUploadedPDFFileUrlFromApi == null ||
docUploadedPDFFileUrlFromApi!.isEmpty) ...[
Text('No Data Found'),
],
// SizedBox(width: 20),
// Show form fields when URL is NOT null AND NOT empty
if (docUploadedPDFFileUrlFromApi != null &&
docUploadedPDFFileUrlFromApi!.isNotEmpty) ...[
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Paymentmode(context),
SizedBox(width: 20),
buildBroker(context),
if (selectedBrokerName != null) ...[
SizedBox(width: 20),
buildUploadPolicyPdf(context),
// SizedBox(width: 20),
],
],
),
if (selectedBrokerName != null) ...[
SizedBox(height: 10),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
policynumber(context),
SizedBox(width: 20),
policyissuedate(context),
SizedBox(width: 20),
policystartdate(context),
SizedBox(width: 20),
policyenddate(context),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildThirdParty(context),
buildOwnDamage(context),
buildPersonalAccident(context),
],
),
SizedBox(width: 20),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildCGST(context),
buildSGST(context),
buildIGST(context),
buildPremiumTotal(context),
],
),
],
),
],
),
if (selectedBrokerName != null) ...[
SizedBox(height: 10),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
policynumber(context),
SizedBox(width: 20),
policyissuedate(context),
SizedBox(width: 20),
policystartdate(context),
SizedBox(width: 20),
policyenddate(context),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildThirdParty(context),
buildOwnDamage(context),
buildPersonalAccident(context),
],
),
SizedBox(width: 20),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildCGST(context),
buildSGST(context),
buildIGST(context),
buildPremiumTotal(context),
],
),
],
),
],
],
),
@ -1393,13 +1422,13 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Policy Number *', style: _textStyle),
Text('Policy Number ', style: _textStyle),
SizedBox(height: 10),
ThemedFormField(
controller: controllers['policyNumber']!,
borderColor: Color(0xFFE2E8F0),
highlightColor: Color(0xFF50A398),
validator: (value) => Validators.requiredField(value, "policyNumber"),
// validator: (value) => Validators.requiredField(value, "policyNumber"),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z 0-9]')),
],
@ -1605,7 +1634,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Issue Date *', style: _textStyle),
Text('Issue Date', style: _textStyle),
SizedBox(height: 10),
ThemedDateField(
hintText: "Select Date",
@ -1614,7 +1643,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
: MediaQuery.of(context).size.width * 0.14,
txtheight: 50,
// backgroundColor: const Color(0xFFECECEC),
validator: (value) => Validators.requiredField(value, "date"),
// validator: (value) => Validators.requiredField(value, "date"),
controller: controllers['issueDate']!,
onDateSelected: (date) {
print("Picked Date: $date");
@ -1633,7 +1662,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Start Date *', style: _textStyle),
Text('Start Date', style: _textStyle),
SizedBox(height: 10),
ThemedDateField(
hintText: "Select Date",
@ -1642,7 +1671,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
: MediaQuery.of(context).size.width * 0.14,
txtheight: 50,
// backgroundColor: const Color(0xFFECECEC),
validator: (value) => Validators.requiredField(value, "date"),
// validator: (value) => Validators.requiredField(value, "date"),
controller: controllers['startDate']!,
onDateSelected: (date) {
print("Picked Date: $date");
@ -1674,7 +1703,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('End Date *', style: _textStyle),
Text('End Date', style: _textStyle),
SizedBox(height: 10),
ThemedDateField(
hintText: "Select Date",
@ -1685,9 +1714,9 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
// backgroundColor: const Color(0xFFECECEC),
// validator: (value) => Validators.requiredField(value, "date"),
validator: (value) {
if (value == null || value.isEmpty) {
return "Required";
}
// if (value == null || value.isEmpty) {
// return "Required";
// }
final startDateControllerText = controllers['startDate']?.text;
if (startDateControllerText == null ||
@ -1698,7 +1727,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
final startDate = DateFormat(
'dd-MM-yyyy',
).parse(startDateControllerText);
final endDate = DateFormat('dd-MM-yyyy').parse(value);
final endDate = DateFormat('dd-MM-yyyy').parse(value!);
if (endDate.isBefore(startDate)) {
return "End date cannot be before start date";
@ -1993,7 +2022,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('Third Party *', style: _textStyle),
child: Text('Third Party', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(
@ -2001,7 +2030,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
// backgroundColor: Color(0xffEDF6F5),
errorBorderColor: Color(0xffEDF6F5),
hintText: '0',
validator: (value) => Validators.requiredField(value, "Third Party"),
// validator: (value) => Validators.requiredField(value, "Third Party"),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[.0-9]')),
],
@ -2025,7 +2054,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('Own Damage *', style: _textStyle),
child: Text('Own Damage ', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(
@ -2033,7 +2062,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
// backgroundColor: Color(0xffEDF6F5),
errorBorderColor: Color(0xffEDF6F5),
hintText: '0',
validator: (value) => Validators.requiredField(value, "OwnDamage"),
// validator: (value) => Validators.requiredField(value, "OwnDamage"),
onChanged: (value) => calculateAmount(),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[.0-9]')),
@ -2053,7 +2082,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('Personal Accident*', style: _textStyle),
child: Text('Personal Accident', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(
@ -2062,8 +2091,8 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
errorBorderColor: Color(0xffEDF6F5),
hintText: '0',
onChanged: (value) => calculateAmount(),
validator: (value) =>
Validators.requiredField(value, "PersonalAccident"),
// validator: (value) =>
// Validators.requiredField(value, "PersonalAccident"),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[.0-9]')),
],
@ -2082,7 +2111,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('CGST *', style: _textStyle),
child: Text('CGST', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(
@ -2109,7 +2138,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('SGST *', style: _textStyle),
child: Text('SGST', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(
@ -2136,7 +2165,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.15,
child: Text('IGST *', style: _textStyle),
child: Text('IGST', style: _textStyle),
),
SizedBox(width: 20),
ThemedFormField(

View File

@ -126,9 +126,11 @@ class TabEnquiryStaffListState extends ConsumerState<TabEnquiryStaffList> {
// }
// Auto-select tab based on showKey
if (widget.showKey == "Policy") {
selectedIndex = 1; // Policy tab index
} else if (tabIndex != null) {
// if (widget.showKey == "Policy") {
// selectedIndex = 1; // Policy tab index
// } else
if (tabIndex != null) {
selectedIndex = tabIndex;
} else {
selectedIndex = 0; // Default Quotation tab

View File

@ -106,9 +106,14 @@ class ThemedFormField extends HookWidget {
),
filled: true,
fillColor: backgroundColor ?? Colors.white,
// contentPadding: EdgeInsets.symmetric(
// vertical: verticalPad ?? 12,
// horizontal: horizonalPad ?? 15,
// ),
contentPadding: EdgeInsets.symmetric(
vertical: verticalPad ?? 14,
horizontal: horizonalPad ?? 15,
vertical: verticalPad ?? 10,
horizontal: 10,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),

View File

@ -30,6 +30,7 @@ class ThemedFormInlineField extends HookWidget {
this.isShowCursor,
this.onChanged,
this.isdense,
this.padVertical,
});
final String? hintText;
@ -52,6 +53,7 @@ class ThemedFormInlineField extends HookWidget {
final TextInputType? keyboardType;
final int? maxLength;
final double? txtheight;
final double? padVertical;
final List<TextInputFormatter>? inputFormatters;
// void Function(dynamic value)? onChanged;
final ValueChanged<String>? onChanged;
@ -100,7 +102,10 @@ class ThemedFormInlineField extends HookWidget {
filled: true,
fillColor: backgroundColor ?? Colors.white,
// contentPadding: const EdgeInsets.symmetric(vertical: 14, horizontal: 2),
contentPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
contentPadding: EdgeInsets.symmetric(
vertical: padVertical ?? 10,
horizontal: 10,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),