@wayke-se/components-react 3.3.2 → 3.5.0

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.
package/README.md CHANGED
@@ -182,7 +182,7 @@ const App = ({}) => {
182
182
  | pathRoute | string | |
183
183
  | hashRoute | boolean | |
184
184
  | filterList | SearchFilterTypes[] | |
185
- | initialQueryParams | URLSearchParams or string | query, manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price.min, price.max, mileage.min, mileage.max, modelYear.min, modelYear.max |
185
+ | initialQueryParams | URLSearchParams or string | query, manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price.min, price.max, mileage.min, mileage.max, modelYear.min, modelYear.max, leasingPrice.min, leasingPrice.max, businessLeasingPrice.min, businessLeasingPrice.max |
186
186
  | removeSearchBar | boolean | |
187
187
  | removeFilterOptions | boolean | |
188
188
  | placeholderImage | string | |
@@ -192,7 +192,7 @@ const App = ({}) => {
192
192
  * Optional
193
193
  * `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
194
194
  * `hashRoute` - If set to true, then if a item is clicked it will append #guid to the url (is not used if `pathRoute` is set).
195
- * `filterList` - Select what filters that should be visible and in whiched order, drivingWheel, price, mileage, modelYear
195
+ * `filterList` - Select what filters that should be visible and in whiched order, drivingWheel, price, mileage, modelYear, leasingPrice, businessLeasingPrice
196
196
  * `initialQueryParams` - Set the default filter that should be applid upon init.
197
197
  * `removeSearchBar` - Removes search bar.
198
198
  * `removeFilterOptions` - Removes filter options.
@@ -271,7 +271,7 @@ WaykeSearchItem & WaykeSearch combined without `id`
271
271
  ### SearchFilterTypes
272
272
  | Property | Type | Required | Values |
273
273
  |-------------|-----------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------|
274
- | filterName | SearchFilterNameTypes | true | manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price, mileage, modelYear |
274
+ | filterName | SearchFilterNameTypes | true | manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price, mileage, modelYear, leasingPrice, businessLeasingPrice |
275
275
  | displayName | string | false | |
276
276
 
277
277
  * `displayName` override default translation of title
@@ -503,6 +503,7 @@ const PRICE = 'price';
503
503
  const MILEAGE = 'mileage';
504
504
  const MODEL_YEAR = 'modelYear';
505
505
  const LEASING_PRICE = 'leasingPrice';
506
+ const BUSINESS_LEASING_PRICE = 'businessLeasingPrice';
506
507
  const COLOR_WHITE = {
507
508
  displayName: 'Vit',
508
509
  hex: '#ffffff'
@@ -595,6 +596,8 @@ const FacetIdToTitle = f => {
595
596
  return 'Modellår';
596
597
  case LEASING_PRICE:
597
598
  return 'Privatleasing';
599
+ case BUSINESS_LEASING_PRICE:
600
+ return 'Företagsleasing';
598
601
  default:
599
602
  return f;
600
603
  }
@@ -993,13 +996,11 @@ const H2 = styled__default(HeadingBase).attrs(props => ({
993
996
  }))`
994
997
  font-size: 1.5rem;
995
998
  `;
996
- /*
997
- export const H3 = styled(HeadingBase).attrs<{ as: string }>((props) => ({
998
- as: props.as || 'h3',
999
+ const H3 = styled__default(HeadingBase).attrs(props => ({
1000
+ as: props.as || 'h3'
999
1001
  }))`
1000
1002
  font-size: 1.125rem;
1001
1003
  `;
1002
- */
1003
1004
  const H4 = styled__default(HeadingBase).attrs(props => ({
1004
1005
  as: props.as || 'h4'
1005
1006
  }))`
@@ -1981,6 +1982,7 @@ const FacetSelector = ({
1981
1982
  unit: "kr",
1982
1983
  formatValues: true
1983
1984
  });
1985
+ case BUSINESS_LEASING_PRICE:
1984
1986
  case LEASING_PRICE:
1985
1987
  return React__default.createElement(RangeFacet, {
1986
1988
  facet: facet,
@@ -2037,6 +2039,8 @@ const isSelected = (f, searchParams) => {
2037
2039
  switch (f.id) {
2038
2040
  case PRICE:
2039
2041
  case MILEAGE:
2042
+ case LEASING_PRICE:
2043
+ case BUSINESS_LEASING_PRICE:
2040
2044
  case MODEL_YEAR:
2041
2045
  return searchParams.has(`${f.id}.min`) || searchParams.has(`${f.id}.max`) ? 1 : 0;
2042
2046
  default:
@@ -2379,6 +2383,7 @@ const ProductCard = ({
2379
2383
  price,
2380
2384
  oldPrice,
2381
2385
  leasingPrice,
2386
+ businessLeasingPrice,
2382
2387
  onClick
2383
2388
  }) => {
2384
2389
  const {
@@ -2415,7 +2420,7 @@ const ProductCard = ({
2415
2420
  }, title) : title), description && React__default.createElement(Description$1, null, description), uspList && React__default.createElement(Usp, null, React__default.createElement(UspList, {
2416
2421
  small: true,
2417
2422
  items: uspList
2418
- }))), React__default.createElement(ContentFooter, null, React__default.createElement(Price, null, React__default.createElement(PriceCell, null, oldPrice ? React__default.createElement(OldPrice, null, oldPrice) : React__default.createElement(Label$3, null, "Pris"), React__default.createElement(CurrentPrice, null, price)), leasingPrice && React__default.createElement(PriceCell, null, React__default.createElement(Label$3, null, "Leasingpris"), React__default.createElement(CurrentPrice, null, leasingPrice))))));
2423
+ }))), React__default.createElement(ContentFooter, null, React__default.createElement(Price, null, React__default.createElement(PriceCell, null, oldPrice ? React__default.createElement(OldPrice, null, oldPrice) : React__default.createElement(Label$3, null, "Pris"), React__default.createElement(CurrentPrice, null, price)), leasingPrice && React__default.createElement(PriceCell, null, React__default.createElement(Label$3, null, "Privatleasing"), React__default.createElement(CurrentPrice, null, leasingPrice)), businessLeasingPrice && React__default.createElement(PriceCell, null, React__default.createElement(Label$3, null, "F\u00F6retagsleasing"), React__default.createElement(CurrentPrice, null, businessLeasingPrice))))));
2419
2424
  };
2420
2425
 
2421
2426
  const resolveImage = document => {
@@ -2475,8 +2480,9 @@ const Grid = ({
2475
2480
  title: document.fuelType
2476
2481
  }],
2477
2482
  price: `${numberSeparator(document.price)} kr`,
2478
- leasingPrice: document.leasingPrice !== undefined ? `${numberSeparator(document.leasingPrice)} kr` : undefined,
2479
- oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice ? `${numberSeparator(document.oldPrice)} kr` : undefined
2483
+ oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice ? `${numberSeparator(document.oldPrice)} kr` : undefined,
2484
+ leasingPrice: document.leasingPrice !== undefined ? `${numberSeparator(document.leasingPrice)} kr/mån` : undefined,
2485
+ businessLeasingPrice: document.businessLeasingPrice !== undefined ? `${numberSeparator(document.businessLeasingPrice)} kr/mån` : undefined
2480
2486
  }));
2481
2487
  })));
2482
2488
  };
@@ -6902,6 +6908,8 @@ const Related = ({
6902
6908
  }],
6903
6909
  price: `${numberSeparator(document.price)} kr`,
6904
6910
  oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice ? `${numberSeparator(document.oldPrice)} kr` : undefined,
6911
+ leasingPrice: document.leasingPrice !== undefined ? `${numberSeparator(document.leasingPrice)} kr/mån` : undefined,
6912
+ businessLeasingPrice: document.businessLeasingPrice !== undefined ? `${numberSeparator(document.businessLeasingPrice)} kr/mån` : undefined,
6905
6913
  pathRoute: pathRoute
6906
6914
  }));
6907
6915
  }))))));
@@ -8069,7 +8077,7 @@ const PdfListItem = styled__default.li.attrs(() => ({
8069
8077
  flex: 0 0 100%;
8070
8078
  }
8071
8079
  `;
8072
- const PdfContainer = styled__default.ul`
8080
+ const List$a = styled__default.ul`
8073
8081
  list-style: none;
8074
8082
  padding: 0;
8075
8083
  display: flex;
@@ -8113,20 +8121,71 @@ const PdfListInner = styled__default.div`
8113
8121
  }
8114
8122
  `;
8115
8123
 
8124
+ const translateContentType = document => {
8125
+ switch (document.contentType) {
8126
+ case 'application/pdf':
8127
+ return 'PDF';
8128
+ default:
8129
+ const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
8130
+ return formattedContentType;
8131
+ }
8132
+ };
8116
8133
  const PdfDownloadItem = ({
8117
8134
  document
8118
- }) => React__default.createElement(PdfListItem, null, React__default.createElement(PdfListInner, null, React__default.createElement(PdfColumn, null, React__default.createElement(PdfTitle, null, document.name), React__default.createElement(PdfSubtitle, null, document.contentType)), React__default.createElement(PdfColumn, null, React__default.createElement(PdfLink, {
8119
- href: document.url,
8120
- rel: "noopener noreferrer nofollow",
8121
- target: "_blank"
8122
- }, "\u00D6ppna"))));
8123
- const PdfDownloadContainer = ({
8135
+ }) => {
8136
+ const contentType = React.useMemo(() => translateContentType(document), [document]);
8137
+ return React__default.createElement(PdfListItem, null, React__default.createElement(PdfListInner, null, React__default.createElement(PdfColumn, null, React__default.createElement(PdfTitle, null, document.name), React__default.createElement(PdfSubtitle, null, contentType)), React__default.createElement(PdfColumn, null, React__default.createElement(PdfLink, {
8138
+ href: document.url,
8139
+ rel: "noopener noreferrer nofollow",
8140
+ target: "_blank"
8141
+ }, "\u00D6ppna"))));
8142
+ };
8143
+ const DocumentList = ({
8124
8144
  documents
8125
- }) => React__default.createElement(PdfContainer, null, documents.map((document, i) => React__default.createElement(PdfDownloadItem, {
8145
+ }) => React__default.createElement(List$a, null, documents.map((document, i) => React__default.createElement(PdfDownloadItem, {
8126
8146
  key: `${document.url}-${i}`,
8127
8147
  document: document
8128
8148
  })));
8129
8149
 
8150
+ const Translation = {
8151
+ 'tyre-label': 'Energideklaration för däck',
8152
+ 'content declaration': 'Varudeklaration',
8153
+ other: 'Övriga dokument'
8154
+ };
8155
+ const SortOrder = {
8156
+ 'tyre-label': 2,
8157
+ 'content declaration': 1,
8158
+ other: 3
8159
+ };
8160
+ const Documents = ({
8161
+ documents
8162
+ }) => {
8163
+ const categorised = documents.reduce((prev, curr) => {
8164
+ const index = prev.findIndex(x => x.category === (curr.category || 'others'));
8165
+ if (index > -1) {
8166
+ prev[index].documents.push(curr);
8167
+ } else {
8168
+ var _SortOrder$category;
8169
+ const category = curr.category || 'others';
8170
+ prev.push({
8171
+ category,
8172
+ documents: [curr],
8173
+ sortOrder: (_SortOrder$category = SortOrder === null || SortOrder === void 0 ? void 0 : SortOrder[category]) !== null && _SortOrder$category !== void 0 ? _SortOrder$category : 99
8174
+ });
8175
+ }
8176
+ return prev;
8177
+ }, []).sort((a, b) => a.sortOrder - b.sortOrder);
8178
+ if (!documents.length) return null;
8179
+ const manyCategories = categorised.length > 1;
8180
+ return React__default.createElement(ProductPageMainSection, null, React__default.createElement(Repeat, null, React__default.createElement(H2, {
8181
+ noMargin: true
8182
+ }, "Dokument")), categorised.map(group => React__default.createElement(Repeat, {
8183
+ key: group.category
8184
+ }, manyCategories && React__default.createElement(H3, null, (Translation === null || Translation === void 0 ? void 0 : Translation[group.category]) || Translation.other), React__default.createElement(DocumentList, {
8185
+ documents: group.documents
8186
+ }))));
8187
+ };
8188
+
8130
8189
  const WaykeSearchItem = ({
8131
8190
  id,
8132
8191
  hashRoute,
@@ -8322,11 +8381,9 @@ const WaykeSearchItem = ({
8322
8381
  onClick: onShowMoreOptionsClick
8323
8382
  }, React__default.createElement(UspList, {
8324
8383
  items: options
8325
- })))), (documents.length || 0) > 0 && React__default.createElement(ProductPageMainSection, null, React__default.createElement(Repeat, null, React__default.createElement(H2, {
8326
- noMargin: true
8327
- }, "Dokument")), React__default.createElement(Repeat, null, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))), React__default.createElement(Repeat, null, React__default.createElement(PdfDownloadContainer, {
8384
+ })))), React__default.createElement(Documents, {
8328
8385
  documents: documents
8329
- }))), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
8386
+ }), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
8330
8387
  branch: branch,
8331
8388
  loading: loadingCentralStorageVehicle
8332
8389
  }), ecommerce && ecommerce.enabled && React__default.createElement(Repeat, null, React__default.createElement(ButtonPrimary, {