refactor: blob 이미지 가져오는 방식 수정

This commit is contained in:
2025-04-08 10:39:04 +09:00
parent 2797ec210e
commit d6b48ea554
5 changed files with 28 additions and 11 deletions
+9 -5
View File
@@ -47,7 +47,7 @@ function BannerForm({
const router = useRouter();
const { confirm } = useConfirm();
const [attachmentFileId, setAttachmentFileId] = useState("");
const [imageUrl, setImageUrl] = useState("");
const [upload, setUpload] = useState<Upload | null>(null);
const [progress, setProgress] = useState(0);
@@ -84,11 +84,15 @@ function BannerForm({
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
if (atflCd) form.setValue("atflCd", atflCd);
if (atflId) setAttachmentFileId(atflId);
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
};
useEffect(() => {
if (atflId) setAttachmentFileId(atflId);
if (!atflId) return;
(async () => {
setImageUrl(await AttachmentApi.getImageUrl(atflId));
})();
}, [atflId]);
return (
@@ -175,9 +179,9 @@ function BannerForm({
{(upload?.file as File)?.name}
</p>
<div className="relative h-full w-full">
{attachmentFileId && (
{imageUrl && (
<Image
src={`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${attachmentFileId}`}
src={imageUrl}
alt="업로드된 이미지"
fill
objectFit="contain"
+9 -5
View File
@@ -42,7 +42,7 @@ function ImageForm({ form, imgSn, handleSave, handleDelete }: ImageFormProps) {
const router = useRouter();
const { confirm } = useConfirm();
const [attachmentFileId, setAttachmentFileId] = useState("");
const [imageUrl, setImageUrl] = useState("");
const [upload, setUpload] = useState<Upload | null>(null);
const [progress, setProgress] = useState(0);
@@ -79,11 +79,15 @@ function ImageForm({ form, imgSn, handleSave, handleDelete }: ImageFormProps) {
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
if (atflCd) form.setValue("atflCd", atflCd);
if (atflId) setAttachmentFileId(atflId);
if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId));
};
useEffect(() => {
if (atflId) setAttachmentFileId(atflId);
if (!atflId) return;
(async () => {
setImageUrl(await AttachmentApi.getImageUrl(atflId));
})();
}, [atflId]);
return (
@@ -228,9 +232,9 @@ function ImageForm({ form, imgSn, handleSave, handleDelete }: ImageFormProps) {
{(upload?.file as File)?.name}
</p>
<div className="relative h-full w-full">
{attachmentFileId && (
{imageUrl && (
<Image
src={`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${attachmentFileId}`}
src={imageUrl}
alt="업로드된 이미지"
fill
objectFit="contain"