Skip to content

Commit 1d0be98

Browse files
authored
Merge pull request #3462 from pablo-maff/part5-spanish
Part5 spanish
2 parents c8a9afa + 2c8af25 commit 1d0be98

File tree

9 files changed

+1039
-880
lines changed

9 files changed

+1039
-880
lines changed

src/content/5/en/part5a.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const App = () => {
8686
export default App
8787
```
8888

89-
The current application code can be found on [Github](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-1), branch <i>part5-1</i>. If you clone the repo, don't forget to run _npm install_ before attempting to run the frontend.
89+
The current application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-1), in the branch <i>part5-1</i>. If you clone the repo, don't forget to run _npm install_ before attempting to run the frontend.
9090

9191
The frontend will not display any notes if it's not connected to the backend. You can start the backend with _npm run dev_ in its folder from Part 4. This will run the backend on port 3001. While that is active, in a separate terminal window you can start the frontend with _npm start_, and now you can see the notes that are saved in your MongoDB database from Part 4.
9292

@@ -294,10 +294,11 @@ return (
294294

295295
<Notification message={errorMessage} />
296296

297-
{!user && loginForm()}
298-
{user && <div>
299-
<p>{user.name} logged in</p>
300-
{noteForm()}
297+
{user === null ?
298+
loginForm() :
299+
<div>
300+
<p>{user.name} logged-in</p>
301+
{noteForm()}
301302
</div>
302303
}
303304

@@ -309,11 +310,11 @@ return (
309310
)
310311
```
311312

312-
The solution isn't perfect, but we'll leave it for now.
313+
The solution isn't perfect, but we'll leave it like this for now.
313314

314315
Our main component <i>App</i> is at the moment way too large. The changes we did now are a clear sign that the forms should be refactored into their own components. However, we will leave that for an optional exercise.
315316

316-
The current application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-2), branch <i>part5-2</i>.
317+
The current application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-2), in the branch <i>part5-2</i>.
317318

318319
### Creating new notes
319320

@@ -376,7 +377,7 @@ const update = (id, newObject) => {
376377
export default { getAll, create, update, setToken } // highlight-line
377378
```
378379

379-
The noteService module contains a private variable _token_. Its value can be changed with a function _setToken_, which is exported by the module. _create_, now with async/await syntax, sets the token to the <i>Authorization</i> header. The header is given to axios as the third parameter of the <i>post</i> method.
380+
The noteService module contains a private variable called _token_. Its value can be changed with the _setToken_ function, which is exported by the module. _create_, now with async/await syntax, sets the token to the <i>Authorization</i> header. The header is given to axios as the third parameter of the <i>post</i> method.
380381

381382
The event handler responsible for login must be changed to call the method <code>noteService.setToken(user.token)</code> with a successful login:
382383

@@ -420,7 +421,7 @@ The value of a key can be found with the method [getItem](https://developer.mozi
420421
window.localStorage.getItem('name')
421422
```
422423

423-
and [removeItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem) removes a key.
424+
while [removeItem](https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem) removes a key.
424425

425426
Values in the local storage are persisted even when the page is re-rendered. The storage is [origin](https://developer.mozilla.org/en-US/docs/Glossary/Origin)-specific so each web application has its own storage.
426427

@@ -453,13 +454,13 @@ Changes to the login method are as follows:
453454
}
454455
```
455456

456-
The details of a logged-in user are now saved to the local storage, and they can be viewed on the console (by typing _window.localStorage_ to the console):
457+
The details of a logged-in user are now saved to the local storage, and they can be viewed on the console (by typing _window.localStorage_ in it):
457458

458-
![browser showing someone logged into notes](../../images/5/3e.png)
459+
![browser showing user data in console saved in local storage](../../images/5/3e.png)
459460

460-
You can also inspect the local storage using the developer tools. On Chrome, go to the <i>Application</i> tab and select <i>Local Storage</i> (more details [here](https://developers.google.com/web/tools/chrome-devtools/storage/localstorage)). On Firefox go to the <i>Storage</i> tab and select <i>Local Storage</i> (details [here](https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector)).
461+
You can also inspect the local storage using the developer tools. On Chrome, go to the <i>Application</i> tab and select <i>Local Storage</i> (more details [here](https://developer.chrome.com/docs/devtools/storage/localstorage)). On Firefox go to the <i>Storage</i> tab and select <i>Local Storage</i> (details [here](https://firefox-source-docs.mozilla.org/devtools-user/storage_inspector/index.html)).
461462

462-
We still have to modify our application so that when we enter the page, the application checks if user details of a logged-in user can already be found on the local storage. If they can, the details are saved to the state of the application and to <i>noteService</i>.
463+
We still have to modify our application so that when we enter the page, the application checks if user details of a logged-in user can already be found on the local storage. If they are there, the details are saved to the state of the application and to <i>noteService</i>.
463464

464465
The right way to do this is with an [effect hook](https://react.dev/reference/react/useEffect): a mechanism we first encountered in [part 2](/en/part2/getting_data_from_server#effect-hooks), and used to fetch notes from the server.
465466

@@ -514,34 +515,34 @@ or with the command which empties <i>localstorage</i> completely:
514515
window.localStorage.clear()
515516
```
516517

517-
The current application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-3), branch <i>part5-3</i>.
518+
The current application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-3), in the branch <i>part5-3</i>.
518519

519520
</div>
520521

521522
<div class="tasks">
522523

523524
### Exercises 5.1.-5.4.
524525

525-
We will now create a frontend for the bloglist backend we created in the last part. You can use [this application](https://github.com/fullstack-hy2020/bloglist-frontend) from GitHub as the base of your solution. You need to connect your backend with proxy as shown in [part 3](https://fullstackopen.com/en/part3/deploying_app_to_internet#proxy).
526+
We will now create a frontend for the blog list backend we created in the last part. You can use [this application](https://github.com/fullstack-hy2020/bloglist-frontend) from GitHub as the base of your solution. You need to connect your backend with a proxy as shown in [part 3](/en/part3/deploying_app_to_internet#proxy).
526527

527-
It is enough to submit your finished solution. You can do a commit after each exercise, but that is not necessary.
528+
It is enough to submit your finished solution. You can commit after each exercise, but that is not necessary.
528529

529530
The first few exercises revise everything we have learned about React so far. They can be challenging, especially if your backend is incomplete.
530531
It might be best to use the backend that we marked as the answer for part 4.
531532

532533
While doing the exercises, remember all of the debugging methods we have talked about, especially keeping an eye on the console.
533534

534-
**Warning:** If you notice you are mixing in the functions _async/await_ and _then_ commands, it's 99.9% certain you are doing something wrong. Use either or, never both.
535+
**Warning:** If you notice you are mixing in the _async/await_ and _then_ commands, it's 99.9% certain you are doing something wrong. Use either or, never both.
535536

536-
#### 5.1: bloglist frontend, step1
537+
#### 5.1: Blog List Frontend, step 1
537538

538539
Clone the application from [GitHub](https://github.com/fullstack-hy2020/bloglist-frontend) with the command:
539540

540541
```bash
541542
git clone https://github.com/fullstack-hy2020/bloglist-frontend
542543
```
543544

544-
<i>remove the git configuration of the cloned application</i>
545+
<i>Remove the git configuration of the cloned application</i>
545546

546547
```bash
547548
cd bloglist-frontend // go to cloned repository
@@ -563,7 +564,7 @@ If a user is not logged in, <i>only</i> the login form is visible.
563564

564565
If the user is logged-in, the name of the user and a list of blogs is shown.
565566

566-
![browser showing notes and who is logged in](../../images/5/5e.png)
567+
![browser showing blogs and who is logged in](../../images/5/5e.png)
567568

568569
User details of the logged-in user do not have to be saved to the local storage yet.
569570

@@ -592,29 +593,29 @@ User details of the logged-in user do not have to be saved to the local storage
592593
}
593594
```
594595

595-
#### 5.2: bloglist frontend, step2
596+
#### 5.2: Blog List Frontend, step 2
596597

597598
Make the login 'permanent' by using the local storage. Also, implement a way to log out.
598599

599600
![browser showing logout button after logging in](../../images/5/6e.png)
600601

601602
Ensure the browser does not remember the details of the user after logging out.
602603

603-
#### 5.3: bloglist frontend, step3
604+
#### 5.3: Blog List Frontend, step 3
604605

605606
Expand your application to allow a logged-in user to add new blogs:
606607

607608
![browser showing new blog form](../../images/5/7e.png)
608609

609-
#### 5.4: bloglist frontend, step4
610+
#### 5.4: Blog List Frontend, step 4
610611

611612
Implement notifications that inform the user about successful and unsuccessful operations at the top of the page. For example, when a new blog is added, the following notification can be shown:
612613

613-
![browser showing successful operation](../../images/5/8e.png)
614+
![browser showing successful operation notification](../../images/5/8e.png)
614615

615616
Failed login can show the following notification:
616617

617-
![browser showing failed login attempt](../../images/5/9e.png)
618+
![browser showing failed login attempt notification](../../images/5/9e.png)
618619

619620
The notifications must be visible for a few seconds. It is not compulsory to add colors.
620621

0 commit comments

Comments
 (0)