Move to Renderer V2

This commit is contained in:
duckietm
2024-04-03 09:27:56 +02:00
parent 110c3ad393
commit b3134ce50b
4080 changed files with 115593 additions and 66375 deletions
@@ -0,0 +1,30 @@
import { IProductData } from '@nitrots/api';
export class ProductData implements IProductData
{
private _type: string;
private _name: string;
private _description: string;
constructor(type: string, name: string, description: string)
{
this._type = type;
this._name = name;
this._description = description;
}
public get type(): string
{
return this._type;
}
public get name(): string
{
return this._name;
}
public get description(): string
{
return this._description;
}
}
@@ -0,0 +1,35 @@
import { IProductData } from '@nitrots/api';
import { GetConfiguration } from '@nitrots/configuration';
import { ProductData } from './ProductData';
export class ProductDataLoader
{
private _products: Map<string, IProductData>;
constructor(products: Map<string, IProductData>)
{
this._products = products;
}
public async init(): Promise<void>
{
const url = GetConfiguration().getValue<string>('productdata.url');
if(!url || !url.length) throw new Error('invalid product data url');
const response = await fetch(url);
if(response.status !== 200) throw new Error('Invalid product data file');
const responseData = await response.json();
this.parseProducts(responseData.productdata);
}
private parseProducts(data: { [index: string]: any }): void
{
if(!data) return;
for(const product of data.product) (product && this._products.set(product.code, new ProductData(product.code, product.name, product.description)));
}
}
+2
View File
@@ -0,0 +1,2 @@
export * from './ProductData';
export * from './ProductDataLoader';