Djordje Mitrovic 3 anni fa
parent
commit
6559e2feaf
1 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 7
    2
      src/components/ImagePicker/ImagePicker.js

+ 7
- 2
src/components/ImagePicker/ImagePicker.js Vedi File

// 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}

Loading…
Annulla
Salva