Skip to content
This repository was archived by the owner on Aug 4, 2026. It is now read-only.

Commit 0dfae74

Browse files
author
Victoria Ivanova
committed
fix uploading attachment
1 parent d728cdd commit 0dfae74

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

frontend/src/pages/Report/components/Bug/Bug.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const Bug = ({ bug }: Props) => {
163163
reportId={reportId}
164164
bugId={bug.id}
165165
attachType={AttachmentTypes.FACT}
166-
onAttachmentUpload={() => handleAttachmentUpload(AttachmentTypes.FACT)}
166+
onAttachmentUpload={handleAttachmentUpload(AttachmentTypes.FACT)}
167167
onAttachmentDelete={handleDeleteAttachment}
168168
/>
169169

@@ -178,9 +178,7 @@ const Bug = ({ bug }: Props) => {
178178
reportId={reportId}
179179
bugId={bug.id}
180180
attachType={AttachmentTypes.EXPECT}
181-
onAttachmentUpload={() =>
182-
handleAttachmentUpload(AttachmentTypes.EXPECT)
183-
}
181+
onAttachmentUpload={handleAttachmentUpload(AttachmentTypes.EXPECT)}
184182
onAttachmentDelete={handleDeleteAttachment}
185183
/>
186184
</div>

frontend/src/pages/Report/components/Bug/components/Result/components/FilePreview/FilePreview.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ function FilePreview({
7878
}
7979
};
8080

81-
const getPreviewUrl = (attachment: Attachment): string => {
82-
return `${API_URL}v2/reports/${reportId}/bugs/${bugId}/attachments/${attachment.id}/content/preview`;
81+
const getImageUrl = (
82+
attachment: Attachment,
83+
hasPreview?: boolean
84+
): string => {
85+
return `${API_URL}v2/reports/${reportId}/bugs/${bugId}/attachments/${
86+
attachment.id
87+
}/content/${hasPreview ? "preview" : ""}`;
8388
};
8489

8590
return (
@@ -104,7 +109,7 @@ function FilePreview({
104109
>
105110
{isImageFile && attachment.hasPreview ? (
106111
<img
107-
src={getPreviewUrl(attachment)}
112+
src={getImageUrl(attachment, true)}
108113
alt={attachment.fileName}
109114
className="w-4 h-4 object-cover rounded"
110115
/>
@@ -139,7 +144,7 @@ function FilePreview({
139144
<div className="modal-box relative w-11/12 max-w-3xl">
140145
{isImage(attachments[activeIndex].fileName) ? (
141146
<img
142-
src={getPreviewUrl(attachments[activeIndex])}
147+
src={getImageUrl(attachments[activeIndex])}
143148
alt={attachments[activeIndex].fileName}
144149
className="w-full h-full object-cover"
145150
/>

0 commit comments

Comments
 (0)