fix: [inspection] 검사 문서 이미지 URL 생성 file_id 기반으로 변경

- getImageUrl 파라미터 순서 변경 (file_id 우선)
- 레거시 tenant path 직접 접근 제거, R2 프록시 사용
- SectionImage에 file_id prop 추가
This commit is contained in:
2026-03-14 08:29:20 +09:00
parent 31157122ca
commit 22a398024c

View File

@@ -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 (
<div className="mb-3">