-
-
Notifications
You must be signed in to change notification settings - Fork 767
React-Ebrahim Beiati-Asl cyf-hotel #539
base: master
Are you sure you want to change the base?
Changes from 2 commits
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,58 +1,77 @@ | ||
.App { | ||
text-align: left; | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
/* animation: App-logo-spin infinite 20s linear; */ | ||
height: 80px; | ||
width: 80px; | ||
} | ||
|
||
.App-header { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 10px; | ||
|
||
background-color: #222; | ||
height: 50px; | ||
padding: 20px; | ||
padding-left: 10px; | ||
color: white; | ||
text-align: left; | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 1em; | ||
font-weight: bold; | ||
padding-top: 20px; | ||
text-align: center; | ||
} | ||
|
||
.App-title { | ||
font-size: 1.5em; | ||
.headerContainer { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.logo { | ||
fill: rgb(55, 59, 55); | ||
width: 50px; | ||
height: 50px; | ||
margin-right: 10px; | ||
padding: 5px; | ||
margin-left: 10px; | ||
filter: invert(1); | ||
} | ||
|
||
.App-content { | ||
padding-top: 20px; | ||
font-size: large; | ||
.cardContainer { | ||
display: flex; | ||
justify-content: center; | ||
gap: 20px; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
.card { | ||
width: 18rem; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 10px; | ||
width: 40vh; | ||
} | ||
.search { | ||
padding: 5px 0 20px 0; | ||
.card-img-top { | ||
object-fit: cover; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
tr { | ||
color: #5b5757; | ||
.order-type { | ||
display: flex; | ||
gap: 20px; | ||
margin-top: 0; | ||
margin-bottom: 1rem; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.results { | ||
padding-top: 15px; | ||
footer ul { | ||
display: flex; | ||
justify-content: space-around; | ||
list-style-type: none; | ||
padding: 20px 0 5px 0; | ||
} | ||
|
||
.footer { | ||
padding-top: 20px; | ||
text-align: center; | ||
table .thead-dark th { | ||
color: #767171; | ||
background-color: #212529; | ||
border-color: #32383e; | ||
margin-left: 15%; | ||
} | ||
|
||
.card { | ||
width: 18rem; | ||
} | ||
.selected-colour { | ||
background-color: rgb(55, 53, 53); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,54 @@ | ||
import React from "react"; | ||
import Search from "./Search.js"; | ||
import SearchResults from "./SearchResults.js"; | ||
import React, { useEffect, useState } from "react"; | ||
import Search from "./Search"; | ||
import SearchResults from "./SearchResults"; | ||
import CustomerProfile from "./CustomerProfile"; | ||
import FakeBookings from "./data/fakeBookings.json"; | ||
|
||
const Bookings = () => { | ||
useEffect(() => { | ||
console.log("Fetching Information be patient ... "); | ||
fetch("https://cyf-react.glitch.me") | ||
.then((response) => response.json()) | ||
.then((data) => setBookings(data)) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}, []); | ||
|
||
const [bookings, setBookings] = useState([]); | ||
const [showList, setShowList] = useState(true); | ||
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. Usually you'd put all the |
||
|
||
const search = (searchVal) => { | ||
console.info("TO DO!", searchVal); | ||
const filterBookings = bookings.filter((booking) => { | ||
booking.firstName.toLowerCase().includes(searchVal.toLowerCase()) || | ||
booking.lastName.toLowerCase().includes(searchVal.toLowerCase()); | ||
}); | ||
setBookings(filterBookings); | ||
setShowList(searchVal.length == 0); | ||
}; | ||
|
||
return ( | ||
<div className="App-content"> | ||
<div className="container"> | ||
<Search search={search} /> | ||
<SearchResults bookings={FakeBookings} /> | ||
<SearchResults results={showList ? bookings : filterBookings} /> | ||
|
||
{/* { <table className="table">} | ||
<thead className="thead-dark"> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Title</th> | ||
<th scope="col">FirstName</th> | ||
<th scope="col">SureName</th> | ||
<th scope="col">Email</th> | ||
<th scope="col">Room ID</th> | ||
<th scope="col">Check in</th> | ||
<th scope="col">Check out</th> | ||
<th scope="col">Nights</th> | ||
</tr> | ||
</thead> | ||
<SearchResults results={bookings} /> | ||
</table> */} | ||
</div> | ||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useState, useEffect } from "react"; | ||
|
||
const CustomerProfile = (props) => { | ||
const [customerData, setCustomerData] = useState(""); | ||
|
||
useEffect(() => { | ||
fetch(`https://cyf-react.glitch.me/customers/${props.id}`) | ||
.then((res) => res.json()) | ||
.then((data) => setCustomerData(data)); | ||
}, [props.id]); | ||
Comment on lines
+4
to
+10
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. This could definitely be a good use for a custom hook, have a go at making one! :) (Don't worry, this is beyond what is expected) |
||
|
||
return ( | ||
<div className="customer-profile-container"> | ||
<h3>Customer Profile</h3> | ||
<p> | ||
Customer ID: <span>{customerData.id}</span> | ||
</p> | ||
<p> | ||
Customer Name:{" "} | ||
<span> | ||
{customerData.title} {customerData.firstName} {customerData.surname} | ||
</span> | ||
Customer Email: <span>{customerData.email}</span> | ||
</p> | ||
<p> | ||
Customer Phone Number: <span>{customerData.phoneNumber}</span> | ||
</p> | ||
<p> | ||
VIP : <span>{customerData.vip ? "Yes" : "No"}</span> | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CustomerProfile; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import React from "react"; | ||
|
||
const props = [ | ||
"123 Fake Street, London, E1 4UD", | ||
"[email protected]", | ||
"0123 456789" | ||
"123 Fake Street, London, E1 4UD", | ||
"[email protected]", | ||
"0123 456789", | ||
]; | ||
|
||
|
||
const Footer = () => { | ||
return ( | ||
<footer> | ||
<ul className="footer-contact"> | ||
<ul> | ||
{props.map((props) => ( | ||
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 variable name
or
|
||
<li key={props}>{props}</li> | ||
))} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import React from "react"; | ||
|
||
const Heading = () => { | ||
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. Perfect! |
||
return ( | ||
<header className="App-header"> | ||
<div className="App-header"> | ||
<img | ||
className="App-logo" | ||
src="https://images.freeimages.com/images/previews/09e/moon-art-1641879.png" | ||
alt="" | ||
className="logo" | ||
src="https://www.svgrepo.com/show/288092/hotel.svg" | ||
alt="Hotel Logo" | ||
/> | ||
CYF Hotel | ||
</header> | ||
<header style={{fontSize:"29px", fontFamily:"cursive", boxShadow:"revert",border:"3px solid white" , padding:"2px"}}>CYF Hotel</header> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Heading; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import moment from "moment"; | ||
|
||
export const numberOfNight = ({ checkInDate, checkOutDate }) => { | ||
const checkIn = moment(checkInDate); | ||
const checkOut = moment(checkOutDate); | ||
const nights = checkOut.diff(checkIn, "days"); | ||
return nights; | ||
}; | ||
Comment on lines
+3
to
+8
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. Because you're not returning any |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import React from "react"; | ||
import Order from "./Order"; | ||
|
||
const Restaurant = () => { | ||
const pizzas = 0; | ||
return ( | ||
<div> | ||
<h3>Restaurant Orders</h3> | ||
|
||
<ul className="list"> | ||
<Order orderType="Pizza" /> | ||
<Order orderType="Salads" /> | ||
<Order orderType="Chocolate cake" /> | ||
</ul> | ||
|
||
<ul className="order-type"> | ||
<Order orderType="Pizza" /> | ||
<Order orderType="Cesar-Salad" /> | ||
<Order orderType="Chocolate cake" /> | ||
<Order orderType="Ice-Cream"/> | ||
Comment on lines
+8
to
+11
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 could instead create an array of order types |
||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
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 stylistic thing,
PascalCase
is often reserved for React components, with normal JS variables beingcamelCase
- you're importing a JSON file here so this should becamelCase
as it is not a React component (it can look confusing as people will assumeFakeBookings
is a React component). This should beimport fakeBookings from "./data/fakeBookings.json"