From dd9f7904908e7def09e2d4514578db59e51ac87a Mon Sep 17 00:00:00 2001 From: "Akhib.Shaik" Date: Fri, 14 Nov 2025 16:47:34 +0530 Subject: [PATCH] fixed qr issue in dundu branch --- src/pages/AssetDetail.tsx | 49 ++++++++++++++++++++++++++++++++++++--- vite.config.ts | 15 ++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/pages/AssetDetail.tsx b/src/pages/AssetDetail.tsx index 1a8cbf5..b09ff44 100644 --- a/src/pages/AssetDetail.tsx +++ b/src/pages/AssetDetail.tsx @@ -4,6 +4,12 @@ import { useAssetDetails, useAssetMutations } from '../hooks/useAsset'; import { FaArrowLeft, FaSave, FaEdit, FaQrcode } from 'react-icons/fa'; import type { CreateAssetData } from '../services/assetService'; +// Helper function to get the base URL for files +const getFileBaseUrl = () => { + // Always use the full URL to avoid proxy path duplication issues + return import.meta.env.VITE_FRAPPE_BASE_URL || 'https://seeraasm-med.seeraarabia.com'; +}; + const AssetDetail: React.FC = () => { const { assetName } = useParams<{ assetName: string }>(); const navigate = useNavigate(); @@ -44,6 +50,9 @@ const AssetDetail: React.FC = () => { // Load asset data for editing or duplicating useEffect(() => { if (asset) { + // Debug: Log asset data to check if name field exists + console.log('Asset data loaded:', asset); + console.log('Asset name:', asset.name); setFormData({ asset_name: isDuplicating ? `${asset.asset_name} (Copy)` : (asset.asset_name || ''), company: asset.company || '', @@ -829,10 +838,44 @@ const AssetDetail: React.FC = () => { {/* QR Code */} -
-
- +
+
+ {asset?.name ? ( + <> + {`QR { + // Hide image and show fallback icon if QR code doesn't exist + const target = e.target as HTMLImageElement; + target.style.display = 'none'; + const fallback = target.nextElementSibling as HTMLElement; + if (fallback) { + fallback.style.display = 'flex'; + } + }} + /> +
+ +
+ + ) : ( +
+ +
+ )}
+ {asset?.name && ( +

+ Asset ID: {asset.name} +

+ )} + {!asset && !loading && ( +

+ Asset data not loaded +

+ )}
diff --git a/vite.config.ts b/vite.config.ts index ff3b5e2..b73c97b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -32,6 +32,21 @@ export default defineConfig({ proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization, X-Frappe-CSRF-Token'; }); }, + }, + // Proxy file requests to Frappe backend + '/files': { + target: process.env.VITE_FRAPPE_BASE_URL || 'https://seeraasm-med.seeraarabia.com', + changeOrigin: true, + secure: true, + // Keep the /files path as-is when forwarding to the target + configure: (proxy, _options) => { + proxy.on('proxyReq', (proxyReq, req, _res) => { + // Log for debugging + if (process.env.DEV) { + console.log('Proxying file request:', req.url, 'to', proxyReq.path); + } + }); + }, } } },