Skip to content

Commit

Permalink
refactor: minor naming changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iSCJT authored and benfurber committed Sep 2, 2024
1 parent 254a39b commit 67fe0f1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/common/Form/ImageInput/ImageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,34 @@ export const ImageInput = (props: IProps) => {
const prevPropsValue = useRef<IInputValue | IMultipleInputValue>()

const { dataTestId, imageDisplaySx, onFilesChange, value } = props

const [inputFiles, setInputFiles] = useState<File[]>([])
const [convertedFiles, setConvertedFiles] = useState<IConvertedFileMeta[]>([])
const [presentFiles, setPresentFiles] = useState<IMultipleInputValue>(
getPresentFiles(value),
)
const [imageCorrupt, setImageCorrupt] = useState<boolean>(false)
const [isImageCorrupt, setIsImageCorrupt] = useState(false)
const [showErrorModal, setShowErrorModal] = useState(false)

const onDrop = async (selectedImage) => {
try {
await imageValid(selectedImage[0])
setImageCorrupt(false)
setIsImageCorrupt(false)

try {
const compressedImage = await compressImage(selectedImage[0])
selectedImage[0] = compressedImage
} catch (compressionError) {
window.console.error(
// eslint-disable-next-line no-console
console.error(
'Image compression failed, using original image: ',
compressionError,
)
}

setInputFiles(selectedImage)
} catch (validationError) {
setImageCorrupt(true)
setIsImageCorrupt(true)
setShowErrorModal(true)
}
}
Expand Down Expand Up @@ -135,7 +136,7 @@ export const ImageInput = (props: IProps) => {
isOpen={showErrorModal}
onDidDismiss={() => setShowErrorModal(false)}
>
{imageCorrupt && (
{isImageCorrupt && (
<Flex
mt={[1, 1, 1]}
sx={{
Expand Down

0 comments on commit 67fe0f1

Please sign in to comment.