├── .gitignore ├── .prettierrc ├── README.md ├── __mocks__ ├── axios.js └── react-router-dom.js ├── package.json ├── public ├── favicon.ico ├── ice-cream-images │ ├── ice-cream-0.svg │ ├── ice-cream-1.svg │ ├── ice-cream-10.svg │ ├── ice-cream-11.svg │ ├── ice-cream-12.svg │ ├── ice-cream-13.svg │ ├── ice-cream-14.svg │ ├── ice-cream-15.svg │ ├── ice-cream-16.svg │ ├── ice-cream-17.svg │ ├── ice-cream-18.svg │ ├── ice-cream-19.svg │ ├── ice-cream-2.svg │ ├── ice-cream-20.svg │ ├── ice-cream-21.svg │ ├── ice-cream-22.svg │ ├── ice-cream-23.svg │ ├── ice-cream-24.svg │ ├── ice-cream-25.svg │ ├── ice-cream-26.svg │ ├── ice-cream-27.svg │ ├── ice-cream-28.svg │ ├── ice-cream-3.svg │ ├── ice-cream-4.svg │ ├── ice-cream-5.svg │ ├── ice-cream-6.svg │ ├── ice-cream-7.svg │ ├── ice-cream-8.svg │ └── ice-cream-9.svg ├── index.html └── manifest.json ├── server └── index.js ├── src ├── App.js ├── __tests__ │ ├── __snapshots__ │ │ └── app.spec.js.snap │ └── app.spec.js ├── assets │ ├── css │ │ └── style.css │ ├── fonts │ │ ├── cornerstone.woff │ │ ├── cornerstone.woff2 │ │ ├── geomanist │ │ │ ├── geomanist-book.eot │ │ │ ├── geomanist-book.svg │ │ │ ├── geomanist-book.ttf │ │ │ ├── geomanist-book.woff │ │ │ ├── geomanist-book.woff2 │ │ │ ├── geomanist-medium.eot │ │ │ ├── geomanist-medium.svg │ │ │ ├── geomanist-medium.ttf │ │ │ ├── geomanist-medium.woff │ │ │ ├── geomanist-medium.woff2 │ │ │ ├── geomanist-regular.eot │ │ │ ├── geomanist-regular.svg │ │ │ ├── geomanist-regular.ttf │ │ │ ├── geomanist-regular.woff │ │ │ └── geomanist-regular.woff2 │ │ └── kathen │ │ │ └── kathen.otf │ └── img │ │ └── ultimate-ice-cream.svg ├── data │ ├── __mocks__ │ │ └── iceCreamData.js │ ├── __tests__ │ │ └── iceCreamData.spec.js │ └── iceCreamData.js ├── hooks │ ├── useUniqueIds.js │ └── useValidation.js ├── ice-cream │ ├── AddIceCream.js │ ├── EditIceCream.js │ ├── ErrorContainer.js │ ├── IceCream.js │ ├── IceCreamCard.js │ ├── IceCreamCardContainer.js │ ├── IceCreamImage.js │ ├── IceCreams.js │ ├── Menu.js │ ├── __mocks__ │ │ ├── IceCream.js │ │ └── IceCreamImage.js │ └── __tests__ │ │ ├── AddIceCream.spec.js │ │ ├── EditIceCream.spec.js │ │ ├── IceCream.spec.js │ │ ├── IceCreamCard.spec.js │ │ ├── IceCreamCardContainer.spec.js │ │ ├── IceCreamImage.spec.js │ │ ├── IceCreams.spec.js │ │ ├── Menu.spec.js │ │ └── __snapshots__ │ │ └── IceCreamImage.spec.js.snap ├── index.js ├── setupTests.js ├── structure │ ├── FocusLink.js │ ├── Footer.js │ ├── Header.js │ ├── LoaderMessage.js │ ├── Main.js │ ├── __mocks__ │ │ ├── FocusLink.js │ │ ├── LoaderMessage.js │ │ └── Main.js │ └── __tests__ │ │ ├── FocusLink.spec.js │ │ ├── Footer.spec.js │ │ ├── Header.spec.js │ │ ├── LoaderMessage.spec.js │ │ ├── Main.spec.js │ │ └── __snapshots__ │ │ ├── FocusLink.spec.js.snap │ │ ├── Footer.spec.js.snap │ │ ├── Header.spec.js.snap │ │ └── Main.spec.js.snap └── utils │ ├── __tests__ │ └── validators.spec.js │ └── validators.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | .idea 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5" 4 | } 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /__mocks__/axios.js: -------------------------------------------------------------------------------- 1 | export default { 2 | get: jest.fn(() => Promise.resolve({ data: {} })), 3 | post: jest.fn(() => Promise.resolve({ data: {} })), 4 | put: jest.fn(() => Promise.resolve({ data: {} })), 5 | delete: jest.fn(() => Promise.resolve()), 6 | }; 7 | -------------------------------------------------------------------------------- /__mocks__/react-router-dom.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export const Link = ({ children, to }) => 4 | typeof to === 'string' ? ( 5 | {children} 6 | ) : ( 7 | 8 | {children} 9 | {to.state && {JSON.stringify(to.state)}} 10 | Link 11 | 12 | ); 13 | 14 | export const NavLink = ({ children, to }) => 15 | typeof to === 'string' ? ( 16 | {children} 17 | ) : ( 18 | 19 | {children} 20 | {to.state && {JSON.stringify(to.state)}} 21 | NavLink 22 | 23 | ); 24 | 25 | export const withRouter = component => component; 26 | 27 | export const Switch =({children}) =>
{children}
; 28 | 29 | export const Route = ({path, component}) => { 30 | return <>{component.name}{path} 31 | } 32 | 33 | export const Redirect = ({to}) => Redirect to {to}; 34 | 35 | export const BrowserRouter = ({children}) =>
{children}
36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "proxy": "http://localhost:5000", 3 | "name": "ultimate-react-icecream", 4 | "version": "0.1.0", 5 | "private": true, 6 | "dependencies": { 7 | "@emotion/core": "^10.0.10", 8 | "axios": "^0.18.0", 9 | "body-parser": "^1.19.0", 10 | "emotion": "^10.0.9", 11 | "express": "^4.16.4", 12 | "prettier": "^1.17.0", 13 | "prop-types": "^15.7.2", 14 | "react": "^16.8.6", 15 | "react-dom": "^16.8.6", 16 | "react-helmet": "^5.2.1", 17 | "react-router-dom": "^5.0.0", 18 | "react-scripts": "3.0.1", 19 | "uniqid": "^5.0.3" 20 | }, 21 | "devDependencies": { 22 | "jest-dom": "^3.2.2", 23 | "jest-emotion": "^10.0.11", 24 | "@testing-library/react": "^8.0.1" 25 | }, 26 | "scripts": { 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject", 31 | "start-server": "node ./server/index.js", 32 | "format": "prettier --write src/**/*.{js,scss}" 33 | }, 34 | "eslintConfig": { 35 | "extends": "react-app" 36 | }, 37 | "jest": { 38 | "collectCoverageFrom": [ 39 | "src/**/*.{js,jsx}", 40 | "!src/index.js" 41 | ], 42 | "snapshotSerializers": [ 43 | "jest-emotion" 44 | ] 45 | }, 46 | "browserslist": { 47 | "production": [ 48 | ">0.2%", 49 | "not dead", 50 | "not op_mini all" 51 | ], 52 | "development": [ 53 | "last 1 chrome version", 54 | "last 1 firefox version", 55 | "last 1 safari version" 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ultimatecourses/ultimate-react-icecream/bc4aadef58841f087d74996955a9342e124b9a80/public/favicon.ico -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-0.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 15 | 16 | 17 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 23 | 25 | 29 | 31 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-10.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 12 | 17 | 25 | 27 | 28 | 29 | 34 | 35 | 38 | 41 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-11.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 31 | 34 | 36 | 39 | 41 | 44 | 47 | 50 | 53 | 56 | 58 | 63 | 70 | 72 | 75 | 77 | 79 | 81 | 83 | 86 | 89 | 92 | 94 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-14.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 11 | 19 | 20 | 21 | 25 | 26 | 30 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-18.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 30 | 31 | 34 | 36 | 39 | 41 | 44 | 46 | 47 | 50 | 51 | 52 | 56 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-19.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 42 | 43 | 44 | 46 | 50 | 52 | 55 | 58 | 62 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 20 | 22 | 25 | 27 | 30 | 32 | 35 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 53 | 56 | 59 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-20.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 27 | 29 | 31 | 35 | 40 | 41 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-22.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 24 | 25 | 27 | 30 | 31 | 40 | 51 | 53 | 56 | 57 | 58 | 63 | 64 | 67 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-23.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 44 | 52 | 63 | 74 | 75 | 79 | 82 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-24.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 19 | 20 | 22 | 24 | 27 | 29 | 32 | 34 | 47 | 48 | 49 | 50 | 51 | 53 | 55 | 58 | 61 | 63 | 65 | 66 | 68 | 70 | 72 | 73 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-4.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 28 | 30 | 47 | 52 | 54 | 55 | 57 | 59 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 17 | 19 | 21 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-6.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 32 | 41 | 50 | 51 | 52 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-7.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 21 | 23 | 28 | 34 | 36 | 37 | 39 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /public/ice-cream-images/ice-cream-8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 41 | 42 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 73 | 75 | 77 | 79 | 81 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | Ultimate Ice Cream 23 | 24 | 25 | 26 |
27 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require('body-parser'); 3 | const app = express(); 4 | app.use(bodyParser.json()); 5 | const port = 5000; 6 | 7 | const iceCreams = [ 8 | { id: 0, name: 'Stripey Madness' }, 9 | { id: 1, name: 'Cherry Blast' }, 10 | { id: 2, name: 'Cookie Tower of Power' }, 11 | { id: 3, name: 'Inverted Stoplight' }, 12 | { id: 4, name: 'Roswell Crash' }, 13 | { id: 5, name: 'Arctic Rainbow' }, 14 | { id: 6, name: 'Chocolate Hat' }, 15 | { id: 7, name: 'Strawberry Jerry' }, 16 | { id: 8, name: 'Mint Stack' }, 17 | { id: 9, name: 'Cookie on a Stick' }, 18 | { id: 10, name: 'Snowman Godfather' }, 19 | { id: 11, name: 'Choco Mirror Ball' }, 20 | { id: 12, name: 'Hearty Treat' }, 21 | { id: 13, name: 'Strawberry Valentine' }, 22 | { id: 14, name: "Stick 'o Lime" }, 23 | { id: 15, name: 'Catastrophe' }, 24 | { id: 16, name: 'Purple People Eater' }, 25 | { id: 17, name: 'Strawberry Pine Tree' }, 26 | { id: 18, name: 'It Blue My Mind' }, 27 | { id: 19, name: 'Pistachio Satellite' }, 28 | { id: 20, name: 'I Come in Peace' }, 29 | { id: 21, name: 'Castle in the Sky' }, 30 | { id: 22, name: 'Young Faithful' }, 31 | { id: 23, name: 'Old Faithful' }, 32 | { id: 24, name: 'Raspberry Pi' }, 33 | { id: 25, name: 'Powerball' }, 34 | { id: 26, name: 'Shaken and Whipped' }, 35 | { id: 27, name: 'Sundae Everyday' }, 36 | { id: 28, name: 'Toxic Sludge' }, 37 | ]; 38 | 39 | let menuData = [ 40 | { 41 | id: 1, 42 | iceCream: { id: 1, name: 'Cherry Blast' }, 43 | inStock: true, 44 | quantity: 20, 45 | price: 1.51, 46 | description: 47 | 'Blast your taste buds into fruity space with this vanilla and cherry bomb', 48 | }, 49 | { 50 | id: 2, 51 | iceCream: { id: 15, name: 'Catastrophe' }, 52 | inStock: true, 53 | quantity: 30, 54 | price: 1.64, 55 | description: 'A feline strawberry cranium, what could possibly go wrong?', 56 | }, 57 | { 58 | id: 3, 59 | iceCream: { id: 10, name: 'Snowman Godfather' }, 60 | inStock: true, 61 | quantity: 30, 62 | price: 1.5, 63 | description: "You'll lose your head over this inverted whisky-vanilla cone", 64 | }, 65 | { 66 | id: 4, 67 | iceCream: { id: 4, name: 'Roswell Crash' }, 68 | inStock: true, 69 | quantity: 10, 70 | price: 1.82, 71 | description: 'A zing of lime straight from Area 51', 72 | }, 73 | { 74 | id: 5, 75 | iceCream: { id: 27, name: 'Sundae Everyday' }, 76 | inStock: false, 77 | quantity: 0, 78 | price: 2.98, 79 | description: 'Hazelnut and vanilla, chocolate and cherries', 80 | }, 81 | { 82 | id: 6, 83 | iceCream: { id: 21, name: 'Castle in the Sky' }, 84 | inStock: true, 85 | quantity: 50, 86 | price: 2.19, 87 | description: 'A floating stronghold of vanilla, chocolate and pistachio', 88 | }, 89 | { 90 | id: 7, 91 | iceCream: { id: 24, name: 'Raspberry Pi' }, 92 | inStock: true, 93 | quantity: 20, 94 | price: 1.29, 95 | description: 'Chocolate electricity on a motherboard of raspberry', 96 | }, 97 | ]; 98 | 99 | const getAvailableStock = () => 100 | iceCreams.filter( 101 | iceCream => 102 | menuData.find(menuItem => menuItem.iceCream.id === iceCream.id) === 103 | undefined 104 | ); 105 | 106 | app.get('/api/menu/stock-ice-creams', (req, res) => { 107 | res.send(getAvailableStock()); 108 | }); 109 | 110 | app.get('/api/menu/stock-ice-creams/:id', (req, res) => { 111 | const iceCream = getAvailableStock().find( 112 | iceCream => iceCream.id === parseInt(req.params.id, 10) 113 | ); 114 | if (iceCream) { 115 | res.send(iceCream); 116 | } else { 117 | res.status(404); 118 | res.send({ error: 'Ice cream not found' }); 119 | } 120 | }); 121 | 122 | app.get('/api/menu', (req, res) => { 123 | res.send(menuData); 124 | }); 125 | 126 | app.post('/api/menu', (req, res) => { 127 | const { iceCream, ...rest } = req.body; 128 | const newMenuItem = { 129 | id: menuData.reduce((prev, cur) => (cur.id > prev ? cur.id : prev), 0) + 1, 130 | iceCream: { 131 | ...iceCreams.find(item => item.id === parseInt(iceCream.id, 10)), 132 | }, 133 | ...rest, 134 | }; 135 | menuData.push(newMenuItem); 136 | 137 | res.send(newMenuItem); 138 | }); 139 | 140 | app.get('/api/menu/:id', (req, res) => { 141 | const menuItem = menuData.find( 142 | item => item.id === parseInt(req.params.id), 143 | 10 144 | ); 145 | if (menuItem) { 146 | res.send(menuItem); 147 | } else { 148 | res.status(404); 149 | res.send('Menu item does not exist'); 150 | } 151 | }); 152 | 153 | app.put('/api/menu/:id', (req, res) => { 154 | const intId = parseInt(req.params.id, 10); 155 | const { iceCream, ...rest } = req.body; 156 | 157 | const updatedItem = { 158 | id: intId, 159 | iceCream: { 160 | ...iceCreams.find(item => item.id === parseInt(iceCream.id, 10)), 161 | }, 162 | ...rest, 163 | }; 164 | menuData = menuData.map(menuItem => { 165 | if (menuItem.id === parseInt(req.params.id, 10)) { 166 | return updatedItem; 167 | } 168 | return menuItem; 169 | }); 170 | 171 | res.send(updatedItem); 172 | }); 173 | 174 | app.delete('/api/menu/:id', (req, res) => { 175 | menuData = menuData.filter( 176 | menuItem => menuItem.id !== parseInt(req.params.id, 10) 177 | ); 178 | res.status(204); 179 | res.send(); 180 | }); 181 | 182 | app.listen(port, () => 183 | console.log(`Project ICE server listening on port ${port}!`) 184 | ); 185 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | BrowserRouter as Router, 4 | Route, 5 | Switch, 6 | Redirect, 7 | } from 'react-router-dom'; 8 | import geomanistBookWoff from './assets/fonts/geomanist/geomanist-book.woff'; 9 | import geomanistBookWoff2 from './assets/fonts/geomanist/geomanist-book.woff2'; 10 | import cornerstoneWoff from './assets/fonts/cornerstone.woff'; 11 | import cornerstoneWoff2 from './assets/fonts/cornerstone.woff2'; 12 | import { Global, css } from '@emotion/core'; 13 | import Header from './structure/Header'; 14 | import Footer from './structure/Footer'; 15 | import Menu from './ice-cream/Menu'; 16 | import IceCreams from './ice-cream/IceCreams'; 17 | import EditIceCream from './ice-cream/EditIceCream'; 18 | import AddIceCream from './ice-cream/AddIceCream'; 19 | 20 | const globalStyle = css` 21 | @font-face { 22 | font-family: 'geomanist'; 23 | src: url(${geomanistBookWoff2}) format('woff2'), 24 | url(${geomanistBookWoff}) format('woff'); 25 | font-weight: 400; 26 | font-style: normal; 27 | } 28 | 29 | @font-face { 30 | font-family: 'cornerstone'; 31 | src: url(${cornerstoneWoff2}) format('woff2'), 32 | url(${cornerstoneWoff}) format('woff'); 33 | font-weight: 400; 34 | font-style: normal; 35 | } 36 | 37 | *, 38 | *:before, 39 | *:after { 40 | box-sizing: border-box; 41 | -webkit-box-sizing: border-box; 42 | -moz-box-sizing: border-box; 43 | } 44 | 45 | html, 46 | body { 47 | height: 100%; 48 | width: 100%; 49 | margin: 0; 50 | padding: 0; 51 | color: #333; 52 | background: #ff71ba; 53 | font-family: 'geomanist', sans-serif; 54 | -webkit-font-smoothing: antialiased; 55 | -moz-osx-font-smoothing: grayscale; 56 | display: flex; 57 | } 58 | 59 | #root { 60 | width: 100%; 61 | } 62 | 63 | a { 64 | &:hover { 65 | text-decoration: none; 66 | } 67 | } 68 | 69 | h1, 70 | h2, 71 | h3, 72 | h4, 73 | h5 { 74 | font-weight: normal; 75 | padding: 0; 76 | margin: 0; 77 | } 78 | 79 | h3 { 80 | font-size: 24px; 81 | } 82 | h4 { 83 | font-size: 20px; 84 | } 85 | 86 | .visually-hidden:not(:focus):not(:active) { 87 | clip: rect(0 0 0 0); 88 | clip-path: inset(100%); 89 | height: 1px; 90 | overflow: hidden; 91 | position: absolute; 92 | white-space: nowrap; 93 | width: 1px; 94 | } 95 | 96 | .skip-link { 97 | padding: 6px; 98 | position: absolute; 99 | top: -40px; 100 | left: 0px; 101 | color: white; 102 | border-right: 1px solid white; 103 | border-bottom: 1px solid white; 104 | border-bottom-right-radius: 8px; 105 | background: #5c4268; 106 | transition: top 1s ease-out; 107 | z-index: 100; 108 | 109 | &:focus { 110 | position: absolute; 111 | left: 0px; 112 | top: 0px; 113 | outline-color: transparent; 114 | transition: top 0.1s ease-in; 115 | } 116 | } 117 | `; 118 | 119 | const App = () => { 120 | return ( 121 | 122 | 123 | 124 | Skip to content 125 | 126 |
127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 |