-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20885e8
commit 8823bf5
Showing
6 changed files
with
92 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { Header } from "./Layout/Header" | ||
export { Footer } from "./Layout/Footer" | ||
export { ProductCard } from "./Elements/ProductCard" | ||
export { ProductCard } from "./Elements/ProductCard" | ||
export { Rating } from "./Elements/Rating"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useEffect, useState } from "react" | ||
import { useParams } from "react-router-dom"; | ||
import { Rating } from "../components"; | ||
|
||
export const ProductDetail = () => { | ||
const [product, setProduct] = useState({}); | ||
const { id } = useParams(); | ||
|
||
useEffect(() => { | ||
async function fetchProducts(){ | ||
const response = await fetch(`http://localhost:8000/products/${id}`); | ||
const data = await response.json() | ||
setProduct(data); | ||
} | ||
fetchProducts(); | ||
}, [id]); | ||
|
||
return ( | ||
<main> | ||
<section> | ||
<h1 className="mt-10 mb-5 text-4xl text-center font-bold text-gray-900 dark:text-slate-200">{product.brand} {product.model}</h1> | ||
<div className="flex flex-wrap justify-around"> | ||
<div className="max-w-xl my-3"> | ||
<img className="rounded" src={product.poster} alt="" /> | ||
</div> | ||
<div className="max-w-xl my-3"> | ||
<p className="text-3xl font-bold text-gray-900 dark:text-slate-200"> | ||
<span className="mr-1">$</span> | ||
<span className="">{product.price}</span> | ||
</p> | ||
<p className="my-3"> | ||
<span> | ||
<Rating rating={product.rating} /> | ||
</span> | ||
</p> | ||
<p className="my-4 select-none"> | ||
{ product.best_seller && <span className="font-semibold text-amber-500 border bg-amber-50 rounded-lg px-3 py-1 mr-2">BEST SELLER</span> } | ||
{ product.in_stock && <span className="font-semibold text-emerald-600 border bg-slate-100 rounded-lg px-3 py-1 mr-2">INSTOCK</span> } | ||
{ !product.in_stock && <span className="font-semibold text-rose-700 border bg-slate-100 rounded-lg px-3 py-1 mr-2">OUT OF STOCK</span> } | ||
</p> | ||
<p className="my-3"> | ||
<button className={`inline-flex items-center py-2 px-5 text-lg font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800`}>Add To Cart <i className="ml-1 bi bi-plus-lg"></i></button> | ||
</p> | ||
<p className="text-lg text-gray-900 dark:text-slate-200"> | ||
{product.long_description} | ||
</p> | ||
</div> | ||
</div> | ||
</section> | ||
</main> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { DashboardPage } from "./Dashboard/DashboardPage"; | ||
export { CartPage } from "./Cart/CartPage"; | ||
export { HomePage } from "./Home/HomePage"; | ||
export { ProductDetail } from "./ProductDetail"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters