Skip to content
This repository was archived by the owner on Feb 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
74af1f2
made ahead file
ali-nasir-ali Jun 16, 2023
e0d41eb
header component with style
RahmaB1 Jun 16, 2023
0257298
Added the TouristInfoCards component
AppolinFotso Jun 17, 2023
70f92f1
Updated the TouristInfoCards component
AppolinFotso Jun 17, 2023
7dcfbee
5-hard coded table
RahmaB1 Jun 17, 2023
4da9cb5
Merge pull request #1 from ali-nasir-ali/1---header-component
ali-nasir-ali Jun 17, 2023
3109c9c
worked on search
ali-nasir-ali Jun 17, 2023
3253a15
Merge pull request #2 from ali-nasir-ali/2---search
ali-nasir-ali Jun 17, 2023
fa9a338
Merge branch 'master' into 3--TouristInfoCards
ali-nasir-ali Jun 17, 2023
f381ce9
Merge pull request #3 from ali-nasir-ali/3--TouristInfoCards
ali-nasir-ali Jun 17, 2023
f61fb11
Added images for TouristInfoCards
AppolinFotso Jun 17, 2023
cd3fa43
done footer component
ali-nasir-ali Jun 17, 2023
5375053
Added Style to TouristInfoCards
AppolinFotso Jun 17, 2023
2f99fdd
try to fix the header
ali-nasir-ali Jun 17, 2023
8547239
done footer eror
ali-nasir-ali Jun 17, 2023
5537041
Merge pull request #5 from ali-nasir-ali/4---Footer
ali-nasir-ali Jun 17, 2023
88711ab
trying to fix header
ali-nasir-ali Jun 17, 2023
88628f3
Merge branch 'master' into 5---table-to-show-hotel-bookings---component
ali-nasir-ali Jun 17, 2023
2034cf5
Merge pull request #6 from ali-nasir-ali/5---table-to-show-hotel-book…
ali-nasir-ali Jun 17, 2023
95a0f6e
Added FakeBookings file to Bookings component
AppolinFotso Jun 19, 2023
4eb8e6c
Used props in SearchResults to populate the table
AppolinFotso Jun 19, 2023
99617b9
Merge pull request #7 from ali-nasir-ali/6--Using_props_to_pass_fakeB…
ali-nasir-ali Jun 19, 2023
71d5def
fixed footer css
ali-nasir-ali Jun 19, 2023
2a406b7
added favicon
ali-nasir-ali Jun 19, 2023
da02c93
8-done
RahmaB1 Jun 19, 2023
e0b95d9
Merge pull request #8 from ali-nasir-ali/8--2--render-restaurant-comp…
ali-nasir-ali Jun 19, 2023
3d3eeb5
Added orders state variable to Restaurant component
AppolinFotso Jun 19, 2023
773d44b
7
RahmaB1 Jun 19, 2023
925d1bc
Merge pull request #10 from ali-nasir-ali/7-calculate-number-of-nights
ali-nasir-ali Jun 19, 2023
ca4a042
Merge pull request #9 from ali-nasir-ali/9--Adding-the-state-variable…
ali-nasir-ali Jun 19, 2023
e31faf4
orders tallyho
ali-nasir-ali Jun 19, 2023
7900e86
Merge pull request #11 from ali-nasir-ali/9---preparing-to-add-pizza
ali-nasir-ali Jun 19, 2023
4272e77
11-extract-add-button
RahmaB1 Jun 19, 2023
eeaa590
Merge pull request #12 from ali-nasir-ali/11-extract-add-button
ali-nasir-ali Jun 19, 2023
4c63c28
Created Order component
AppolinFotso Jun 19, 2023
b2cfaf0
Added RestaurantButton to Order component
AppolinFotso Jun 19, 2023
650ddc0
Merge pull request #13 from ali-nasir-ali/12--extra-pizza-order-to-it…
ali-nasir-ali Jun 20, 2023
6996d85
added more items, fixed adding error
ali-nasir-ali Jun 20, 2023
90641f1
Merge pull request #14 from ali-nasir-ali/13---Render-more-orders
ali-nasir-ali Jun 20, 2023
ae06bd3
Added event handler and some style
AppolinFotso Jun 21, 2023
ca2b9e4
17 - Storing the search input in a state
RahmaB1 Jun 21, 2023
5921bfe
Added EachRowInSearchResults component and a state variable
AppolinFotso Jun 21, 2023
456f8cd
Merge pull request #16 from ali-nasir-ali/15--Highlight-booking-row-w…
AppolinFotso Jun 21, 2023
67a0447
Merge pull request #15 from ali-nasir-ali/17-storing-the-search-input…
RahmaB1 Jun 21, 2023
f5b6942
Added onSubmit event handler on the form
AppolinFotso Jun 21, 2023
036ceed
Merge pull request #17 from ali-nasir-ali/18--Triggering-search-when-…
AppolinFotso Jun 21, 2023
52a6712
added api capabilities
ali-nasir-ali Jun 21, 2023
45d081e
Merge pull request #18 from ali-nasir-ali/16---load-booking-romotly
ali-nasir-ali Jun 21, 2023
5d78cb2
testing the search parameter, not working now
ali-nasir-ali Jun 21, 2023
be87d0d
its working now
ali-nasir-ali Jun 21, 2023
61dbdc1
Merge pull request #19 from ali-nasir-ali/19---implementing-search-fu…
ali-nasir-ali Jun 21, 2023
d708716
update 20
RahmaB1 Jun 21, 2023
14f8d90
update
RahmaB1 Jun 21, 2023
8ae5853
update
RahmaB1 Jun 21, 2023
4c74e23
update
RahmaB1 Jun 21, 2023
5c11cf0
update passing props
RahmaB1 Jun 21, 2023
18d14cc
update
RahmaB1 Jun 21, 2023
cd9e33e
Merge pull request #21 from ali-nasir-ali/20---3----Display-a-custome…
RahmaB1 Jun 21, 2023
5234e91
Added some functionality to show prile button and customerProfile com…
AppolinFotso Jun 22, 2023
be53476
Merge pull request #22 from ali-nasir-ali/21--Display-a-customer-prof…
AppolinFotso Jun 22, 2023
1f36aa3
Added the error message when url not working
AppolinFotso Jun 22, 2023
16cd452
Merge pull request #23 from ali-nasir-ali/23--display-error-message
AppolinFotso Jun 22, 2023
1a4cad0
added the loading wheel for when api taking time
ali-nasir-ali Jun 23, 2023
0fdc503
Merge pull request #24 from ali-nasir-ali/22---Show-a-loading-message
ali-nasir-ali Jun 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,180 changes: 14,743 additions & 2,437 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"moment": "^2.29.4",
"nanoid": "^4.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1"
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
92 changes: 88 additions & 4 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
text-align: left;
}

.hotel-logo {
height: 80px;
position: absolute;
top: 0;
left: 0;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}

.App-header {
background-color: #222;
height: 50px;
height: 80px;
padding: 20px;
color: white;
text-align: left;
/* color: white; */
color: #b8860b;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
font-size: 2em;
font-weight: bold;
}

Expand Down Expand Up @@ -48,10 +56,86 @@ tr {
}

.footer {
background-color: #222;
padding-top: 20px;
text-align: center;
padding-bottom: 15px;
margin-bottom: -17px;
}
.footer > ul {
color: #b8860b;
}

.card {
width: 18rem;
}

.cities-info {
display: flex;
justify-content: center;
gap: 5em;
margin-top: 1em;
}

.center {
text-align: center;
margin-top: 2rem;
}

.on {
background-color: blue;
color: white;
cursor: pointer;
}
.off {
background-color: none;
cursor: pointer;
}
.profile-container {
color: white;
background-color: blue;
padding: 1em;
}
.profile {
font-weight: bold;
font-size: 1.5em;
}
.viewOn {
display: block;
}
.viewOff {
display: none;
}
.error {
width: 100vw;
height: 100vh;
text-align: center;
background-color: white;
padding: 5em;
color: red;
font-weight: bold;
}

/* the loading wheel in the booking component */
.loading-wheel {
display: inline-block;
width: 80px;
height: 80px;
border: 8px solid #f3f3f3;
border-top: 8px solid darkgray;
border-radius: 50%;
animation: spin 2s linear infinite;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

@keyframes spin {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
18 changes: 14 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import React from "react";

import React, { useState } from "react";
import TouristInfoCards from "./TouristInfoCards";
import Bookings from "./Bookings";
import "./App.css";
import Heading from "./Header";
import Footer from "./Footer";
import Restaurant from "./Restaurant";

const App = () => {
const [count, setCount] = useState(0);
if (count > 0) {
return <Bookings setCount={setCount} />;
}
return (
<div className="App">
<header className="App-header">CYF Hotel</header>
<Bookings />
<Heading />
<TouristInfoCards />
<Bookings setCount={setCount} />
<Restaurant />
<Footer />
</div>
);
};
Expand Down
50 changes: 44 additions & 6 deletions src/Bookings.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
import React from "react";
import React, { useState, useEffect } from "react";
import Search from "./Search.js";
// import SearchResults from "./SearchResults.js";
// import FakeBookings from "./data/fakeBookings.json";
import SearchResults from "./SearchResults.js";
import CustomerProfile from "./CustomerProfile.js";
import UrlNotWorking from "./UrlNotWorking.js";

const Bookings = () => {
const search = searchVal => {
const Bookings = (props) => {
const [bookings, setBookings] = useState([]);
const [filteredBookings, setFilteredBookings] = useState([]);
const [customerProfile, setCustomerProfile] = useState("");
const [customerId, setCustomerId] = useState("");
const [view, setView] = useState("viewOff");
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
fetch("https://cyf-react.glitch.me/delayed")
.then((response) => response.json())
.then((data) => {
setBookings(data);
setFilteredBookings(data);
setIsLoading(false);
})
.catch((error) => {
const urlNotWorking = "Not Found";
setBookings(urlNotWorking);
setIsLoading(false);
});
}, []);

const search = (searchVal) => {
console.info("TO DO!", searchVal);
const searchedBookings = bookings.filter(
(searchedNames) => searchedNames.firstName.toLowerCase().includes(searchVal.toLowerCase()) || searchedNames.surname.toLowerCase().includes(searchVal.toLowerCase())
);
setFilteredBookings(searchedBookings);
};

if (bookings === "Not Found") {
props.setCount(1);
return <UrlNotWorking />;
}

if (isLoading) {
// return <div>Loading...</div>;
return <div className="loading-wheel"></div>;
}

return (
<div className="App-content">
<div className="container">
<Search search={search} />
{/* <SearchResults results={FakeBookings} /> */}
<SearchResults booking={filteredBookings} setCustomerId={setCustomerId} setCustomerProfile={setCustomerProfile} setView={setView} view={view} />
<CustomerProfile customerId={customerId} customerProfile={customerProfile} view={view} />
</div>
</div>
);
Expand Down
24 changes: 24 additions & 0 deletions src/CustomerProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { useState, useEffect } from "react";
import "./App.css";

function CustomerProfile(props) {
const [customer, setCustomer] = useState({});
useEffect(() => {
fetch(`https://cyf-react.glitch.me/customers/${props.customerId}`)
.then((response) => response.json())
.then((data) => setCustomer(data));
}, [props.customerId]);
return (
<div className={props.view}>
<div className="profile-container">
<p className="profile">{props.customerProfile}</p>
<p>ID: {props.customerId}</p>
<p>Email: {customer.email}</p>
<p>VIP: {customer.vip ? "Yes" : "No"}</p>
<p>Tel: {customer.phoneNumber}</p>
</div>
</div>
);
}

export default CustomerProfile;
44 changes: 44 additions & 0 deletions src/EachRowInSearchResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import react, { useState } from "react";

function EachRowInSearchResults(props) {
const [switchMe, setSwitchMe] = useState("off");

function handleClick() {
if (switchMe === "off") {
setSwitchMe("on");
} else {
setSwitchMe("off");
}
}

function handleShowProfile() {
props.setCustomerId(props.booking.id);
props.setCustomerProfile("Customer Profile");
if (props.view === "viewOff") {
props.setView("viewOn");
} else {
props.setView("viewOff");
}
}

return (
<tr className={switchMe} onClick={handleClick}>
<th scope="row">{props.booking.id}</th>
<td>{props.booking.title}</td>
<td>{props.booking.firstName}</td>
<td>{props.booking.surname}</td>
<td>{props.booking.email}</td>
<td>{props.booking.roomId}</td>
<td>{props.booking.checkInDate}</td>
<td>{props.booking.checkOutDate}</td>
<td>{props.numberOfNights}</td>
Comment on lines +26 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructuring the object here would be nice, you dont have to type props.booking. on every line

<td>
<button onClick={handleShowProfile} className="btn btn-primary">
Show Profile
</button>
</td>
</tr>
);
}

export default EachRowInSearchResults;
18 changes: 18 additions & 0 deletions src/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";

// address
const props = ["123 Fake Street, London, E1 4UD", "hello@fakehotel.com", "0123 456789"];

const Footer = () => {
return (
<footer className="footer">
<ul>
{props.map((props) => (
<p key={props}>{props}</p>
))}
</ul>
</footer>
);
};
// footer export
export default Footer;
16 changes: 16 additions & 0 deletions src/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import "./App.css";

function Heading() {
return (
<>
<header className="App-header">CYF Hotel</header>
<img
className="hotel-logo"
src="https://img.freepik.com/free-vector/golden-elegant-logo-template-with-ornaments_23-2148212128.jpg?w=900&t=st=1686937700~exp=1686938300~hmac=96cba09c7292154b8447b7c54e0d24116ed3c8fc0a2ec07ffc4ac28cab762b20"
></img>
</>
);
}

export default Heading;
Binary file added src/Images/London.avif
Binary file not shown.
Binary file added src/Images/Manchester.avif
Binary file not shown.
Binary file added src/Images/PeopleMakeGlasgow.avif
Binary file not shown.
16 changes: 16 additions & 0 deletions src/Order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { useState } from "react";
import RestaurantButton from "./RestaurantButton";

function Order(props) {
const [orders, setOrders] = useState(0);
function orderOne() {
setOrders(orders + 1);
}
return (
<p>
{props.orderType}: {orders} <RestaurantButton orderOne={orderOne} />
</p>
);
}

export default Order;
13 changes: 7 additions & 6 deletions src/Restaurant.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from "react";
import React, { useState } from "react";
import RestaurantButton from "./RestaurantButton";
import Order from "./Order";

const Restaurant = () => {
const pizzas = 0;
return (
<div>
<div className="center">
<h3>Restaurant Orders</h3>
<ul>
<li>
Pizzas: {pizzas} <button className="btn btn-primary">Add</button>
</li>
<Order orderType="Pizzas" />
<Order orderType="Salads" />
<Order orderType="Chocolate ake" />
</ul>
</div>
);
Expand Down
13 changes: 13 additions & 0 deletions src/RestaurantButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

const RestaurantButton = ({ orderOne }) => {
return (
<>
<button className="btn btn-primary" onClick={orderOne}>
Add
</button>
</>
);
};

export default RestaurantButton;
Loading