-
-
Notifications
You must be signed in to change notification settings - Fork 767
London10_Afsha_Hossain_cyf-hotel-react_React_Week1 #600
base: master
Are you sure you want to change the base?
Changes from all commits
2f3a0ce
99edee7
596a65c
edabd7e
2d70af8
72db9d0
1b59ada
9504c89
eb88f7b
c5515f4
471fe85
0ea985a
b0d82f7
cf22b3e
74da50a
819f1d2
984256e
da55007
ef63070
2a7b1de
4b14a00
d06b76a
d600947
60e6aa3
cbec91e
e03521f
723f946
bc22ee1
defc909
efd9702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": [] | ||
} |
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,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}/> | ||
</div> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
import React from "react"; | ||
import React, {useEffect, useState} from 'react'; | ||
import Search from "./Search.js"; | ||
// import SearchResults from "./SearchResults.js"; | ||
// import FakeBookings from "./data/fakeBookings.json"; | ||
import SearchResults from "./components/SearchResults.jsx"; | ||
// import SearchResultsOther from './components/SearchResultsOther.js'; | ||
|
||
const Bookings = () => { | ||
const search = searchVal => { | ||
console.info("TO DO!", searchVal); | ||
const [bookings, setBookings] = useState([]); | ||
|
||
const [searchVal, setSearchVal] = useState(""); | ||
|
||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
const [isError, setIsError] = useState(false); | ||
|
||
useEffect(() => { | ||
fetch("https://cyf-react.glitch.me/error") | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
if (data.error !== undefined) { | ||
console.log("error"); | ||
setIsError(true); | ||
} else { | ||
setIsLoading(false); | ||
setBookings(data); | ||
} | ||
}) | ||
}, []); | ||
|
||
/* | ||
isLoading: true, isError: false, | ||
isLoading: false, isError: false, | ||
isLoading: false, isError: true, | ||
*/ | ||
|
||
const search = (searchVal) => { | ||
console.log("TO DO!", searchVal); | ||
setSearchVal(searchVal); | ||
}; | ||
|
||
let displayedBookings = bookings.filter( | ||
(booking) => | ||
booking.firstName.toLowerCase().includes(searchVal.toLowerCase()) || | ||
booking.surname.toLowerCase().includes(searchVal.toLowerCase()) | ||
); | ||
|
||
|
||
return ( | ||
<div className="App-content"> | ||
<div className="container"> | ||
<Search search={search} /> | ||
{/* <SearchResults results={FakeBookings} /> */} | ||
{isError ? ( | ||
<p>Error loading...</p> | ||
) : isLoading ? ( | ||
<p>Page loading...</p> | ||
) : ( | ||
<> | ||
<Search search={search} /> | ||
<SearchResults results={displayedBookings} /> | ||
</> | ||
)} | ||
{/* <SearchResultsOther results={bookings} /> */} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Bookings; | ||
|
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; | ||
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. How are you looking to implement the restaurant component? Looks like for right now you are only getting the header and the ordertypes |
||
|
||
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> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.profile-container { | ||
border: 1px solid grey; | ||
padding: 1rem; | ||
} | ||
|
||
.profile-list { | ||
list-style-type: none; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
This is how we'd like to display the customer's profile: | ||
|
||
"id": 1, | ||
"email": "[email protected]", | ||
"vip": true, | ||
"phoneNumber": "+44 1632 960185" | ||
|
||
*/ | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import "./CustomerProfile.css"; | ||
|
||
const CustomerProfile = ({ id }) => { | ||
const [customerProfile, setCustomerProfile] = useState({}); | ||
|
||
useEffect(() => { | ||
console.log(id); | ||
fetch(`https://cyf-react.glitch.me/customers/${id}`) | ||
.then((res) => res.json()) | ||
.then((data) => setCustomerProfile(data)); | ||
}, [id]); | ||
|
||
return ( | ||
<div className="profile-container"> | ||
<p>Customer Profile: </p> | ||
<ul className="profile-list"> | ||
<li>ID: {customerProfile.id}</li> | ||
<li>Email: {customerProfile.email}</li> | ||
<li>VIP: {customerProfile.vip?.toString()}</li> | ||
<li>Phone number: {customerProfile.phoneNumber}</li> | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CustomerProfile; | ||
|
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>; | ||
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. nice use of map! this looks very good |
||
})} | ||
</ul> | ||
</footer> | ||
); | ||
}; | ||
|
||
export default Footer; |
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; |
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> | ||
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. so because this is all wrapped in |
||
{orderType}: {orders} | ||
<RestaurantButton orderOne={orderOne} /> | ||
</li> | ||
); | ||
}; | ||
|
||
export default Order; |
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; | ||
} |
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}> | ||
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. The button looks good! Time to add the reset button ;) |
||
Add | ||
</button> | ||
); | ||
}; | ||
|
||
export default RestaurantButton; |
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>; | ||
}; | ||
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. Search button is nicely implemented! Looks like you still need to work on the search functionality though :) |
||
|
||
export default SearchButton; |
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.
Nice organization and adding all the components into the app.js