-
-
Notifications
You must be signed in to change notification settings - Fork 767
London-9-Turing-Farnoosh_Moayeri-React-WEEK1 #549
base: master
Are you sure you want to change the base?
Changes from 20 commits
ba10bda
4506ac0
f1263cc
7c214e6
7c4ab17
02bd06b
996eef1
d7ab216
fd12bc1
00596ed
e7d95a4
f607727
876846e
eab0277
a9719ce
edefa40
3ba67d2
73f8e77
4ac477b
89bb454
a9e3d1e
0f29279
e2310ed
024a8b5
2c43a67
ff69af4
63f4a5b
d579f18
acf36f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | ||
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> | ||
); | ||
}; | ||
|
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() || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
); | ||
|
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; |
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; |
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; |
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; |
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; |
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; |
There was a problem hiding this comment.
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