-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature/issue 562/hide&show volunteers button settings #564
Feature/issue 562/hide&show volunteers button settings #564
Conversation
src/pages/history/[year].tsx
Outdated
@@ -77,12 +80,15 @@ export const getServerSideProps = async ({ params }: GetServerSidePropsContext<R | |||
throw new InternalServerError(); | |||
} | |||
} | |||
|
|||
const settings = await fetcher<{ show_volunteers: boolean }>('/info/settings/'); |
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.
Уже есть класс под эту апи
show_team: boolean; |
есть даже методы для получения данных
export function fetchSettings() { |
Не знаю что из этого лучше использовать, но дублирования должно быть как можно меньше.
Вообще, должен быть какой-то сервис, вызывая методы которого будут возвращаться данные отпределённого типа. И этот сервис должен вызываться в во всех местах, а не через фетч в каждом компоненте и странице
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.
я добавил volunteers-dto в mapDTOToSettings, a в year.tsx добавил функция fetchSettings для получения show_volunteers
src/services/api/settings-adapter.ts
Outdated
team: dto.show_team, | ||
volunteers: dto.show_volunteers, | ||
sponsors: dto.show_sponsors, | ||
mission: true, | ||
'about-us': true, |
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.
Названия на стороне фронта плохие. когда смотришь на переменную volunteers
, то можно ожидать чего угодно, например. что внутри список волонтёров. show_volunteers
уже выглядит как предикат, который содержит флаг true/false.
Давай назовём как в переменной с бэка. В идеале, переименовать и другие переменные в этом блоке.
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.
Предлагаю все свойства поменять.
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.
всех местах пр сделано изменения
show_team: dto.show_team,
show_volunteers: dto.show_volunteers,
show_sponsors: dto.show_sponsors,
Ссылка на задачу
Переход по ссылке на список волонтёров падает с 500 ошибкой. #562
Когда show_volunteers равно false: Кнопка с ссылкой на страницу команды не отображается, а поле ведет себя как обычное числовое поле.
Когда show_volunteers равно true: Появляется кнопка со ссылкой на страницу команды.
Получение значения show_volunteers:
В getServerSideProps компонента Team добавлено извлечение значения show_volunteers из API (/info/settings/).
Значение show_volunteers передается в компонент History и далее в компонент HistoryTitle.
Обработка логики в HistoryTitle:
Компонент HistoryTitle принимает свойство showVolunteers.
В объекте cards добавлен buttonProps только если showVolunteers равно true. Если showVolunteers равно false, свойство buttonProps не устанавливается, и кнопка не рендерится.