|
1 | 1 | # React project setup. Class components. Error boundary |
2 | 2 |
|
3 | | -## Application Requirements |
4 | | - |
5 | | -1. Divide your page into at least two sections/components. The smaller section should be at the top, and the larger section should be at the bottom. |
6 | | -2. In the top section, place a _Search_ input and a "Search" button. The _Search_ component should look for a previously saved search term in the local storage (LS). If there isn't any, leave the input empty. |
7 | | -3. The bottom section should be used for displaying search results (name and a small description). |
8 | | -4. By default, the application makes a call to the selected API to get a list of items using the search term from the input (only the first page). If the input is empty, make a call to get all items. |
9 | | -5. When the user modifies the _Search_ input and clicks the "Search" button, the application makes a call to the API with the newly provided search term (the search term should not have any trailing spaces; process the input) to get the results (only the first page). |
10 | | -6. The provided search term should be saved to the LS. If the value exists, overwrite it. |
11 | | -7. If your application makes a request to the server API, this should be visible to the user. Implement a Spinner, Skeleton, Loading Bar, Blurring Content, or any other appropriate method in your UI to indicate this. |
12 | | -8. If the request didn't succeed (status code **4xx** or **5xx**), show the meaningful message. You can use [ModResponse](https://chromewebstore.google.com/detail/modresponse-mock-and-repl/bbjcdpjihbfmkgikdkplcalfebgcjjpm) or similar, to test this functionality. |
13 | | -9. Wrap the application in an error boundary to catch errors. Report an error to the console and show a fallback UI (use respective methods for this). Create a button that will throw an error on click to test the functionality. |
| 3 | +## Functional Requirements |
| 4 | + |
| 5 | +### Feature 1: Application Layout Structure (**5 points**) |
| 6 | + |
| 7 | +**As a** user |
| 8 | +**I want** to see a clearly organized page layout |
| 9 | +**So that** I can easily interact with the search functionality and view results |
| 10 | + |
| 11 | +**Scenario:** Page Layout Organization |
| 12 | + |
| 13 | +- **Given** I am on the application page |
| 14 | +- **Then** I should see two distinct sections: |
| 15 | + - A smaller search section at the top |
| 16 | + - A larger results section at the bottom |
| 17 | + |
| 18 | +### Feature 2: Search Functionality with Local Storage (**15 points**) |
| 19 | + |
| 20 | +**As a** user |
| 21 | +**I want** to have a search interface that remembers my last search |
| 22 | +**So that** I can continue my previous search session |
| 23 | + |
| 24 | +**Scenario:** Initial Search Component Load |
| 25 | + |
| 26 | +- **Given** I open the application |
| 27 | +- **When** the search component loads |
| 28 | +- **Then** it should check local storage for a previous search term |
| 29 | +- **And** populate the search input if a term exists |
| 30 | +- **Or** leave it empty if no previous term is found |
| 31 | + |
| 32 | +### Feature 3: Search Results Display (**10 points**) |
| 33 | + |
| 34 | +**As a** user |
| 35 | +**I want** to see search results clearly displayed |
| 36 | +**So that** I can easily review the found items |
| 37 | + |
| 38 | +**Scenario:** Results Display Format |
| 39 | + |
| 40 | +- **Given** I am viewing the results section |
| 41 | +- **Then** each result should display: |
| 42 | + - Item name |
| 43 | + - Item description |
| 44 | + |
| 45 | +### Feature 4: Initial Data Load (**10 points**) |
| 46 | + |
| 47 | +**As a** user |
| 48 | +**I want** to see relevant items when I first open the application |
| 49 | +**So that** I can start browsing immediately |
| 50 | + |
| 51 | +**Scenario:** Default Data Load |
| 52 | + |
| 53 | +- **Given** I open the application |
| 54 | +- **When** it initially loads |
| 55 | +- **Then** it should fetch the first page of items based on: |
| 56 | + - The search term from input if it exists |
| 57 | + - All available items if no search term exists |
| 58 | + |
| 59 | +### Feature 5: Search Execution (**20 points**) |
| 60 | + |
| 61 | +**As a** user |
| 62 | +**I want** to search for specific items |
| 63 | +**So that** I can find relevant content |
| 64 | + |
| 65 | +**Scenario:** Perform Search |
| 66 | + |
| 67 | +- **Given** I am on the search page |
| 68 | +- **When** I enter a search term |
| 69 | +- **And** click the "Search" button |
| 70 | +- **Then** the system should: |
| 71 | + - Remove any trailing spaces from the input |
| 72 | + - Fetch the first page of matching results |
| 73 | + - Update the display with new results |
| 74 | + |
| 75 | +### Feature 6: Search Term Persistence (**5 points**) |
| 76 | + |
| 77 | +**As a** user |
| 78 | +**I want** my search terms to be saved |
| 79 | +**So that** I can resume my search later |
| 80 | + |
| 81 | +**Scenario:** Save Search Term |
| 82 | + |
| 83 | +- **Given** I perform a search |
| 84 | +- **When** I click the "Search" button |
| 85 | +- **Then** the search term should be saved to local storage |
| 86 | +- **And** overwrite any existing saved term |
| 87 | + |
| 88 | +### Feature 7: Loading State Indication (**10 points**) |
| 89 | + |
| 90 | +**As a** user |
| 91 | +**I want** to know when the application is loading data |
| 92 | +**So that** I understand when to wait for results |
| 93 | + |
| 94 | +**Scenario:** API Request Loading State |
| 95 | + |
| 96 | +- **Given** I initiate any API request |
| 97 | +- **Then** I should see a loading indicator (Spinner/Skeleton/Loading Bar/Blur) |
| 98 | +- **And** the indicator should remain until data loads |
| 99 | + |
| 100 | +### Feature 8: Error Handling (**10 points**) |
| 101 | + |
| 102 | +**As a** user |
| 103 | +**I want** to be informed when something goes wrong |
| 104 | +**So that** I understand why my request failed |
| 105 | + |
| 106 | +**Scenario:** Failed API Request |
| 107 | + |
| 108 | +- **Given** I make a search request |
| 109 | +- **When** the server returns an error (4xx or 5xx) |
| 110 | +- **Then** I should see a meaningful error message |
| 111 | + |
| 112 | +### Feature 9: Application Error Boundary (**15 points**) |
| 113 | + |
| 114 | +**As a** user |
| 115 | +**I want** the application to handle errors gracefully |
| 116 | +**So that** I can still use the app even if parts of it fail |
| 117 | + |
| 118 | +**Scenario:** Error Boundary Implementation |
| 119 | + |
| 120 | +- **Given** an error occurs in the application |
| 121 | +- **Then** the error should be logged to the console |
| 122 | +- **And** a fallback UI should be displayed |
| 123 | +- **And** there should be a test button to simulate errors |
14 | 124 |
|
15 | 125 | ## Template |
16 | 126 |
|
@@ -73,10 +183,6 @@ Non-successful response. |
73 | 183 |
|
74 | 184 | 6. You can use CSS frameworks (e.g. Tailwind CSS). |
75 | 185 |
|
76 | | -## Points |
77 | | - |
78 | | -A student can achieve a maximum of 100 points. |
79 | | - |
80 | 186 | ## FAQ (Frequently Asked Questions) |
81 | 187 |
|
82 | 188 | ### ❓ Does the search input require an exact name match? |
@@ -109,31 +215,28 @@ No. The PR will update automatically as long as it's not merged. |
109 | 215 | Function components are allowed, but **state and lifecycle functionality must be implemented using class components**. |
110 | 216 | Hooks are not permitted in this task. |
111 | 217 |
|
112 | | -### Cross-check (score can be less if some parts of the functionality don't work) |
| 218 | +### Penalties |
113 | 219 |
|
114 | | -- Eslint is set up, when _lint_ command is run it doesn't produce any errors (if there are warnings score might be less) - **15 points** |
115 | | -- Prettier is set up, _format:fix_ command fixes issues - **15 points** |
116 | | -- Husky is set up, linting is run on pre-commit - **10 points** |
117 | | -- Page is split into at least two sections, top one has _Search_ input and "Search" button, main section displays the list of results from the selected api when page is opened for the first time (loader should be shown while app makes a call to the api) - **20 points** |
118 | | -- When user types something to the _Search_ input and clicks "Search" button, a loader is displayed and the list is changed according to the response results for a provided search term - **15 points** |
119 | | -- The search term typed into the _Search_ input is saved in the LS when user clicks on "Search" button (check it by closing the tab and open the app in the new one - the initial call should contain previously entered search term) - **15 points** |
120 | | -- Application is wrapped with ErrorBoundary, which logs error to a console and shows a fallback UI. There should be a button to throw an error - **10 points** |
| 220 | +- **1. Project setup** |
121 | 221 |
|
122 | | -### Penalties |
| 222 | + - Project has been set up without using [Vite](https://vitejs.dev/guide/) with the [_react-ts_ template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts): **-95 points** |
| 223 | + |
| 224 | +- **2. TypeScript & Code Quality** |
123 | 225 |
|
124 | | -- **1. TypeScript & Code Quality** |
125 | 226 | - TypeScript isn't used: **-95 points** |
126 | 227 | - Usage of _any_: **-20 points per each** |
127 | 228 | - Usage of _ts-ignore_: **-20 points per each** |
128 | 229 | - Presence of _code-smells_ (God-object, chunks of duplicate code), commented code sections: **-10 points per each** |
129 | 230 |
|
130 | | -- **2. React Best Practices** |
| 231 | +- **3. React Best Practices** |
| 232 | + |
131 | 233 | - Direct DOM manipulations inside the React components: **-50 points per each** |
132 | 234 | - React hooks are used to get access to either state, or to the component lifecycle: **-70 points** |
133 | 235 |
|
134 | | -- **3. External Dependencies** |
| 236 | +- **4. External Dependencies** |
| 237 | + |
135 | 238 | - Usage of Redux or other state management libraries: **-100 points** |
136 | 239 | - Usage of component libraries, e.g. Material UI, Ant Design: **-100 points** |
137 | 240 |
|
138 | | -- **4. Project Management** |
| 241 | +- **5. Project Management** |
139 | 242 | - Pull Request doesn't follow guideline (including checkboxes in Score) [PR example](https://rs.school/docs/en/pull-request-review-process#pull-request-description-must-contain-the-following): **-10 points** |
0 commit comments