diff --git a/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx b/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx index 6300cc0f..848be3bf 100644 --- a/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx +++ b/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx @@ -68,19 +68,14 @@ interface TemplateInspectionContentProps { // ===== 유틸 ===== -/** API 저장소 이미지 URL 생성 — R2 전환 후 프록시 사용 */ -function getImageUrl(path: string | null | undefined, fileId?: number | null): string { - if (!path && !fileId) return ''; +/** API 저장소 이미지 URL 생성 — file_id 기반 R2 프록시 사용 */ +function getImageUrl(fileId?: number | null, path?: string | null): string { // file_id가 있으면 프록시 경로 사용 if (fileId) return `/api/proxy/files/${fileId}/view`; + // fallback: 레거시 경로 if (!path) return ''; if (path.startsWith('http://') || path.startsWith('https://')) return path; if (path.startsWith('/api/proxy/')) return path; - // API 업로드 형식 (tenant path: 287/temp/2026/02/xxx.jpg) → API 스토리지 직접 접근 - if (/^\d+\//.test(path)) { - const apiUrl = process.env.NEXT_PUBLIC_API_URL || ''; - return `${apiUrl}/storage/tenants/${path}`; - } return path; } @@ -289,10 +284,10 @@ function buildBendingProducts(order: WorkOrder): BendingProduct[] { } // ===== 이미지 섹션 컴포넌트 (onError 핸들링) ===== -function SectionImage({ section }: { section: { id: number; title?: string; name?: string; image_path?: string | null } }) { +function SectionImage({ section }: { section: { id: number; title?: string; name?: string; image_path?: string | null; file_id?: number | null } }) { const [imgError, setImgError] = useState(false); const title = section.title || section.name || ''; - const url = section.image_path ? getImageUrl(section.image_path) : ''; + const url = (section.file_id || section.image_path) ? getImageUrl(section.file_id, section.image_path) : ''; return (