Skip to content
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

Merged

Conversation

VLGrigoryan
Copy link
Contributor

@VLGrigoryan VLGrigoryan commented Aug 29, 2024

Ссылка на задачу

Переход по ссылке на список волонтёров падает с 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 не устанавливается, и кнопка не рендерится.

AlMkin
AlMkin previously approved these changes Sep 2, 2024
@@ -77,12 +80,15 @@ export const getServerSideProps = async ({ params }: GetServerSidePropsContext<R
throw new InternalServerError();
}
}

const settings = await fetcher<{ show_volunteers: boolean }>('/info/settings/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Уже есть класс под эту апи


есть даже методы для получения данных
export function fetchSettings() {

Не знаю что из этого лучше использовать, но дублирования должно быть как можно меньше.

Вообще, должен быть какой-то сервис, вызывая методы которого будут возвращаться данные отпределённого типа. И этот сервис должен вызываться в во всех местах, а не через фетч в каждом компоненте и странице

Copy link
Contributor Author

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

Comment on lines 38 to 42
team: dto.show_team,
volunteers: dto.show_volunteers,
sponsors: dto.show_sponsors,
mission: true,
'about-us': true,
Copy link
Member

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.
Давай назовём как в переменной с бэка. В идеале, переименовать и другие переменные в этом блоке.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

во всех местах пр делать изменении? или только мой?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предлагаю все свойства поменять.

Copy link
Contributor Author

@VLGrigoryan VLGrigoryan Sep 10, 2024

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,

@AntonZelinsky AntonZelinsky merged commit 6167e10 into develop Sep 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Переход по ссылке на список волонтёров падает с 500 ошибкой
3 participants