@@ -34,7 +34,10 @@ function NotesPage() {
3434
3535 /** очистка ошибок хука запросов и запись ошибки в сообщение*/
3636 React . useEffect ( ( ) => {
37- if ( error ) setMessage ( error )
37+ if ( error ) {
38+ setMessage ( error )
39+ unsetEditNoteId ( )
40+ }
3841 /**Выйти в случае неавторизации */
3942 if ( error === 'Нет авторизации' ) auth . logout ( )
4043 clearError ( )
@@ -346,23 +349,29 @@ function NotesPage() {
346349 { /**Компонент добавления карточки и модальное окно редактирования */ }
347350 < AddNote />
348351 < 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+ }
349363 { /**Вариативное отображение контента (заметок) */ }
350- { notesArr && notesArr . length ? (
364+ { notesArr && notesArr . length ?
351365 /**Список карточек */
352366 < NoteList notes = { notesArr } />
353- ) : ( loading ) ? null : ! message ? (
367+ : ! loading && ! message &&
354368 /**Сообщение об отсутствии карточек */
355369 < div className = "container text-center" >
356370 < p className = "m-3 p-3 h5 text-muted" > No Notes. You can add a new one!</ p >
357371 </ 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+ }
364373 { /**Колесико загрузки */ }
365- { ( loading && ! notesArr && editNoteId === null ) &&
374+ { loading && ! notesArr && editNoteId === null &&
366375 < div className = "container display-4 text-center p-3" >
367376 < Loader />
368377 </ div >
0 commit comments