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

London-9-Turing-Farnoosh_Moayeri-React-WEEK1 #549

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ba10bda
Hotel-React- week one
Farnooshmo Feb 28, 2023
4506ac0
update TouristInfoCards
Farnooshmo Mar 3, 2023
f1263cc
Update CYF Hotel
Farnooshmo Mar 3, 2023
7c214e6
Adding footer component
Farnooshmo Mar 3, 2023
7c4ab17
Add Restaurant component
Farnooshmo Mar 3, 2023
02bd06b
Add key to SearchResults component
Farnooshmo Mar 6, 2023
996eef1
update RestaurantButton component
Farnooshmo Mar 6, 2023
d7ab216
Add Order component
Farnooshmo Mar 6, 2023
fd12bc1
Passing bookings from a state variable
Farnooshmo Mar 7, 2023
00596ed
update Heading
Farnooshmo Mar 7, 2023
e7d95a4
remove list-style
Farnooshmo Mar 7, 2023
f607727
add className to TouristInfoCards
Farnooshmo Mar 7, 2023
876846e
Highlight booking row when clicked
Farnooshmo Mar 7, 2023
eab0277
Add CSS
Farnooshmo Mar 13, 2023
a9719ce
Create CustomerProfile component
Farnooshmo Mar 13, 2023
edefa40
Add emoji to Restaurant component
Farnooshmo Mar 13, 2023
3ba67d2
Update Bookings component to load bookings remotely
Farnooshmo Mar 13, 2023
73f8e77
Add a logo to Heading component
Farnooshmo Mar 13, 2023
4ac477b
Storing the search input in a state
Farnooshmo Mar 13, 2023
89bb454
Change background colour of Footer & Restaurant components
Farnooshmo Mar 13, 2023
a9e3d1e
Update step 20; customer profile - step 1
Farnooshmo Mar 15, 2023
0f29279
Display a customer profile - step2-22 completed
Farnooshmo Mar 15, 2023
e2310ed
Show a loading message
Farnooshmo Mar 15, 2023
024a8b5
Update Order component
Farnooshmo Mar 16, 2023
2c43a67
Show an error message step 23
Farnooshmo Mar 16, 2023
ff69af4
Update Booking component
Farnooshmo Mar 16, 2023
63f4a5b
Update Bookings component
Farnooshmo Mar 16, 2023
d579f18
Restructure the data of TouristCards component
Farnooshmo Mar 16, 2023
acf36f3
change the order button
Farnooshmo Apr 26, 2024
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
113 changes: 92 additions & 21 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
li{
list-style: none;
padding:2px;
}


.App {
text-align: left;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
/* ---header--- */
.App-title {
font-size: 1.5em;
}


.App-header {
background-color: #222;
height: 50px;
width: 100%;
height: 200px;
padding: 20px;
color: white;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
font-weight: bold;
}

.App-title {
font-size: 1.5em;
}

.App-content {
padding-top: 20px;
font-size: large;
/* ---logo--- */
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
width: 100px;
margin-left: 3em;
}

@keyframes App-logo-spin {
Expand All @@ -35,23 +41,88 @@
transform: rotate(360deg);
}
}

/* ---cards ---- */
.card {
width:400px;
}

.card-img-top{
width: 100%;
height: 300px;
}


.cards{
display: inline-flex;
border: 10px solid #698474;
}

/* ---search--- */
.App-content {
padding-top: 20px;
font-size: large;

}

.search {
margin-top: 2em;
padding: 5px 0 20px 0;
}

tr {
color: #5b5757;
}

.results {
padding-top: 15px;

}

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

/* ---table--- */
.table-row-main{
background-color:#698474 ;
color: #fcf8f3;
}

.card {
width: 18rem;
tr {
color: black;
}

td button{
background-color:#698474 ;
color:#fcf8f3 ;
border-radius: 5px;
}

/* ---restaurant--- */
.restaurant{
display: flex;
flex-direction: column;
gap: 2px;
background-color: #a2c11c;
align-items: center;
border:2px solid #222;
}

.restaurant ul{
display: flex;
flex-direction: row;
}

.restaurant button{
background-color:red;
margin-left: 5px;
margin-right: 10px;
}

/* --- footer --- */
.footer {
padding-top: 2px;
text-align: center;
}
.contact-container{
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
background-color: #698474;
}
35 changes: 33 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
import React from "react";

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

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

Choose a reason for hiding this comment

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

small improvement: you can store these data in a data structure like a list of object, and then produce List of TouristInfoCards from that.

This approach will be more flexible, and less verbose

image="https://ik.imagekit.io/panmac/tr:f-auto,w-740,pr-true//bcd02f72-b50c-0179-8b4b-5e44f5340bd4/4f007762-5423-497d-920f-f4a5b6c86259/glasgow-crime-books-min.png"
title="Glasgow"
link="href=https://peoplemakeglasgow.com"
description="Is the most populous city in Scotland and the fourth-most populous city in the United Kingdom, as well as being the 27th largest city by population in Europe.Today it's a national cultural hub, home to institutions including the Scottish Opera, Scottish Ballet and National Theatre of Scotland"
/>
<TouristInfoCards
image="https://www.picturesforwalls.com/blackandwhite/manchester/images/curvedpassage.jpg"
title="Manchester"
link="href=https://visitmanchester.com"
description="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."
/>
<TouristInfoCards
image="https://images.unsplash.com/photo-1581950196064-0b98a6586d04?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1752&q=80"
title="London"
link="href=https://visitlondon.com"
description="The capital of England and the United Kingdom, is a 21st-century city with history stretching back to Roman times. At its centre stand the imposing Houses of Parliament, the iconic ‘Big Ben’ clock tower and Westminster Abbey, site of British monarch coronations"
/>
<Bookings />
<Restaurant />
{/* <Order /> */}

<Footer contact={contact} />
</div>
);
};
Expand Down
29 changes: 25 additions & 4 deletions src/Bookings.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import React from "react";
import React, { useEffect , useState } from "react";
import Search from "./Search.js";
// import SearchResults from "./SearchResults.js";
import SearchResults from "./SearchResults.js";
// import FakeBookings from "./data/fakeBookings.json";

const Bookings = () => {
const search = searchVal => {
const [bookings, setBookings]= useState([])


useEffect(() => {
console.log("Fetching data from FakeBookings");

fetch("https://cyf-react.glitch.me.")
.then((res) => res.json())
.then((data) => {
setBookings(data);
});
}, []);
const search = (searchVal) => {
console.info("TO DO!", searchVal);
const filteredBooking = bookings.filter((name) =>
name.firstName.toLowerCase() === searchVal.toLowerCase() ||
name.surname.toLowerCase() === searchVal.toLowerCase() ||

Choose a reason for hiding this comment

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

I think the top 2 conidition might be redundant since you're performing includes search next?

Copy link
Author

Choose a reason for hiding this comment

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

You are right, they can be deleted.

name.firstName.toLowerCase().includes(searchVal.toLowerCase()) ||
name.surname.toLowerCase().includes(searchVal.toLowerCase())
? setBookings([name])

Choose a reason for hiding this comment

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

If you're performing some state changes, it might be better to call setBookings outside of filter function.

Generally, filter function should be pure, pure in this context means it does not mutate any variables that is outside of the scope of the function.

:-1
);
console.log(filteredBooking);
};

return (
<div className="App-content">
<div className="container">
<Search search={search} />
{/* <SearchResults results={FakeBookings} /> */}
<SearchResults results ={bookings} />
</div>
</div>
);
Expand Down
16 changes: 16 additions & 0 deletions src/CustomerProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";

function CustomerProfile(props){

return <div>Customer {props.id} profile</div>
}









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

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

export default Footer;
16 changes: 16 additions & 0 deletions src/Heading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
const Heading = () => {
return (
<header className="App-header">
<h1>CYF Hotel</h1>
<img
className="App-logo"
src="https://images.emojiterra.com/google/noto-emoji/v2.034/512px/1f3e8.png"
// src="https://housing.com/news/wp-content/uploads/2022/11/hotel-room-design-compressed-1.jpg"
alt="Hotel room"
/>
</header>
);
};

export default Heading;
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";

const Order = ({orderType}) => {
const [orders, setOrders] = useState(0);
function orderOne() {
return setOrders(orders + 1);
}
return (
<li key={orderType}>
{orderType}:{orders}
<button className="btn btn-primary" onClick={orderOne}>Add</button>
</li>
);
};

export default Order;
14 changes: 7 additions & 7 deletions src/Restaurant.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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="restaurant">
<h3>Restaurant Orders</h3>
<ul>
<li>
Pizzas: {pizzas} <button className="btn btn-primary">Add</button>
</li>
<Order orderType="🍕 Pizzas " />
<Order orderType=" 🥗 Salads " />
<Order orderType=" 🍰 Cakes " />
</ul>
</div>
);
};

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

function RestaurantButton(props) {
return (<button onClick={props.orderOne}></button>);
}

export default RestaurantButton;
Loading