(null);
const [isMobile, setIsMobile] = useState(false);
const [isIOS, setIsIOS] = useState(false);
const [isPDF, setIsPDF] = useState(false);
useEffect(() => {
// Detect mobile and iOS
const userAgent = navigator.userAgent.toLowerCase();
setIsMobile(
/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(
userAgent,
),
);
setIsIOS(/iphone|ipad|ipod/i.test(userAgent));
// Try to detect if file is PDF from extension
setIsPDF(allegato.mime_type === "application/pdf");
}, [allegato]);
const handleIframeLoad = () => {
if (if_ref.current?.contentWindow) {
// For images
const img = if_ref.current.contentWindow.document.querySelector("img");
if (img) {
img.style.width = "100%";
img.style.height = "100%";
img.style.objectFit = "contain";
}
}
};
const requestUrl = getStorageUrl({
id: allegato.id,
params: { mode: "inline" },
});
// For PDF on iOS, provide download link instead
if (isPDF && (isIOS || isMobile)) {
return (
);
}
return (
{/** biome-ignore lint/a11y/noNoninteractiveElementInteractions: */}
);
};