From 212b66c7586a230a910d57f357e9d9fe05e4554a Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Sat, 11 Jul 2026 19:15:31 +0000 Subject: [PATCH] =?UTF-8?q?fix(qa):=20randeaz=C4=83=20codul=20QR=20=C3=AEn?= =?UTF-8?q?=20cardul=20de=20link=20public?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Două probleme, ambele găsite la QA în browser: - `qrcode` e CommonJS; sub Vite metodele stau pe `.default`, deci `QRCode.toCanvas` era undefined → throw prins de un catch gol (blank canvas). - `renderQr()` era apelat în load() înainte ca ref-ul canvas să fie montat, și nu se relua. Adăugat un watch care randează când canvas + is_public sunt gata. Verificat live: canvas 512x512, QR desenat, buton „Descarcă QR" activ. Co-Authored-By: Claude Fable 5 --- frontend/src/views/PropertyDetail.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/PropertyDetail.vue b/frontend/src/views/PropertyDetail.vue index e392ac6..881cd1d 100644 --- a/frontend/src/views/PropertyDetail.vue +++ b/frontend/src/views/PropertyDetail.vue @@ -653,17 +653,29 @@ const renderQr = async () => { await nextTick() if (!qrCanvas.value) return try { - const QRCode = await import('qrcode') + const mod = await import('qrcode') + // `qrcode` is CommonJS; under Vite its methods land on `.default`. + const QRCode = (mod as any).default ?? mod await QRCode.toCanvas(qrCanvas.value, publicBookingIdUrl.value, { width: 512, margin: 4 }) qrReady.value = true - } catch { + } catch (err) { + console.error('QR render failed', err) qrReady.value = false } } +// Render the QR whenever the canvas is mounted and the property is public. +// (renderQr called during load() can run before the canvas ref binds.) +watch( + [qrCanvas, () => property.value?.is_public, publicBookingIdUrl], + ([canvas, isPublic]) => { + if (canvas && isPublic) renderQr() + } +) + const downloadQr = () => { if (!qrCanvas.value || !qrReady.value) return const link = document.createElement('a')