summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/product.ts26
1 files changed, 26 insertions, 0 deletions
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