diff --git a/package-lock.json b/package-lock.json
index 8197e6f22..94217b93a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,7 @@
"name": "react-hotel",
"version": "0.1.0",
"dependencies": {
+ "moment": "^2.29.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1"
@@ -11681,6 +11682,14 @@
"mkdirp": "bin/cmd.js"
}
},
+ "node_modules/moment": {
+ "version": "2.29.4",
+ "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
+ "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
+ "engines": {
+ "node": "*"
+ }
+ },
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
diff --git a/package.json b/package.json
index e3e1562a7..f81c28013 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
+ "moment": "^2.29.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1"
diff --git a/src/App.js b/src/App.js
index 953c98560..26c40d934 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,13 +1,26 @@
import React from "react";
-
+import Heading from "./Heading";
+import TouristInfoCards from "./TouristInfoCards";
import Bookings from "./Bookings";
+import Footer from "./Footer";
+import Restaurant from "./Restaurant"
import "./App.css";
const App = () => {
+ const addressData = [
+ "123 Fake Street, London, E1 4UD",
+ "hello@fakehotel.com",
+ "0123 456789"
+ ];
return (
-
+
+
+
+
+
+
);
};
diff --git a/src/BookingRow.jsx b/src/BookingRow.jsx
new file mode 100644
index 000000000..1942b755a
--- /dev/null
+++ b/src/BookingRow.jsx
@@ -0,0 +1,27 @@
+import React from "react";
+
+const BookingRow = ({ booking, onClick, isSelected }) => {
+ const calculateNumberOfNights = () => {
+ const oneDay = 24 * 60 * 60 * 1000;
+ const checkInDate = new Date(booking.checkInDate);
+ const checkOutDate = new Date(booking.checkOutDate);
+ const nightCount = Math.round(Math.abs((checkOutDate - checkInDate) / oneDay));
+ return nightCount;
+ };
+
+ return (
+
+ {booking.id}
+ {booking.title}
+ {booking.firstName}
+ {booking.surname}
+ {booking.email}
+ {booking.roomId}
+ {booking.checkInDate}
+ {booking.checkOutDate}
+ {calculateNumberOfNights()}
+
+ );
+};
+
+export default BookingRow;
diff --git a/src/Bookings.js b/src/Bookings.js
index e0d911b13..3f0101bdf 100644
--- a/src/Bookings.js
+++ b/src/Bookings.js
@@ -1,18 +1,40 @@
-import React from "react";
-import Search from "./Search.js";
-// import SearchResults from "./SearchResults.js";
-// import FakeBookings from "./data/fakeBookings.json";
+import React, { useState, useEffect } from 'react';
+import Search from "./Search";
+import SearchResults from "./SearchResults";
+
const Bookings = () => {
+ const [bookings, setBookings] = useState([]);
+ const [filteredBookings, setFilteredBookings] = useState([]);
+
const search = searchVal => {
- console.info("TO DO!", searchVal);
+ const filtered = bookings.filter((booking) => {
+ const { firstName, surname } = booking;
+ return (
+ firstName.toLowerCase().includes(searchVal.toLowerCase()) ||
+ surname.toLowerCase().includes(searchVal.toLowerCase())
+ );
+ });
+
+ setFilteredBookings(filtered);
};
+ useEffect(() => {
+ fetch("https://cyf-react.glitch.me")
+ .then(response => response.json())
+ .then(data => {
+ setBookings(data);
+ })
+ .catch(error => {
+ console.error("Error fetching data:", error);
+ });
+ }, []);
+
return (
);
diff --git a/src/Footer.jsx b/src/Footer.jsx
new file mode 100644
index 000000000..86c6bf500
--- /dev/null
+++ b/src/Footer.jsx
@@ -0,0 +1,18 @@
+import React from "react";
+
+
+const Footer = (props) => {
+ const addressItems = props.addressData.map((item, index) => (
+ {item}
+ ));
+
+ return (
+
+ );
+}
+
+export default Footer;
diff --git a/src/Heading.jsx b/src/Heading.jsx
new file mode 100644
index 000000000..61f2e5f6f
--- /dev/null
+++ b/src/Heading.jsx
@@ -0,0 +1,10 @@
+import React from "react";
+
+const Heading = () => {
+ return (
+
+
+
+
);
+}
+export default Heading;
\ No newline at end of file
diff --git a/src/Order.js b/src/Order.js
new file mode 100644
index 000000000..36dc8122f
--- /dev/null
+++ b/src/Order.js
@@ -0,0 +1,19 @@
+import React, { useState } from "react";
+import RestaurantButton from "./RestaurantButton"
+
+const Order = (props) => {
+ const [orders, setOrders] = useState(0);
+
+ const orderOne = () => {
+ setOrders(prevOrders => prevOrders + 1);
+ };
+
+ return (
+
+ {props.orderType}: {orders}
+
+
+ );
+};
+
+export default Order;
\ No newline at end of file
diff --git a/src/Restaurant.js b/src/Restaurant.js
index ecb2b43a2..531105f7d 100644
--- a/src/Restaurant.js
+++ b/src/Restaurant.js
@@ -1,14 +1,14 @@
import React from "react";
+import Order from "./Order"
const Restaurant = () => {
- const pizzas = 0;
return (
Restaurant Orders
-
- Pizzas: {pizzas} Add
-
+
+
+
);
diff --git a/src/RestaurantButton.jsx b/src/RestaurantButton.jsx
new file mode 100644
index 000000000..c38f02b61
--- /dev/null
+++ b/src/RestaurantButton.jsx
@@ -0,0 +1,10 @@
+import React from "react"
+
+const RestaurantButton = ({ orderOne }) => (
+
+
+ Add
+
+);
+
+export default RestaurantButton;
\ No newline at end of file
diff --git a/src/Search.js b/src/Search.js
index 7bd5871c0..95e5cba21 100644
--- a/src/Search.js
+++ b/src/Search.js
@@ -1,6 +1,19 @@
-import React from "react";
+import React, { useState } from "react";
+import SearchButton from "./SearchButton";
+
+const Search = ({ search }) => {
+ const [searchInput, setSearchInput] = useState("");
+
+ const handleSearchInput = (event) => {
+ const inputValue = event.target.value;
+ setSearchInput(inputValue);
+ };
+
+ const handleSubmit = (event) => {
+ event.preventDefault();
+ search(searchInput);
+ };
-const Search = () => {
return (
@@ -8,7 +21,7 @@ const Search = () => {
diff --git a/src/SearchButton.jsx b/src/SearchButton.jsx
new file mode 100644
index 000000000..d71e984cc
--- /dev/null
+++ b/src/SearchButton.jsx
@@ -0,0 +1,10 @@
+import React from "react";
+
+const SearchButton = () => {
+ return (
+
Search
+);
+}
+
+
+export default SearchButton;
\ No newline at end of file
diff --git a/src/SearchResults.jsx b/src/SearchResults.jsx
new file mode 100644
index 000000000..570745c09
--- /dev/null
+++ b/src/SearchResults.jsx
@@ -0,0 +1,47 @@
+import React, { useState } from "react";
+import BookingRow from "./BookingRow";
+
+const SearchResults = ({ bookings }) => {
+ const [selectedRow, setSelectedRow] = useState(null);
+
+ const handleRowClick = (index) => {
+ if (selectedRow === index) {
+ setSelectedRow(null);
+ } else {
+ setSelectedRow(index);
+ }
+ };
+
+ return (
+
+
Search Results
+
+
+
+ ID
+ Title
+ First Name
+ Surname
+ Email
+ Room ID
+ Check-in Date
+ Check-out Date
+ Nights
+
+
+
+ {bookings.map((booking, index) => (
+ handleRowClick(index)}
+ isSelected={selectedRow === index}
+ />
+ ))}
+
+
+
+ );
+};
+
+export default SearchResults;
diff --git a/src/TouristInfoCards.js b/src/TouristInfoCards.js
new file mode 100644
index 000000000..8dcd6eb90
--- /dev/null
+++ b/src/TouristInfoCards.js
@@ -0,0 +1,49 @@
+import React from "react";
+
+const TouristInfoCards = () => {
+ return (
+
+
+
+
+
Glasgow
+
+ Glasgow is a vibrant city in Scotland known for its rich cultural heritage and friendly atmosphere.
+ It offers a blend of stunning architecture, art galleries, and a lively music scene.
+
+ Visit Glasgow
+
+
More Information
+
+
+
+
+
+
Manchester
+
+ Manchester is a city in England known for its industrial history, vibrant arts scene, and football culture.
+ It offers a mix of museums, galleries, and entertainment options.
+
+ Visit Manchester
+
+
More Information
+
+
+
+
+
+
London
+
+ London, the capital of England, is a global city known for its history, culture, and iconic landmarks.
+ It offers world-class museums, theaters, shopping, and diverse culinary experiences.
+
+ Visit London
+
+
More Information
+
+
+
+ );
+};
+
+export default TouristInfoCards;