view data fixes
This commit is contained in:
@@ -1,25 +1,21 @@
|
||||
/**
|
||||
* CategoryIconViewDataBuilder
|
||||
*
|
||||
* Transforms MediaBinaryDTO into CategoryIconViewData for server-side rendering.
|
||||
* Deterministic; side-effect free; no HTTP calls.
|
||||
*/
|
||||
'use client';
|
||||
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
import { CategoryIconViewData } from '@/lib/view-data/CategoryIconViewData';
|
||||
import type { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
||||
import type { CategoryIconViewData } from '@/lib/view-data/CategoryIconViewData';
|
||||
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
export class CategoryIconViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
build(input: any): any {
|
||||
return CategoryIconViewDataBuilder.build(input);
|
||||
}
|
||||
|
||||
static build(
|
||||
static build(apiDto: MediaBinaryDTO): CategoryIconViewData {
|
||||
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.from(apiDto.buffer).toString('base64'),
|
||||
contentType: apiDto.contentType,
|
||||
buffer: buffer ? Buffer.from(buffer).toString('base64') : '',
|
||||
contentType: apiDto.type,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CategoryIconViewDataBuilder satisfies ViewDataBuilder<GetMediaOutputDTO, CategoryIconViewData>;
|
||||
|
||||
Reference in New Issue
Block a user