From 451b63b71c01952f59291a3b200d34e170aa8c0f Mon Sep 17 00:00:00 2001 From: Bart Akeley Date: Sun, 31 May 2020 15:43:53 -0500 Subject: [PATCH] wip converting to products from scraper --- js/apis/FavesApi.js | 5 +++-- js/pages/ProductDetail.js | 8 ++++---- js/records/ProductRecord.js | 6 ++---- js/streams/FavesStream.js | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/js/apis/FavesApi.js b/js/apis/FavesApi.js index 3ff5f49..3970172 100644 --- a/js/apis/FavesApi.js +++ b/js/apis/FavesApi.js @@ -21,13 +21,14 @@ export const fetchFaves = withLoggedInEmail(async email => { }); }); -export const putFaves = withLoggedInEmail(async (email, productIds) => { +export const putFaves = withLoggedInEmail(async (email, productId, photoUrl) => { return fetchRequest({ endpoint: '/fave', method: 'PUT', body: { email, - productIds, + productId, + photoUrl, }, }); }); diff --git a/js/pages/ProductDetail.js b/js/pages/ProductDetail.js index 2b1013c..d18fad5 100644 --- a/js/pages/ProductDetail.js +++ b/js/pages/ProductDetail.js @@ -53,7 +53,7 @@ const ProductImages = ({ )} @@ -63,12 +63,12 @@ const ProductImages = ({ onAnimateNextPage={changeCurrentImage} style={stretchedStyle} currentPage={currentImage}> - {visibleImages.map(image => ( + {visibleImages.map(imageUrl => ( ))} diff --git a/js/records/ProductRecord.js b/js/records/ProductRecord.js index a25e10f..e1f8394 100644 --- a/js/records/ProductRecord.js +++ b/js/records/ProductRecord.js @@ -2,7 +2,6 @@ import { Set, Record } from 'immutable'; import { type RawProduct } from '../apis/ProductsApi'; import { type Category } from '../constants/CategoryConstants'; import { type Quantity } from '../constants/QuantityConstants'; -import ImageRecord, { buildImageRecord } from './ImageRecord'; export type Product = { id: ?string, @@ -13,7 +12,7 @@ export type Product = { distance: number, quantity: Quantity, category: Category, - images: Set, + images: Set, thumbImage: ?string, titleImage: ?string, lastupdated: number, @@ -45,8 +44,7 @@ export const createProduct = (productRaw: ?RawProduct) => { ...productRaw, placeType: productRaw.placeType, thumbImage: productRaw.thumbimage, - // images: new Set(map(buildImageRecord, pathOr([], ['images'], productRaw))), - images: new Set([buildImageRecord({ url: productRaw.thumbimage })]), + images: new Set([productRaw.thumbimage]), }); }; diff --git a/js/streams/FavesStream.js b/js/streams/FavesStream.js index fcc4daa..2eb39fb 100644 --- a/js/streams/FavesStream.js +++ b/js/streams/FavesStream.js @@ -24,7 +24,7 @@ export function emitOne(fave: ?Fave) { export default observable .combineLatest(products$) .map(([faves, products]) => { - return faves && faves.map(fave => get(products, get(fave, 'food_item_id'))); + return faves && faves.map(fave => get(products, get(fave, 'product_id'))); }) .combineLatest(filter$) .map(([faveProducts, filter]) => {