diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-09-12 17:26:25 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-09-12 17:26:25 -0400 |
commit | 78daddbbbee1b67bbf3960e3d4d08d0757547207 (patch) | |
tree | 21a91819e4f88fdbb559748dfa06d5e491ea3554 /iridescence/src/api/dichroism.js | |
parent | 4dffff999d4025ddb593f5f44bf4ecccf577a0e5 (diff) | |
download | theglassyladies-78daddbbbee1b67bbf3960e3d4d08d0757547207.tar.xz theglassyladies-78daddbbbee1b67bbf3960e3d4d08d0757547207.zip |
Working product name updating; working mock Dichroism API.
Diffstat (limited to 'iridescence/src/api/dichroism.js')
-rw-r--r-- | iridescence/src/api/dichroism.js | 29 |
1 files changed, 19 insertions, 10 deletions
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; } } |