@wayke-se/components-react 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +5 -1
  2. package/dist-node/index.js +49 -18
  3. package/dist-node/index.js.map +1 -1
  4. package/dist-src/State/RelatedSearch/useRelatedSearch.js +4 -1
  5. package/dist-src/components/ActionList/toggle-item.js +1 -4
  6. package/dist-src/components/Grid/index.js +2 -2
  7. package/dist-src/components/ProductCard/index.js +3 -2
  8. package/dist-src/components/ProductCard/wrapper.js +6 -1
  9. package/dist-src/layouts/WaykeComposite.js +2 -2
  10. package/dist-src/layouts/search/index.js +2 -2
  11. package/dist-src/layouts/searchItem/Branch.js +6 -4
  12. package/dist-src/layouts/searchItem/Related.js +3 -3
  13. package/dist-src/layouts/searchItem/index.js +3 -9
  14. package/dist-src/queries/SEARCH_ITEM_BRANCH_QUERY.js +1 -0
  15. package/dist-src/utils/sortOptions.js +6 -0
  16. package/dist-src/utils/vehicle-properties/property-hint-enricher.js +2 -0
  17. package/dist-types/@types/codegen/types.d.ts +5 -0
  18. package/dist-types/State/RelatedSearch/useRelatedSearch.d.ts +1 -1
  19. package/dist-types/components/Grid/index.d.ts +2 -1
  20. package/dist-types/components/ProductCard/index.d.ts +2 -1
  21. package/dist-types/components/ProductCard/wrapper.d.ts +1 -0
  22. package/dist-types/layouts/WaykeComposite.d.ts +1 -1
  23. package/dist-types/layouts/search/index.d.ts +2 -1
  24. package/dist-types/layouts/searchItem/Branch.d.ts +2 -1
  25. package/dist-types/layouts/searchItem/Related.d.ts +3 -1
  26. package/dist-types/layouts/searchItem/index.d.ts +2 -1
  27. package/dist-types/utils/sortOptions.d.ts +3 -1
  28. package/dist-web/index.js +40 -24
  29. package/dist-web/index.js.map +1 -1
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -164,7 +164,8 @@ const App = ({}) => {
164
164
  | disableResetScrollOnInit | boolean | false | |
165
165
  | placeholderImage | string | false | |
166
166
  | onClickSearchItem | function | false | (id: string) => void |
167
- | modifyDocumentTitleItem | boolean | false | |
167
+ | modifyDocumentTitleItem | boolean | false | |
168
+ | displayBranchName | boolean | false | |
168
169
 
169
170
  * Required
170
171
  * `id` - Guid that represents a vehicle.
@@ -175,6 +176,7 @@ const App = ({}) => {
175
176
  * `placeholderImage` - Provide custom placeholder image when image is missing.
176
177
  * `onClickSearchItem` - Function that can be provided that will be triggered once a item is clicked.
177
178
  * `modifyDocumentTitleItem` - Update document title with vehicle data
179
+ * `displayBranchName` - Displays branch name on related product cards and using branch name in presentation of where the vehicle exist
178
180
 
179
181
  ### WaykeSearch
180
182
  | Property | Type | Values |
@@ -188,6 +190,7 @@ const App = ({}) => {
188
190
  | placeholderImage | string | |
189
191
  | onClickSearchItem | function | (id: string) => void |
190
192
  | modifyDocumentTitleSearch | string | |
193
+ | displayBranchName | string | |
191
194
 
192
195
  * Optional
193
196
  * `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
@@ -199,6 +202,7 @@ const App = ({}) => {
199
202
  * `placeholderImage` - Provide custom placeholder image when image is missing.
200
203
  * `onClickSearchItem` - Function that can be provided that will be triggered once a item is clicked.
201
204
  * `modifyDocumentTitleSearch` - Set custom document title
205
+ * `displayBranchName` - Displays branch name on product cards
202
206
 
203
207
  ## Types
204
208
 
@@ -806,7 +806,9 @@ const SortOptionDisplayName = {
806
806
  PriceAsc: 'price-asc',
807
807
  Pricedesc: 'price-desc',
808
808
  ModelAsc: 'model-asc',
809
- Modeldesc: 'model-desc'
809
+ Modeldesc: 'model-desc',
810
+ MileageAsc: 'mileage-asc',
811
+ Mileagedesc: 'mileage-desc'
810
812
  };
811
813
  const getTranslatedSortOptionDisplayName = str => {
812
814
  switch (str) {
@@ -822,6 +824,10 @@ const getTranslatedSortOptionDisplayName = str => {
822
824
  return 'Årsmodell äldst';
823
825
  case SortOptionDisplayName.Modeldesc:
824
826
  return 'Årsmodell nyast';
827
+ case SortOptionDisplayName.MileageAsc:
828
+ return 'Miltal lägst';
829
+ case SortOptionDisplayName.Mileagedesc:
830
+ return 'Miltal högst';
825
831
  default:
826
832
  return str;
827
833
  }
@@ -2184,6 +2190,11 @@ const ContentFooter = styled__default.div`
2184
2190
  margin-top: auto;
2185
2191
  padding-top: ${size(1)};
2186
2192
  `;
2193
+ const PreHeading = styled__default.div`
2194
+ margin-bottom: ${size(0.25)};
2195
+ color: ${props => props.theme.color.textDarkLighten};
2196
+ font-size: 0.75rem;
2197
+ `;
2187
2198
  const Heading$2 = styled__default.h1.attrs(() => ({
2188
2199
  className: 'wayke__theme wayke__font--bold'
2189
2200
  }))`
@@ -2248,7 +2259,7 @@ const OldPrice = styled__default.div`
2248
2259
  `;
2249
2260
  const Label$3 = styled__default.label`
2250
2261
  color: ${props => props.theme.color.disabledText};
2251
- font-size: 0.875rem;
2262
+ font-size: 0.75rem;
2252
2263
  `;
2253
2264
 
2254
2265
  const Item$5 = styled__default.li`
@@ -2378,6 +2389,7 @@ const ProductCard = ({
2378
2389
  image,
2379
2390
  pathRoute,
2380
2391
  placeholderImage,
2392
+ branchName,
2381
2393
  description,
2382
2394
  uspList,
2383
2395
  price,
@@ -2412,7 +2424,7 @@ const ProductCard = ({
2412
2424
  alt: title
2413
2425
  }))) : React__default.createElement(Picture, null, React__default.createElement(Img, {
2414
2426
  src: placeholderImage || DEFAULT_PLACEHOLDER_IMAGE
2415
- })))), React__default.createElement(Content, null, React__default.createElement(ContentBody, null, React__default.createElement(Heading$2, null, href ? React__default.createElement(Link, {
2427
+ })))), React__default.createElement(Content, null, React__default.createElement(ContentBody, null, branchName && React__default.createElement(PreHeading, null, branchName), React__default.createElement(Heading$2, null, href ? React__default.createElement(Link, {
2416
2428
  onClick: onHrefClick,
2417
2429
  href: href,
2418
2430
  title: title,
@@ -2436,12 +2448,14 @@ const Grid = ({
2436
2448
  placeholderImage,
2437
2449
  hashRoute,
2438
2450
  pathRoute,
2451
+ displayBranchName,
2439
2452
  onClickItem
2440
2453
  }) => {
2441
2454
  if (!documents) {
2442
2455
  return null;
2443
2456
  }
2444
2457
  return React__default.createElement(Wrapper$7, null, React__default.createElement(List$4, null, documents.map(document => {
2458
+ var _document$branches, _document$branches$;
2445
2459
  /*
2446
2460
  const _path = pathRoute?.replace(/^\/|\/$/g, '');
2447
2461
  const prefix = _path ? `/${_path}/` : '/';
@@ -2470,6 +2484,7 @@ const Grid = ({
2470
2484
  image: resolveImage(document),
2471
2485
  placeholderImage: placeholderImage,
2472
2486
  description: document.shortDescription,
2487
+ branchName: displayBranchName ? (_document$branches = document.branches) === null || _document$branches === void 0 ? void 0 : (_document$branches$ = _document$branches[0]) === null || _document$branches$ === void 0 ? void 0 : _document$branches$.name : undefined,
2473
2488
  uspList: [{
2474
2489
  title: document.modelYear
2475
2490
  }, {
@@ -2922,6 +2937,7 @@ const WaykeSearch = ({
2922
2937
  placeholderImage,
2923
2938
  removeFilterOptions,
2924
2939
  modifyDocumentTitleSearch,
2940
+ displayBranchName,
2925
2941
  onClickSearchItem
2926
2942
  }) => {
2927
2943
  const {
@@ -2966,7 +2982,8 @@ const WaykeSearch = ({
2966
2982
  pathRoute: pathRoute,
2967
2983
  onClickItem: onItemClicked,
2968
2984
  documents: documents,
2969
- placeholderImage: placeholderImage
2985
+ placeholderImage: placeholderImage,
2986
+ displayBranchName: displayBranchName
2970
2987
  }), !error && documents && documents.length === 0 && React__default.createElement(Snackbar, {
2971
2988
  severity: "warning",
2972
2989
  icon: true,
@@ -6286,8 +6303,6 @@ const ManufacturerPackageOption = ({
6286
6303
  })));
6287
6304
  };
6288
6305
 
6289
- const initialValue = {};
6290
- const getInitialValue = title => title && !!initialValue[title];
6291
6306
  const ToggleItem = ({
6292
6307
  title,
6293
6308
  value,
@@ -6295,7 +6310,7 @@ const ToggleItem = ({
6295
6310
  onClickVisible,
6296
6311
  onClickValue
6297
6312
  }) => {
6298
- const [visible, setVisible] = React.useState(() => getInitialValue(type));
6313
+ const [visible, setVisible] = React.useState(false);
6299
6314
  const _onClickValue = React.useCallback(() => {
6300
6315
  if (onClickValue) {
6301
6316
  onClickValue();
@@ -6303,7 +6318,6 @@ const ToggleItem = ({
6303
6318
  }, []);
6304
6319
  const onClick = React.useCallback(() => {
6305
6320
  if (!visible) {
6306
- initialValue[type] = true;
6307
6321
  setVisible(true);
6308
6322
  if (onClickVisible) {
6309
6323
  onClickVisible();
@@ -6824,7 +6838,7 @@ const RelatedSearchContext = React.createContext({
6824
6838
  fetchRelated: _ => {}
6825
6839
  });
6826
6840
 
6827
- const useRelatedSearch = id => {
6841
+ const useRelatedSearch = (id, authorizedReseller) => {
6828
6842
  const data = React.useContext(RelatedSearchContext);
6829
6843
  React.useEffect(() => {
6830
6844
  const searchParams = new URLSearchParams();
@@ -6832,6 +6846,9 @@ const useRelatedSearch = id => {
6832
6846
  if (data.moreLikeThisUrl && id) {
6833
6847
  searchParams.set('id', id);
6834
6848
  }
6849
+ if (authorizedReseller) {
6850
+ searchParams.set('isAuthorizedResellerForManufacturer', 'true');
6851
+ }
6835
6852
  data.fetchRelated(searchParams);
6836
6853
  }, [id]);
6837
6854
  return data;
@@ -6851,13 +6868,15 @@ const Related = ({
6851
6868
  id,
6852
6869
  hashRoute,
6853
6870
  pathRoute,
6871
+ authorizedReseller,
6872
+ displayBranchName,
6854
6873
  onClickSearchItem
6855
6874
  }) => {
6856
6875
  const {
6857
6876
  loading,
6858
6877
  response,
6859
6878
  moreLikeThisUrl
6860
- } = useRelatedSearch(id);
6879
+ } = useRelatedSearch(id, !!authorizedReseller);
6861
6880
  const onItemClicked = React.useCallback(id => {
6862
6881
  PubSub.publish('ItemClicked', id);
6863
6882
  if (onClickSearchItem) {
@@ -6884,7 +6903,7 @@ const Related = ({
6884
6903
  }, React__default.createElement(H2, {
6885
6904
  noMargin: true
6886
6905
  }, "Senast inkomna"))), React__default.createElement(Repeat, null, React__default.createElement(OverflowGrid, null, React__default.createElement(OverflowGridList, null, response === null || response === void 0 ? void 0 : response.documentList.documents.map(document => {
6887
- var _document$featuredIma, _document$featuredIma2, _document$featuredIma3;
6906
+ var _document$featuredIma, _document$featuredIma2, _document$featuredIma3, _document$branches, _document$branches$;
6888
6907
  const prefix = pathRoute ? `/${pathRoute}` : '/';
6889
6908
  const r = regexPathGuid();
6890
6909
  const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : r.test(`${pathRoute}${id}`) ? window.location.pathname.replace(r, document._id) : `${window.location.pathname}${prefix}${document._id}`;
@@ -6897,6 +6916,7 @@ const Related = ({
6897
6916
  href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined,
6898
6917
  image: (_document$featuredIma = document.featuredImage) === null || _document$featuredIma === void 0 ? void 0 : (_document$featuredIma2 = _document$featuredIma.files) === null || _document$featuredIma2 === void 0 ? void 0 : (_document$featuredIma3 = _document$featuredIma2[0]) === null || _document$featuredIma3 === void 0 ? void 0 : _document$featuredIma3.url,
6899
6918
  description: document.shortDescription,
6919
+ branchName: displayBranchName ? (_document$branches = document.branches) === null || _document$branches === void 0 ? void 0 : (_document$branches$ = _document$branches[0]) === null || _document$branches$ === void 0 ? void 0 : _document$branches$.name : undefined,
6900
6920
  uspList: [{
6901
6921
  title: document.modelYear
6902
6922
  }, {
@@ -7150,7 +7170,8 @@ const StaticMap = ({
7150
7170
 
7151
7171
  const Branch = ({
7152
7172
  branch,
7153
- loading
7173
+ loading,
7174
+ displayBranchName
7154
7175
  }) => {
7155
7176
  var _branch$location, _branch$location2, _branch$location3, _branch$connections, _branch$location4, _branch$location5, _branch$location6, _branch$location7, _branch$contact;
7156
7177
  const [modal, setModal] = React.useState(false);
@@ -7170,7 +7191,7 @@ const Branch = ({
7170
7191
  onClose: closeModal
7171
7192
  }), React__default.createElement(Repeat, null, React__default.createElement(H2, {
7172
7193
  noMargin: true
7173
- }, branch !== null && branch !== void 0 && (_branch$location = branch.location) !== null && _branch$location !== void 0 && _branch$location.city ? `Den här bilen finns på vår anläggning i ${branch === null || branch === void 0 ? void 0 : (_branch$location2 = branch.location) === null || _branch$location2 === void 0 ? void 0 : _branch$location2.city}` : 'Kontakt')), React__default.createElement(Repeat, null, React__default.createElement(StaticMap, {
7194
+ }, displayBranchName ? `Den här bilen finns på ${branch.name}` : branch !== null && branch !== void 0 && (_branch$location = branch.location) !== null && _branch$location !== void 0 && _branch$location.city ? `Den här bilen finns på vår anläggning i ${branch === null || branch === void 0 ? void 0 : (_branch$location2 = branch.location) === null || _branch$location2 === void 0 ? void 0 : _branch$location2.city}` : 'Kontakt')), React__default.createElement(Repeat, null, React__default.createElement(StaticMap, {
7174
7195
  position: branch === null || branch === void 0 ? void 0 : (_branch$location3 = branch.location) === null || _branch$location3 === void 0 ? void 0 : _branch$location3.position
7175
7196
  })), ((branch === null || branch === void 0 ? void 0 : (_branch$connections = branch.connections) === null || _branch$connections === void 0 ? void 0 : _branch$connections.length) || 0) > 1 && React__default.createElement(Repeat, null, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar.", ' ', React__default.createElement(ButtonInline, {
7176
7197
  as: "span",
@@ -7228,6 +7249,7 @@ const SEARCH_ITEM_BRANCH_QUERY = client.gql`
7228
7249
  mrf
7229
7250
  centralStorage
7230
7251
  ecommerce
7252
+ authorizedReseller
7231
7253
  }
7232
7254
  logotype
7233
7255
  openingHours {
@@ -7622,6 +7644,8 @@ const HINTS = Object.freeze({
7622
7644
  finish: '',
7623
7645
  fuelConsumptionCityDriving: 'Bränsleförbrukning vid stadskörning.',
7624
7646
  fuelConsumptionCountryRoadDriving: 'Bränsleförbrukning vid landsvägskörning.',
7647
+ fuelConsumptionMixedDrivingNEDC: 'Bränsleförbrukning vid blandad körning.',
7648
+ fuelConsumptionMixedDrivingWLTP: 'Bränsleförbrukning vid blandad körning.',
7625
7649
  fuelConsumptionMixedDriving: 'Bränsleförbrukning vid blandad körning. Dvs. stadskörning och landsvägskörning under en och samma färd.',
7626
7650
  fuelType: 'Vad bilen ska tankas med och drivs av.',
7627
7651
  gearboxName: '',
@@ -8193,9 +8217,10 @@ const WaykeSearchItem = ({
8193
8217
  disableResetScrollOnInit,
8194
8218
  placeholderImage,
8195
8219
  modifyDocumentTitleItem,
8220
+ displayBranchName,
8196
8221
  onClickSearchItem
8197
8222
  }) => {
8198
- var _result$vehicle3, _result$vehicle3$data, _result$vehicle4;
8223
+ var _result$vehicle3, _result$vehicle3$data, _result$vehicle4, _branch$flags;
8199
8224
  const {
8200
8225
  ecomSettings
8201
8226
  } = useSettings();
@@ -8385,6 +8410,7 @@ const WaykeSearchItem = ({
8385
8410
  documents: documents
8386
8411
  }), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
8387
8412
  branch: branch,
8413
+ displayBranchName: displayBranchName,
8388
8414
  loading: loadingCentralStorageVehicle
8389
8415
  }), ecommerce && ecommerce.enabled && React__default.createElement(Repeat, null, React__default.createElement(ButtonPrimary, {
8390
8416
  disabled: !!ecommerce.reserved,
@@ -8401,8 +8427,10 @@ const WaykeSearchItem = ({
8401
8427
  id: id,
8402
8428
  hashRoute: hashRoute,
8403
8429
  pathRoute: pathRoute,
8430
+ authorizedReseller: !!(branch !== null && branch !== void 0 && (_branch$flags = branch.flags) !== null && _branch$flags !== void 0 && _branch$flags.authorizedReseller),
8431
+ displayBranchName: displayBranchName,
8404
8432
  onClickSearchItem: onClickSearchItem
8405
- })), false , React__default.createElement(PortalElement, {
8433
+ })), React__default.createElement(PortalElement, {
8406
8434
  id: DefaultPortal
8407
8435
  }), demoCarModal && React__default.createElement(DemoCarModal, {
8408
8436
  onClose: onToggleDemoCarModal
@@ -8867,7 +8895,8 @@ const WaykeComposite = ({
8867
8895
  placeholderImage,
8868
8896
  pathRoute,
8869
8897
  modifyDocumentTitleItem,
8870
- modifyDocumentTitleSearch
8898
+ modifyDocumentTitleSearch,
8899
+ displayBranchName
8871
8900
  }) => {
8872
8901
  const hashId = useHashGuid();
8873
8902
  const {
@@ -8889,7 +8918,8 @@ const WaykeComposite = ({
8889
8918
  disableResetScrollOnInit: disableResetScrollOnInit,
8890
8919
  placeholderImage: placeholderImage,
8891
8920
  pathRoute: pathRoute,
8892
- modifyDocumentTitleItem: modifyDocumentTitleItem
8921
+ modifyDocumentTitleItem: modifyDocumentTitleItem,
8922
+ displayBranchName: displayBranchName
8893
8923
  }) : React__default.createElement(WaykeSearch, {
8894
8924
  filterList: filterList,
8895
8925
  initialQueryParams: initialQueryParams,
@@ -8898,7 +8928,8 @@ const WaykeComposite = ({
8898
8928
  placeholderImage: placeholderImage,
8899
8929
  pathRoute: pathRoute,
8900
8930
  removeFilterOptions: removeFilterOptions,
8901
- modifyDocumentTitleSearch: modifyDocumentTitleSearch
8931
+ modifyDocumentTitleSearch: modifyDocumentTitleSearch,
8932
+ displayBranchName: displayBranchName
8902
8933
  }));
8903
8934
  };
8904
8935