diff --git a/frontend/src/components/AuthImage.tsx b/frontend/src/components/AuthImage.tsx new file mode 100644 index 0000000..e3e7142 --- /dev/null +++ b/frontend/src/components/AuthImage.tsx @@ -0,0 +1,24 @@ +import { useEffect, useState, ImgHTMLAttributes } from "react"; +import client from "../api/client"; + +interface AuthImageProps extends ImgHTMLAttributes { + src: string; +} + +export function AuthImage({ src, ...props }: AuthImageProps) { + const [objectUrl, setObjectUrl] = useState(null); + + useEffect(() => { + let url: string | null = null; + client.get(src, { responseType: "blob" }).then((res) => { + url = URL.createObjectURL(res.data); + setObjectUrl(url); + }); + return () => { + if (url) URL.revokeObjectURL(url); + }; + }, [src]); + + if (!objectUrl) return null; + return ; +} diff --git a/frontend/src/pages/AnalysisView.tsx b/frontend/src/pages/AnalysisView.tsx index b5fba3e..1052383 100644 --- a/frontend/src/pages/AnalysisView.tsx +++ b/frontend/src/pages/AnalysisView.tsx @@ -3,6 +3,7 @@ import { useParams, useNavigate } from "react-router-dom"; import { useAnalysis, useDeleteAnalysis } from "../hooks/useAnalysis"; import { useAnalysisStore, type AnalysisTab } from "../stores/analysisStore"; import { getAnalysisImageUrl, checkAIInsightsAvailable, generateAIInsights } from "../api/analysis"; +import { AuthImage } from "../components/AuthImage"; import type { Insight } from "../types/analysis"; function getScoreInfo(score: number) { @@ -76,7 +77,7 @@ function ZoomableImage({ src, alt }: { src: string; alt: string }) { const zoom = useAnalysisStore((s) => s.zoom); return (
- {alt}{analysis.model}

- {`Heatmap:
- {analysis.name} { - (e.target as HTMLImageElement).style.display = "none"; - }} />