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 { Future<void> getPolicyFilePath() async {
_pdfViewerKey.currentState?.openBookmarkView(); _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']; final policyId = widget.item?['policy_id'];
if (policyId == null) { if (policyId == null) {
@ -284,42 +276,10 @@ class _policyValidationState extends ConsumerState<policyValidation> {
setState(() { setState(() {
pdfUrl = "$url"; 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) { } catch (e, st) {
debugPrint('Exception in getPolicyFilePath: $e\n$st'); print('Exception in getPolicyFilePath: $e\n$st');
} finally { } finally {
if (!mounted) return; if (!mounted) return;
setState(() => isLoading = false); setState(() => isLoading = false);
@ -905,7 +865,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Remarks', 'Remarks',
remarksController,required: true remarksController,required: false
), ),
), ),
], ],
@ -1025,14 +985,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'RTO State Name', 'RTO State Name',
rtoStateCodeController,required: true, rtoStateCodeController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'RTO City Code', 'RTO City Code',
rtoCityCodeController,required: true, rtoCityCodeController,required: false,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter, inputFormatters: digitsOnlyFormatter,
), ),
@ -1041,7 +1001,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Weight', 'Weight',
weightController,required: true, weightController,required: false,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter, inputFormatters: digitsOnlyFormatter,
), ),
@ -1053,14 +1013,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Fuel Type', 'Fuel Type',
fuelTypeController,required: true, fuelTypeController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Date of Registration', 'Date of Registration',
registrationDateController,required: true, registrationDateController,required: false,
readOnly: true, readOnly: true,
onTap: () => _pickDate( onTap: () => _pickDate(
registrationDateController, registrationDateController,
@ -1072,7 +1032,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Year of Manufacture', 'Year of Manufacture',
yomController,required: true, yomController,required: false,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: digitsOnlyFormatter, inputFormatters: digitsOnlyFormatter,
), ),
@ -1084,14 +1044,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Engine No', 'Engine No',
engineNoController,required: true, engineNoController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Chassis No', 'Chassis No',
chassisNoController,required: true, chassisNoController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
@ -1099,7 +1059,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
child: Expanded( child: Expanded(
child: _buildInput( child: _buildInput(
'Make', 'Make',
makeController,required: true, makeController,required: false,
), ),
), ),
), ),
@ -1110,14 +1070,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Model', 'Model',
modelController,required: true, modelController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Cubic Capacity', 'Cubic Capacity',
cubicCapacityController,required: true, cubicCapacityController,required: false,
keyboardType: TextInputType.numberWithOptions(decimal: true), keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: decimalFormatter, inputFormatters: decimalFormatter,
), ),
@ -1126,7 +1086,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Vehicle Type', 'Vehicle Type',
vehicleTypeController,required: true, vehicleTypeController,required: false,
), ),
), ),
], ],
@ -1161,14 +1121,14 @@ class _policyValidationState extends ConsumerState<policyValidation> {
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Broker Name', 'Broker Name',
brokerNameController,required: true, brokerNameController,required: false,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: _buildInput( child: _buildInput(
'Commission Amount', 'Commission Amount',
commissionAmountController,required: true, commissionAmountController,required: false,
keyboardType: TextInputType.numberWithOptions(decimal: true), keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: decimalFormatter, inputFormatters: decimalFormatter,
), ),