@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.
@@ -0,0 +1,23 @@
1
+ import React, { useMemo } from 'react';
2
+ import { PdfListItem, PdfSubtitle, PdfTitle, List, PdfListInner, PdfLink, PdfColumn, } from './wrapper';
3
+ const translateContentType = (document) => {
4
+ switch (document.contentType) {
5
+ case 'application/pdf':
6
+ return 'PDF';
7
+ default:
8
+ const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
9
+ return formattedContentType;
10
+ }
11
+ };
12
+ export const PdfDownloadItem = ({ document }) => {
13
+ const contentType = useMemo(() => translateContentType(document), [document]);
14
+ return (React.createElement(PdfListItem, null,
15
+ React.createElement(PdfListInner, null,
16
+ React.createElement(PdfColumn, null,
17
+ React.createElement(PdfTitle, null, document.name),
18
+ React.createElement(PdfSubtitle, null, contentType)),
19
+ React.createElement(PdfColumn, null,
20
+ React.createElement(PdfLink, { href: document.url, rel: "noopener noreferrer nofollow", target: "_blank" }, "\u00D6ppna")))));
21
+ };
22
+ export const DocumentList = ({ documents }) => (React.createElement(List, null, documents.map((document, i) => (React.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
23
+ export default DocumentList;
@@ -10,7 +10,7 @@ export const PdfListItem = styled.li.attrs(() => ({
10
10
  flex: 0 0 100%;
11
11
  }
12
12
  `;
13
- export const PdfContainer = styled.ul `
13
+ export const List = styled.ul `
14
14
  list-style: none;
15
15
  padding: 0;
16
16
  display: flex;
@@ -1,13 +1,15 @@
1
1
  import React, { useState, useCallback } from 'react';
2
2
  import { List, Item, Action, Label, Indicator, IndicatorValue } from './wrapper';
3
3
  import { FacetIdToTitle } from '../../utils/formats';
4
- import { PRICE, MILEAGE, MODEL_YEAR } from '../../utils/constants';
4
+ import { PRICE, MILEAGE, MODEL_YEAR, LEASING_PRICE, BUSINESS_LEASING_PRICE, } from '../../utils/constants';
5
5
  import useSearch from '../../State/Search/useSearch';
6
6
  import FilterPanel from '../FilterPanel/index';
7
7
  const isSelected = (f, searchParams) => {
8
8
  switch (f.id) {
9
9
  case PRICE:
10
10
  case MILEAGE:
11
+ case LEASING_PRICE:
12
+ case BUSINESS_LEASING_PRICE:
11
13
  case MODEL_YEAR:
12
14
  return searchParams.has(`${f.id}.min`) || searchParams.has(`${f.id}.max`) ? 1 : 0;
13
15
  default:
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import CheckListFacet from './checkListFacet';
3
3
  import ColorSelectFacet from './colorFacet';
4
4
  import RangeFacet from './rangeFacet';
5
- import { MANUFACTURER, MODEL_SERIES, FUEL_TYPE, GEARBOX_TYPE, ENVIRONMENT_CLASS, SEGMENT, DRIVING_WHEEL, COLOR, PRICE, BRANCH, MILEAGE, MODEL_YEAR, LEASING_PRICE, } from '../../utils/constants';
5
+ import { MANUFACTURER, MODEL_SERIES, FUEL_TYPE, GEARBOX_TYPE, ENVIRONMENT_CLASS, SEGMENT, DRIVING_WHEEL, COLOR, PRICE, BRANCH, MILEAGE, MODEL_YEAR, LEASING_PRICE, BUSINESS_LEASING_PRICE, } from '../../utils/constants';
6
6
  const FacetSelector = ({ facet }) => {
7
7
  switch (facet.id) {
8
8
  case MANUFACTURER:
@@ -18,6 +18,7 @@ const FacetSelector = ({ facet }) => {
18
18
  return React.createElement(ColorSelectFacet, { facet: facet });
19
19
  case PRICE:
20
20
  return React.createElement(RangeFacet, { facet: facet, unit: "kr", formatValues: true });
21
+ case BUSINESS_LEASING_PRICE:
21
22
  case LEASING_PRICE:
22
23
  return React.createElement(RangeFacet, { facet: facet, unit: "kr/m\u00E5n", formatValues: true });
23
24
  case MILEAGE:
@@ -49,10 +49,12 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
49
49
  {
50
50
  title: document.fuelType,
51
51
  },
52
- ], price: `${numberSeparator(document.price)} kr`, leasingPrice: document.leasingPrice !== undefined
53
- ? `${numberSeparator(document.leasingPrice)} kr`
54
- : undefined, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
52
+ ], price: `${numberSeparator(document.price)} kr`, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
55
53
  ? `${numberSeparator(document.oldPrice)} kr`
54
+ : undefined, leasingPrice: document.leasingPrice !== undefined
55
+ ? `${numberSeparator(document.leasingPrice)} kr/mån`
56
+ : undefined, businessLeasingPrice: document.businessLeasingPrice !== undefined
57
+ ? `${numberSeparator(document.businessLeasingPrice)} kr/mån`
56
58
  : undefined })));
57
59
  }))));
58
60
  };
@@ -23,13 +23,11 @@ export const H2 = styled(HeadingBase).attrs((props) => ({
23
23
  })) `
24
24
  font-size: 1.5rem;
25
25
  `;
26
- /*
27
- export const H3 = styled(HeadingBase).attrs<{ as: string }>((props) => ({
28
- as: props.as || 'h3',
29
- }))`
26
+ export const H3 = styled(HeadingBase).attrs((props) => ({
27
+ as: props.as || 'h3',
28
+ })) `
30
29
  font-size: 1.125rem;
31
30
  `;
32
- */
33
31
  export const H4 = styled(HeadingBase).attrs((props) => ({
34
32
  as: props.as || 'h4',
35
33
  })) `
@@ -4,7 +4,7 @@ import { Wrapper, Image, Picture, Source, Img, Content, ContentBody, ContentFoot
4
4
  import UspList from '../UspList/index';
5
5
  import { DEFAULT_PLACEHOLDER_IMAGE } from '../../utils/constants';
6
6
  import usePath from '../../State/Path/usePath';
7
- const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, onClick, }) => {
7
+ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }) => {
8
8
  const { pushState } = usePath();
9
9
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
10
10
  const onHrefClick = useCallback((e) => {
@@ -35,7 +35,10 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
35
35
  oldPrice ? React.createElement(OldPrice, null, oldPrice) : React.createElement(Label, null, "Pris"),
36
36
  React.createElement(CurrentPrice, null, price)),
37
37
  leasingPrice && (React.createElement(PriceCell, null,
38
- React.createElement(Label, null, "Leasingpris"),
39
- React.createElement(CurrentPrice, null, leasingPrice))))))));
38
+ React.createElement(Label, null, "Privatleasing"),
39
+ React.createElement(CurrentPrice, null, leasingPrice))),
40
+ businessLeasingPrice && (React.createElement(PriceCell, null,
41
+ React.createElement(Label, null, "F\u00F6retagsleasing"),
42
+ React.createElement(CurrentPrice, null, businessLeasingPrice))))))));
40
43
  };
41
44
  export default ProductCard;
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { H2, H3 } from '../../components/Heading/index';
3
+ import { ProductPageMainSection } from '../../components/ProductPage/index';
4
+ import DocumentList from '../../components/DocumentList/index';
5
+ import { Repeat } from '../../components/Repeat/index';
6
+ const Translation = {
7
+ 'tyre-label': 'Energideklaration för däck',
8
+ 'content declaration': 'Varudeklaration',
9
+ other: 'Övriga dokument',
10
+ };
11
+ const SortOrder = {
12
+ 'tyre-label': 2,
13
+ 'content declaration': 1,
14
+ other: 3,
15
+ };
16
+ const Documents = ({ documents }) => {
17
+ const categorised = documents
18
+ .reduce((prev, curr) => {
19
+ const index = prev.findIndex((x) => x.category === (curr.category || 'others'));
20
+ if (index > -1) {
21
+ prev[index].documents.push(curr);
22
+ }
23
+ else {
24
+ const category = curr.category || 'others';
25
+ prev.push({
26
+ category,
27
+ documents: [curr],
28
+ sortOrder: SortOrder?.[category] ?? 99,
29
+ });
30
+ }
31
+ return prev;
32
+ }, [])
33
+ .sort((a, b) => a.sortOrder - b.sortOrder);
34
+ if (!documents.length)
35
+ return null;
36
+ const manyCategories = categorised.length > 1;
37
+ return (React.createElement(ProductPageMainSection, null,
38
+ React.createElement(Repeat, null,
39
+ React.createElement(H2, { noMargin: true }, "Dokument")),
40
+ categorised.map((group) => (React.createElement(Repeat, { key: group.category },
41
+ manyCategories && (React.createElement(H3, null, Translation?.[group.category] || Translation.other)),
42
+ React.createElement(DocumentList, { documents: group.documents }))))));
43
+ };
44
+ export default Documents;
@@ -58,6 +58,10 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
58
58
  },
59
59
  ], price: `${numberSeparator(document.price)} kr`, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
60
60
  ? `${numberSeparator(document.oldPrice)} kr`
61
+ : undefined, leasingPrice: document.leasingPrice !== undefined
62
+ ? `${numberSeparator(document.leasingPrice)} kr/mån`
63
+ : undefined, businessLeasingPrice: document.businessLeasingPrice !== undefined
64
+ ? `${numberSeparator(document.businessLeasingPrice)} kr/mån`
61
65
  : undefined, pathRoute: pathRoute })));
62
66
  })))))));
63
67
  };
@@ -32,8 +32,8 @@ import PageLoading from './PageLoading';
32
32
  import PubSub from '../../utils/pubsub/pubsub';
33
33
  import Property from './Property';
34
34
  import DemoCarModal from './DemoCarModal';
35
- import PdfDownloadContainer from '../../components/Pdf/index';
36
35
  import useSettings from '../../State/Settings/useSettings';
36
+ import Documents from './Documents';
37
37
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
38
38
  const { ecomSettings } = useSettings();
39
39
  const ecomContext = useRef();
@@ -165,14 +165,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
165
165
  React.createElement(Repeat, null,
166
166
  React.createElement(ExtendContent, { actionTitle: "Visa mer", onClick: onShowMoreOptionsClick },
167
167
  React.createElement(UspList, { items: options }))))),
168
- (documents.length || 0) > 0 && (React.createElement(ProductPageMainSection, null,
169
- React.createElement(Repeat, null,
170
- React.createElement(H2, { noMargin: true }, "Dokument")),
171
- React.createElement(Repeat, null,
172
- React.createElement(Content, null,
173
- React.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))),
174
- React.createElement(Repeat, null,
175
- React.createElement(PdfDownloadContainer, { documents: documents })))),
168
+ React.createElement(Documents, { documents: documents }),
176
169
  React.createElement(ProductPageMainSection, null,
177
170
  React.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
178
171
  ecommerce && ecommerce.enabled && (React.createElement(Repeat, null,
@@ -11,6 +11,7 @@ export const PRICE = 'price';
11
11
  export const MILEAGE = 'mileage';
12
12
  export const MODEL_YEAR = 'modelYear';
13
13
  export const LEASING_PRICE = 'leasingPrice';
14
+ export const BUSINESS_LEASING_PRICE = 'businessLeasingPrice';
14
15
  export const COLOR_WHITE = { displayName: 'Vit', hex: '#ffffff' };
15
16
  export const COLOR_BLACK = { displayName: 'Svart', hex: '#000000' };
16
17
  export const COLOR_GRAY = { displayName: 'Grå', hex: '#808080' };
@@ -10,7 +10,7 @@ export const numberSeparator = (value, n = 0, x = 3, s = ' ', c = '.') => {
10
10
  const num = value.toFixed(Math.max(0, ~~n));
11
11
  return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), `$&${s || ','}`);
12
12
  };
13
- import { MANUFACTURER, MODEL_SERIES, FUEL_TYPE, GEARBOX_TYPE, ENVIRONMENT_CLASS, SEGMENT, DRIVING_WHEEL, COLOR, PRICE, BRANCH, MILEAGE, MODEL_YEAR, LEASING_PRICE, } from './constants';
13
+ import { MANUFACTURER, MODEL_SERIES, FUEL_TYPE, GEARBOX_TYPE, ENVIRONMENT_CLASS, SEGMENT, DRIVING_WHEEL, COLOR, PRICE, BRANCH, MILEAGE, MODEL_YEAR, LEASING_PRICE, BUSINESS_LEASING_PRICE, } from './constants';
14
14
  export const FacetIdToTitle = (f) => {
15
15
  switch (f) {
16
16
  case MANUFACTURER:
@@ -39,6 +39,8 @@ export const FacetIdToTitle = (f) => {
39
39
  return 'Modellår';
40
40
  case LEASING_PRICE:
41
41
  return 'Privatleasing';
42
+ case BUSINESS_LEASING_PRICE:
43
+ return 'Företagsleasing';
42
44
  default:
43
45
  return f;
44
46
  }
@@ -21,6 +21,8 @@ export declare type Scalars = {
21
21
  DateTime: Date;
22
22
  Email: string;
23
23
  FileDocument: {
24
+ webp: string;
25
+ category: string;
24
26
  contentType: string;
25
27
  name: string;
26
28
  url: string;
@@ -1,4 +1,4 @@
1
- export declare type SearchFilterNameTypes = 'manufacturer' | 'modelSeries' | 'fuelType' | 'gearboxType' | 'branch' | 'color' | 'environmentClass' | 'properties.segment' | 'drivingWheel' | 'price' | 'mileage' | 'modelYear';
1
+ export declare type SearchFilterNameTypes = 'manufacturer' | 'modelSeries' | 'fuelType' | 'gearboxType' | 'branch' | 'color' | 'environmentClass' | 'properties.segment' | 'drivingWheel' | 'price' | 'mileage' | 'modelYear' | 'leasingPrice' | 'businessLeasingPrice';
2
2
  export declare type SearchFilterTypes = {
3
3
  filterName: SearchFilterNameTypes;
4
4
  displayName?: string;
@@ -73,6 +73,7 @@ export interface Document {
73
73
  shortDescription: string;
74
74
  title: string;
75
75
  leasingPrice?: number;
76
+ businessLeasingPrice?: number;
76
77
  }
77
78
  export interface FacetFilter {
78
79
  displayName: string;
@@ -4,8 +4,8 @@ interface PdfDownloadItemProps {
4
4
  document: Scalars['FileDocument'];
5
5
  }
6
6
  export declare const PdfDownloadItem: ({ document }: PdfDownloadItemProps) => JSX.Element;
7
- interface PdfDownloadContainerProps {
7
+ interface IDocumentList {
8
8
  documents: Scalars['FileDocument'][];
9
9
  }
10
- export declare const PdfDownloadContainer: ({ documents }: PdfDownloadContainerProps) => JSX.Element;
11
- export default PdfDownloadContainer;
10
+ export declare const DocumentList: ({ documents }: IDocumentList) => JSX.Element;
11
+ export default DocumentList;
@@ -1,7 +1,7 @@
1
1
  export declare const PdfListItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {
2
2
  className: "wayke__theme wayke__color--primary-text";
3
3
  }, "className">;
4
- export declare const PdfContainer: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const List: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
5
5
  export declare const PdfLink: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, {
6
6
  className: "wayke__theme wayke__color--primary-text wayke__font--bold";
7
7
  }, "className">;
@@ -9,6 +9,11 @@ export declare const H2: import("styled-components").StyledComponent<"div", impo
9
9
  } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
10
10
  noMargin?: boolean | undefined;
11
11
  }, "className">;
12
+ export declare const H3: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
13
+ className: "wayke__theme wayke__font--bold";
14
+ } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
15
+ noMargin?: boolean | undefined;
16
+ }, "className">;
12
17
  export declare const H4: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
13
18
  className: "wayke__theme wayke__font--bold";
14
19
  } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
@@ -12,7 +12,8 @@ interface Props {
12
12
  price: string;
13
13
  leasingPrice?: string;
14
14
  oldPrice?: string;
15
+ businessLeasingPrice?: string;
15
16
  onClick?: (id: string) => void;
16
17
  }
17
- declare const ProductCard: ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, onClick, }: Props) => JSX.Element;
18
+ declare const ProductCard: ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }: Props) => JSX.Element;
18
19
  export default ProductCard;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { Scalars } from '../../@types/codegen/types';
3
+ interface DocumentsProps {
4
+ documents: Scalars['FileDocument'][];
5
+ }
6
+ declare const Documents: ({ documents }: DocumentsProps) => JSX.Element | null;
7
+ export default Documents;
@@ -11,6 +11,7 @@ export declare const PRICE = "price";
11
11
  export declare const MILEAGE = "mileage";
12
12
  export declare const MODEL_YEAR = "modelYear";
13
13
  export declare const LEASING_PRICE = "leasingPrice";
14
+ export declare const BUSINESS_LEASING_PRICE = "businessLeasingPrice";
14
15
  export declare const COLOR_WHITE: {
15
16
  displayName: string;
16
17
  hex: string;
package/dist-web/index.js CHANGED
@@ -476,6 +476,7 @@ const PRICE = 'price';
476
476
  const MILEAGE = 'mileage';
477
477
  const MODEL_YEAR = 'modelYear';
478
478
  const LEASING_PRICE = 'leasingPrice';
479
+ const BUSINESS_LEASING_PRICE = 'businessLeasingPrice';
479
480
  const COLOR_WHITE = { displayName: 'Vit', hex: '#ffffff' };
480
481
  const COLOR_BLACK = { displayName: 'Svart', hex: '#000000' };
481
482
  const COLOR_GRAY = { displayName: 'Grå', hex: '#808080' };
@@ -532,6 +533,8 @@ const FacetIdToTitle = (f) => {
532
533
  return 'Modellår';
533
534
  case LEASING_PRICE:
534
535
  return 'Privatleasing';
536
+ case BUSINESS_LEASING_PRICE:
537
+ return 'Företagsleasing';
535
538
  default:
536
539
  return f;
537
540
  }
@@ -806,13 +809,11 @@ const H2 = styled(HeadingBase).attrs((props) => ({
806
809
  })) `
807
810
  font-size: 1.5rem;
808
811
  `;
809
- /*
810
- export const H3 = styled(HeadingBase).attrs<{ as: string }>((props) => ({
811
- as: props.as || 'h3',
812
- }))`
812
+ const H3 = styled(HeadingBase).attrs((props) => ({
813
+ as: props.as || 'h3',
814
+ })) `
813
815
  font-size: 1.125rem;
814
816
  `;
815
- */
816
817
  const H4 = styled(HeadingBase).attrs((props) => ({
817
818
  as: props.as || 'h4',
818
819
  })) `
@@ -1611,6 +1612,7 @@ const FacetSelector = ({ facet }) => {
1611
1612
  return React__default.createElement(ColorSelectFacet, { facet: facet });
1612
1613
  case PRICE:
1613
1614
  return React__default.createElement(RangeFacet, { facet: facet, unit: "kr", formatValues: true });
1615
+ case BUSINESS_LEASING_PRICE:
1614
1616
  case LEASING_PRICE:
1615
1617
  return React__default.createElement(RangeFacet, { facet: facet, unit: "kr/m\u00E5n", formatValues: true });
1616
1618
  case MILEAGE:
@@ -1643,6 +1645,8 @@ const isSelected = (f, searchParams) => {
1643
1645
  switch (f.id) {
1644
1646
  case PRICE:
1645
1647
  case MILEAGE:
1648
+ case LEASING_PRICE:
1649
+ case BUSINESS_LEASING_PRICE:
1646
1650
  case MODEL_YEAR:
1647
1651
  return searchParams.has(`${f.id}.min`) || searchParams.has(`${f.id}.max`) ? 1 : 0;
1648
1652
  default:
@@ -1956,7 +1960,7 @@ const usePath = () => {
1956
1960
  return context;
1957
1961
  };
1958
1962
 
1959
- const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, onClick, }) => {
1963
+ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }) => {
1960
1964
  const { pushState } = usePath();
1961
1965
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
1962
1966
  const onHrefClick = useCallback((e) => {
@@ -1987,8 +1991,11 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1987
1991
  oldPrice ? React__default.createElement(OldPrice, null, oldPrice) : React__default.createElement(Label$3, null, "Pris"),
1988
1992
  React__default.createElement(CurrentPrice, null, price)),
1989
1993
  leasingPrice && (React__default.createElement(PriceCell, null,
1990
- React__default.createElement(Label$3, null, "Leasingpris"),
1991
- React__default.createElement(CurrentPrice, null, leasingPrice))))))));
1994
+ React__default.createElement(Label$3, null, "Privatleasing"),
1995
+ React__default.createElement(CurrentPrice, null, leasingPrice))),
1996
+ businessLeasingPrice && (React__default.createElement(PriceCell, null,
1997
+ React__default.createElement(Label$3, null, "F\u00F6retagsleasing"),
1998
+ React__default.createElement(CurrentPrice, null, businessLeasingPrice))))))));
1992
1999
  };
1993
2000
 
1994
2001
  const resolveImage = (document) => {
@@ -2038,10 +2045,12 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
2038
2045
  {
2039
2046
  title: document.fuelType,
2040
2047
  },
2041
- ], price: `${numberSeparator(document.price)} kr`, leasingPrice: document.leasingPrice !== undefined
2042
- ? `${numberSeparator(document.leasingPrice)} kr`
2043
- : undefined, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
2048
+ ], price: `${numberSeparator(document.price)} kr`, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
2044
2049
  ? `${numberSeparator(document.oldPrice)} kr`
2050
+ : undefined, leasingPrice: document.leasingPrice !== undefined
2051
+ ? `${numberSeparator(document.leasingPrice)} kr/mån`
2052
+ : undefined, businessLeasingPrice: document.businessLeasingPrice !== undefined
2053
+ ? `${numberSeparator(document.businessLeasingPrice)} kr/mån`
2045
2054
  : undefined })));
2046
2055
  }))));
2047
2056
  };
@@ -5949,6 +5958,10 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5949
5958
  },
5950
5959
  ], price: `${numberSeparator(document.price)} kr`, oldPrice: document.oldPrice !== undefined && document.price < document.oldPrice
5951
5960
  ? `${numberSeparator(document.oldPrice)} kr`
5961
+ : undefined, leasingPrice: document.leasingPrice !== undefined
5962
+ ? `${numberSeparator(document.leasingPrice)} kr/mån`
5963
+ : undefined, businessLeasingPrice: document.businessLeasingPrice !== undefined
5964
+ ? `${numberSeparator(document.businessLeasingPrice)} kr/mån`
5952
5965
  : undefined, pathRoute: pathRoute })));
5953
5966
  })))))));
5954
5967
  };
@@ -7108,7 +7121,7 @@ const PdfListItem = styled.li.attrs(() => ({
7108
7121
  flex: 0 0 100%;
7109
7122
  }
7110
7123
  `;
7111
- const PdfContainer = styled.ul `
7124
+ const List$a = styled.ul `
7112
7125
  list-style: none;
7113
7126
  padding: 0;
7114
7127
  display: flex;
@@ -7152,14 +7165,65 @@ const PdfListInner = styled.div `
7152
7165
  }
7153
7166
  `;
7154
7167
 
7155
- const PdfDownloadItem = ({ document }) => (React__default.createElement(PdfListItem, null,
7156
- React__default.createElement(PdfListInner, null,
7157
- React__default.createElement(PdfColumn, null,
7158
- React__default.createElement(PdfTitle, null, document.name),
7159
- React__default.createElement(PdfSubtitle, null, document.contentType)),
7160
- React__default.createElement(PdfColumn, null,
7161
- React__default.createElement(PdfLink, { href: document.url, rel: "noopener noreferrer nofollow", target: "_blank" }, "\u00D6ppna")))));
7162
- const PdfDownloadContainer = ({ documents }) => (React__default.createElement(PdfContainer, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
7168
+ const translateContentType = (document) => {
7169
+ switch (document.contentType) {
7170
+ case 'application/pdf':
7171
+ return 'PDF';
7172
+ default:
7173
+ const formattedContentType = document.url && document.url.includes('.') ? document.url.split('.').pop() : '';
7174
+ return formattedContentType;
7175
+ }
7176
+ };
7177
+ const PdfDownloadItem = ({ document }) => {
7178
+ const contentType = useMemo(() => translateContentType(document), [document]);
7179
+ return (React__default.createElement(PdfListItem, null,
7180
+ React__default.createElement(PdfListInner, null,
7181
+ React__default.createElement(PdfColumn, null,
7182
+ React__default.createElement(PdfTitle, null, document.name),
7183
+ React__default.createElement(PdfSubtitle, null, contentType)),
7184
+ React__default.createElement(PdfColumn, null,
7185
+ React__default.createElement(PdfLink, { href: document.url, rel: "noopener noreferrer nofollow", target: "_blank" }, "\u00D6ppna")))));
7186
+ };
7187
+ const DocumentList = ({ documents }) => (React__default.createElement(List$a, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
7188
+
7189
+ const Translation = {
7190
+ 'tyre-label': 'Energideklaration för däck',
7191
+ 'content declaration': 'Varudeklaration',
7192
+ other: 'Övriga dokument',
7193
+ };
7194
+ const SortOrder = {
7195
+ 'tyre-label': 2,
7196
+ 'content declaration': 1,
7197
+ other: 3,
7198
+ };
7199
+ const Documents = ({ documents }) => {
7200
+ const categorised = documents
7201
+ .reduce((prev, curr) => {
7202
+ const index = prev.findIndex((x) => x.category === (curr.category || 'others'));
7203
+ if (index > -1) {
7204
+ prev[index].documents.push(curr);
7205
+ }
7206
+ else {
7207
+ const category = curr.category || 'others';
7208
+ prev.push({
7209
+ category,
7210
+ documents: [curr],
7211
+ sortOrder: SortOrder?.[category] ?? 99,
7212
+ });
7213
+ }
7214
+ return prev;
7215
+ }, [])
7216
+ .sort((a, b) => a.sortOrder - b.sortOrder);
7217
+ if (!documents.length)
7218
+ return null;
7219
+ const manyCategories = categorised.length > 1;
7220
+ return (React__default.createElement(ProductPageMainSection, null,
7221
+ React__default.createElement(Repeat, null,
7222
+ React__default.createElement(H2, { noMargin: true }, "Dokument")),
7223
+ categorised.map((group) => (React__default.createElement(Repeat, { key: group.category },
7224
+ manyCategories && (React__default.createElement(H3, null, Translation?.[group.category] || Translation.other)),
7225
+ React__default.createElement(DocumentList, { documents: group.documents }))))));
7226
+ };
7163
7227
 
7164
7228
  const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
7165
7229
  const { ecomSettings } = useSettings();
@@ -7292,14 +7356,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7292
7356
  React__default.createElement(Repeat, null,
7293
7357
  React__default.createElement(ExtendContent, { actionTitle: "Visa mer", onClick: onShowMoreOptionsClick },
7294
7358
  React__default.createElement(UspList, { items: options }))))),
7295
- (documents.length || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
7296
- React__default.createElement(Repeat, null,
7297
- React__default.createElement(H2, { noMargin: true }, "Dokument")),
7298
- React__default.createElement(Repeat, null,
7299
- React__default.createElement(Content$2, null,
7300
- React__default.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))),
7301
- React__default.createElement(Repeat, null,
7302
- React__default.createElement(PdfDownloadContainer, { documents: documents })))),
7359
+ React__default.createElement(Documents, { documents: documents }),
7303
7360
  React__default.createElement(ProductPageMainSection, null,
7304
7361
  React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
7305
7362
  ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,