summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-05-22 21:18:20 -0600
committerHombreLaser <sebastian-440@live.com>2023-05-22 21:18:20 -0600
commit21508a3514500f8f38ddaa8bef7a9cd420d76628 (patch)
treee416d58752154f7cbe78a96c1fbe35dd34a8703f /src/models
parentb5885b23a8d3593428334683b8c03075ce071f3a (diff)
Añade carrito
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