-
Notifications
You must be signed in to change notification settings - Fork 0
Task 3 react api #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
KseniyaYatskevich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Использование кнопки Search для перехода на другую страницу - не лучшее решение, не понятно для пользователя
| onChangeSize('5'); | ||
| setSize('5'); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в данном случает также можно было бы использоать конструкцию switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправлено
src/components/Articles.tsx
Outdated
| <select name="pageSize" value={size} onChange={handleChoose} onBlur={handleChoose}> | ||
| <option value="5">5</option> | ||
| <option value="10">10</option> | ||
| <option value="20">20</option> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для option лучше создать массив значений и пройтити по этому массиву - проще измеить значения, добавить новые или удалить const pageSize = [ 5, 10, 20]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сделано
src/index.tsx
Outdated
| import App from './App'; | ||
|
|
||
| ReactDOM.render( | ||
| <BrowserRouter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не совсем понимаю зачем используется Router в этом задании...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправила
src/pages/Dashboard.tsx
Outdated
| import { ChangeEvent, FC, useState } from 'react'; | ||
| import Articles from '../components/Articles'; | ||
| import axios from '../services/api'; | ||
| import { Article, Get200Articles, SortType } from '../types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошая идея вынести типы в отдельный файл! Обычно название такого файла связано с названием файла к которому относится ComponentModel.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Заменено
| const [page, setPage] = useState<number>(1); | ||
| const [pageSize, setPageSize] = useState<string>('5'); | ||
| const [totalPages, setTotalPages] = useState<number>(1); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Молодец, что используешь хуки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/pages/Dashboard.tsx
Outdated
| checked={sortBy === SortType.publishedAt} | ||
| onChange={() => setSortBy(SortType.publishedAt)} | ||
| />{' '} | ||
| publishedAt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для пользователя лучше использовать что-то более понятное, хотя бы published
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Заменено на publication date
2

3. Выполнено задание согласно пунктам: строка поиска, список резульатов, переключатели сортировки, пагинация