Skip to content

Commit ef8694f

Browse files
committed
view detail page
1 parent f2da487 commit ef8694f

File tree

7 files changed

+105
-4
lines changed

7 files changed

+105
-4
lines changed

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"firebase": "^10.12.2",
1717
"localforage": "^1.10.0",
1818
"match-sorter": "^6.3.4",
19+
"moment": "^2.30.1",
1920
"react": "^18.2.0",
2021
"react-dom": "^18.2.0",
2122
"react-hook-form": "^7.51.5",

src/Dashbord/AdminPages/AllMeals.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const AllMeals = () => {
4949
</Link>
5050
</td>
5151
<td>
52-
<Link>
52+
<Link to={`/dashbord/vievdetial/${meal._id}`}>
5353
<button className="btn btn-outline btn-primary">
5454
View Deatils
5555
</button>

src/Dashbord/AdminPages/Upcommingmeal.jsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { useState } from "react";
3+
import toast from "react-hot-toast";
4+
import Swal from "sweetalert2";
35
import useAxiosCommon from "../../Hooks/useAxiosCommon";
6+
import useAxiosSecqur from "../../Hooks/useAxiosSecqur";
47
import LogingSpiner from "../../Sheare/LogingSpiner";
58
import AddUpcoming from "./AddUpcoming";
69

710
const Upcommingmeal = () => {
811
let [isOpen, setIsOpen] = useState(false);
912
const axioscommon = useAxiosCommon();
10-
const { data: upcommingmeals = [], isLoading } = useQuery({
13+
const axiosSec = useAxiosSecqur();
14+
const {
15+
data: upcommingmeals = [],
16+
isLoading,
17+
refetch,
18+
} = useQuery({
1119
queryKey: ["upcommingmeals"],
1220
queryFn: async () => {
1321
const { data } = await axioscommon.get("/upcommingmeals");
@@ -16,7 +24,36 @@ const Upcommingmeal = () => {
1624
});
1725

1826
const handelPublic = (upcom) => {
19-
console.log(upcom);
27+
const items = {
28+
title: upcom?.title,
29+
catagory: upcom?.catagory,
30+
price: parseFloat(upcom?.price),
31+
rating: parseFloat(upcom?.rating),
32+
likes: parseFloat(upcom?.likes),
33+
ingredients: upcom?.ingredients,
34+
description: upcom?.description,
35+
admin_name: upcom?.admin_name,
36+
email: upcom?.email,
37+
};
38+
39+
Swal.fire({
40+
title: "Are you sure?",
41+
text: "you punlish thid item",
42+
icon: "warning",
43+
showCancelButton: true,
44+
confirmButtonColor: "#3085d6",
45+
cancelButtonColor: "#d33",
46+
confirmButtonText: "Yes, delete it!",
47+
}).then(async (result) => {
48+
if (result.isConfirmed) {
49+
const res = await axiosSec.delete(`/upcommingmeals/${upcom?._id}`);
50+
const posts = await axiosSec.post("/addmeals", items);
51+
if (posts.data.insertedId) {
52+
toast.success("publish successfully !");
53+
}
54+
}
55+
refetch();
56+
});
2057
};
2158

2259
if (isLoading) return <LogingSpiner></LogingSpiner>;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { useQuery } from "@tanstack/react-query";
2+
import { useParams } from "react-router-dom";
3+
import useAxiosCommon from "../../Hooks/useAxiosCommon";
4+
import LogingSpiner from "../../Sheare/LogingSpiner";
5+
6+
const ViewDeteal = () => {
7+
const { id } = useParams();
8+
const axiosSeequr = useAxiosCommon();
9+
const { data: meal = [], isLoading } = useQuery({
10+
queryKey: ["meal", id],
11+
queryFn: async () => {
12+
const { data } = await axiosSeequr.get(`/meal/${id}`);
13+
return data;
14+
},
15+
});
16+
console.log(meal);
17+
if (isLoading) return <LogingSpiner></LogingSpiner>;
18+
return (
19+
<div className=" flex justify-center">
20+
<div className=" md:w-2/3 mx-auto bg-slate-300 rounded-xl shadow-xl p-7">
21+
<div className="md:flex gap-3">
22+
<div className=" flex-1 space-y-3">
23+
<h2 className="text-2xl font-bold">{meal.title} </h2>
24+
<img className=" w-full" src={meal.image} alt="" />
25+
<div className=" flex justify-between">
26+
<p>Likes : {meal.likes} </p>
27+
<p>Price : ${meal.price} </p>
28+
</div>
29+
</div>
30+
<div className=" flex-1 space-y-3 border-1 p-2">
31+
<p> {meal.post_time}</p>
32+
<p> {meal.description}</p>
33+
<p>rating: {meal.rating}</p>
34+
<p>
35+
ingredients:
36+
{meal.ingredients.map((itm, inx) => (
37+
<li key={inx}>{itm} </li>
38+
))}
39+
</p>
40+
<p>Proviser: {meal.admin_name}</p>
41+
<p>Email: {meal.email}</p>
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
);
47+
};
48+
49+
export default ViewDeteal;

src/Route/Route.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Addmeal from "../Dashbord/AdminPages/Addmeal";
88
import AllMeals from "../Dashbord/AdminPages/AllMeals";
99
import Allusers from "../Dashbord/AdminPages/Allusers";
1010
import Upcommingmeal from "../Dashbord/AdminPages/Upcommingmeal";
11+
import ViewDeteal from "../Dashbord/AdminPages/ViewDeteal";
1112
import UserProfil from "../Dashbord/UserProfil";
1213
import ErrorPage from "../Pages/ErrorPage";
1314
import Dashboard from "../Root/Dashboard";
@@ -71,6 +72,10 @@ const router = createBrowserRouter([
7172
path: "allmeals",
7273
element: <AllMeals></AllMeals>,
7374
},
75+
{
76+
path: "vievdetial/:id",
77+
element: <ViewDeteal></ViewDeteal>,
78+
},
7479
],
7580
},
7681
]);

src/Sheare/MealsDetails.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MealsDetails = () => {
1818
return (
1919
<div>
2020
<h1 className="text-3xl md:text-5xl font-bold">{title} </h1>
21-
<img src={image} alt="" />
21+
<img className=" w-[500px]" src={image} alt="" />
2222
</div>
2323
);
2424
};

0 commit comments

Comments
 (0)