feat: enhance poster download functionality by ensuring images load before PDF generation and adding QR readiness check

This commit is contained in:
hamed
2026-07-04 21:50:57 +03:30
parent 3344a2f77a
commit 199c843b08
6 changed files with 255 additions and 38 deletions
+8 -3
View File
@@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import QRCode from "qrcode";
import { getStateInfoClient } from "@/lib/getStateInfoClient";
export default function QrImg() {
export default function QrImg({ onReady }) {
const [host, setHost] = useState("");
const [qrCodeData, setQrCodeData] = useState("");
@@ -14,9 +14,14 @@ export default function QrImg() {
setHost(linkHost);
if (linkURL) {
QRCode.toDataURL(linkURL).then(setQrCodeData);
QRCode.toDataURL(linkURL).then((url) => {
setQrCodeData(url);
onReady?.();
});
} else {
onReady?.();
}
}, []);
}, [onReady]);
return (
<div className="flex items-center flex-col justify-center mt-[100%]">