From 9a03c3ef854d136467cbd0c312b100c866e9236c Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 14 Jul 2025 14:59:11 +0200 Subject: [PATCH] feat(_mock): add typed attributes to document mocks and extend `Attribute` types --- src/client/dd-hub-react/src/_mock/_data.ts | 67 ++++++++++++++++++- .../src/services/document-service.ts | 3 + 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/client/dd-hub-react/src/_mock/_data.ts b/src/client/dd-hub-react/src/_mock/_data.ts index c660b27..69d78d1 100644 --- a/src/client/dd-hub-react/src/_mock/_data.ts +++ b/src/client/dd-hub-react/src/_mock/_data.ts @@ -1,7 +1,7 @@ import { Doc } from 'src/services/document-service'; import { Product } from 'src/services/product-service'; -import { Attribute } from 'src/services/attribute-service'; +import { Attribute, Type } from 'src/services/attribute-service'; import { _id, @@ -267,7 +267,60 @@ export const _documents: Doc[] = [ name: "example1.pdf", data: base64ToUint8Array(_base64.example1_pdf), addedWhen: new Date("2024-01-12T10:00:00Z"), - addedWho: "TekH" + addedWho: "TekH", + attributes: [ + { + name: "invoiceNumber", + serilizedValue: "INV-20250714-001", + type: 'VARCHAR' + }, + { + name: "customerName", + serilizedValue: "John Doe", + type: 'VARCHAR' + }, + { + name: "startDate", + serilizedValue: "2025-07-01", + type: 'DATE' + }, + { + name: "endDate", + serilizedValue: "2025-07-14", + type: 'DATE' + }, + { + name: "minAmount", + serilizedValue: "100.50", + type: 'DECIMAL' + }, + { + name: "maxAmount", + serilizedValue: "1000.00", + type: 'DECIMAL' + }, + { + name: "taxIncluded", + serilizedValue: "true", + type: 'BOOLEAN' + }, + { + name: "createdAt", + serilizedValue: "2025-07-10", + type: 'DATE' + }, + { + name: "deliveryTime", + serilizedValue: "15:30:00", + type: 'TIME' + }, + { + name: "lastUpdated", + serilizedValue: "2025-07-14T10:45:00", + type: 'DATETIME' + } + ] + }, { id: 2, @@ -301,4 +354,12 @@ export const _documents: Doc[] = [ addedWhen: new Date("2024-04-17T11:25:00Z"), addedWho: "SchreiberM" } -].map(doc => Doc.map(doc)); \ No newline at end of file +] + .map(doc => ({ + ...doc, + attributes: doc.attributes?.map(attr => ({ + ...attr, + type: attr.type as Type + })) + })) + .map(doc => Doc.map(doc)); \ No newline at end of file diff --git a/src/client/dd-hub-react/src/services/document-service.ts b/src/client/dd-hub-react/src/services/document-service.ts index 4545e44..bf44adf 100644 --- a/src/client/dd-hub-react/src/services/document-service.ts +++ b/src/client/dd-hub-react/src/services/document-service.ts @@ -1,5 +1,7 @@ import { _documents } from "src/_mock" +import { Type } from "./attribute-service"; + export type FileFormat = | 'pdf' | 'docx' @@ -25,6 +27,7 @@ const validExtensions: FileFormat[] = [ type DocAttribute = { name: string; serilizedValue: string; + type: Type; } export class Doc {