|
|
|
@ -1,9 +1,11 @@ |
|
|
|
|
import React, {useState, useEffect} from "react"; |
|
|
|
|
import trashIcon from '../../../assets/img/trash.svg'; |
|
|
|
|
|
|
|
|
|
const AddPic = () => { |
|
|
|
|
const [imageUrl, setImageUrl] = useState([]); |
|
|
|
|
const [selectedImage, setSelectedImage] = useState(null); |
|
|
|
|
const [fakeState, setFakeState] = useState(5); |
|
|
|
|
const [deleteFirst, setDeleteFirst] = useState(false) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (selectedImage) { |
|
|
|
@ -21,8 +23,18 @@ const AddPic = () => { |
|
|
|
|
<div className="w-full px-4 flex items-center"> |
|
|
|
|
<div> |
|
|
|
|
{ |
|
|
|
|
imageUrl.length > 0 && <div className="w-32 h-32 rounded-xl flex flex-col items-center"> |
|
|
|
|
imageUrl.length > 0 && <div className="w-32 h-32 rounded-xl flex flex-col items-center" |
|
|
|
|
onMouseOver={() => setDeleteFirst(true)} |
|
|
|
|
onMouseLeave={() => setDeleteFirst(false)}> |
|
|
|
|
<img src={imageUrl[0]} className="h-full w-32 rounded-lg" /> |
|
|
|
|
{ |
|
|
|
|
deleteFirst && <div className="absolute w-32 z-10 h-32 rounded-lg bg-black bg-opacity-50 flex items-center justify-center"> |
|
|
|
|
<img src={trashIcon} className="w-1/3 h-1/3 cursor-pointer" onClick={() => { |
|
|
|
|
let newImageArray = imageUrl.filter((itm, index) => index !== 0); |
|
|
|
|
setImageUrl(newImageArray) |
|
|
|
|
}}/> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
{/* <p className="">تصویر شاخص</p> */} |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|