diff --git a/backend b/backend index 01bc008..d86ee9c 160000 --- a/backend +++ b/backend @@ -1 +1 @@ -Subproject commit 01bc0087cc8a4d3eae81a757a34e19129ee4ed76 +Subproject commit d86ee9ce553a0421211a48bacce8a2ea49b69c5d diff --git a/src/App.jsx b/src/App.jsx index cd29bdf..2ce09d9 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -4,6 +4,7 @@ import Cart from "./Cart"; import Footer from "./Footer"; import Home from "./Home"; import Navbar from "./Navbar"; +import Pizza from "./components/Pizza"; function App() { return ( @@ -13,6 +14,7 @@ function App() { + > ); diff --git a/src/Home.jsx b/src/Home.jsx index 4877eda..3a5e9e2 100644 --- a/src/Home.jsx +++ b/src/Home.jsx @@ -1,11 +1,22 @@ +import { useState } from "react"; import española from "./assets/española.jpg"; import napolitana from "./assets/napolitana.jpg"; import pepperoni from "./assets/pepperoni.jpg"; import CardPizza from "./components/CardPizza"; import Header from "./Header"; -import { pizzas } from "./pizzas"; +import { useEffect } from "react"; const Home = () => { + const [pizzas, setPizzas] = useState([]); + const fetchPizzas = async () => { + const url = "http://localhost:5000/api/pizzas"; + const res = await fetch(url); + const data = await res.json(); + setPizzas(data); + }; + useEffect(() => { + fetchPizzas(); + }, []); return ( diff --git a/src/components/Pizza.jsx b/src/components/Pizza.jsx new file mode 100644 index 0000000..686fa24 --- /dev/null +++ b/src/components/Pizza.jsx @@ -0,0 +1,37 @@ +import { useEffect, useState } from "react"; + +const Pizza = () => { + const [pizza, setPizza] = useState(null); + const fetchPizza = async () => { + const url = "http://localhost:5000/api/pizzas/p001"; + const res = await fetch(url); + const data = await res.json(); + setPizza(data); + }; + useEffect(() => { + fetchPizza(); + }); + return ( + pizza && ( + + Pizza {pizza.name} + + ${pizza.price.toLocaleString("es-CL")} + + + {pizza.descripcion} + Ingredientes + + {pizza.ingredients.map((i, index) => ( + - {i} + ))} + + + Añadir al carrito + + + ) + ); +}; + +export default Pizza;
+ ${pizza.price.toLocaleString("es-CL")} +
{pizza.descripcion}