| // Check if file is type of string or File | // Check if file is type of string or File | ||||
| useEffect(() => { | useEffect(() => { | ||||
| if (props.image) { | if (props.image) { | ||||
| if (typeof props.image === "string") { | if (typeof props.image === "string") { | ||||
| setImage(getImageUrl(props.image, variants.offerCard)); | setImage(getImageUrl(props.image, variants.offerCard)); | ||||
| } else { | } else { | ||||
| // Reads image as both base64 and multipart type | // Reads image as both base64 and multipart type | ||||
| const handleImage = (file) => { | const handleImage = (file) => { | ||||
| if ( | |||||
| file.type !== "image/jpeg" && | |||||
| file.type !== "image/jpg" && | |||||
| file.type !== "image/png" | |||||
| ) | |||||
| return; | |||||
| let reader = new FileReader(); | let reader = new FileReader(); | ||||
| reader.readAsDataURL(file); | reader.readAsDataURL(file); | ||||
| reader.onload = () => { | reader.onload = () => { | ||||
| setImage(""); | setImage(""); | ||||
| setIsEditing(false); | setIsEditing(false); | ||||
| }; | }; | ||||
| return ( | return ( | ||||
| <ImagePickerContainer | <ImagePickerContainer | ||||
| className={props.className} | className={props.className} |