From b401389bbba4de8acff04a52ea1953b248545cea Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Mon, 15 Dec 2025 16:00:35 +0530 Subject: [PATCH] Policy validation --- .../staff/policy/policy_validation.dart | 74 +++++-------------- 1 file changed, 17 insertions(+), 57 deletions(-) diff --git a/lib/presentation/screens/staff/policy/policy_validation.dart b/lib/presentation/screens/staff/policy/policy_validation.dart index 9f4164e..2bd8e2f 100644 --- a/lib/presentation/screens/staff/policy/policy_validation.dart +++ b/lib/presentation/screens/staff/policy/policy_validation.dart @@ -258,14 +258,6 @@ class _policyValidationState extends ConsumerState { Future 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 { 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 { Expanded( child: _buildInput( 'Remarks', - remarksController,required: true + remarksController,required: false ), ), ], @@ -1025,14 +985,14 @@ class _policyValidationState extends ConsumerState { 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 { Expanded( child: _buildInput( 'Weight', - weightController,required: true, + weightController,required: false, keyboardType: TextInputType.number, inputFormatters: digitsOnlyFormatter, ), @@ -1053,14 +1013,14 @@ class _policyValidationState extends ConsumerState { 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 { 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 { 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 { child: Expanded( child: _buildInput( 'Make', - makeController,required: true, + makeController,required: false, ), ), ), @@ -1110,14 +1070,14 @@ class _policyValidationState extends ConsumerState { 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 { Expanded( child: _buildInput( 'Vehicle Type', - vehicleTypeController,required: true, + vehicleTypeController,required: false, ), ), ], @@ -1161,14 +1121,14 @@ class _policyValidationState extends ConsumerState { 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, ),