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