diff --git a/.env.local b/.env.local index ab8770d..0673661 100644 --- a/.env.local +++ b/.env.local @@ -3,4 +3,5 @@ VITE_projectId=practice-bistro-boss-76004 VITE_storageBucket=practice-bistro-boss-76004.appspot.com VITE_messagingSenderId=276896028259 - VITE_appId=1:276896028259:web:85d0b1b451d1627ea24a56 \ No newline at end of file + VITE_appId=1:276896028259:web:85d0b1b451d1627ea24a56 + VITE_IMAGEBB_API_KEY=dee147da6fa286e04281ed02aadad7bf \ No newline at end of file diff --git a/src/Componenets/Dashboard/AddItem/AddItem.jsx b/src/Componenets/Dashboard/AddItem/AddItem.jsx index 22ffae8..dbcea11 100644 --- a/src/Componenets/Dashboard/AddItem/AddItem.jsx +++ b/src/Componenets/Dashboard/AddItem/AddItem.jsx @@ -1,9 +1,83 @@ +import toast from "react-hot-toast"; +import useAxiosSecure from "../../Hooks/useAxiosSecure"; +import { imageUpload } from "../../Hooks/useImage"; +import SectionTitle from "../../SectionTiltle/SectionTitle/SectionTitle"; const AddItem = () => { + const axiosSecure = useAxiosSecure(); + const handleAddItems = async event => { + event.preventDefault(); + const form = event.target; + const name = form.name.value; + const category = form.category.value; + const price = parseFloat(form.price.value); + const recipe = form.recipe.value; + const image = form.image.files[0] + const imageData = await imageUpload(image) + console.log(imageData); + console.log(name, category, price, image); + const menuItem = { + name, + category, + price, + recipe, + image :imageData?.data?.display_url + } + axiosSecure.post("/menu" , menuItem) + .then(res => { + console.log(res.data); + if(res.data.insertedId){ + toast.success("Successfully Add Item") + } + }) + } + return (