Policy validation

This commit is contained in:
Surendiran 2025-12-15 16:00:35 +05:30
parent 5482d76788
commit b401389bbb

View File

@ -258,14 +258,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Future<void> getPolicyFilePath() async {
_pdfViewerKey.currentState?.openBookmarkView();
// 🔥 Use DIRECT FIXED URL you asked for
// const directPdfUrl = "https://venbait.in/nhance/mypdf.pdf";
//
// setState(() {
// pdfUrl = directPdfUrl;
// });
//
// debugPrint("FINAL PDF URL -> $pdfUrl");
final policyId = widget.item?['policy_id'];
if (policyId == null) {
@ -284,42 +276,10 @@ class _policyValidationState extends ConsumerState<policyValidation> {
setState(() {
pdfUrl = "$url";
});
print("FINAL PDF URL -> $pdfUrl");
final response = await apiService.policyFilePathApi(
policyId,
'policy_pdf',
);
debugPrint('policyFilePathApi response: $response');
if (response != null && response['status'] == 'success') {
// final filePath = response['data']?.toString();
//
// // The API returns a server absolute path like:
// // /home3/.../uploads/policy/policy_pdf/yourfile.pdf
// // You must convert it to a usable URL for web/mobile.
//
// if (filePath != null && filePath.isNotEmpty) {
// // EXAMPLE:
// // Build full URL based on your domain
// // final baseUrl = filePath;
// final baseUrl = "https://venbait.in/nhance/mypdf.pdf";
//
// final fileName = filePath.split('/').last;
//
// setState(() {
// pdfUrl = "$baseUrl$fileName";
// });
//
// debugPrint("FINAL PDF URL -> $pdfUrl");
// }
} else {
debugPrint(
'policyFilePathApi returned error: ${response?['message'] ?? 'unknown'}',
);
}
} catch (e, st) {
debugPrint('Exception in getPolicyFilePath: $e\n$st');
print('Exception in getPolicyFilePath: $e\n$st');
} finally {
if (!mounted) return;
setState(() => isLoading = false);
@ -905,7 +865,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Remarks',
remarksController,required: true
remarksController,required: false
),
),
],
@ -1025,14 +985,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'RTO State Name',
rtoStateCodeController,required: true,
rtoStateCodeController,required: false,
),
),
const SizedBox(width: 8),
Expanded(
child: _buildInput(
'RTO City Code',
rtoCityCodeController,required: true,
rtoCityCodeController,required: false,
keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter,
),
@ -1041,7 +1001,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Weight',
weightController,required: true,
weightController,required: false,
keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter,
),
@ -1053,14 +1013,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Fuel Type',
fuelTypeController,required: true,
fuelTypeController,required: false,
),
),
const SizedBox(width: 8),
Expanded(
child: _buildInput(
'Date of Registration',
registrationDateController,required: true,
registrationDateController,required: false,
readOnly: true,
onTap: () => _pickDate(
registrationDateController,
@ -1072,7 +1032,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Year of Manufacture',
yomController,required: true,
yomController,required: false,
keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter,
),
@ -1084,14 +1044,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Engine No',
engineNoController,required: true,
engineNoController,required: false,
),
),
const SizedBox(width: 8),
Expanded(
child: _buildInput(
'Chassis No',
chassisNoController,required: true,
chassisNoController,required: false,
),
),
const SizedBox(width: 8),
@ -1099,7 +1059,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
child: Expanded(
child: _buildInput(
'Make',
makeController,required: true,
makeController,required: false,
),
),
),
@ -1110,14 +1070,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Model',
modelController,required: true,
modelController,required: false,
),
),
const SizedBox(width: 8),
Expanded(
child: _buildInput(
'Cubic Capacity',
cubicCapacityController,required: true,
cubicCapacityController,required: false,
keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: decimalFormatter,
),
@ -1126,7 +1086,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Vehicle Type',
vehicleTypeController,required: true,
vehicleTypeController,required: false,
),
),
],
@ -1161,14 +1121,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded(
child: _buildInput(
'Broker Name',
brokerNameController,required: true,
brokerNameController,required: false,
),
),
const SizedBox(width: 8),
Expanded(
child: _buildInput(
'Commission Amount',
commissionAmountController,required: true,
commissionAmountController,required: false,
keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: decimalFormatter,
),