From 21508a3514500f8f38ddaa8bef7a9cd420d76628 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Mon, 22 May 2023 21:18:20 -0600 Subject: AƱade carrito MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/product.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/models/product.ts (limited to 'src/models/product.ts') diff --git a/src/models/product.ts b/src/models/product.ts new file mode 100644 index 0000000..b375537 --- /dev/null +++ b/src/models/product.ts @@ -0,0 +1,26 @@ +export interface Product { + id: number; + name: string; + picture: string; + unitary_price: number; + bulk_price: number; + available_quantity: number; + company_name: string; +} + +export function mapProduct(data: any) { + if(!data) + return null; + + const product: Product = { + id: data.id, + name: data.attributes.name, + picture: data.attributes.picture, + unitary_price: data.attributes.unitary_price, + bulk_price: data.attributes.bulk_price, + available_quantity: data.attributes.available_quantity, + company_name: data.attributes.company.name + }; + + return product; +} \ No newline at end of file -- cgit v1.2.3