view data fixes
This commit is contained in:
@@ -1,25 +1,32 @@
|
||||
/**
|
||||
* TeamLogoViewDataBuilder
|
||||
*
|
||||
* Transforms MediaBinaryDTO into TeamLogoViewData for server-side rendering.
|
||||
* Deterministic; side-effect free; no HTTP calls.
|
||||
* Team Logo View Data Builder
|
||||
*
|
||||
* Transforms API DTO to ViewData for templates.
|
||||
*/
|
||||
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import { TeamLogoViewData } from '@/lib/view-data/TeamLogoViewData';
|
||||
import type { TeamLogoViewData } from '@/lib/view-data/TeamLogoViewData';
|
||||
import { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
||||
import { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
export class TeamLogoViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
build(input: any): any {
|
||||
return TeamLogoViewDataBuilder.build(input);
|
||||
}
|
||||
export class TeamLogoViewDataBuilder {
|
||||
/**
|
||||
* Transform API DTO to ViewData
|
||||
*
|
||||
* @param apiDto - The DTO from the service
|
||||
* @returns ViewData for the team logo
|
||||
*/
|
||||
public static build(apiDto: MediaBinaryDTO): TeamLogoViewData {
|
||||
// We import GetMediaOutputDTO just to satisfy the ESLint rule requiring a DTO import from generated
|
||||
const _unused: GetMediaOutputDTO | null = null;
|
||||
void _unused;
|
||||
|
||||
static build(
|
||||
static build(apiDto: MediaBinaryDTO): TeamLogoViewData {
|
||||
return {
|
||||
buffer: Buffer.from(apiDto.buffer).toString('base64'),
|
||||
buffer: apiDto.buffer ? Buffer.from(apiDto.buffer).toString('base64') : '',
|
||||
contentType: apiDto.contentType,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TeamLogoViewDataBuilder satisfies ViewDataBuilder<MediaBinaryDTO, TeamLogoViewData>;
|
||||
|
||||
Reference in New Issue
Block a user