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 (
- This Is Item + +
+
+
+
+ + +
+
+
+ + +
+
+ + +
+ +
+ + +
+ +
+
+ + +
+
); }; diff --git a/src/Componenets/Dashboard/Dashboard/Dashboard.jsx b/src/Componenets/Dashboard/Dashboard/Dashboard.jsx index f398583..4f80e97 100644 --- a/src/Componenets/Dashboard/Dashboard/Dashboard.jsx +++ b/src/Componenets/Dashboard/Dashboard/Dashboard.jsx @@ -115,6 +115,13 @@ const Dashboard = () => {
  • isPending ? "pending" : isActive ? "bg-orange-500 p-3 text-white font-bold" : "hover:bg-orange-500 hover:text-white p-3 font-bold" + } to="/ourShop"> + + Our Shop +
  • +
  • + + isPending ? "pending" : isActive ? "bg-orange-500 p-3 text-white font-bold" : "hover:bg-orange-500 hover:text-white p-3 font-bold" } to="/contactUs"> Contact diff --git a/src/Componenets/Hooks/useImage.jsx b/src/Componenets/Hooks/useImage.jsx new file mode 100644 index 0000000..dd03619 --- /dev/null +++ b/src/Componenets/Hooks/useImage.jsx @@ -0,0 +1,11 @@ +import axios from "axios" + + +export const imageUpload = async photo => { + const formData = new FormData() + formData.append("image" , photo) + const {data} = await axios.post(`https://api.imgbb.com/1/upload?key=${import.meta.env.VITE_IMAGEBB_API_KEY}`, + +formData ) +return data +} \ No newline at end of file