From 0b4266be175f0486a477d31a2fd84a1561f3f3ba Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Mon, 21 Feb 2022 18:22:07 +0330 Subject: [PATCH] Tags Done --- src/view/addProduct/Sidebar/index.js | 2 ++ src/view/addProduct/components/grade.js | 2 +- src/view/addProduct/components/tags.js | 48 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/view/addProduct/components/tags.js diff --git a/src/view/addProduct/Sidebar/index.js b/src/view/addProduct/Sidebar/index.js index c64e8fa..3497c32 100644 --- a/src/view/addProduct/Sidebar/index.js +++ b/src/view/addProduct/Sidebar/index.js @@ -1,5 +1,6 @@ import React from "react"; import Grades from "../components/grade"; +import TagsInput from "../components/tags"; const SideAP = () => { @@ -20,6 +21,7 @@ const SideAP = () => { + ) } diff --git a/src/view/addProduct/components/grade.js b/src/view/addProduct/components/grade.js index bc865d5..06f2c33 100644 --- a/src/view/addProduct/components/grade.js +++ b/src/view/addProduct/components/grade.js @@ -20,7 +20,7 @@ const Grades = () => { inputs.map( (item, index) => (
- +

{item}

) diff --git a/src/view/addProduct/components/tags.js b/src/view/addProduct/components/tags.js new file mode 100644 index 0000000..dc0b99b --- /dev/null +++ b/src/view/addProduct/components/tags.js @@ -0,0 +1,48 @@ +import React, {useState, useEffect} from "react"; + +const TagsInput = () => { + const [tags, setTags] = useState([]); + const [tag, setTag] = useState(null); + const [fakeState, setFakeState] = useState(5); + + useEffect(() => { + if (tag) { + tags.push(tag); + setFakeState(fakeState + 1) + console.log(tags) + } + + }, [tag]); + return( +
+

+ برچسب ها +

+
+ {if(e.key == 'Enter'){ setTag(e.target.value); document.getElementById('tagInput').value = null}}}/> + + +
+
+ { + tags.map( + (item, index) => ( +
+ +

{item}

+

x

+ +
+ ) + ) + } +
+ + +
+ ) +} + +export default TagsInput; \ No newline at end of file