Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

London10 | Adrian Ilovan | cyf-hotel-react #589

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
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
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 35 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

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


.App-header {
background-color: #222;
height: 50px;
Expand Down Expand Up @@ -48,10 +49,42 @@ tr {
}

.footer {
padding-top: 20px;
padding-top: 10px;
text-align: center;
}

.card-img {
width: 100%;
height: auto;
flex-grow: 1;
}

.card-container {
display: flex;
justify-content: space-around;
margin-top: 50px;
}

.card {
width: 18rem;
}

/* .footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
padding: 10px;
text-align: center;
background-color: #222;
}

.footer, h1 {
color:white;
} */

.selected-row {
background-color: yellow;
color: black;
font-weight: bold;
}
12 changes: 10 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import React from "react";

import Bookings from "./Bookings";
import "./App.css";
import Heading from "./Heading";
import TouristInfoCards from "./TouristInfoCards"
import Footer from "./Footer";
import SearchResults from "./SearchResults";
import FakeBookings from "./data/fakeBookings.json"
import Restaurant from './Restaurant'

const App = () => {
return (
<div className="App">
<header className="App-header">CYF Hotel</header>
<Heading />
<TouristInfoCards />
<Bookings />
<Restaurant />
<Footer />
</div>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/Bookings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import React, { useState } from "react";
import Search from "./Search.js";
// import SearchResults from "./SearchResults.js";
// import FakeBookings from "./data/fakeBookings.json";
import SearchResults from "./SearchResults.js";
import FakeBookings from "./data/fakeBookings.json";

const Bookings = () => {
const [bookings, setBookings] = useState(FakeBookings);

const search = searchVal => {
console.info("TO DO!", searchVal);
};
Expand All @@ -12,7 +14,7 @@ const Bookings = () => {
<div className="App-content">
<div className="container">
<Search search={search} />
{/* <SearchResults results={FakeBookings} /> */}
{<SearchResults bookings={bookings} />}
</div>
</div>
);
Expand Down
17 changes: 17 additions & 0 deletions src/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";

const Footer = () => {

const myProps = ["123 Fake Street, London, E1 4UD", "[email protected]", "0123 456789"];

Choose a reason for hiding this comment

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

It sounds like this data should be passed into the component using React props. You can have a look at how props normally work here: https://www.w3schools.com/react/react_props.asp
Can you think of how to update the code so the data is defined in the parent component, and is passed to the Footer component as a prop?

Copy link
Author

Choose a reason for hiding this comment

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

I will make the updates , thanks :)

return(
<div className="footer">
<ul className="ul">
{myProps.map((item, index) => <li key={index}>{item}</li>
)}
</ul>
</div>
)


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

const Heading = () => {
return(
<header className="App-header">
<img alt="App-logo" className="App-logo" src="https://marketplace.canva.com/EAE8Xyb2xY8/1/0/1600w/canva-gold-exclusive-royal-luxury-hotel-logo-izeElzvImEY.jpg"></img>
<h1>CYF Hotel</h1></header>

Choose a reason for hiding this comment

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

It's a minor point, but just keep an eye on the formatting of your embedded html.
It would be good </header> was on a new line

);
}

export default Heading;
19 changes: 19 additions & 0 deletions src/Order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { useState } from "react";
import RestaurantButton from "./RestaurantButton";

const Order = ({orderType}) => {
const [orders, setOrders] = useState(0);

const orderOne = () => {
setOrders(orders + 1);
};

return(
<li>
{orderType} {orders} <RestaurantButton onClick={orderOne}/>
</li>

)
}

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

const Restaurant = () => {
const pizzas = 0;

return (
<div>
<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 cake"/>
</ul>
</div>
);
Expand Down
14 changes: 14 additions & 0 deletions src/RestaurantButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { useState } from "react";

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


}


export default RestaurantButton;

4 changes: 3 additions & 1 deletion src/Search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import SearchButton from "./SearchButton";

const Search = () => {
return (
Expand All @@ -17,7 +18,7 @@ const Search = () => {
className="form-control"
placeholder="Customer name"
/>
<button className="btn btn-primary">Search</button>
<SearchButton />
</div>
</form>
</div>
Expand All @@ -26,4 +27,5 @@ const Search = () => {
);
};


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


const SearchButton = () => {

Choose a reason for hiding this comment

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

Nice 👍

return(
<button className="btn btn-primary">Search</button>
);
}

export default SearchButton;
52 changes: 52 additions & 0 deletions src/SearchResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useState } from "react";
import FakeBookings from "./data/fakeBookings.json";
import moment from "moment/moment";

const SearchResults = (props) => {

Choose a reason for hiding this comment

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

This looks great!
You did a good job of passing the props in and using them in the component 👍

const [selectedRows, setSelectedRows] = useState([]);
const selectedClicks = (bookingId) => {
setSelectedRows((selectedClickedRows) => {

Choose a reason for hiding this comment

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

Awesome - great work! 😄

if (selectedClickedRows.includes(bookingId)) {
return selectedClickedRows.filter((id) => id !== bookingId)
} else {
return [...selectedClickedRows, bookingId];
}
});
}


return(
<table className="table">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">First Name</th>
<th scope="col">Surname</th>
<th scope="col">Email</th>
<th scope="col">Room ID</th>
<th scope="col">CheckIn</th>
<th scope="col">CheckOut</th>
<th scope="col">Nights</th>
</tr>
</thead>
<tbody className="tbody">
{props.bookings.map((booking, key) => (
<tr
key={booking.id}
className={selectedRows.includes(booking.id) ? "selected-row" : ""}
onClick={() => selectedClicks(booking.id)}>
<th scope="row">{booking.title}</th>
<td>{booking.firstName}</td>
<td>{booking.surname}</td>
<td>{booking.email}</td>
<td>{booking.roomId}</td>
<td>{booking.checkInDate}</td>
<td>{booking.checkOutDate}</td>
<td>{moment(booking.checkOutDate).diff(booking.checkInDate, "days")}</td>

Choose a reason for hiding this comment

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

Nice 👏

</tr>
))}
</tbody>
</table>
)
};
export default SearchResults;
31 changes: 31 additions & 0 deletions src/TouristInfoCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";

Choose a reason for hiding this comment

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

This looks great. But it seems like there's some duplication here - the structure of each card is the same, and we are repeating that structure 3 times.
Using React, can you think of how you might be able to reduce that duplication? 😄

Copy link
Author

Choose a reason for hiding this comment

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

Yes I think I can create a separate component "const Card" and pass all object info in there so I can add any other card with ease . thanks for letting me know :)

const TouristInfoCards = () => {
return(
<div className="card-container">
<img src="" alt=""></img>
<div className="card">
<img className="card-img" src="https://media.istockphoto.com/id/1421242432/photo/glasgow-united-kingdom-aerial-shot-of-modern-buildings-in-the-central-area-of-the-city-with.jpg?s=612x612&w=0&k=20&c=5atqO3S6NsvBJazWGSyth82FhvVfgajQARHv8KQ0J-Q=" alt="glasgow"></img>
<h4>Glasgow</h4>
<p>Glasgow's city centre is home to flagship stores, impressive shopping centres and designer favourites all within an easily walkable area.</p>
<a href="https://www.peoplemakeglasgow.com" className="btn btn-primary">More Information</a>
</div>
<img src="" alt=""></img>
<div className="card">
<img className="card-img" src="https://media.istockphoto.com/id/1061647528/photo/view-of-a-footbridge-in-salford-quays-in-manchester-england.jpg?s=612x612&w=0&k=20&c=vl5COcWWCtvUM8Nu26oP2WUTfhP45wcGNN8nrbtjcsw=" alt="manchester"></img>
<h4>Manchester</h4>
<p>Manchester is one of the most exciting places to visit in the UK right now where everybody and anybody is very warmly welcomed.</p>
<a href="https://www.visitmanchester.com" className="btn btn-primary">More Information</a>
</div>
<img src="" alt=""></img>
<div className="card">
<img className="card-img" src="https://img.freepik.com/free-photo/panoramic-view-big-ben-london-sunset-uk_268835-1401.jpg?w=2000" alt="london"></img>
<h4>London</h4>
<p>Visit London, the official guide to England’s exciting capital. For more Information click the link and visit the wonders of London</p>
<a href="https://www.visitlondon.com" className="btn btn-primary">More Information</a>
</div>
</div>
)
}

export default TouristInfoCards;