diff --git a/README.md b/README.md index 5711ee7f8..9ef230c01 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ A hotel booking application in React. Homework for the [CodeYourFuture React mod #### 9. Preparing to add more pizzas -**Instructions:** At the moment, the number of pizzas a guest can order is static and set to 0, even if they click on the 'Add' button. We will change that in the following to let a guest add more pizzas to their order. First, declare a new state variable `orders` along with the function to set the orders state `setOrders`. The initial value of the `orders` state should be **0**. Use the new `orders` variable instead of the `pizzas` variable (that you can now delete). +**Instructions:** At the moment, the number of pizzas a guest can order is static and set to 0, even if they click on the 'Add' button. We will change that in the following to let a guest add more pizzas to their order. First, declare a new state variable `orders` along with the function to set the orders state `setOrders`. The initial value of the `orders` state should be **0**. **Hint:** You need to use the React function `useState` to create a state variable. Remember to import the function at the top with `import React, {useState} from "react";`. diff --git a/package-lock.json b/package-lock.json index 8197e6f22..dc32d04f2 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" @@ -2863,9 +2864,9 @@ } }, "node_modules/@jridgewell/source-map": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", - "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.3.tgz", + "integrity": "sha512-b+fsZXeLYi9fEULmfBrhxn4IrPlINf8fiNarzTof004v3lFdntdwa9PF7vFJqm3mg7s+ScJMxXaE3Acp1irZcg==", "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -3891,133 +3892,133 @@ } }, "node_modules/@webassemblyjs/ast": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", - "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", + "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==", "dependencies": { - "@webassemblyjs/helper-numbers": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + "@webassemblyjs/helper-numbers": "1.11.6", + "@webassemblyjs/helper-wasm-bytecode": "1.11.6" } }, "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", - "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==" + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz", + "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==" }, "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", - "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==" + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz", + "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==" }, "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", - "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==" + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz", + "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==" }, "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", - "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz", + "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==", "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.11.1", - "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/floating-point-hex-parser": "1.11.6", + "@webassemblyjs/helper-api-error": "1.11.6", "@xtuc/long": "4.2.2" } }, "node_modules/@webassemblyjs/helper-wasm-bytecode": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", - "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==" + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz", + "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==" }, "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz", - "integrity": "sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz", + "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/helper-buffer": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1", - "@webassemblyjs/wasm-gen": "1.11.1" + "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/helper-wasm-bytecode": "1.11.6", + "@webassemblyjs/wasm-gen": "1.11.6" } }, "node_modules/@webassemblyjs/ieee754": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz", - "integrity": "sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz", + "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==", "dependencies": { "@xtuc/ieee754": "^1.2.0" } }, "node_modules/@webassemblyjs/leb128": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz", - "integrity": "sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz", + "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==", "dependencies": { "@xtuc/long": "4.2.2" } }, "node_modules/@webassemblyjs/utf8": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz", - "integrity": "sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==" + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz", + "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==" }, "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz", - "integrity": "sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz", + "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/helper-buffer": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1", - "@webassemblyjs/helper-wasm-section": "1.11.1", - "@webassemblyjs/wasm-gen": "1.11.1", - "@webassemblyjs/wasm-opt": "1.11.1", - "@webassemblyjs/wasm-parser": "1.11.1", - "@webassemblyjs/wast-printer": "1.11.1" + "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/helper-wasm-bytecode": "1.11.6", + "@webassemblyjs/helper-wasm-section": "1.11.6", + "@webassemblyjs/wasm-gen": "1.11.6", + "@webassemblyjs/wasm-opt": "1.11.6", + "@webassemblyjs/wasm-parser": "1.11.6", + "@webassemblyjs/wast-printer": "1.11.6" } }, "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz", - "integrity": "sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz", + "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1", - "@webassemblyjs/ieee754": "1.11.1", - "@webassemblyjs/leb128": "1.11.1", - "@webassemblyjs/utf8": "1.11.1" + "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/helper-wasm-bytecode": "1.11.6", + "@webassemblyjs/ieee754": "1.11.6", + "@webassemblyjs/leb128": "1.11.6", + "@webassemblyjs/utf8": "1.11.6" } }, "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz", - "integrity": "sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz", + "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/helper-buffer": "1.11.1", - "@webassemblyjs/wasm-gen": "1.11.1", - "@webassemblyjs/wasm-parser": "1.11.1" + "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/wasm-gen": "1.11.6", + "@webassemblyjs/wasm-parser": "1.11.6" } }, "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz", - "integrity": "sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz", + "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/helper-api-error": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1", - "@webassemblyjs/ieee754": "1.11.1", - "@webassemblyjs/leb128": "1.11.1", - "@webassemblyjs/utf8": "1.11.1" + "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/helper-api-error": "1.11.6", + "@webassemblyjs/helper-wasm-bytecode": "1.11.6", + "@webassemblyjs/ieee754": "1.11.6", + "@webassemblyjs/leb128": "1.11.6", + "@webassemblyjs/utf8": "1.11.6" } }, "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", - "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz", + "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==", "dependencies": { - "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/ast": "1.11.6", "@xtuc/long": "4.2.2" } }, @@ -4080,9 +4081,9 @@ } }, "node_modules/acorn-import-assertions": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", - "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", + "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", "peerDependencies": { "acorn": "^8" } @@ -6289,9 +6290,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", - "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "version": "5.15.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -6395,9 +6396,9 @@ } }, "node_modules/es-module-lexer": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", - "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.0.tgz", + "integrity": "sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==" }, "node_modules/es-set-tostringtag": { "version": "2.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", @@ -14631,9 +14640,9 @@ } }, "node_modules/schema-utils": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", - "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", + "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==", "dependencies": { "@types/json-schema": "^7.0.8", "ajv": "^6.12.5", @@ -15469,12 +15478,12 @@ } }, "node_modules/terser": { - "version": "5.16.5", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.5.tgz", - "integrity": "sha512-qcwfg4+RZa3YvlFh0qjifnzBHjKGNbtDo9yivMqMFDy9Q6FSaQWSB/j1xKhsoUFJIqDOM3TsN6D5xbrMrFcHbg==", + "version": "5.18.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.18.0.tgz", + "integrity": "sha512-pdL757Ig5a0I+owA42l6tIuEycRuM7FPY4n62h44mRLRfnOxJkkOHd6i89dOpwZlpF6JXBwaAHF6yWzFrt+QyA==", "dependencies": { - "@jridgewell/source-map": "^0.3.2", - "acorn": "^8.5.0", + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, @@ -15486,15 +15495,15 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", - "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", + "version": "5.3.9", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", + "integrity": "sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==", "dependencies": { - "@jridgewell/trace-mapping": "^0.3.14", + "@jridgewell/trace-mapping": "^0.3.17", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", - "serialize-javascript": "^6.0.0", - "terser": "^5.14.1" + "serialize-javascript": "^6.0.1", + "terser": "^5.16.8" }, "engines": { "node": ">= 10.13.0" @@ -16002,21 +16011,21 @@ } }, "node_modules/webpack": { - "version": "5.75.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz", - "integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==", + "version": "5.87.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.87.0.tgz", + "integrity": "sha512-GOu1tNbQ7p1bDEoFRs2YPcfyGs8xq52yyPBZ3m2VGnXGtV9MxjrkABHm4V9Ia280OefsSLzvbVoXcfLxjKY/Iw==", "dependencies": { "@types/eslint-scope": "^3.7.3", - "@types/estree": "^0.0.51", - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/wasm-edit": "1.11.1", - "@webassemblyjs/wasm-parser": "1.11.1", + "@types/estree": "^1.0.0", + "@webassemblyjs/ast": "^1.11.5", + "@webassemblyjs/wasm-edit": "^1.11.5", + "@webassemblyjs/wasm-parser": "^1.11.5", "acorn": "^8.7.1", - "acorn-import-assertions": "^1.7.6", + "acorn-import-assertions": "^1.9.0", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.10.0", - "es-module-lexer": "^0.9.0", + "enhanced-resolve": "^5.15.0", + "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", @@ -16025,9 +16034,9 @@ "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", - "schema-utils": "^3.1.0", + "schema-utils": "^3.2.0", "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.1.3", + "terser-webpack-plugin": "^5.3.7", "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" }, @@ -16284,11 +16293,6 @@ "node": ">=10.13.0" } }, - "node_modules/webpack/node_modules/@types/estree": { - "version": "0.0.51", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz", - "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==" - }, "node_modules/webpack/node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.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/src/App.css b/src/App.css index 05fe2d52e..76109353a 100644 --- a/src/App.css +++ b/src/App.css @@ -1,57 +1,143 @@ -.App { - text-align: left; +/* HEADER......... */ + +/* .hotel-logo{ + border-radius: 50%; + margin: 10px; + padding: 10px; + +} */ + +.App-header{ + display: flex; + align-items: center; + justify-content:space-between; + background-color: rgb(35, 38, 37); + margin-top: 2px; + margin-bottom: 2px; + } -.App-logo { - animation: App-logo-spin infinite 20s linear; - height: 80px; +.span{ + color: rgb(15, 119, 216); + font-family: fantasy; + text-align: center; } -.App-header { - background-color: #222; - height: 50px; - padding: 20px; - color: white; - text-align: left; - font-family: Arial, Helvetica, sans-serif; - font-size: 1em; - font-weight: bold; +.span2{ + color: orange; + font-family: fantasy; + text-align: center; } -.App-title { - font-size: 1.5em; + +/* ......TOURIST INFO..... */ + +.card-img-top { + margin-top: 5px; + margin-bottom: 5px; + width: 40%; + height: 40%; + border-radius: 5px; } -.App-content { - padding-top: 20px; - font-size: large; +.h3, .para { + text-align: center; + padding: 10px; + margin: 10px; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.Tourist-info{ + display: flex; + flex-direction: column; + align-items: center; + margin: 5px; + padding: 5px; + background-color: rgb(35, 38, 37); + color: aliceblue; } -.search { - padding: 5px 0 20px 0; + +/* ..........RESTAURANT........ */ + +/* Restaurant Button */ +.btn-zero{ + background-color: coral; + color: aliceblue; + font-size: 1rem; + line-height: 1.5; + border-radius: 0.25rem; + margin: 10px; } -tr { - color: #5b5757; +/* .......SEARCH RESULTS..... */ + +table, +th, +td { + border: 1px solid black; + font-family: fantasy; + text-align: center; + height: 50px; + padding: 8px; + color: black; + } -.results { - padding-top: 15px; +.row-highlight{ + background-color: rgb(170, 170, 162); } -.footer { - padding-top: 20px; +.row-none-highlight{ + background-color: white; +} +/* tr:hover {background-color: rgb(236, 149, 118);} */ +/* tr:hover {background-color: rgb(95, 184, 226);} */ +/* tr:nth-child(even) {background-color: #f2f2f2;} */ + +.card{ + padding: 5px; + margin: 5px; + display: flex; + flex-direction: row; + gap: 0rem; + margin-bottom: 0rem; + background-color:rgb(35, 38, 37); + +} + +.loading-message{ + margin: 10px; + padding: 10px; +} + +.container{ + display: flex; + margin: 20px; + padding: 20px; + flex-direction: column; + flex-wrap: nowrap; + align-items: center; + +} + +/* FOOTER...... */ + +.address{ + font-family: fantasy; text-align: center; + height: 50px; + padding: 10px; + margin: 10px; + list-style: none; + border-top: 1px solid rgb(49, 46, 42);; + background-color: rgb(16, 14, 13); + color: orange; + height: auto; } -.card { - width: 18rem; +.span{ + font-weight: bold; + color: orange; + padding: 8px; + margin: 10px; + border-bottom: 1px orange solid; } diff --git a/src/App.js b/src/App.js index 953c98560..55fdc89f2 100644 --- a/src/App.js +++ b/src/App.js @@ -1,13 +1,20 @@ import React from "react"; - +import Heading from "./Header"; +import Footer from "./Footer"; +import TouristInfoCards from "./TouristInfoCards"; import Bookings from "./Bookings"; +import Restaurant from "./Restaurant"; import "./App.css"; const App = () => { return (
-
CYF Hotel
+ {/*
CYF Hotel
*/} + + + +
); }; diff --git a/src/Bookings.js b/src/Bookings.js index e0d911b13..16970e0c5 100644 --- a/src/Bookings.js +++ b/src/Bookings.js @@ -1,11 +1,46 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; import Search from "./Search.js"; +import SearchResults from "../src/components/SearchResults.js"; +import CustomerProfile from "./CustomerProfile.js"; // import SearchResults from "./SearchResults.js"; // import FakeBookings from "./data/fakeBookings.json"; const Bookings = () => { - const search = searchVal => { - console.info("TO DO!", searchVal); + const [bookings, setBookings] = useState([]); + const [reset, setReset] = useState([]); + const [error, setError] = useState(false); + + useEffect(() => { + fetch(`https://cyf-react.glitch.me/delayed`) + .then((res) => res.json()) + .then((data) => { + setBookings(data); + setReset(data); + setError(true); + }); + }, []) + + if (bookings == false) { + return

Loading booking, Please wait.....

+ }; + + if(bookings.error) { + return error &&

HTTP eror 500...

+ } + + const search = (searchVal) => { + + const filterSearch = bookings.filter(function (bookings) { + return bookings.firstName == searchVal || bookings.surname == searchVal; + }); + + setBookings(filterSearch); + }; + + const resetHandler = () => { + console.log(reset); + + return setBookings(reset); }; return ( @@ -13,6 +48,10 @@ const Bookings = () => {
{/* */} + {/* */} + + + {/* */}
); diff --git a/src/CustomerProfile.js b/src/CustomerProfile.js new file mode 100644 index 000000000..5fe1929f1 --- /dev/null +++ b/src/CustomerProfile.js @@ -0,0 +1,41 @@ +// import { useState } from "react"; +// import { useEffect } from "react"; +import React, { useState, useEffect } from "react"; + +const CustomerProfile = ({id}) => { + + const [profile, setProfile] = useState(null); + + useEffect(() => { + fetch(`https://cyf-react.glitch.me/customers/${id}`) + .then((response) => { + return response.json(); + }) + .then((data) => { + setProfile(data); + console.log(id); + }) + .catch((error) => { + console.error(error); + }); + + }, [id]); + +// const { results } = props; + + return profile ? ( +
+

Customer ID: {profile.id}

+

Name: {profile.firstName} {profile.surname} +

+

E-mail: {profile.email}

+ {profile.vip ?

VIP

: "Not VIP"} +

Mobile: {profile.phoneNumber}

+
+ ) : ( + id &&

loading profile....

+ ); +}; + + +export default CustomerProfile; diff --git a/src/Footer.js b/src/Footer.js new file mode 100644 index 000000000..1d37fbc78 --- /dev/null +++ b/src/Footer.js @@ -0,0 +1,23 @@ +import React from "react"; +// import "./Footer.css"; + +const Footer = () => { + const address = [ + "123 Fake Street, London, E1 4UD", + "hello@fakehotel.com", + "0123 456789", + ]; + + const currentDate = new Date().toLocaleDateString(); + return ( + + ); +}; +export default Footer; diff --git a/src/Header.js b/src/Header.js new file mode 100644 index 000000000..93fb952f4 --- /dev/null +++ b/src/Header.js @@ -0,0 +1,23 @@ +import React from "react"; +// import "./Header.css"; + +const Header = () => { + // const logo = + + return ( +
+
+

CYFHOTEL LTD

+ {/* */} + + {/* */} +
+
+ ); +}; + +export default Header; diff --git a/src/Order.js b/src/Order.js new file mode 100644 index 000000000..b75549af0 --- /dev/null +++ b/src/Order.js @@ -0,0 +1,35 @@ +import React, { useState } from "react"; +import RestaurantButton from "./RestaurantButton"; +// import OrderCalculation from "./Utilities/OrderCalculation/" + +const Order = ({ orderType }) => { + const [count, setCount] = useState(0); + + const addOrder = () => { + setCount(count + 1); + }; + + +// const removeOrder = () => { +// setCount(count - 1); +// } + +const setToZero = () => { + setCount(0); +}; + + return ( +
+ +
+ ); +} + + +export default Order; diff --git a/src/Restaurant.js b/src/Restaurant.js index ecb2b43a2..fac96e16a 100644 --- a/src/Restaurant.js +++ b/src/Restaurant.js @@ -1,15 +1,19 @@ -import React from "react"; +// import React from "react" + +import Order from "./Order"; + const Restaurant = () => { - const pizzas = 0; + return ( -
-

Restaurant Orders

- +
+

Restaurant Orders:

+
+ + + + +
); }; diff --git a/src/RestaurantButton.js b/src/RestaurantButton.js new file mode 100644 index 000000000..ad5d032f2 --- /dev/null +++ b/src/RestaurantButton.js @@ -0,0 +1,11 @@ +const RestaurantButton = ({ handleClick, handleClick1 }) => { + return ( +
+ + + +
+ ); +}; + +export default RestaurantButton; diff --git a/src/Search.js b/src/Search.js index 7bd5871c0..9484e1929 100644 --- a/src/Search.js +++ b/src/Search.js @@ -1,6 +1,21 @@ -import React from "react"; +import React, { useState } from "react"; +import SearchButton from "./SearchButton"; + +const Search = (props) => { + + const [searchInput, setSearchInput] = useState(""); + function handleSearchInput(event) { + const updatedKeyword = event.target.value; + console.log(updatedKeyword); + setSearchInput(updatedKeyword); + } + + // get value from search input and pass it to the function called search that we get from the props + function handleSubmit(event) { + event.preventDefault(); + props.search(searchInput); + } -const Search = () => { return (
@@ -8,16 +23,18 @@ const Search = () => {
-
+
handleSearchInput(event)} id="customerName" className="form-control" placeholder="Customer name" /> - +
diff --git a/src/SearchButton.js b/src/SearchButton.js new file mode 100644 index 000000000..1f7f0f7ce --- /dev/null +++ b/src/SearchButton.js @@ -0,0 +1,11 @@ +import React from "react"; + + +const SearchButton = () => { + + return ( + + ); +}; + +export default SearchButton; \ No newline at end of file diff --git a/src/SearchResultsOld.js b/src/SearchResultsOld.js new file mode 100644 index 000000000..0e78d6a1d --- /dev/null +++ b/src/SearchResultsOld.js @@ -0,0 +1,79 @@ +// import React, { useState } from "react"; + +// import CustomerProfile from "./CustomerProfile"; +// import data from "./data/fakeBookings.json"; +// import moment from "moment"; +// const numberOfNights() + +// const SearchResults = (props) => { +// const [highlight, sethighlight] = useState(null); +// // const [customerid, setCustomerId] = useState(null); + +// const handleId = (props) => { + +// setCustomerId(props.id) +// } + +// const { results } = props; + +// const toggleHighlight = (index) => { +// if (index == highlight) { +// sethighlight(null); +// } else { +// sethighlight(index); +// } +// }; + +// console.log(props.id) + + +// return ( +// +// + +// +// +// +// +// +// +// +// +// +// +// +// +// + +// {results.map((item, index) => { +// return ( +// toggleHighlight(index)} +// style={{ backgroundColor: index == highlight ? "yellow" : "" }} +// key={index} +// > +// +// +// +// +// +// +// +// +// +// +// +// ); +// })} +// +// +//
IDTittleFirst NameSurnameEmailRoom IDcheck in Datecheck out DateNo of Night stayShow profile
{item.id}{item.title}{item.firstName}{item.surname}{item.email}{item.roomId}{item.checkInDate}{item.checkOutDate} +// {(new Date(`${item.checkOutDate}T00:00:01Z`) - +// new Date(`${item.checkInDate}T00:00:01Z`)) / +// 86400000} +// +// +//
+// ); +// }; +// export default SearchResults; diff --git a/src/TouristInfoCards.js b/src/TouristInfoCards.js new file mode 100644 index 000000000..3c4d78d62 --- /dev/null +++ b/src/TouristInfoCards.js @@ -0,0 +1,89 @@ +import React from "react"; + +const TouristInfoCards = () => { + return ( + <> + {/* TouristInfoCards - Glasgow */} +
+
+
+ Glasgow-img + +

Glasgow

+ +

+ Glasgow is a port city on the River Clyde in Scotland's western + Lowlands. It's famed for its Victorian and art nouveau + architecture, a rich legacy of the city's 18th century prosperity + due to trade and shipbuilding. +

+ + +
+ + {/* TouristInfoCards - Manchester */} + +
+ Manchester-img + +

Manchester

+ +

+ Manchester is a major city in the northwest of England with a rich + industrial heritage. The Castlefield conservation area’s + 18th-century canal system. +

+ + +
+ + {/* TouristInfoCards - London */} + +
+ Manchester-img +

London

+

+ London, 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. +

+ + +
+
+
+ + ); +}; +export default TouristInfoCards; diff --git a/src/Utilities/OrderCalculation.js b/src/Utilities/OrderCalculation.js new file mode 100644 index 000000000..03e9f8334 --- /dev/null +++ b/src/Utilities/OrderCalculation.js @@ -0,0 +1,16 @@ +// import React from "react"; + + +// const addOrder = () => { +// setCount(count + 1); +// }; + +// const removeOrder = () => { +// setCount(count - 1); +// }; + +// const setToZero = () => { +// setCount((0)); +// } + +// export default Order; \ No newline at end of file diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js new file mode 100644 index 000000000..8c052db84 --- /dev/null +++ b/src/components/SearchResults.js @@ -0,0 +1,24 @@ +import React, { useState } from "react"; +import TableHead from "./TableHead"; +import TableBody from "./TableBody"; +import CustomerProfile from "../CustomerProfile"; + +const SearchResults = ({ results, id }) => { + const [customerId, setCustomerId] = useState(""); + + function changeId(id) { + id > 0 && setCustomerId(id); + } +console.log(customerId) + return ( +
+ + + + +
+
+ ); +}; + +export default SearchResults; diff --git a/src/components/TableBody.js b/src/components/TableBody.js new file mode 100644 index 000000000..4ccedb124 --- /dev/null +++ b/src/components/TableBody.js @@ -0,0 +1,17 @@ +import React from "react"; + +import TableRow from "./TableRow"; + +const TableBody = ({ bookings, changeId }) => { + return ( + + {bookings && + bookings.length > 0 && + bookings.map((booking) => ( + + ))} + + ); +}; + +export default TableBody; diff --git a/src/components/TableHead.js b/src/components/TableHead.js new file mode 100644 index 000000000..2b376e014 --- /dev/null +++ b/src/components/TableHead.js @@ -0,0 +1,24 @@ +import React from "react"; + +const TableHead = () => { + + + return ( + + + Id + Title + First name + Surname + E-mail + Room id + Check-in date + Check-out date + No. of nights + Profile + + + ); +}; + +export default TableHead; diff --git a/src/components/TableRow.js b/src/components/TableRow.js new file mode 100644 index 000000000..46a761092 --- /dev/null +++ b/src/components/TableRow.js @@ -0,0 +1,63 @@ + +import react, {useState} from "react"; +import moment from "moment"; +const TableRow = ({ booking, changeId }) => { + + + const { + id, + title, + firstName, + surname, + email, + roomId, + checkInDate, + checkOutDate, + } = booking; + + const numOfDays = (checkInDate, checkOutDate) => { + const checkIn = moment(checkInDate); + const checkOut = moment(checkOutDate); + + return checkOut.diff(checkIn, "days"); + }; + + const [highlight, sethighlight] = useState(false); + const handleColor = () => sethighlight(!highlight); + + const handleClick = () => { + changeId(id); + + console.log(id); + + if (id) { + return console.log("handleClick clicked"); + } + }; + + return ( + + {id} + + {title} + {firstName} + {surname} + {email} + {roomId} + {checkInDate} + {checkOutDate} + {numOfDays(checkInDate, checkOutDate)} + + + + + ); +}; + +export default TableRow; diff --git a/src/data/fakeBookings.json b/src/data/fakeBookings.json index 2997792ea..da50bff3b 100644 --- a/src/data/fakeBookings.json +++ b/src/data/fakeBookings.json @@ -48,5 +48,15 @@ "roomId": 3, "checkInDate": "2017-08-30", "checkOutDate": "2017-10-02" + }, + { + "id": 6, + "title": "Mrs", + "firstName": "Anuradha", + "surname": "smith", + "email": "anu@smith.net", + "roomId": 3, + "checkInDate": "2017-08-30", + "checkOutDate": "2017-10-02" } ] diff --git a/src/index.css b/src/index.css index 4607bb217..a3d2de968 100644 --- a/src/index.css +++ b/src/index.css @@ -2,6 +2,10 @@ body { margin: 0; padding: 0; font-family: sans-serif; + /* background-color: rgb(35, 38, 37); + color: aliceblue; */ + /* font-family: fantasy; */ + } .search-wrapper {