|
1 | | -# Advanced Web Applications Sprint Challenge |
| 1 | +# Class Based Components - React Todo |
2 | 2 |
|
3 | | -**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** |
| 3 | +We're going to practice building a stateful class component with this project. Even though hooks are gaining popularity among react developers, class components are going to be around for a long time. It's imperative that you get use to class components, and feel comfortable working with class components since you'll most likely need to work with them if you are hired to work on a React app. |
4 | 4 |
|
5 | | -This challenge allows you to practice the concepts and techniques learned over the past sprint and apply them in a concrete project. This sprint explored **advanced web applications**. During this sprint, you studied **React testing, client-side auth, HTTP methods, and Vercel**. |
6 | 5 |
|
7 | | -In your challenge this week, you will demonstrate your mastery of these skills by creating **a login page** and **basic CRUD application.** |
8 | | - |
9 | | -This is an individual assessment. All work must be your own. All projects will be submitted to codegrade for automated review. You will also be given feedback by code reviewers the Monday (Wednesday for PT) after challenge submissions. For more information on the review process [click here.](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a) |
10 | | - |
11 | | -You are not allowed to collaborate during the sprint challenge. However, you are encouraged to follow the twenty-minute rule and seek support by dropping a :wave: in your help channel when needed. |
| 6 | +## Objectives |
| 7 | +- Build class components from scratch |
| 8 | +- Defining application state |
| 9 | +- Defining component state |
| 10 | +- Connecting state changes to components |
12 | 11 |
|
13 | 12 | ## Introduction |
14 | | - |
15 | | -In this project you will create a login page and request a token from the server that you'll use to send all other requests to the server. You will then be able to fetch the article data array, update data, and delete data, and watch the fun happen! |
16 | | - |
17 | | -## Instructions |
18 | | - |
19 | | -### Task 1: Project Setup |
20 | | - |
21 | | -* [ ] Fork and clone this repository. |
22 | | -* [ ] Implement the project with the `<firstName-lastName>` branch, committing changes regularly. |
23 | | -* [ ] Push commits: git push origin `<firstName-lastName>`. |
24 | | -* [ ] **RUN** `npm install` to install your dependencies. |
25 | | -* [ ] **RUN** `npm start` to start your application backend and frontend. |
26 | | -* [ ] **RUN** `npm test` to start your application's test runner. |
27 | | - |
28 | | -### Task 2: CodeGrade Setup |
29 | | - |
30 | | -* [ ] Open the assignment in Canvas and click on the "Set up git" option. |
31 | | -* [ ] Follow instructions to set up Codegrade's Webhook and Deploy Key, making sure your deployment is set to your `<firstName-lastName>`. **Make sure to add in `?branch=<firstname-lastname>` at the end of your webhook payload URL.** |
32 | | -* [ ] Push your first commit: `git commit --allow-empty -m "first commit" && git push` |
33 | | -* [ ] Check to see that Codegrade has accepted your git submission. |
34 | | - |
35 | | -### Task 3: Project Requirements |
36 | | - |
37 | | -Your finished project must include all of the following requirements. |
38 | | - |
39 | | -**See reference materials at the bottom of the this document for API Reference Details.** |
40 | | - |
41 | | -#### Login Authentication |
42 | | -> *Build a login form to authenticate your users along with all the components and utilities needed to support authentication.* |
43 | | -
|
44 | | -* [ ] In `Login.js`, build all UI and state functionality needed to capture a username and password. On a successful login, redirect user to the `View.js` component. |
45 | | -* [ ] **Make sure that the input for your username and password includes the id="username" and id="password" attributes. Codegrade autotests will fail without them.** |
46 | | -* [ ] **Make sure that the submit button to your login form includes the id="submit" attribute.** |
47 | | -* [ ] In `Login.js`, add a p tag that will hold an error state if occurs. Add in all state functionality needed to support error display. |
48 | | -* [ ] **Make sure your error p tag has an id="error" attribute attached. Codegrade autotests will fail without them.** |
49 | | -* [ ] Construct an http request that retrieves an auth token from the server when the username `Lambda` and the password `School` is passed into the request. Complete successful login auth flow and redirect to `View.js.` |
50 | | -* [ ] Display an appropriate error message when login is not successful. |
51 | | - |
52 | | -#### Route Authentication |
53 | | -> *Build the needed utilities to restrict access to private routes.* |
54 | | -* [ ] Build a `PrivateRoute` component within the components folder. |
55 | | -* [ ] Use the `PrivateRoute` component to build a route rendering `View.js` to the path `/view`. |
56 | | -* [ ] Use the `PrivateRoute` component to build a route rendering `Logout.js` to the path `/logout`. |
57 | | - |
58 | | -#### Request Authentication |
59 | | -> *Complete the requests needed to execute all CRUD functions.* |
60 | | -* [ ] Build a `axiosWithAuth` module within the utils folder to create an instance of axios with the authentication header. |
61 | | -* [ ] Complete the `services/articleService.js` module. It should make an authenticated call to retrieve and return all articles from the server. |
62 | | - |
63 | | -* [ ] In `View.js`, when the component mounts, use `articleService` to make an http request and add all articles to state. |
64 | | - |
65 | | -* [ ] In `View.js`, complete `handleDelete` so that a http request is made that deletes the article with the included id. After successfully deleting the article on the api, update local state to reflect these changes. |
66 | | - |
67 | | -* [ ] In `EditForm.js`, make a http request to get the article with the id `editId`. Save the result in state. |
68 | | - |
69 | | -* [ ] In `View.js`, complete `handleEdit` so that a http request is made that updates the passed in article. Set the editing state to false when the request is complete. After successfully deleting the article on the api, update local state to reflect these changes. |
70 | | - |
71 | | - |
72 | | -#### Logout Authentication |
73 | | -> *Add in the http requests needed to logout of the application.* |
74 | | -
|
75 | | -* [ ] In `Logout.js`, execute a http request to logout on mount. When the request is complete, the user's security token should be removed and the browser should redirect to the login page. |
76 | | - |
77 | | -#### Advanced Testing |
78 | | -> *Add the following tests within Article.test.js.* |
79 | | -* [ ] Build a test that shows the `Article` component, given the correct props, can render without errors. |
80 | | -* [ ] Build a test that shows that when a correctly formatted article is passed into the `Article` component, the correct headline, author, summary and body are displayed. |
81 | | -* [ ] The `Article` component should display "Associated Press" when an author attribute is not avalible. Build a test that verifies that that is true. |
82 | | -* [ ] Build a test that show that when the deleteButton is pressed on an Article, the handleDelete functional property is executed. |
83 | | - |
84 | | -> *Add the following tests within View.test.js.* |
85 | | -* [ ] Build a test that shows the `View` component can render zero articles without errors. Make sure the mock service called made when View mounts. |
86 | | -* [ ] Build a test that shows the `View` component can render three articles without errors. Make sure the mock service called made when View mounts. |
87 | | - |
88 | | -**Notes:** |
89 | | -* You are welcome to create additional files but **do not move or rename existing files** or folders. |
90 | | -* Do not change your `package.json` file except to install additional libraries. |
91 | | -* In your solution, it is essential that you follow best practices and produce clean and professional results. |
92 | | -* Schedule time to review, refine, and assess your work and perform basic professional polishing including spell-checking and grammar-checking on your work. |
93 | | -* It is better to submit a challenge that meets MVP than one that attempts too much and does not. |
94 | | - |
95 | | -### Reference Materials |
96 | | - |
97 | | -#### API Documentation |
98 | | -* **[POST]** * to `http://localhost:5000/api/login`: returns a the current authenication information of the user. Pass in the following credentials as the `body` of the request: `{ username: 'Lambda', password: 'School' }` for a successful login. |
99 | | - |
100 | | -* **[POST]** * to `http://localhost:5000/api/logout`: returns the expired authentication information of the user. |
101 | | - |
102 | | -* **[GET]** to `http://localhost:5000/api/articles`: returns the all posts currently available. **This endpoint can only be accessed by an authenticated user.** |
103 | | - |
104 | | -* **[POST]** to `http://localhost:5000/api/articles`: creates a article object. Returns all available articles. Pass the article as the `body` of the request. **This endpoint can only be accessed by an authenticated user.** |
105 | | - |
106 | | -* **[PUT]** to `http://localhost:5000/api/articles/:id`: updates the article using the `id` passed as part of the URL. Returns all available articles. Send the updated article object as the `body` of the request. **This endpoint can only be accessed by an authenticated user.** |
107 | | - |
108 | | -* **[DELETE]** to `http://localhost:5000/api/articles/:id`: removes the article with the `id` referenced. Returns all available articles. **This endpoint can only be accessed by an authenticated user.** |
109 | | - |
110 | | -#### Article Data Structure |
111 | | -``` |
112 | | -{ |
113 | | - id: 'aMqwd', //unique article id |
114 | | - headline: "headline", //title of article |
115 | | - createdOn: '2021-08-09T18:02:38-04:00 |
116 | | -', //timestamp of when article was added |
117 | | - summary: "summary", //short summary statement of article |
118 | | - body: "" //paragraph of article text |
119 | | -} |
| 13 | +In this project you will build an application that allows for todos to be added, toggle and checked off. Please use ALL CLASS BASED COMPONENTS when creating this application and use the Guided project as a model. This application should: |
| 14 | +- Use the following gif as base for building DOM: |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +- Hold all todos in state within the App.js component. That todos state slice should look like the following: |
| 19 | +```js |
| 20 | +[ |
| 21 | + { |
| 22 | + task: 'Organize Garage', |
| 23 | + id: 1528817077286, |
| 24 | + completed: false |
| 25 | + }, |
| 26 | + { |
| 27 | + task: 'Bake Cookies', |
| 28 | + id: 1528817084358, |
| 29 | + completed: false |
| 30 | + } |
| 31 | +]; |
120 | 32 | ``` |
| 33 | +- Allow for a todo to be toggled when clicking on an item. |
| 34 | +- Allow for a todo be be added when submitting the todo form component. |
| 35 | +- Allow for completed todos to be cleared when clicking the clear completed button. |
121 | 36 |
|
122 | | -## Submission format |
123 | | -* [ ] Submit via Codegrade by commiting and pushing any new changes. |
124 | | -* [ ] Check codegrade for automated feedback. |
125 | | -* [ ] Check codegrade on Monday following the Sprint Challenge for reviewer feedback. For more information on how to access and read your feedback, check [here](https://www.notion.so/lambdaschool/How-to-View-Feedback-in-CodeGrade-c5147cee220c4044a25de28bcb6bb54a) |
126 | | -* [ ] Any changes pushed to your <firstName-lastName> branch will resubmited to codegrade if pushed before the sprint challenge deadline. Changes after the deadline will not be reviewed. |
127 | 37 |
|
128 | | -## Interview Questions |
| 38 | +***Make sure to complete your tasks one at a time and complete test each task before proceding forward.*** |
129 | 39 |
|
130 | | -Be prepared to demonstrate your understanding of this week's concepts by answering questions on the following topics. Add your answers to the questions within `interview_answers.md` file. These will not be counted as a part of your sprint score but will be helpful for preparing you for your endorsement interview, and enhancing overall understanding. |
131 | | - |
132 | | -1. Explain what a token is used for. |
133 | | -2. What steps can you take in your web apps to keep your data secure? |
134 | | -3. Describe how web servers work. |
135 | | -4. Which HTTP methods can be mapped to the CRUD acronym that we use when interfacing with APIs/Servers. |
| 40 | +## Instructions |
| 41 | +### Task 1: Project Set Up |
| 42 | +* [ ] Create a forked copy of this project. |
| 43 | +* [ ] Clone your OWN version of the repository in your terminal |
| 44 | +* [ ] cd into the project base directory `cd web-module-project-lifecycle` |
| 45 | +* [ ] Download project dependencies by running `npm install` |
| 46 | +* [ ] Start up the app using `npm start` |
| 47 | + |
| 48 | +### Task 2: Project Requirements |
| 49 | +- **Don't focus on styling yet**. We want you to worry about function over form today. |
| 50 | +- **Build all components as class components.** |
| 51 | +- Your todo list should display a list of todos, an input field, a submit button, and a clear all button. |
| 52 | +- Be sure to use the given files for building out these components. |
| 53 | +- `<App />` will hold all the data needed for this project. It will also be the container for your Todo Components. |
| 54 | + - All of your application data will be stored here on `<App />`. |
| 55 | + - All of your `handler` functions should live here on `<App />`. |
| 56 | +- `<TodoList />` receives your Todos array and iterates over the list generating a new `<Todo />` for each element in the array. |
| 57 | +- `<Todo />` is a component that takes in the `todo` data and displays the task to the screen. |
| 58 | +- `<TodoForm>` will hold your input field and your `Add Todo` and `Clear Completed` buttons. |
| 59 | + - Your input field should take in user input, and allow a user to press `Enter` or click on the `Submit Button` to add a todo to your list. |
| 60 | + - Once a todo is submitted, the Todo List should re-render and show the added todo. |
0 commit comments