@@ -34,7 +34,10 @@ function NotesPage() {
34
34
35
35
/** очистка ошибок хука запросов и запись ошибки в сообщение*/
36
36
React . useEffect ( ( ) => {
37
- if ( error ) setMessage ( error )
37
+ if ( error ) {
38
+ setMessage ( error )
39
+ unsetEditNoteId ( )
40
+ }
38
41
/**Выйти в случае неавторизации */
39
42
if ( error === 'Нет авторизации' ) auth . logout ( )
40
43
clearError ( )
@@ -346,23 +349,29 @@ function NotesPage() {
346
349
{ /**Компонент добавления карточки и модальное окно редактирования */ }
347
350
< AddNote />
348
351
< ModalNoteEdit />
352
+ { /**Вывод ошибок */ }
353
+ { message &&
354
+ /**Ошибка загрузки данных */
355
+ < div className = "container text-center" >
356
+ < p className = "m-3 p-3 h5 text-muted" >
357
+ { ! ( notesArr && notesArr . length ) && "Data not loaded" }
358
+ < br />
359
+ { message }
360
+ </ p >
361
+ </ div >
362
+ }
349
363
{ /**Вариативное отображение контента (заметок) */ }
350
- { notesArr && notesArr . length ? (
364
+ { notesArr && notesArr . length ?
351
365
/**Список карточек */
352
366
< NoteList notes = { notesArr } />
353
- ) : ( loading ) ? null : ! message ? (
367
+ : ! loading && ! message &&
354
368
/**Сообщение об отсутствии карточек */
355
369
< div className = "container text-center" >
356
370
< p className = "m-3 p-3 h5 text-muted" > No Notes. You can add a new one!</ p >
357
371
</ div >
358
- ) : (
359
- /**Ошибка загрузки данных */
360
- < div className = "container text-center" >
361
- < p className = "m-3 p-3 h5 text-muted" > Data not loaded< br /> { message } </ p >
362
- </ div >
363
- ) }
372
+ }
364
373
{ /**Колесико загрузки */ }
365
- { ( loading && ! notesArr && editNoteId === null ) &&
374
+ { loading && ! notesArr && editNoteId === null &&
366
375
< div className = "container display-4 text-center p-3" >
367
376
< Loader />
368
377
</ div >
0 commit comments