From bcb8a7579bcfd978fd2089e2e4d993585eba6ab9 Mon Sep 17 00:00:00 2001 From: anwarjunaidkm Date: Tue, 7 Feb 2023 15:05:58 +0530 Subject: [PATCH] add categoty api done --- src/components/dashbords/admin/AddCategory.js | 41 ++++++++++++++----- src/components/login/Login.js | 1 + src/store/admin/AdminSlice.js | 18 ++++++-- src/store/auth/AuthSlice.js | 4 +- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/components/dashbords/admin/AddCategory.js b/src/components/dashbords/admin/AddCategory.js index 31f6d83..6d2354c 100644 --- a/src/components/dashbords/admin/AddCategory.js +++ b/src/components/dashbords/admin/AddCategory.js @@ -7,22 +7,39 @@ import { AddCategoryApi } from '../../../store/admin/AdminSlice'; function AddCategory() { const dispatch = useDispatch() - const [Input,setInput] =useState() + const [inputValue, setInputValue] = useState(""); +const [imageFile, setImageFile] = useState(null); - console.log("add cstegory state=====",Input); const categoryHandle= (e) =>{ e.preventDefault() - dispatch(AddCategoryApi(Input)) + const data = { + inputValue, + imageFile, + }; + dispatch(AddCategoryApi(data)) } - const handle =(e)=>{ - setInput({ - ...Input, - [e.target.name] : e.target.value - }); - } + const handleInputChange = (e) => { + setInputValue( + + e.target.value); + }; + + const handleImageChange = (e) => { + setImageFile( + + e.target.files[0]); + }; + + // const handle =(e)=>{ + // setInput({ + // ...Input, + // [e.target.name] : e.target.value + // }); + + // } @@ -49,7 +66,8 @@ function AddCategory() { }} - onChange={(e)=>handle(e)} + // onChange={(e)=>handle(e)} + onChange={handleInputChange} /> handle(e)} + // onChange={(e)=>handle(e)} + onChange={handleImageChange} /> {/*