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

London10_Afsha_Hossain_cyf-hotel-react_React_Week1 #600

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2f3a0ce
1. Extracted the search button in its own component
Afsha10 Jun 15, 2023
99edee7
2. Extracted the header in its own component and put the search butto…
Afsha10 Jun 16, 2023
596a65c
Minor change to exercise 2
Afsha10 Jun 16, 2023
edabd7e
3. Created and used a new component to show info cards
Afsha10 Jun 19, 2023
2d70af8
4. Create a Footer component
Afsha10 Jun 19, 2023
72db9d0
5. Create a table to show hotel bookings
Afsha10 Jun 19, 2023
1b59ada
6. Showed more bookings in the table
Afsha10 Jun 20, 2023
9504c89
7. Calculated and showed the number of nights for each booking
Afsha10 Jun 20, 2023
eb88f7b
8. Rendered the Restaurant component
Afsha10 Jun 23, 2023
c5515f4
9. Prepared to add more pizzas
Afsha10 Jun 23, 2023
471fe85
10. Adding more pizzas
Afsha10 Jun 23, 2023
0ea985a
11. Extracted the Add button to its own component
Afsha10 Jun 23, 2023
b0d82f7
12. Extracted pizza order to its own Order component
Afsha10 Jun 23, 2023
cf22b3e
13. Rendered more orders
Afsha10 Jun 23, 2023
74da50a
14. Passing bookings from a state variable
Afsha10 Jun 23, 2023
819f1d2
Minor styling changes to restaurantButton component
Afsha10 Jun 23, 2023
984256e
15. a) Highlighted single booking row when clicked
Afsha10 Jun 25, 2023
da55007
Able to highlight and unhighlight multiple rows by clicking other rows
Afsha10 Jun 26, 2023
ef63070
Exercise 15
Afsha10 Jul 4, 2023
2a7b1de
16. Load bookings remotely
Afsha10 Jul 4, 2023
4b14a00
17. Storing the search input in a state
Afsha10 Jul 4, 2023
d06b76a
17. Storing the search input in a state
Afsha10 Jul 4, 2023
d600947
18. Triggering search when submitting the form
Afsha10 Jul 5, 2023
60e6aa3
Merge branch 'master' of https://github.com/Afsha10/cyf-hotel-react
Afsha10 Jul 5, 2023
cbec91e
19. Implementing the search functionality and refactoring the SearchR…
Afsha10 Jul 9, 2023
e03521f
20. Displaying a customer profile - step 1
Afsha10 Jul 10, 2023
723f946
21. Display a customer profile - step 2
Afsha10 Jul 11, 2023
bc22ee1
22. Show a loading message
Afsha10 Jul 11, 2023
defc909
23. Show an error message
Afsha10 Jul 13, 2023
efd9702
Changed styling
Afsha10 Sep 7, 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
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
24 changes: 21 additions & 3 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

.App-header {
background-color: #222;
height: 50px;
padding: 20px;
height: 8.5rem;
padding: 1rem;
color: white;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
font-weight: bold;
display: flex;
flex-direction: row;
}

.App-title {
Expand All @@ -39,6 +41,10 @@
padding: 5px 0 20px 0;
}

.table-bordered {
margin:2rem 0 5rem 0;
}

tr {
color: #5b5757;
}
Expand All @@ -52,6 +58,18 @@ tr {
text-align: center;
}

.footer-ul {
list-style-type: none;
}


.card {
width: 18rem;
width: 35rem;
}

.cards-container {
display: flex;
flex-direction: row;
gap: 4rem;
margin-bottom: 4rem;
}
15 changes: 13 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import React from "react";

import Heading from "./components/Heading";
import TouristInfoCards from "./components/TouristInfoCards";
import Bookings from "./Bookings";
import Footer from "./components/Footer";
import "./App.css";
import Restaurant from "./Restaurant";

const App = () => {
const address = [
"123 Fake Street, London, E1 4UD",
"[email protected]",
"0123 456789",
];
return (
<div className="App">
<header className="App-header">CYF Hotel</header>
<Heading />
<TouristInfoCards />
<Bookings />
<Restaurant />
<Footer address = {address}/>

Choose a reason for hiding this comment

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

Nice organization and adding all the components into the app.js

</div>
);
};
Expand Down
9 changes: 6 additions & 3 deletions src/Bookings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from "react";
import React, {useState} from 'react';
import Search from "./Search.js";
import SearchResults from "./components/SearchResults.jsx";

// import SearchResults from "./SearchResults.js";
// import FakeBookings from "./data/fakeBookings.json";
import FakeBookings from "./data/fakeBookings.json";

const Bookings = () => {
const [bookings, setBookings] = useState(FakeBookings);
const search = searchVal => {
console.info("TO DO!", searchVal);

Choose a reason for hiding this comment

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

Looking forward to seeing how you will implement this!

};
Expand All @@ -12,7 +15,7 @@ const Bookings = () => {
<div className="App-content">
<div className="container">
<Search search={search} />
{/* <SearchResults results={FakeBookings} /> */}
<SearchResults results={bookings} />
</div>
</div>
);
Expand Down
11 changes: 6 additions & 5 deletions src/Restaurant.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from "react";
import Order from "./components/Order";

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

Choose a reason for hiding this comment

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

How are you looking to implement the restaurant component? Looks like for right now you are only getting the header and the ordertypes
should this be a separate component? Or will you be adding additional functionality in the restaurant component?


return (
<div>
<div className="restaurant-orders">
<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
3 changes: 2 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 "./components/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 Down
15 changes: 15 additions & 0 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

const Footer = (props) => {
return (
<footer className="footer">
<ul className="footer-ul">
{props.address.map((element, index) => {
return <li className="footer-list" key={index}>{element}</li>;

Choose a reason for hiding this comment

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

nice use of map! this looks very good

})}
</ul>
</footer>
);
};

export default Footer;
15 changes: 15 additions & 0 deletions src/components/Heading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import react from "react";

function Heading() {
return (
<header className="App-header">
<img
src="https://images.unsplash.com/photo-1564501049412-61c2a3083791?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1932&q=80"
alt="logo"
/>
<h1>CYF Hotel</h1>
</header>
);
}

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

const Order = ({orderType}) => {
const [orders, setOrders] = useState(0);
const orderOne = () => {
setOrders((orders) => orders + 1);
};
return (
<li>

Choose a reason for hiding this comment

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

so because this is all wrapped in

  • you are having your ordertype/ orders and your button on the same line. Is this how you would like it to look?

  • {orderType}: {orders}
    <RestaurantButton orderOne={orderOne} />
    </li>
    );
    };

    export default Order;
    10 changes: 10 additions & 0 deletions src/components/RestaurantButton.css

    Choose a reason for hiding this comment

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

    Love that you have the restaurantbutton css in its own file! Very clean and easy to read :)

    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    .restaurant-orders {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 6rem;
    }

    .btn {
    margin: 1.5rem 2rem;
    }
    10 changes: 10 additions & 0 deletions src/components/RestaurantButton.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    import "./RestaurantButton.css";
    const RestaurantButton = ({ orderOne }) => {
    return (
    <button className="btn btn-primary" onClick={orderOne}>

    Choose a reason for hiding this comment

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

    The button looks good! Time to add the reset button ;)

    Add
    </button>
    );
    };

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

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

    Choose a reason for hiding this comment

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

    Search button is nicely implemented! Looks like you still need to work on the search functionality though :)


    export default SearchButton;
    44 changes: 44 additions & 0 deletions src/components/SearchResults.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    import React from "react";
    import moment from "moment";

    const SearchResults = (props) => {
    return (
    <table className="table table-bordered">
    <thead>

    Choose a reason for hiding this comment

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

    Got to love bootstrap! The table looks good and very well formatted. Good work!

    <tr>
    <th scope="col">Id</th>
    <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">Check in date</th>
    <th scope="col">Check out date</th>
    <th scope="col">Number of nights</th>
    </tr>
    </thead>
    <tbody>
    {props.results.map((result, index) => {
    const a = moment(result.checkOutDate);
    const b = moment(result.checkInDate);
    const days = a.diff(b, "days"); // 1

    Choose a reason for hiding this comment

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

    Really good implementation for the days

    good job creating the two consts and using diff

    return (
    <tr key={index}>
    <td>{result.id}</td>
    <td>{result.title}</td>
    <td>{result.firstName}</td>
    <td>{result.surname}</td>
    <td>{result.email}</td>
    <td>{result.roomId}</td>
    <td>{result.checkInDate}</td>
    <td>{result.checkOutDate}</td>
    <td>{days}</td>
    </tr>
    );
    })}
    </tbody>
    </table>
    );
    };

    export default SearchResults;
    75 changes: 75 additions & 0 deletions src/components/TouristInfoCards.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    import React from "react";

    const TouristInfoCards = () => {

    Choose a reason for hiding this comment

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

    Good job pulling this out into its own component


    return (
    <div className="cards-container">
    <div className="card">
    <img
    src="https://peoplemakeglasgow.com/imager/general/86786/Kelvingrove-Art-Gallery-and-Museum_8dc3bdbc8660ad389ec95cdf9b15d797.jpg"
    className="card-img-top"
    alt="Picture of Glasgow"
    />
    <div className="card-body">
    <h5 className="card-title">Glasgow</h5>
    <p className="card-text">
    Glasgow is unique in that many of the city's top museums and
    galleries are free-to-visit. Kelvingrove Art Gallery and Museum
    and The Burrell Collection are 2 of Scotland's cultural gems,
    famed for their world-class cultural collections, as well as their
    beautiful parkland settings.
    </p>
    <a href="peoplemakeglasgow.com" className="btn btn-primary">
    More Information
    </a>
    </div>
    </div>

    <div className="card">
    <img
    src="https://eu-assets.simpleview-europe.com/manchester2016/imageresizer/?image=%2Fdmsimgs%2FConwy_Harbour_22481198.jpg&action=ProductDetailFullWidth2"
    className="card-img-top"
    alt="Picture of Manchester"
    />
    <div className="card-body">
    <h5 className="card-title">Manchester</h5>
    <p className="card-text">
    Manchester is a major city in the northwest of England with a rich
    industrial heritage. The Castlefield conservation area’s
    18th-century canal system recalls the city’s days as a textile
    powerhouse, and visitors can trace this history at the interactive
    Museum of Science & Industry. The revitalised Salford Quays
    dockyards now house the Daniel Libeskind-designed Imperial War
    Museum North and the Lowry cultural centre.
    </p>
    <a href="https://www.visitmanchester.com/" className="btn btn-primary">
    More Information
    </a>
    </div>
    </div>
    <div className="card">
    <img
    src="https://cdn-lnp.dataweavers.io/-/media/images/london/visit/whats-on/event-pages/buckinghampalace1920x1080.jpg?rev=c88f581f5aa2444f97f3343f60008663?mw=640&hash=52C77C542B4531A72B120C5586046410"
    className="card-img-top"
    alt="Picture of London"
    />
    <div className="card-body">
    <h5 className="card-title">London</h5>
    <p className="card-text">
    Welcome to London! Discover the best of London with Visit London,
    the official guide to England’s exciting capital. Find things to
    do in London, from iconic sightseeing spots and fun-filled days
    out to top restaurants, theatre and unmissable London events. If
    you’re not able to visit just yet, plan ahead to make the most of
    your next visit.
    </p>
    <a href="https://www.visitlondon.com/" className="btn btn-primary">
    More Information
    </a>
    </div>
    </div>
    </div>
    );
    }

    export default TouristInfoCards;
    5 changes: 5 additions & 0 deletions src/index.css
    Original file line number Diff line number Diff line change
    Expand Up @@ -24,3 +24,8 @@ body {
    .search-row input {
    margin-right: 10px;
    }

    /* making space between logo and h1 */
    header > img {
    margin-right: 2rem;
    }

    Choose a reason for hiding this comment

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

    Is there a reason to have this in the index.css? Remember for index.css this would be to change the whole project.