From 281c4f3ced7415aa6289ca4ddf922c63e9fb39af Mon Sep 17 00:00:00 2001 From: Alvin Date: Fri, 6 Sep 2019 14:45:24 -0700 Subject: [PATCH 01/82] Fix banners in production build. --- components/src/style/reset.less | 1 - 1 file changed, 1 deletion(-) diff --git a/components/src/style/reset.less b/components/src/style/reset.less index a08d5dc69..008ca0c8f 100644 --- a/components/src/style/reset.less +++ b/components/src/style/reset.less @@ -38,7 +38,6 @@ time, mark, audio, video { padding: 0; border: 0; font-size: inherit; - vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ From bc0d56190673dd2b52d4b9d0228cbee183bcc6b6 Mon Sep 17 00:00:00 2001 From: Alvin Date: Mon, 9 Sep 2019 15:07:38 -0700 Subject: [PATCH 02/82] Able to get br search suggestion working --- app/src/ep.config.json | 32 ++++ components/src/AppHeader/appheader.main.tsx | 7 +- .../bloomreach.appheadersearch.main.tsx | 163 ++++++++++++++++++ .../bloomreach.headersearch.main.less | 126 ++++++++++++++ 4 files changed, 327 insertions(+), 1 deletion(-) create mode 100644 components/src/Bloomreach/bloomreach.appheadersearch.main.tsx create mode 100644 components/src/Bloomreach/bloomreach.headersearch.main.less diff --git a/app/src/ep.config.json b/app/src/ep.config.json index 580a76c39..47079fc21 100644 --- a/app/src/ep.config.json +++ b/app/src/ep.config.json @@ -94,6 +94,38 @@ "pageId": "", "applicationId": "" }, + "bloomreachSearch": { + "enable": true, + "config": { + "baseUri": "http://core.dxpapi.com/api/v1/core/?", + "accountId": "account_id=6226", + "authKey": "auth_key=fcao6uq86z58xup0", + "domainKey": "domain_key=elastic_path", + "requestId": "request_id=1239723156472", + "brUID2":"_br_uid_2=uid%3D8030319374785%3Av%3D11.8%3Ats%3D1536857546532%3Ahc%3D111", + "url": "url=www.bloomique.com", + "refurl": "ref_url=www.bloomique.com", + "keywordSearchConfig": { + "requestType": "request_type=search", + "rows": "rows=10", + "start": "start=0", + "facetLimit": "facet.limit=20", + "fl": "fl=pid%2Ctitle%2Cbrand%2Cprice%2Csale_price%2Cpromotions%2Cthumb_image%2Csku_thumb_images%2Csku_swatch_images%2Csku_color_group%2Curl%2Cprice_range%2Csale_price_range%2Cdescription", + "searchType": "search_type=keyword" + }, + "suggestionConfig": { + "baseUri": "http://suggest.dxpapi.com/api/v1/suggest/?", + "requestType": "request_type=suggest" + }, + "productRecommendationConfig": { + "requestType": "request_type=mlt", + "rows": "rows=10", + "start": "start=0", + "facetLimit": "facet.limit=20", + "fl": "fl=pid%2Ctitle%2Cbrand%2Cprice%2Csale_price%2Cpromotions%2Cthumb_image%2Csku_thumb_images%2Csku_swatch_images%2Csku_color_group%2Curl%2Cprice_range%2Csale_price_range%2Cdescription" + } + } + }, "GDPR": { "enable": false }, diff --git a/components/src/AppHeader/appheader.main.tsx b/components/src/AppHeader/appheader.main.tsx index 0893b6f6f..09ebd99b9 100644 --- a/components/src/AppHeader/appheader.main.tsx +++ b/components/src/AppHeader/appheader.main.tsx @@ -22,6 +22,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import AppHeaderSearchMain from '../AppHeaderSearch/appheadersearch.main'; +import BloomreachAppHeaderSearchMain from '../Bloomreach/bloomreach.appheadersearch.main'; import AppHeaderLoginMain from '../AppHeaderLogin/appheaderlogin.main'; import AppHeaderLocaleMain from '../AppHeaderLocale/appheaderlocale.main'; import AppHeaderNavigationMain from '../AppHeaderNavigation/appheadernavigation.main'; @@ -255,7 +256,11 @@ class AppHeaderMain extends React.Component
- + {Config.bloomreachSearch.enable ? ( + + ) : ( + + )}
+
+ ); + } + return ( +
+ +
+ ); + } + return null; + }); + } + return null; + } + + renderFacets() { + const { facetModel } = this.state; + return Object.keys(facetModel).map((facetKey) => { + if (facetKey && facetModel[facetKey].length > 0) { + const facetDisplayNameId = facetKey.toLowerCase().replace(/ /g, '_'); + const facetCategoryChildren = facetModel[facetKey]; + return ( +
+ +
+
    + {this.renderFacetSelectors(facetKey, facetCategoryChildren)} +
+
+
+ ); + } + return null; + }); + } + + render() { + const { facetModel } = this.state; + if (facetModel) { + return ( +
+
+
+ {this.renderFacets()} +
+
+
+ ); + } + return (''); + } +} + +export default withRouter(BloomreachSearchFacetNavigationMain); diff --git a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx index 3218735f3..1262ee2cd 100644 --- a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx +++ b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx @@ -22,9 +22,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import intl from 'react-intl-universal'; -// import { bloomreachSuggestionSearch } from '../utils/BloomreachSearchService'; +import { bloomreachKeywordSearchLookup } from '../utils/BloomreachSearchService'; // import BloomreachProductListMain from './bloomreach.productlist.main'; -// import BloomreachSearchFacetNavigationMain from './bloomreach.searchfacetnavigation.main'; +import BloomreachSearchFacetNavigationMain from '../BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main'; // import '../searchresultsitems.main.less'; @@ -32,8 +32,6 @@ import { getConfig, IEpConfig } from '../utils/ConfigProvider'; let Config: IEpConfig | any = {}; - - interface BloomreachSearchResultsItemsMainProps { searchKeywordsProps: { [key: string]: any @@ -50,7 +48,81 @@ interface BloomreachSearchResultsItemsMainState { [key: string]: any }, loadSortedProduct: boolean, - searchKeywords: any + searchKeywords: any, + searchQueryParams: any, +} + +interface BloomreachKeywordSearchLookupResponse { + response: Response; + facet_counts: FacetCounts; + category_map: CategoryMap; + did_you_mean: any[]; +} + +interface CategoryMap { + VESTRI_BM_APPAREL: string; + VESTRI_APPAREL_MENS: string; +} + +interface FacetCounts { + facet_ranges: Facet; + facet_fields: FacetFields; + facet_queries: Facet; +} + +interface FacetFields { + category: Category[]; + sizes: AgeGroup[]; + brand: any[]; + colors: AgeGroup[]; + color_groups: any[]; + color: AgeGroup[]; + gender: AgeGroup[]; + material: AgeGroup[]; + apparel_type: AgeGroup[]; + age_group: AgeGroup[]; +} + +interface AgeGroup { + count: number; + name: string; +} + +interface Category { + count: number; + crumb: string; + cat_name: string; + parent: string; + cat_id: string; + tree_path: string; +} + +interface Facet { +} + +interface Response { + numFound: number; + start: number; + docs: Doc[]; +} + +interface Doc { + sale_price: number; + price: number; + description: string; + title: string; + url: string; + brand: string; + pid: string; + thumb_image: string; + sale_price_range: number[]; + price_range: number[]; + variants: Variant[]; +} + +interface Variant { + sku_swatch_images: string[]; + sku_thumb_images: string[]; } class BloomreachSearchResultsItemsMain extends React.Component { @@ -65,6 +137,7 @@ class BloomreachSearchResultsItemsMain extends React.Component { - // this.setState({ - // isLoading: false, - // searchResultsModel: res, - // searchKeywords: searchKeyword, - // searchQueryParams, - // }); - // }) - // .catch((error) => { - // // eslint-disable-next-line no-console - // console.error(error.message); - // }); + this.setState({ + isLoading: false, + searchResultsModel: res, + searchKeywords: searchKeyword, + }); } render() { @@ -113,8 +180,6 @@ class BloomreachSearchResultsItemsMain extends React.Component
@@ -143,7 +208,7 @@ class BloomreachSearchResultsItemsMain extends React.Component - {/* */} +
{/* */}
diff --git a/components/src/utils/BloomreachSearchService.ts b/components/src/utils/BloomreachSearchService.ts index f079afe7e..4ea128f23 100644 --- a/components/src/utils/BloomreachSearchService.ts +++ b/components/src/utils/BloomreachSearchService.ts @@ -38,7 +38,7 @@ function generateBaseBloomreachUrl(baseUri = getConfig().config.bloomreachSearch } // TODO: Will have to use generic types here. -export function bloomreachKeywordSearchLookup(searchKeyword, searchQueryParams) { +export function bloomreachKeywordSearchLookup(searchKeyword, searchQueryParams): Promise { const baseUrl = generateBaseBloomreachUrl(); const { requestType, From 2c29b4428df04936c51c6f24924cad2e867bb984 Mon Sep 17 00:00:00 2001 From: Alvin Date: Thu, 19 Sep 2019 17:14:51 -0700 Subject: [PATCH 41/82] Add less file for facet navigation and include checkmark for each facet --- ...bloomreach.searchfacetnavigation.main.less | 279 ++++++++++++++++++ .../bloomreach.searchfacetnavigation.main.tsx | 2 + 2 files changed, 281 insertions(+) diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less index e69de29bb..1ee1afc8b 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less @@ -0,0 +1,279 @@ +/** + * Copyright © 2019 Elastic Path Software Inc. All rights reserved. + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this license. If not, see + * + * https://www.gnu.org/licenses/ + * + * + */ + + @import './../../../app/src/theme/common.less'; + + .product-list-facet-navigation-component { + float: left; + display: table; + min-width: 25%; + padding-bottom: 30px; + + .card-stack { + margin-top: 11px; + + .card { + border-radius: 0; + margin-top: -1px; + + .card-title { + .facet { + color: #40B1F3; + font-weight: 500; + display: inline-block; + width: 100%; + .glyphicon { + display: inline-block; + height: 12px; + width: 16px; + background: url('../../../app/src/images/header-icons/baseline-filter_list-24px.svg') no-repeat center center; + margin-right:10px; + } + + &:hover { + text-decoration: none; + color: @firstComplimentColor; + cursor: pointer; + } + } + } + + .facet-value { + padding-left: 12.5px; + + button { + color: #777777; + display: inline-block; + vertical-align: middle; + position: relative; + padding-left: 5px; + padding-right: 0px; + background:none; + border:none; + + .checkmark { + top: 4px; + position: relative; + display: inline-block; + width: 18px; + height: 18px; + margin-right: 10px; + border: #cccccc 2px solid; + border-radius: 2px; + + &.chosen { + border-color: #6dd401; + background-color: #6dd401; + &:before { + content: ""; + position: absolute; + top: 1px; + left: -1px; + width: 12px; + height: 7px; + border: solid 2px #FFFFFF; + border-right: none; + border-top: none; + transform: translate(2px, 1px) rotate(-45deg); + } + } + } + + &:hover { + text-decoration: none; + color: @firstComplimentColor; + cursor: pointer; + } + + &:focus { + outline: 0 auto transparent; + } + } + } + } + + @media (max-width: @tabletWidth - 1px) { + display: none; + position: fixed; + left: 0; + top: 100%; + width: 100vw; + height: 100vh; + z-index: 5; + background: @mainBackgroundColor; + margin-top: 0; + + &.show-filter-mobile-menu { + display: flex; + flex-direction: column; + top: 0; + -webkit-animation: appear-up-long 1s forwards cubic-bezier(.23,1,.32,1); + animation: appear-up-long 1s forwards cubic-bezier(.23,1,.32,1); + text-align: left; + } + + .navbar-collapse { + display: block; + } + } + } + + @media (min-width: @tabletWidth) { + .card-title > a { + pointer-events: none; + } + + .in.collapse { + display: block; + } + } + + @media (max-width: @tabletWidth - 1px) { + display: block; + float: none; + + .card-header { + border-bottom: none; + } + } + + .filter-btn { + height: 48px; + min-width: 78px; + padding: 0 10px; + font-size: 14px; + font-weight: 500; + color: #40B1F3; + border: 1px solid #EEEEEE; + background-color: #F7F7F7; + &:focus { + outline: 2px solid #007bff80; + } + + &-wrap { + display: none; + text-align: right; + + @media (max-width: @tabletWidth - 1px) { + display: block; + } + } + + .check-icon { + opacity: 0; + display: inline-block; + width: 6px; + height: 12px; + border: solid #40B1F3; + border-width: 0 2px 2px 0; + -webkit-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + margin-left: 8px; + } + + &.filtered { + .check-icon { + opacity: 1; + } + } + } + + .close-filter-mobile-menu { + position: relative; + height: 15px; + width: 15px; + border: none; + background: transparent; + + &:before, + &:after { + position: absolute; + top: 0; + left: 7px; + content: ' '; + height: 15px; + width: 1px; + background-color: #333; + } + + &:before { + transform: rotate(45deg); + } + + &:after { + transform: rotate(-45deg); + } + + &-wrap { + display: none; + padding: 1.5rem 1.25rem; + + @media (max-width: @tabletWidth - 1px) { + display: flex; + justify-content: space-between; + } + + h2 { + font-size: 14px; + font-weight: 800; + margin: 0; + color: @mainTextColor; + } + } + } + + .facets-container { + @media (max-width: @tabletWidth - 1px) { + flex-grow: 1; + overflow: auto; + } + } + } + + @-webkit-keyframes appear-up-long { + 0% { + top: 100%; + -webkit-transform: translate(0,4rem); + transform: translate(0,4rem) + } + + 100% { + top: 0; + -webkit-transform: translate(0,0); + transform: translate(0,0) + } + } + + @keyframes appear-up-long { + 0% { + top: 100%; + -webkit-transform: translate(0,4rem); + transform: translate(0,4rem) + } + + 100% { + top: 0; + -webkit-transform: translate(0,0); + transform: translate(0,0) + } + } + \ No newline at end of file diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index ee1d6b416..6911345ed 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -258,6 +258,7 @@ class BloomreachSearchFacetNavigationMain extends React.Component
@@ -266,6 +267,7 @@ class BloomreachSearchFacetNavigationMain extends React.Component From 8d88c48c95d825799ae73d1300692e6d679c512b Mon Sep 17 00:00:00 2001 From: Alvin Date: Thu, 19 Sep 2019 19:04:33 -0700 Subject: [PATCH 42/82] Enable clicking --- .../bloomreach.searchfacetnavigation.main.tsx | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index 6911345ed..ad7c23e0c 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -60,32 +60,35 @@ class BloomreachSearchFacetNavigationMain extends React.Component params.replace('&', '')); + } - const filteredQueryParamsTree = filteredQueryParams.reduce((acc, outerFacetStr) => { - if (outerFacetStr) { - const outerFacetArray = outerFacetStr.split(':'); - const category = outerFacetArray[0]; - const loFacets = outerFacetArray[1].split('OR'); - - loFacets.forEach((innerFacet) => { - if (acc[category] == null) { - acc[category] = [innerFacet]; - } else { - acc[category].push(innerFacet); - } - }); - } + const filteredQueryParamsTree = filteredQueryParams.reduce((acc, outerFacetStr:string) => { + if (outerFacetStr) { + const outerFacetArray = outerFacetStr.split(':'); + const category = outerFacetArray[0]; + const loFacets = outerFacetArray[1].split('OR'); - return acc; - }, {}); + loFacets.forEach((innerFacet) => { + if (acc[category] == null) { + acc[category] = [innerFacet]; + } else { + acc[category].push(innerFacet); + } + }); + } - return filteredQueryParamsTree; - } + return acc; + }, {}); + + return filteredQueryParamsTree; + } constructor(props) { @@ -224,7 +227,7 @@ class BloomreachSearchFacetNavigationMain extends React.Component { @@ -281,6 +284,7 @@ class BloomreachSearchFacetNavigationMain extends React.Component { if (facetKey && facetModel[facetKey].length > 0) { const facetDisplayNameId = facetKey.toLowerCase().replace(/ /g, '_'); From c819991a3aac78f3a2ba9be41cfad706dcd0d439 Mon Sep 17 00:00:00 2001 From: Alvin Date: Fri, 20 Sep 2019 14:10:23 -0700 Subject: [PATCH 43/82] Able to get facets functioning properly --- .../bloomreach.searchfacetnavigation.main.tsx | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index ad7c23e0c..0a1754a00 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -101,6 +101,9 @@ class BloomreachSearchFacetNavigationMain extends React.Component { - if (facet.includes(facetName)) { - return true; - } - return false; - }); - } + + if (currentFacets[facetKey]) { + + return currentFacets[facetKey].some((facet) => { + if (facet.includes(facetName)) { + return true; + } + return false; + }); } return false; @@ -261,16 +269,17 @@ class BloomreachSearchFacetNavigationMain extends React.Component ); } + return (
@@ -312,7 +321,8 @@ class BloomreachSearchFacetNavigationMain extends React.Component From 77f0078f171c91310188f1aabe1ca018d189239c Mon Sep 17 00:00:00 2001 From: Alvin Date: Fri, 20 Sep 2019 15:47:11 -0700 Subject: [PATCH 44/82] Able to get product list item showing up on search --- .../bloomreach.productlist.main.less | 100 +++++++++++ .../bloomreach.productlist.main.tsx | 170 ++++++++++++++++++ .../bloomreach.searchresultsitems.main.tsx | 4 +- 3 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 components/src/BloomreachProductListMain/bloomreach.productlist.main.less create mode 100644 components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx diff --git a/components/src/BloomreachProductListMain/bloomreach.productlist.main.less b/components/src/BloomreachProductListMain/bloomreach.productlist.main.less new file mode 100644 index 000000000..a611897e0 --- /dev/null +++ b/components/src/BloomreachProductListMain/bloomreach.productlist.main.less @@ -0,0 +1,100 @@ +/** + * Copyright © 2018 Elastic Path Software Inc. All rights reserved. + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this license. If not, see + * + * https://www.gnu.org/licenses/ + * + * + */ + + @import './../style/common.less'; + + .product-list-container { + text-align: left; + + .compare-button{ + text-align: center; + margin-bottom: 30px; + + .top-compare-link{ + margin: 0; + padding: 0; + text-transform: none; + + &:hover{ + text-decoration: none; + } + + &.disabled { + background-color: #9d9d9d; + pointer-events: none; + cursor: default; + } + } + + .toggle-compare-link{ + min-height: 40px; + line-height: 40px; + display: inline-block; + padding: 0 15px; + text-decoration: none; + color: #fff; + } + } + + .category-items-listing { + .category-item-container { + position: relative; + display: inline-block; + width: 25%; + padding: 0 10px 30px 10px; + vertical-align: top; + + .compare-checkbox{ + position: absolute; + left: 10px; + bottom: 10px; + } + + .category-item-inner { + .category-item-availability-container { + display: block; + } + + .category-item-title { + padding-top: 10px; + min-height: 70px; + font-size: 14px; + font-weight: 800; + line-height: 1.13; + color: @mainBlueColor; + + a { + color: @mainBlueColor; + } + } + } + + @media (max-width: @tabletWidth - 1px) { + width: 33%; + } + + @media (max-width: @mobileWidth - 1px) { + width: 50%; + } + } + } + } + \ No newline at end of file diff --git a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx new file mode 100644 index 000000000..0074ce837 --- /dev/null +++ b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx @@ -0,0 +1,170 @@ +/** + * Copyright © 2018 Elastic Path Software Inc. All rights reserved. + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this license. If not, see + * + * https://www.gnu.org/licenses/ + * + * + */ + +import React from 'react'; +import PropTypes, { string } from 'prop-types'; +import intl from 'react-intl-universal'; +import { Link } from 'react-router-dom'; +import ProductListItemMain from '../ProductListItem/productlistitem.main'; + +// import '../productlist.main.less'; + +interface BloomreachProductListMainProps { + productData: any, + showCompareButton: any + } + +interface BloomreachProductListMainState { + isCompare: any, + compareLink: any, + categoryModel: any, + compareList: any, +} + +// TODO: Have to create types for all these files... +class BloomreachProductListMain extends React.Component  { + static propTypes = { + productData: PropTypes.objectOf(PropTypes.any).isRequired, + showCompareButton: PropTypes.bool, + } + + static defaultProps = { + showCompareButton: true, + } + + constructor(props) { + super(props); + const { productData } = this.props; + this.state = { + isCompare: false, + compareLink: '', + categoryModel: productData, + compareList: [], + }; + this.handleCompareToggle = this.handleCompareToggle.bind(this); + } + + componentWillReceiveProps(nextProps) { + const { productData } = nextProps; + this.setState({ categoryModel: productData }); + } + + handleCompare(event) { + this.setState({ + isCompare: !event, + }); + } + + handleCompareToggle(event) { + const { compareList } = this.state; + const elementCode:string = event.target.name; + const index = compareList.indexOf(elementCode); + if (index === -1 && compareList.length > 2) return; + if (index !== -1) { + this.setState({ + compareList: compareList.slice(0, index).concat(compareList.slice(index + 1)), + compareLink: `/productscompare/${encodeURIComponent(compareList.slice(0, index).concat(compareList.slice(index + 1)).join())}`, + }); + } else { + this.setState({ + compareList: [...compareList, elementCode], + compareLink: `/productscompare/${encodeURIComponent([...compareList, elementCode].join())}`, + }); + } + } + + checkComparison(product) { + const { compareList, isCompare } = this.state; + const code:string = product._code[0].code; + const isChecked = compareList.indexOf(code) !== -1; + if (product._definition && isCompare) { + return ( +
+ +
+ ); + } + return null; + } + + renderProducts() { + const { categoryModel } = this.state; + console.log(categoryModel); + return categoryModel.map((product) => { + if (product.pid) { + const sku = product.variants[0].sku_swatch_images[0]; + return ( +
  • + +
  • + ); + } + return null; + }); + } + + render() { + const { + isCompare, + compareList, + compareLink, + } = this.state; + const { showCompareButton } = this.props; + return ( +
    + {showCompareButton ? ( +
    + +
    + ) : ''} +
      + {this.renderProducts()} +
    +
    + ); + } +} + +export default BloomreachProductListMain; diff --git a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx index 1262ee2cd..53cc2413d 100644 --- a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx +++ b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx @@ -23,7 +23,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import intl from 'react-intl-universal'; import { bloomreachKeywordSearchLookup } from '../utils/BloomreachSearchService'; -// import BloomreachProductListMain from './bloomreach.productlist.main'; +import BloomreachProductListMain from '../BloomreachProductListMain/bloomreach.productlist.main'; import BloomreachSearchFacetNavigationMain from '../BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main'; // import '../searchresultsitems.main.less'; @@ -210,7 +210,7 @@ class BloomreachSearchResultsItemsMain extends React.Component
    - {/* */} +
    ); From f38e84757ef9b094c6d515cdbed9a97004ca04c3 Mon Sep 17 00:00:00 2001 From: Alvin Date: Mon, 23 Sep 2019 14:41:30 -0700 Subject: [PATCH 45/82] Able to get the facets to filter properly --- .../bloomreach.productlist.main.tsx | 1 - .../bloomreach.searchfacetnavigation.main.tsx | 68 +++++++++++-------- .../bloomreach.searchresultsitems.main.tsx | 27 ++++++-- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx index 0074ce837..88a3dbab0 100644 --- a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx +++ b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx @@ -121,7 +121,6 @@ class BloomreachProductListMain extends React.Component { if (product.pid) { const sku = product.variants[0].sku_swatch_images[0]; diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index 0a1754a00..8e8c45a18 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -20,8 +20,7 @@ */ import React from 'react'; -import ReactRouterPropTypes from 'react-router-prop-types'; -import PropTypes from 'prop-types'; + import { withRouter } from 'react-router'; import './bloomreach.searchfacetnavigation.main.less'; @@ -31,6 +30,7 @@ interface BloomreachSearchFacetNavigationMainProps { titleString: any, categoryMap: any, currentFacets: any, + onFacetSelected: any, history: any, } @@ -56,20 +56,21 @@ class BloomreachSearchFacetNavigationMain extends React.Component params.replace('&', '')); + filteredQueryParamsArray = filteredQueryParams.split('fq='); + filteredQueryParamsArray = filteredQueryParamsArray.map(params => params.replace('&', '')); } - const filteredQueryParamsTree = filteredQueryParams.reduce((acc, outerFacetStr:string) => { + const filteredQueryParamsTree = filteredQueryParamsArray.reduce((acc, outerFacetStr:string) => { if (outerFacetStr) { const outerFacetArray = outerFacetStr.split(':'); const category = outerFacetArray[0]; @@ -87,26 +88,31 @@ class BloomreachSearchFacetNavigationMain extends React.Component { if (facet.includes(facetName)) { @@ -124,10 +130,12 @@ class BloomreachSearchFacetNavigationMain extends React.Component { + const facets = this.reconstructTreeIntoQueryParamsString(); + window.history.pushState('', '', `/search/${keywords}${facets}`); + onFacetSelected(facets); + } + if (this.hasFacetBeenSelected(facetKey, facetId)) { - this.removeFacetFromQueryParamsTree(facetKey, facetId); + this.removeFacetFromQueryParamsTree(facetKey, facetId, onFacetFinishUpdate); } else { - this.addFacetFromQueryParamsTree(facetKey, facetId); + this.addFacetFromQueryParamsTree(facetKey, facetId, onFacetFinishUpdate); } + + // TODO: Here we should call something that changes the state here... Might want to update the state from the setState function. } hasFacetBeenSelected(facetKey, facetName) { @@ -322,7 +333,8 @@ class BloomreachSearchFacetNavigationMain extends React.Component diff --git a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx index 53cc2413d..e9b665936 100644 --- a/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx +++ b/components/src/BloomreachSearchResultsItems/bloomreach.searchresultsitems.main.tsx @@ -139,29 +139,35 @@ class BloomreachSearchResultsItemsMain extends React.Component Date: Mon, 23 Sep 2019 14:47:52 -0700 Subject: [PATCH 46/82] Get rid of errors --- .../bloomreach.productlist.main.tsx | 16 ++++------------ .../bloomreach.searchfacetnavigation.main.tsx | 7 +++---- .../bloomreach.searchresultsitems.main.tsx | 8 +------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx index 88a3dbab0..b51d2ae59 100644 --- a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx +++ b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx @@ -28,27 +28,19 @@ import ProductListItemMain from '../ProductListItem/productlistitem.main'; // import '../productlist.main.less'; interface BloomreachProductListMainProps { - productData: any, + productData: [], showCompareButton: any } interface BloomreachProductListMainState { isCompare: any, - compareLink: any, - categoryModel: any, - compareList: any, + compareLink: any, + categoryModel: any, + compareList: any, } // TODO: Have to create types for all these files... class BloomreachProductListMain extends React.Component  { - static propTypes = { - productData: PropTypes.objectOf(PropTypes.any).isRequired, - showCompareButton: PropTypes.bool, - } - - static defaultProps = { - showCompareButton: true, - } constructor(props) { super(props); diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index 8e8c45a18..a43cc816b 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -269,16 +269,15 @@ class BloomreachSearchFacetNavigationMain extends React.Component { + return facetselector.map((choice, i) => { if (choice) { const name = choice.name ? choice.name : choice.cat_name; const id = choice.cat_id ? `${choice.cat_id}` : `${name}`; if (!this.hasFacetBeenSelected(facetKey, id)) { return ( -
    +
    +
    {count}
    ); } @@ -236,6 +241,7 @@ class BloomreachSearchFacetNavigationMain extends React.Component {`${this.generateFacetName(facetKey, name, choice)}`} +
    {count}
    ); } From 7dfec44e340eef9327557e8b913f11f2f81d1463 Mon Sep 17 00:00:00 2001 From: Alvin Date: Wed, 25 Sep 2019 13:36:18 -0700 Subject: [PATCH 67/82] Add counters to the facets --- ...bloomreach.searchfacetnavigation.main.less | 21 +++++++++++++------ .../bloomreach.searchfacetnavigation.main.tsx | 8 +++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less index 1b1225517..f0ec5bad9 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.less @@ -59,23 +59,32 @@ .facet-value { padding-left: 12.5px; display: flex; - + justify-content: space-between; .facet-count { - flex: right; - width: 30%; - text-align: right; + text-align: center; margin-top:4px; + margin-right:12.5px; height: 18px; width: 18px; position: relative; + + .circle { + width:30px; + background: @firstBorderColor; + color: @firstComplimentTextColor; + -moz-border-radius: 70px; + -webkit-border-radius: 70px; + border-radius: 70px; + margin-right: 10px; + } } button { - color: #777777; + color: @firstComplimentTextColor; display: inline-block; vertical-align: middle; position: relative; - padding-left: 5px; + padding-left: 0px; padding-right: 0px; background:none; border:none; diff --git a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx index a69ab4de7..38914b701 100644 --- a/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx +++ b/components/src/BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main.tsx @@ -230,7 +230,9 @@ class BloomreachSearchFacetNavigationMain extends React.Component {`${this.generateFacetName(facetKey, name, choice)}`} -
    {count}
    +
    +
    {count}
    +
    ); } @@ -241,7 +243,9 @@ class BloomreachSearchFacetNavigationMain extends React.Component {`${this.generateFacetName(facetKey, name, choice)}`} -
    {count}
    +
    +
    {count}
    +
    ); } From 9bcd8b6bdde37fc728bdfc64255d93786d4c0de3 Mon Sep 17 00:00:00 2001 From: Alvin Date: Wed, 25 Sep 2019 14:04:40 -0700 Subject: [PATCH 68/82] Add modules to export file --- components/src/AppHeader/appheader.main.less | 1 - components/src/index.ts | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/src/AppHeader/appheader.main.less b/components/src/AppHeader/appheader.main.less index 97e6d24c6..226561c5e 100644 --- a/components/src/AppHeader/appheader.main.less +++ b/components/src/AppHeader/appheader.main.less @@ -88,7 +88,6 @@ vertical-align: top; .cart-link { - position: relative; display: block; width: 23px; padding: 10px; diff --git a/components/src/index.ts b/components/src/index.ts index 05d5c122e..e08db7d3a 100644 --- a/components/src/index.ts +++ b/components/src/index.ts @@ -77,6 +77,8 @@ import ChatComponent from './ChatBot/chatbot'; import BarcodeScanner from './BarcodeScanner/barcodescanner'; import BloomreachAppHeaderSearchMain from './BloomreachAppHeaderSearch/bloomreach.appheadersearch.main'; import BloomreachSearchResultsItems from './BloomreachSearchResultsItems/bloomreach.searchresultsitems.main'; +import BloomreachSearchFacetNavigation from './BloomreachSearchFacetNavigation/bloomreach.searchfacetnavigation.main'; +import BloomreachProductListMain from './BloomreachProductListMain/bloomreach.productlist.main'; export { init, @@ -137,4 +139,6 @@ export { BarcodeScanner, BloomreachAppHeaderSearchMain, BloomreachSearchResultsItems, + BloomreachSearchFacetNavigation, + BloomreachProductListMain }; From 258acd4f296b66a59a0180f4cdecc6151ba45b7b Mon Sep 17 00:00:00 2001 From: Alvin Date: Wed, 25 Sep 2019 15:09:41 -0700 Subject: [PATCH 69/82] delete unused lines --- .../bloomreach.productlist.main.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx index 01f4b1608..fe3970c43 100644 --- a/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx +++ b/components/src/BloomreachProductListMain/bloomreach.productlist.main.tsx @@ -113,7 +113,6 @@ class BloomreachProductListMain extends React.Component
    {count}
    -
    + ); } return ( -
    +