Skip to content

Commit 6347499

Browse files
committed
update meal
1 parent b2e7810 commit 6347499

File tree

9 files changed

+260
-21
lines changed

9 files changed

+260
-21
lines changed

.firebase/hosting.ZGlzdA.cache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
badge.json,1718017793881,33511d102658248ca81efcd2eb75c54df143d937f55f19fd056c08b89eb95964
2+
index.html,1718161162661,699062a3ca34c216c6084cf084fc612c1a9197d633e2cd7297d68d86a557d998
3+
assets/index-buGaNZFf.css,1718161162685,107ffffb4a5b1d1ee7254f3987c9a188f68a00beab4c91803beb13017cc3bd5b
4+
blog.json,1717270760062,103377ce7d408e1aeaf3990cc018cb6ecfc3d07ab2a559be75825a998cb0a9f5
5+
assets/logos-CeWA07j-.png,1718161162655,0436dce91e3283a5e1b50bb804b3d0ca56a24830527b2343d1daf9bb2cabfaef
6+
vite.svg,1711360300018,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a
7+
logos.png,1717217521625,0436dce91e3283a5e1b50bb804b3d0ca56a24830527b2343d1daf9bb2cabfaef
8+
assets/index-D84-5Qn4.js,1718161162664,5d471354bfa13b51486c1d5633f8e098d155797c86bfe18b4dd555047f48e11c
9+
assets/404-DAsD6jbh.gif,1718161162665,f1c39464ff074bb7cc4f0bf6f6149b0702a2db1a767f1fd842cc822608c291a1

.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "sms-clint"
4+
}
5+
}

firebase.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"hosting": {
3+
"public": "dist",
4+
"ignore": [
5+
"firebase.json",
6+
"**/.*",
7+
"**/node_modules/**"
8+
],
9+
"rewrites": [
10+
{
11+
"source": "**",
12+
"destination": "/index.html"
13+
}
14+
]
15+
}
16+
}

public/blog.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
[
22
{
33
"title": "Exploring the Hidden Gems of the Pacific Northwest",
4-
"image": "https://i.ibb.co/KVr2ZMK/l2.jpg",
4+
"image": "https://i.ibb.co/hVPHv3b/thai-beef-salad-1980x1320-118406-1.jpg",
55
"short_description": "Discover the lush forests, breathtaking coastlines, and charming small towns that make the Pacific Northwest a traveler's paradise. Join us as we uncover the region's best-kept secrets and hidden gems."
66
},
77
{
88
"title": "The Rise of Sustainable Fashion: A Greener Future",
9-
"image": "https://i.ibb.co/41GSy4w/l1.jpg",
9+
"image": "https://i.ibb.co/4F0hLKk/impossible-quiche-24036-1.jpg",
1010
"short_description": "Sustainable fashion is more than just a trend; it's a movement towards a more ethical and eco-friendly industry. Learn about the innovative brands and practices paving the way for a greener future in fashion."
1111
},
1212
{
1313
"title": "Mastering the Art of Homemade Pasta",
14-
"image": "https://i.ibb.co/mqwS3hD/b1.jpg",
14+
"image": "https://i.ibb.co/GPpLSLx/images-5.jpg",
1515
"short_description": "There's nothing quite like the taste of fresh, homemade pasta. Our step-by-step guide will walk you through the process of making pasta from scratch, with tips and tricks to perfect your technique."
1616
},
1717
{
1818
"title": "A Beginner's Guide to Meditation: Finding Inner Peace",
19-
"image": "https://i.ibb.co/VqwHbds/d1.jpg",
19+
"image": "https://i.ibb.co/qY7Ck03/classic-shepherds-pie-1980x1320-118395-1.jpg",
2020
"short_description": "Meditation can be a powerful tool for reducing stress and improving mental clarity. This beginner's guide will introduce you to the basics of meditation and help you start your journey toward inner peace and mindfulness."
2121
},
2222
{
2323
"title": "The Ultimate Guide to Urban Gardening",
24-
"image": "https://i.ibb.co/WfqvCKz/b2.jpg",
24+
"image": "https://i.ibb.co/B6GJZCW/images-9.jpg",
2525
"short_description": "No backyard? No problem! Urban gardening is all about growing your own greens in small spaces. From container gardens to vertical gardening, we'll show you how to turn any urban area into a thriving garden."
2626
}
2727
]

src/Dashbord/AdminPages/Addmeal.jsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,6 @@ const Addmeal = () => {
125125
/>
126126
</div>
127127

128-
{/* <div>
129-
<label> reviewscount</label>
130-
<input
131-
type="number"
132-
className=" input input-disabled w-full"
133-
name=" review"
134-
defaultValue={0}
135-
disabled
136-
{...register("reviewscount")}
137-
id=""
138-
required
139-
/>
140-
</div> */}
141-
142128
<div>
143129
<label>ingredients</label>
144130
<div className="grid md:grid-cols-2 gap-2">

src/Dashbord/AdminPages/AllMeals.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const AllMeals = () => {
9090
<button onClick={() => handeldelet(meal._id)} className="btn">
9191
<MdDelete></MdDelete>{" "}
9292
</button>
93-
<Link className="btn">
93+
<Link to={`/dashbord/updatemeal/${meal._id}`} className="btn">
9494
<FaEdit />{" "}
9595
</Link>
9696
</td>
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
import { useForm } from "react-hook-form";
2+
import moment from "moment";
3+
import useAxiosSecqur from "../../Hooks/useAxiosSecqur";
4+
import useAxiosCommon from "../../Hooks/useAxiosCommon";
5+
import { useParams } from "react-router-dom";
6+
import { useQuery } from "@tanstack/react-query";
7+
import LogingSpiner from "../../Sheare/LogingSpiner";
8+
import toast from "react-hot-toast";
9+
const imgHosting_api = `https://api.imgbb.com/1/upload?key=${
10+
import.meta.env.VITE_IMGBB_key
11+
}`;
12+
13+
const Updatemeaks = () => {
14+
const axiosSec = useAxiosSecqur();
15+
const axiospub = useAxiosCommon();
16+
const { id } = useParams();
17+
const {
18+
data: meal = [],
19+
isLoading,
20+
refetch,
21+
} = useQuery({
22+
queryKey: ["meal", id],
23+
queryFn: async () => {
24+
const { data } = await axiospub.get(`/meal/${id}`);
25+
return data;
26+
},
27+
});
28+
29+
const { register, handleSubmit } = useForm();
30+
31+
const onSubmit = async (data) => {
32+
const {
33+
title,
34+
catagory,
35+
price,
36+
rating,
37+
likes,
38+
itm1,
39+
itm2,
40+
itm3,
41+
itm4,
42+
image,
43+
description,
44+
} = data;
45+
46+
const imageFile = { image: data.image[0] };
47+
const res = await axiospub.post(imgHosting_api, imageFile, {
48+
headers: {
49+
"Content-Type": "multipart/form-data",
50+
},
51+
});
52+
53+
if (res.data.success) {
54+
const mealItem = {
55+
title,
56+
catagory,
57+
price: parseFloat(price),
58+
rating: parseFloat(rating),
59+
likes: parseFloat(likes),
60+
ingredients: { itm1, itm2, itm3, itm4 },
61+
image: res.data.data.display_url,
62+
description,
63+
post_time: moment().format("LLLL"),
64+
};
65+
// const menuRes = await axiosSec.put(`/updatemeals/${id}`, mealItem);
66+
// console.log(mealItem);
67+
68+
refetch();
69+
}
70+
};
71+
72+
if (isLoading) return <LogingSpiner></LogingSpiner>;
73+
return (
74+
<div>
75+
<div>
76+
<h2 className="text-3xl font-bold my-5 text-center">Add Meal</h2>
77+
<form onSubmit={handleSubmit(onSubmit)}>
78+
<div className="grid md:grid-cols-2 gap-3">
79+
<div>
80+
<label>Meal Title</label>
81+
<input
82+
type="text"
83+
className=" input input-disabled w-full"
84+
name=""
85+
defaultValue={meal.title}
86+
{...register("title")}
87+
id=""
88+
/>
89+
</div>
90+
91+
<div>
92+
<label>Catagory</label>
93+
<select
94+
className=" input input-disabled w-full"
95+
id="meal"
96+
name="catagory"
97+
defaultValue={meal.catagory}
98+
{...register("catagory")}
99+
>
100+
<option value="breakfast">Breakfast</option>
101+
<option value="lunch">Lunch</option>
102+
<option value="dinner">Dinner</option>
103+
</select>
104+
</div>
105+
106+
<div>
107+
<label>Meal Price</label>
108+
<input
109+
type="number"
110+
className=" input input-disabled w-full"
111+
name="price"
112+
defaultValue={meal.price}
113+
{...register("price")}
114+
id=""
115+
/>
116+
</div>
117+
118+
<div>
119+
<label>Meal Rating</label>
120+
<input
121+
type="number"
122+
className=" input input-disabled w-full"
123+
name="rating"
124+
defaultValue={meal.rating}
125+
{...register("rating")}
126+
id=""
127+
/>
128+
</div>
129+
130+
<div>
131+
<label>Meal likes</label>
132+
<input
133+
type="number"
134+
className=" input input-disabled w-full"
135+
name=" likes"
136+
defaultValue={meal.likes}
137+
{...register("likes")}
138+
id=""
139+
/>
140+
</div>
141+
142+
<div>
143+
<label>ingredients</label>
144+
<div className="grid md:grid-cols-2 gap-2">
145+
<input
146+
type="text"
147+
className=" input input-disabled w-full"
148+
name=" itm1"
149+
defaultValue={meal.ingredients.itm1}
150+
{...register("itm1")}
151+
id=""
152+
required
153+
/>
154+
<input
155+
type="text"
156+
className=" input input-disabled w-full"
157+
name=" itm2"
158+
defaultValue={meal.ingredients.itm2}
159+
{...register("itm2")}
160+
id=""
161+
/>
162+
<input
163+
type="text"
164+
className=" input input-disabled w-full"
165+
defaultValue={meal.ingredients.itm3}
166+
name=" itm3"
167+
{...register("itm3")}
168+
id=""
169+
/>
170+
<input
171+
type="text"
172+
className=" input input-disabled w-full"
173+
defaultValue={meal.ingredients.itm4}
174+
name=" itm4"
175+
{...register("itm4")}
176+
id=""
177+
/>
178+
</div>
179+
</div>
180+
181+
<div>
182+
<img className="w-14 h-14" src={meal.image} alt="" />
183+
<input
184+
type="file"
185+
className="file-input file-input-bordered file-input-secondary w-full max-w-xs"
186+
{...register("image")}
187+
/>
188+
</div>
189+
</div>
190+
<div>
191+
<label>description </label>
192+
<textarea
193+
className=" input input-disabled w-full"
194+
name=""
195+
{...register("description")}
196+
defaultValue={meal.description}
197+
id=""
198+
cols="30"
199+
rows="50"
200+
></textarea>
201+
</div>
202+
<input
203+
className=" btn btn-primary w-full"
204+
type="submit"
205+
disabled
206+
value="Add Meal"
207+
/>
208+
</form>
209+
</div>
210+
</div>
211+
);
212+
};
213+
214+
export default Updatemeaks;

src/Pages/Home/UpcomMeal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const UpcomMeal = () => {
9292
</p>
9393
</div>
9494
<h2 className="text-2xl font-bold">{items?.title} </h2>
95-
<p>{items?.description} </p>
95+
<p>{items?.description.slice(0, 50)}.... </p>
9696
</div>
9797
))}
9898
</div>

src/Route/Route.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import AllReviews from "../Dashbord/AdminPages/AllReviews";
1313
import Allusers from "../Dashbord/AdminPages/Allusers";
1414
import ServicMeal from "../Dashbord/AdminPages/ServicMeal";
1515
import Upcommingmeal from "../Dashbord/AdminPages/Upcommingmeal";
16+
import Updatemeaks from "../Dashbord/AdminPages/Updatemeaks";
1617
import ViewDeteal from "../Dashbord/AdminPages/ViewDeteal";
1718
import MyReview from "../Dashbord/MyReview";
1819
import Payment from "../Dashbord/Payment";
@@ -123,6 +124,14 @@ const router = createBrowserRouter([
123124
</Adminrouter>
124125
),
125126
},
127+
{
128+
path: "updatemeal/:id",
129+
element: (
130+
<Adminrouter>
131+
<Updatemeaks></Updatemeaks>
132+
</Adminrouter>
133+
),
134+
},
126135
{
127136
path: "upcommingmeal",
128137
element: (

0 commit comments

Comments
 (0)