From 78daddbbbee1b67bbf3960e3d4d08d0757547207 Mon Sep 17 00:00:00 2001
From: "Adam T. Carpenter" <atc@53hor.net>
Date: Sat, 12 Sep 2020 17:26:25 -0400
Subject: Working product name updating; working mock Dichroism API.

---
 iridescence/src/api/dichroism.js | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

(limited to 'iridescence/src/api')

diff --git a/iridescence/src/api/dichroism.js b/iridescence/src/api/dichroism.js
index ff64ced..718269a 100644
--- a/iridescence/src/api/dichroism.js
+++ b/iridescence/src/api/dichroism.js
@@ -9,7 +9,7 @@ export default class Dichroism {
         imgPath: "/beach_box.jpg",
         description: "This is a beach box.",
         featured: false,
-        categories: ["Fused Glass", ["Beachy"]]
+        categories: ["Fused Glass", "Beachy"]
       },
       {
         id: 2,
@@ -19,7 +19,7 @@ export default class Dichroism {
         imgPath: "/wind-chime.jpg",
         description: "Makes noise when the wind blows.",
         featured: false,
-        categories: ["Fused Glass", ["Beachy"]]
+        categories: ["Fused Glass", "Beachy"]
       },
       {
         id: 3,
@@ -29,7 +29,7 @@ export default class Dichroism {
         imgPath: "/beach_box.jpg",
         description: "This is a beach box.",
         featured: false,
-        categories: ["Stained Glass", ["Christmas"]]
+        categories: ["Stained Glass", "Christmas"]
       },
       {
         id: 4,
@@ -39,7 +39,7 @@ export default class Dichroism {
         imgPath: "/wind-chime.jpg",
         description: "Makes noise when the wind blows.",
         featured: false,
-        categories: ["Fused Glass", ["Kiln-y"]]
+        categories: ["Fused Glass", "Kiln-y"]
       },
       {
         id: 5,
@@ -49,22 +49,31 @@ export default class Dichroism {
         imgPath: "/beach_box.jpg",
         description: "This is a beach box.",
         featured: true,
-        categories: ["Stained Glass", ["Christmas"]]
+        categories: ["Stained Glass", "Christmas"]
       }
     ];
   }
 
   getProducts() {
-    return this.products;
+    return this.products.slice(0);
   }
 
-  updateProduct(product) {
-    if (!product) {
+  updateProduct(newProduct) {
+    if (!newProduct) {
       return;
     }
+
     for (let i = 0; i < this.products.length; i++) {
-      if (product.id == this.products[i].id) {
-        this.products[i] = product;
+      if (newProduct.id == this.products[i].id) {
+        let currentProduct = this.products[i];
+        currentProduct.id = newProduct.id;
+        currentProduct.name = newProduct.name;
+        currentProduct.quantity = newProduct.quantity;
+        currentProduct.cents = newProduct.cents;
+        currentProduct.imgPath = newProduct.imgPath;
+        currentProduct.description = newProduct.description;
+        currentProduct.featured = newProduct.featured;
+        currentProduct.categories = newProduct.categories.slice(0);
         return;
       }
     }
-- 
cgit v1.2.3