Skip to content

Commit

Permalink
Quick addition to error msg setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwain-Anderson committed Dec 4, 2024
1 parent ff39907 commit cc871be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/components/EmployeeModal/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Upload = ({ imageChange, existingPhoto }: UploadProps) => {
const [imageURL, setImageURL] = useState(
existingPhoto ? `${existingPhoto}` : ''
);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const inputRef = createRef<HTMLInputElement>();

/* This is for accessibility purposes only */
Expand All @@ -30,8 +31,8 @@ const Upload = ({ imageChange, existingPhoto }: UploadProps) => {
setImageURL(URL.createObjectURL(files[0]));
imageChange(e);
} else {
alert(`Images must be under ${IMAGE_SIZE_LIMIT} MB`); // works but not preferred.
//showToast(`Images must be under ${IMAGE_SIZE_LIMIT} MB`, ToastStatus.ERROR) : The ideal version but does not work.
setErrorMessage(`Images must be under ${IMAGE_SIZE_LIMIT / 1000} KB`);
console.log(errorMessage); // placeholder for MUI chane.
}
}

Expand All @@ -52,7 +53,7 @@ const Upload = ({ imageChange, existingPhoto }: UploadProps) => {
accept="image/png, image/jpeg"
ref={inputRef}
style={{ display: 'none' }}
onChange={(e) => previewImage(e)}
onChange={previewImage}
/>
<label htmlFor="driverPhotoInput" className={styles.uploadText}>
<span
Expand All @@ -63,6 +64,8 @@ const Upload = ({ imageChange, existingPhoto }: UploadProps) => {
>
Upload a picture
</span>


</label>
</div>
);
Expand Down

0 comments on commit cc871be

Please sign in to comment.