|
| 1 | +# Sprint Challenge: Advanced React |
| 2 | + |
| 3 | +## Intro |
| 4 | + |
| 5 | +In this challenge, you will write the logic for [THIS](https://the-gabe-grid.herokuapp.com/) widget. |
| 6 | + |
| 7 | +Study its functionality and also inspect the Console, the Network tab and the Elements tab in Chrome Dev Tools: |
| 8 | + |
| 9 | +- There are two versions of the widget, with identical functionality. |
| 10 | +- The input box at the bottom of the page expects a valid email address. |
| 11 | +- Email validation errors arrive from the server, as you can see in the Network tab, under "Preview". |
| 12 | +- The payload sent to the server on form submit can also be seen in the Network tab, under "Payload". |
| 13 | +- The origin of coordinates of the grid is at its top-left corner. |
| 14 | +- One valid email in particular, `[email protected]`, **results in a server error. ** |
| 15 | + |
| 16 | +## Requirements |
| 17 | + |
| 18 | +### Tools |
| 19 | + |
| 20 | +- Node 16.x |
| 21 | +- NPM 8.x (update NPM executing `npm i -g npm`) |
| 22 | +- Chrome >= 96.x |
| 23 | + |
| 24 | +Other configurations might work but haven't been tested. |
| 25 | + |
| 26 | +### Optional Tools |
| 27 | + |
| 28 | +- Postman (download [here](https://www.postman.com/downloads/)) |
| 29 | + |
| 30 | +## Project Setup |
| 31 | + |
| 32 | +- Fork, clone, and `npm install`. You don't need to add any extra libraries. |
| 33 | +- Launch the project on a dev server running `npm run dev`. |
| 34 | +- See your widget visiting `http://localhost:3000` in Chrome. |
| 35 | +- Run tests locally executing `npm test`. The test file is `codegrade_mvp.test`. |
| 36 | + |
| 37 | +## API |
| 38 | + |
| 39 | +- The application includes an endpoint on `POST http://localhost:9000/result`. |
| 40 | +- You can experiment with this endpoint using an HTTP client like Postman. |
| 41 | +- The endpoint expects a payload like `{ "x": 1, "y": 2, "steps": 3, "email": "[email protected]" }`: |
| 42 | + - `x` is an integer between 1 and 3. |
| 43 | + - `y` is an integer between 1 and 3. |
| 44 | + - `steps` is an integer larger than 0. |
| 45 | + - `email` is a valid email address. |
| 46 | + |
| 47 | +## MVP |
| 48 | + |
| 49 | +### MVP 1, The Grid -- Long Explanation |
| 50 | + |
| 51 | +- Replicate the **functionality and DOM** shown in the prototype linked at the top of this README. |
| 52 | +- Keep your code inside `frontend/components/AppFunctional.js` and `frontend/components/AppClass.js`. |
| 53 | +- The component exposed by `AppFunctional.js` must be a stateful functional component. |
| 54 | +- The one in `AppClass.js` must be a stateful class-based component. |
| 55 | +- The DOM produced by your components must match exactly the DOM in the prototype: |
| 56 | + - The HTML hierarchy, ids, class names etc must be the same. |
| 57 | + - The current square is marked with a capital B. |
| 58 | + - Success and error messages must be those sent by the API (see Network tab -> "Preview"). |
| 59 | + - No frontend form validation code is required. |
| 60 | +- The coordinates of each square of the grid are as follows: |
| 61 | + |
| 62 | + ``` |
| 63 | + (1, 1) (2, 1) (3, 1) |
| 64 | + (1, 2) (2, 2) (3, 2) |
| 65 | + (1, 3) (2, 3) (3, 3) |
| 66 | + ``` |
| 67 | + |
| 68 | +### MVP 1, The Grid -- Short Explanation |
| 69 | + |
| 70 | +- Make **ALL** the tests pass! |
| 71 | + |
| 72 | +### MVP 2, Testing |
| 73 | + |
| 74 | +- Using `codegrade_mvp.test.js` as inspiration, write a few tests inside `frontend/components/App.test.js`: |
| 75 | + - From inside the test file, import a component of your choosing, either `AppClass.js` or `AppFunctional.js`. |
| 76 | + - Test that emails over 100 characters long result in a particular server error on the screen. |
| 77 | + - Inspect the API with Postman to see what this error actually is. |
| 78 | + |
| 79 | +### Stretch Goals |
| 80 | + |
| 81 | +- Extract some of the stateful logic into a custom hook at the top of `AppFunctional.js`. |
| 82 | +- Build a stateless component responsible for rendering the markup in the stateful components, so it does not have to be repeated. |
| 83 | +- Do not break your MVP by pushing broken stretch goals. You must keep your tests passing at 100%. |
| 84 | + |
| 85 | +### Important Notes |
| 86 | + |
| 87 | +- Design the state of the app before opening your editor. You might need fewer pieces of state than you think! |
| 88 | +- Find the simplest data structure that describes effectively the state of the grid. |
| 89 | +- "Product" works hard designing the messages: we must reproduce them faithfully, down to the last comma. |
| 90 | +- If you start with Functional, don't switch to Class-Based until Functional is passing all tests (and viceversa). |
| 91 | +- If the direction of the `y` axis surprises you, know that elements in HTML also have their origin of coordinates at their top-left corner. |
0 commit comments