diff --git a/README.md b/README.md index 5711ee7f8..2f20a2d4d 100644 --- a/README.md +++ b/README.md @@ -216,13 +216,13 @@ A hotel booking application in React. Homework for the [CodeYourFuture React mod **Test:** Each column in the table should be clickable to sort results in ascending or descending order. -#### 26. Validate new booking +#### 26. Validate new booking **Instructions:** Add validation to some fields from exercise 24: the first name and last name must not be empty, the email must contain exactly 1 `@` symbol, and at least one `.` symbol after the `@`; the room ID must be a number between 0 and 100. If the fields do not contain correct information when the 'Submit' button is pressed, display a red error message at the top of the page, but do not clear the text already in the field. **Test:** An invalid input displays an error message after the 'Submit' button is pressed (e.g. an email like `react@com` is invalid). A valid input shows the correct values at the bottom of the page. -**Reflection:** Validating user input is an important part of any application. Without checking the input, you might see unexpected errors when working with the data later. +**Reflection:** Validating user input is an important part of any application. Without checking the input, you might see unexpected errors when working with the data later. What do you think would happen if you were asked to remove a booking for room number '81', but the user had typed 'eightyOne' or 'EIGHTY ONE'? @@ -234,27 +234,29 @@ What do you think would happen if you were asked to remove a booking for room nu **Test:** The 'Submit' button is initially not clickable, and becomes clickable once every field has the correct input. -**Reflection:** You have used native form validations in HTML. How have you improved this feature with React? +**Reflection:** You have used native form validations in HTML. How have you improved this feature with React? As a user of this booking system, would you prefer: + - To find out you made a mistake when you submit the whole form? - To find out you made a mistake after each input? #### 28. Date picker -**Instructions:** Add the [js-datepicker](https://www.npmjs.com/package/js-datepicker) package to your project using `npm install`, and import it at the top of the file. Add different IDs to your 'check in date' and 'check out date' `` elements, then create two date pickers using `const checkInPicker = datepicker(YOUR_ID)` (where `YOUR_ID` is the ID you assigned to your check in/check out date elements). +**Instructions:** Add the [js-datepicker](https://www.npmjs.com/package/js-datepicker) package to your project using `npm install`, and import it at the top of the file. Add different IDs to your 'check in date' and 'check out date' `` elements, then create two date pickers using `const checkInPicker = datepicker(YOUR_ID)` (where `YOUR_ID` is the ID you assigned to your check in/check out date elements). **Hint:** Read the [js-datepicker usage guide](https://www.npmjs.com/package/js-datepicker#basic-usage) **Test:** The date picker appears when you click on the 'check in date' and 'check out date' input elements. -**Reflection:** Using `js-datepicker` in this exercise allows you to practice installing and working with packages in JavaScript. +**Reflection:** Using `js-datepicker` in this exercise allows you to practice installing and working with packages in JavaScript. Packages contain new functions and properties to work with that may not be available in native JavaScript/HTML. Using packages can often save time instead of writing your own functions, as you are importing code that someone else has written. However, this can have downsides; not all packages are high quality, and some may have bugs or may reduce accessibility by recreating native elements (`js-datepicker` recreates HTML's native [datepicker](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date) element). Think about some of the code you have written in this lesson - are there any packages available that might have helped you to complete the exercises? For example, exercise 26 and 27 used validation. Searching npmjs.com for '[validate](https://www.npmjs.com/search?q=validate)' shows multiple packages, such as '[validator](https://www.npmjs.com/package/validator)' and '[Validate](https://www.npmjs.com/package/Validate)'. Open both of these packages in your browser, and consider the following questions: + - Is it clear what this package does? Will it solve my specific problem better than writing my own code? - Do I trust that the code in this package is safe to run on my machine? Do other people trust this package? (Hint: look at weekly downloads, last update, dependents, and visit the repository) - Is this package accessible? Will it work on all browsers? diff --git a/package-lock.json b/package-lock.json index 8197e6f22..94217b93a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "react-hotel", "version": "0.1.0", "dependencies": { + "moment": "^2.29.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "^5.0.1" @@ -11681,6 +11682,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, "node_modules/mri": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", diff --git a/package.json b/package.json index e3e1562a7..f81c28013 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/public/images/glasgow.jpg b/public/images/glasgow.jpg new file mode 100644 index 000000000..c7f5670ea Binary files /dev/null and b/public/images/glasgow.jpg differ diff --git a/public/images/hotel.png b/public/images/hotel.png new file mode 100644 index 000000000..e5a0a3284 Binary files /dev/null and b/public/images/hotel.png differ diff --git a/public/images/london.jpg b/public/images/london.jpg new file mode 100644 index 000000000..87c98b1a0 Binary files /dev/null and b/public/images/london.jpg differ diff --git a/public/images/manchester.jpg b/public/images/manchester.jpg new file mode 100644 index 000000000..8abc99ac9 Binary files /dev/null and b/public/images/manchester.jpg differ diff --git a/src/App.css b/src/App.css index 05fe2d52e..bb637ec9e 100644 --- a/src/App.css +++ b/src/App.css @@ -9,13 +9,27 @@ .App-header { background-color: #222; - height: 50px; + height: 100px; padding: 20px; color: white; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 1em; font-weight: bold; + display:flex; + align-items: center; + gap: 0.5rem; + +} +.hotel-title { + text-align: center; + font-size: 1.5rem; + margin-top: 20px; +} + +.hotel-logo { + width: 40px; + height: 40px; } .App-title { @@ -55,3 +69,21 @@ tr { .card { width: 18rem; } + +.cards { + display: flex; + justify-content: center; + gap: 2rem; + margin-top: 1rem; +} +/* +.selectRow { + background: red; +} */ +.profile-flex { + display:flex; + justify-content: space-around; +} +.profile-title { + text-align: center; +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index 953c98560..ce2937741 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,8 @@ import React from "react"; +import Heading from "./Heading"; +import TouristInfoCards from "./TouristInfoCards"; +import Footer from "./Footer"; +import Restaurant from "./Restaurant"; import Bookings from "./Bookings"; import "./App.css"; @@ -6,8 +10,17 @@ import "./App.css"; const App = () => { return (
Customer {customerProfile.id} Profile
+E-mail: {customerProfile.email}
+Telephone number: {customerProfile.phoneNumber}
+{customerProfile.vip ? "VIP" : null}
+
+