website refactor
This commit is contained in:
21
apps/website/lib/presenters/TeamsPresenter.ts
Normal file
21
apps/website/lib/presenters/TeamsPresenter.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { TeamsPageDto } from '@/lib/page-queries/TeamsPageQuery';
|
||||
import type { TeamsViewData, TeamSummaryData } from '@/templates/TeamsViewData';
|
||||
|
||||
/**
|
||||
* TeamsPresenter - Client-side presenter for teams page
|
||||
* Transforms PageQuery DTO into ViewData for the template
|
||||
* Deterministic; no hooks; no side effects
|
||||
*/
|
||||
export class TeamsPresenter {
|
||||
static createViewData(pageDto: TeamsPageDto): TeamsViewData {
|
||||
const teams = pageDto.teams.map((team): TeamSummaryData => ({
|
||||
teamId: team.id,
|
||||
teamName: team.name,
|
||||
leagueName: team.leagues[0] || '',
|
||||
memberCount: team.memberCount,
|
||||
logoUrl: team.logoUrl,
|
||||
}));
|
||||
|
||||
return { teams };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user