Skip to content

Commit 02c5637

Browse files
authored
Merge pull request #72 from ModusCreateOrg/ADE-60
feat: Add cancel notice functionality in UploadModal component
2 parents e9d9342 + 70aecbc commit 02c5637

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

frontend/src/common/components/Upload/UploadModal.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,32 @@
357357
--background: rgba(0, 0, 0, 0.1);
358358
--progress-background: var(--ion-color-primary);
359359
}
360+
361+
// Fixing the cancel notice styles to match the design exactly
362+
&__cancel-notice {
363+
display: flex;
364+
align-items: center;
365+
border-radius: 4px;
366+
background: rgba(41, 69, 196, 0.5); // Darker blue background matching design
367+
padding: 12px 16px;
368+
margin: 16px 0;
369+
width: 100%;
370+
border: 1px solid #FF9cb4; // Border matching the icon color
371+
text-align: left;
372+
373+
span {
374+
color: white;
375+
font-size: 14px;
376+
font-weight: 400;
377+
}
378+
}
379+
380+
&__cancel-notice-icon {
381+
color: #FF9cb4; // Using the danger color
382+
margin-right: 12px;
383+
display: flex;
384+
align-items: center;
385+
justify-content: center;
386+
font-size: 18px;
387+
}
360388
}

frontend/src/common/components/Upload/UploadModal.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const UploadModal = ({ isOpen, onClose, onUploadComplete }: UploadModalProps): J
2828
const fileInputRef = useRef<HTMLInputElement>(null);
2929
// Track the upload result to use when the user closes the success screen
3030
const [uploadResult, setUploadResult] = useState<MedicalReport | null>(null);
31+
// Track when to show the upload cancelled notice
32+
const [showCancelNotice, setShowCancelNotice] = useState(false);
3133

3234
const {
3335
file,
@@ -49,6 +51,8 @@ const UploadModal = ({ isOpen, onClose, onUploadComplete }: UploadModalProps): J
4951
// Effect to automatically start upload when a file is selected and validated
5052
useEffect(() => {
5153
if (file && status === UploadStatus.IDLE) {
54+
// When starting a new upload, hide the cancel notice if it's showing
55+
setShowCancelNotice(false);
5256
uploadFile();
5357
}
5458
}, [file, status, uploadFile]);
@@ -71,6 +75,8 @@ const UploadModal = ({ isOpen, onClose, onUploadComplete }: UploadModalProps): J
7175
const handleCancel = () => {
7276
if (status === UploadStatus.UPLOADING) {
7377
cancelUpload?.();
78+
// Show the cancel notice when a user explicitly cancels an upload in progress
79+
setShowCancelNotice(true);
7480
} else {
7581
reset();
7682
setUploadResult(null);
@@ -87,6 +93,7 @@ const UploadModal = ({ isOpen, onClose, onUploadComplete }: UploadModalProps): J
8793
// Reset state
8894
reset();
8995
setUploadResult(null);
96+
setShowCancelNotice(false);
9097

9198
// Close modal
9299
onClose();
@@ -107,7 +114,18 @@ const UploadModal = ({ isOpen, onClose, onUploadComplete }: UploadModalProps): J
107114
{t('upload.imageSizeLimit')} / {t('upload.pdfSizeLimit')}
108115
</p>
109116
</div>
110-
{error &&
117+
118+
{/* Show cancel notice */}
119+
{showCancelNotice && (
120+
<div className="upload-modal__cancel-notice">
121+
<div className="upload-modal__cancel-notice-icon">
122+
<FontAwesomeIcon icon={faCircleXmark} />
123+
</div>
124+
<span>Upload cancelled.</span>
125+
</div>
126+
)}
127+
128+
{error && !showCancelNotice &&
111129
<IonItem className='upload-modal__error-message'>
112130
<div className='upload-modal__error-icon' slot='start'>
113131
<FontAwesomeIcon icon={faCircleXmark} aria-hidden="true"/>

0 commit comments

Comments
 (0)