diff --git a/src/components/Footer.js b/src/components/Footer.js
new file mode 100644
index 0000000..f2fe75d
--- /dev/null
+++ b/src/components/Footer.js
@@ -0,0 +1,28 @@
+import Order from './Order'
+
+function Footer() {
+ const hour = new Date().getHours()
+ const openHour = 12
+ const closeHour = 22
+ const isOpen = hour >= openHour && hour <= closeHour
+ console.log(isOpen)
+
+ // if (hour >= openHour && hour <= closeHour) alert("We're currently open!")
+ // else alert("Sorry we're close")
+
+ return (
+
+ )
+ // return React.createElement('footer', null, "We're currently open!")
+}
+
+export default Footer
diff --git a/src/components/Header.js b/src/components/Header.js
new file mode 100644
index 0000000..2b29905
--- /dev/null
+++ b/src/components/Header.js
@@ -0,0 +1,9 @@
+function Header() {
+ return (
+
+ )
+}
+
+export default Header
diff --git a/src/components/Menu.js b/src/components/Menu.js
new file mode 100644
index 0000000..bc0205e
--- /dev/null
+++ b/src/components/Menu.js
@@ -0,0 +1,47 @@
+import { pizzaData } from '../data'
+import Pizza from './Pizza'
+
+function Menu() {
+ const pizzas = pizzaData
+ // const pizzas = []
+ const numPizzas = pizzas.length
+
+ return (
+
+ Our Menu
+
+ {numPizzas > 0 ? (
+ <>
+
+ Authentic Italian cuisine. 6 creative dishes to choose from. All
+ from our stone oven, all organic, all delicious.
+
+
+
+ {/* Another aproach of iterating over the data list. */}
+ {pizzas.map((pizza) => (
+
+ ))}
+
+ >
+ ) : (
+ We're still working in our menu. Please come back later
+ )}
+
+ {/*
+ */}
+
+ )
+}
+
+export default Menu
diff --git a/src/components/Order.js b/src/components/Order.js
new file mode 100644
index 0000000..9927caa
--- /dev/null
+++ b/src/components/Order.js
@@ -0,0 +1,13 @@
+function Order({ closeHour, openHour }) {
+ return (
+
+
+ We're open from {openHour}:00 until {closeHour}:00. Come visit us or
+ order online.
+
+
+
+ )
+}
+
+export default Order
diff --git a/src/components/Pizza.js b/src/components/Pizza.js
new file mode 100644
index 0000000..7107774
--- /dev/null
+++ b/src/components/Pizza.js
@@ -0,0 +1,35 @@
+//Pizza component receiving props from Menu component
+function Pizza({ pizzaObj }) {
+ return (
+
+
+
+
{pizzaObj.name}
+
{pizzaObj.ingredients}
+
{pizzaObj.soldOut ? 'SOLD OUT' : pizzaObj.price}
+
+
+ )
+}
+
+//Pizza component with map functionality inside.
+// function Pizza() {
+// return (
+//
+// {pizzaData.map((data) => {
+// return (
+//
+//
+//
+//
{data.name}
+//
{data.ingredients}
+//
{data.price}
+//
+//
+// )
+// })}
+//
+// )
+// }
+
+export default Pizza
diff --git a/public/data.js b/src/data.js
similarity index 97%
rename from public/data.js
rename to src/data.js
index e1f80a5..c8a660b 100644
--- a/public/data.js
+++ b/src/data.js
@@ -1,4 +1,4 @@
-const pizzaData = [
+export const pizzaData = [
{
name: 'Focaccia',
ingredients: 'Bread with italian olive oil and rosemary',
diff --git a/src/index.js b/src/index.js
index a5eeca7..ad7fca0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,57 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
-
-const pizzaData = [
- {
- id: 1,
- name: 'Focaccia',
- ingredients: 'Bread with italian olive oil and rosemary',
- price: 6,
- photoName: 'pizzas/focaccia.jpg',
- soldOut: false,
- },
- {
- id: 2,
- name: 'Pizza Margherita',
- ingredients: 'Tomato and mozarella',
- price: 10,
- photoName: 'pizzas/margherita.jpg',
- soldOut: false,
- },
- {
- id: 3,
- name: 'Pizza Spinaci',
- ingredients: 'Tomato, mozarella, spinach, and ricotta cheese',
- price: 12,
- photoName: 'pizzas/spinaci.jpg',
- soldOut: false,
- },
- {
- id: 4,
- name: 'Pizza Funghi',
- ingredients: 'Tomato, mozarella, mushrooms, and onion',
- price: 12,
- photoName: 'pizzas/funghi.jpg',
- soldOut: false,
- },
- {
- id: 5,
- name: 'Pizza Salamino',
- ingredients: 'Tomato, mozarella, and pepperoni',
- price: 15,
- photoName: 'pizzas/salamino.jpg',
- soldOut: true,
- },
- {
- id: 6,
- name: 'Pizza Prosciutto',
- ingredients: 'Tomato, mozarella, ham, aragula, and burrata cheese',
- price: 18,
- photoName: 'pizzas/prosciutto.jpg',
- soldOut: false,
- },
-]
+import Header from './components/Header'
+import Menu from './components/Menu'
+import Footer from './components/Footer'
function App() {
return (
@@ -63,127 +15,5 @@ function App() {
)
}
-function Header() {
- return (
-
- )
-}
-
-function Menu() {
- const pizzas = pizzaData
- // const pizzas = []
- const numPizzas = pizzas.length
-
- return (
-
- Our Menu
-
- {numPizzas > 0 ? (
- <>
-
- Authentic Italian cuisine. 6 creative dishes to choose from. All
- from our stone oven, all organic, all delicious.
-
-
-
- {/* Another aproach of iterating over the data list. */}
- {pizzaData.map((pizza) => (
-
- ))}
-
- >
- ) : (
- We're still working in our menu. Please come back later
- )}
-
- {/*
- */}
-
- )
-}
-
-//Pizza component receiving props from Menu component
-function Pizza({ pizzaObj }) {
- return (
-
-
-
-
{pizzaObj.name}
-
{pizzaObj.ingredients}
-
{pizzaObj.soldOut ? 'SOLD OUT' : pizzaObj.price}
-
-
- )
-}
-
-//Pizza component with map functionality inside.
-// function Pizza() {
-// return (
-//
-// {pizzaData.map((data) => {
-// return (
-//
-//
-//
-//
{data.name}
-//
{data.ingredients}
-//
{data.price}
-//
-//
-// )
-// })}
-//
-// )
-// }
-
-function Footer() {
- const hour = new Date().getHours()
- const openHour = 12
- const closeHour = 22
- const isOpen = hour >= openHour && hour <= closeHour
- console.log(isOpen)
-
- // if (hour >= openHour && hour <= closeHour) alert("We're currently open!")
- // else alert("Sorry we're close")
-
- return (
-
- )
- // return React.createElement('footer', null, "We're currently open!")
-}
-
-function Order({ closeHour, openHour }) {
- return (
-
-
- We're open from {openHour}:00 until {closeHour}:00. Come visit us or
- order online.
-
-
-
- )
-}
-
const root = ReactDOM.createRoot(document.getElementById('root'))
root.render()