22 lines
834 B
TypeScript
22 lines
834 B
TypeScript
'use client';
|
|
|
|
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
|
import type { CategoryIconViewData } from '@/lib/view-data/CategoryIconViewData';
|
|
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
|
|
|
export class CategoryIconViewDataBuilder {
|
|
public static build(apiDto: GetMediaOutputDTO): CategoryIconViewData {
|
|
// Note: GetMediaOutputDTO from OpenAPI doesn't have buffer,
|
|
// but the implementation expects it for binary data.
|
|
const binaryDto = apiDto as unknown as { buffer?: ArrayBuffer };
|
|
const buffer = binaryDto.buffer;
|
|
|
|
return {
|
|
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
|
|
contentType: apiDto.type,
|
|
};
|
|
}
|
|
}
|
|
|
|
CategoryIconViewDataBuilder satisfies ViewDataBuilder<GetMediaOutputDTO, CategoryIconViewData>;
|