From a0261c01710044a9dd84cdabf41a9472cd619f08 Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Wed, 6 Apr 2022 14:19:48 +0430 Subject: [PATCH] Deleting the First Image Works --- src/assets/img/trash.svg | 4 ++ src/components/input/signUpInput.js | 56 +++++++++++------------ src/view/addProduct/components/addPic.js | 14 +++++- src/view/addProduct/components/metrics.js | 5 +- 4 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 src/assets/img/trash.svg diff --git a/src/assets/img/trash.svg b/src/assets/img/trash.svg new file mode 100644 index 0000000..77e363c --- /dev/null +++ b/src/assets/img/trash.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/input/signUpInput.js b/src/components/input/signUpInput.js index eacb557..cbe8f13 100644 --- a/src/components/input/signUpInput.js +++ b/src/components/input/signUpInput.js @@ -22,35 +22,35 @@ const inputStatusHandler = (value, focus, status, primary, success, danger) => { } }; -export default function Input(props) { +export default function Input({ backgroundColor, + lang, + theme, + inputMode, + label, + status, + maxLength, + message, + onChange, + align, + name, + regex, + direction, + width, + + title, + borderType, + gapSize, + id, + type, + className, + style, + bg}) { const [value, setValue] = useState(""); const [focusToggle, setFocusToggle] = useState(false); - const { - backgroundColor, - lang, - theme, - inputMode, - label, - status, - maxLength, - message, - onChange, - align, - name, - regex, - direction, - width, - - title, - borderType, - gapSize, - id, - type, - className, - style, - bg - } = props; + // const { + + // } = props; const focusHandler = (id) => { let inputs = document.querySelectorAll(".Login-box-form-item"); @@ -106,12 +106,12 @@ const blurHandler = (id) => { {label} */} { 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 = () => {
{ - imageUrl.length > 0 &&
+ imageUrl.length > 0 &&
setDeleteFirst(true)} + onMouseLeave={() => setDeleteFirst(false)}> + { + deleteFirst &&
+ { + let newImageArray = imageUrl.filter((itm, index) => index !== 0); + setImageUrl(newImageArray) + }}/> +
+ } {/*

تصویر شاخص

*/}
} diff --git a/src/view/addProduct/components/metrics.js b/src/view/addProduct/components/metrics.js index afa4c39..5fc5c1b 100644 --- a/src/view/addProduct/components/metrics.js +++ b/src/view/addProduct/components/metrics.js @@ -1,4 +1,5 @@ import React, {useState, useEffect} from "react"; +import Input from "../../../components/input/signUpInput"; const Metrics = () => { const inputs = [ @@ -17,7 +18,9 @@ const Metrics = () => { inputs.map( (item, index) => (
- + {/* 7 + */} +
) )