fix(mobile): do not mutate SVG attributes, only replace qr-placeholder group
This commit is contained in:
@@ -45,22 +45,19 @@ export default function QrScreen() {
|
||||
const currentSvgRaw = MOBILE_SVG_TEMPLATES[selectedKey] || MOBILE_SVG_TEMPLATES["qr-4"] || Object.values(MOBILE_SVG_TEMPLATES)[0] || "";
|
||||
|
||||
// Inject the live QR code image directly into the SVG's #qr-placeholder group
|
||||
// SVG içeriğine başka hiçbir şey dokunulmaz, sadece #qr-placeholder replace edilir
|
||||
function buildSvgWithQr(svgRaw: string, pngBase64: string): string {
|
||||
const qrImgTag = `<g id="qr-placeholder" transform="translate(90, 215)">
|
||||
<rect width="220" height="220" rx="20" fill="#FFFFFF"/>
|
||||
<image href="data:image/png;base64,${pngBase64}" x="10" y="10" width="200" height="200" preserveAspectRatio="xMidYMid meet"/>
|
||||
</g>`;
|
||||
// Replace the entire qr-placeholder group
|
||||
const replaced = svgRaw.replace(
|
||||
return svgRaw.replace(
|
||||
/<g id="qr-placeholder"[\s\S]*?<\/g>/,
|
||||
qrImgTag
|
||||
);
|
||||
// Also ensure the SVG scales properly by setting width/height to 100%
|
||||
return replaced
|
||||
.replace(/width="400"/, 'width="100%"')
|
||||
.replace(/height="650"/, 'height="100%"');
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const activeRest = await getActiveRestaurant();
|
||||
|
||||
Reference in New Issue
Block a user