@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
@@ -1,6 +1,6 @@
1
1
  import { useContext, useEffect } from 'react';
2
2
  import { RelatedSearchContext } from './RelatedSearchContext';
3
- const useRelatedSearch = (id) => {
3
+ const useRelatedSearch = (id, authorizedReseller) => {
4
4
  const data = useContext(RelatedSearchContext);
5
5
  useEffect(() => {
6
6
  const searchParams = new URLSearchParams();
@@ -8,6 +8,9 @@ const useRelatedSearch = (id) => {
8
8
  if (data.moreLikeThisUrl && id) {
9
9
  searchParams.set('id', id);
10
10
  }
11
+ if (authorizedReseller) {
12
+ searchParams.set('isAuthorizedResellerForManufacturer', 'true');
13
+ }
11
14
  data.fetchRelated(searchParams);
12
15
  }, [id]);
13
16
  return data;
@@ -1,10 +1,8 @@
1
1
  import React, { useState, useCallback } from 'react';
2
2
  import { ButtonSecondary, ButtonContent } from '../Button/index';
3
3
  import { RepeatTiny } from '../Repeat/index';
4
- const initialValue = {};
5
- const getInitialValue = (title) => title && !!initialValue[title];
6
4
  const ToggleItem = ({ title, value, type, onClickVisible, onClickValue }) => {
7
- const [visible, setVisible] = useState(() => getInitialValue(type));
5
+ const [visible, setVisible] = useState(false);
8
6
  const _onClickValue = useCallback(() => {
9
7
  if (onClickValue) {
10
8
  onClickValue();
@@ -12,7 +10,6 @@ const ToggleItem = ({ title, value, type, onClickVisible, onClickValue }) => {
12
10
  }, []);
13
11
  const onClick = useCallback(() => {
14
12
  if (!visible) {
15
- initialValue[type] = true;
16
13
  setVisible(true);
17
14
  if (onClickVisible) {
18
15
  onClickVisible();
@@ -9,7 +9,7 @@ const resolveImage = (document) => {
9
9
  }
10
10
  return undefined;
11
11
  };
12
- const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }) => {
12
+ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, displayBranchName, onClickItem, }) => {
13
13
  if (!documents) {
14
14
  return null;
15
15
  }
@@ -36,7 +36,7 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
36
36
  */
37
37
  const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
38
38
  return (React.createElement(Item, { key: document._id },
39
- React.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
39
+ React.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, branchName: displayBranchName ? document.branches?.[0]?.name : undefined, uspList: [
40
40
  {
41
41
  title: document.modelYear,
42
42
  },
@@ -1,10 +1,10 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import LazyLoad from 'react-lazyload';
3
- import { Wrapper, Image, Picture, Source, Img, Content, ContentBody, ContentFooter, Heading, Link, Description, Usp, Price, CurrentPrice, OldPrice, PriceCell, Label, } from './wrapper';
3
+ import { Wrapper, Image, Picture, Source, Img, Content, ContentBody, ContentFooter, Heading, Link, Description, Usp, Price, CurrentPrice, OldPrice, PriceCell, Label, PreHeading, } from './wrapper';
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, businessLeasingPrice, onClick, }) => {
7
+ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, branchName, 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) => {
@@ -25,6 +25,7 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
25
25
  React.createElement(Img, { src: placeholderImage || DEFAULT_PLACEHOLDER_IMAGE }))))),
26
26
  React.createElement(Content, null,
27
27
  React.createElement(ContentBody, null,
28
+ branchName && React.createElement(PreHeading, null, branchName),
28
29
  React.createElement(Heading, null, href ? (React.createElement(Link, { onClick: onHrefClick, href: href, title: title, "aria-label": title }, title)) : (title)),
29
30
  description && React.createElement(Description, null, description),
30
31
  uspList && (React.createElement(Usp, null,
@@ -61,6 +61,11 @@ export const ContentFooter = styled.div `
61
61
  margin-top: auto;
62
62
  padding-top: ${size(1)};
63
63
  `;
64
+ export const PreHeading = styled.div `
65
+ margin-bottom: ${size(0.25)};
66
+ color: ${(props) => props.theme.color.textDarkLighten};
67
+ font-size: 0.75rem;
68
+ `;
64
69
  export const Heading = styled.h1.attrs(() => ({
65
70
  className: 'wayke__theme wayke__font--bold',
66
71
  })) `
@@ -125,5 +130,5 @@ export const OldPrice = styled.div `
125
130
  `;
126
131
  export const Label = styled.label `
127
132
  color: ${(props) => props.theme.color.disabledText};
128
- font-size: 0.875rem;
133
+ font-size: 0.75rem;
129
134
  `;
@@ -4,7 +4,7 @@ import PubSub from '../utils/pubsub/pubsub';
4
4
  import WaykeSearch from './search/index';
5
5
  import WaykeSearchItem from './searchItem/index';
6
6
  import usePath from '../State/Path/usePath';
7
- const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, }) => {
7
+ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, displayBranchName, }) => {
8
8
  const hashId = useHashGuid();
9
9
  const { id: pathId } = usePath();
10
10
  useEffect(() => {
@@ -18,6 +18,6 @@ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, remov
18
18
  }
19
19
  }, [hashId]);
20
20
  const id = pathId || hashId;
21
- return (React.createElement(React.Fragment, null, id ? (React.createElement(WaykeSearchItem, { id: id, hashRoute: !pathRoute, disableResetScrollOnInit: disableResetScrollOnInit, placeholderImage: placeholderImage, pathRoute: pathRoute, modifyDocumentTitleItem: modifyDocumentTitleItem })) : (React.createElement(WaykeSearch, { filterList: filterList, initialQueryParams: initialQueryParams, removeSearchBar: removeSearchBar, hashRoute: !pathRoute, placeholderImage: placeholderImage, pathRoute: pathRoute, removeFilterOptions: removeFilterOptions, modifyDocumentTitleSearch: modifyDocumentTitleSearch }))));
21
+ return (React.createElement(React.Fragment, null, id ? (React.createElement(WaykeSearchItem, { id: id, hashRoute: !pathRoute, disableResetScrollOnInit: disableResetScrollOnInit, placeholderImage: placeholderImage, pathRoute: pathRoute, modifyDocumentTitleItem: modifyDocumentTitleItem, displayBranchName: displayBranchName })) : (React.createElement(WaykeSearch, { filterList: filterList, initialQueryParams: initialQueryParams, removeSearchBar: removeSearchBar, hashRoute: !pathRoute, placeholderImage: placeholderImage, pathRoute: pathRoute, removeFilterOptions: removeFilterOptions, modifyDocumentTitleSearch: modifyDocumentTitleSearch, displayBranchName: displayBranchName }))));
22
22
  };
23
23
  export default WaykeComposite;
@@ -10,7 +10,7 @@ import SearchFilter from '../../components/SearchFilter/index';
10
10
  import Snackbar from '../../components/Snackbar/index';
11
11
  import useSearch from '../../State/Search/useSearch';
12
12
  import PubSub from '../../utils/pubsub/pubsub';
13
- const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, onClickSearchItem, }) => {
13
+ const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, displayBranchName, onClickSearchItem, }) => {
14
14
  const { error, documents, queryFilter, onFilterUpdate, onInitialize } = useSearch();
15
15
  useEffect(() => {
16
16
  if (modifyDocumentTitleSearch) {
@@ -48,7 +48,7 @@ const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, rem
48
48
  React.createElement(Result, null,
49
49
  React.createElement(React.Fragment, null,
50
50
  error && (React.createElement(Snackbar, { severity: "error", icon: true, heading: "Ett fel har intr\u00E4ffat" }, "V\u00E4nligen f\u00F6rs\u00F6k igen.")),
51
- !error && documents && documents.length > 0 && (React.createElement(Grid, { hashRoute: hashRoute, pathRoute: pathRoute, onClickItem: onItemClicked, documents: documents, placeholderImage: placeholderImage })),
51
+ !error && documents && documents.length > 0 && (React.createElement(Grid, { hashRoute: hashRoute, pathRoute: pathRoute, onClickItem: onItemClicked, documents: documents, placeholderImage: placeholderImage, displayBranchName: displayBranchName })),
52
52
  !error && documents && documents.length === 0 && (React.createElement(Snackbar, { severity: "warning", icon: true, heading: "Inga resultat" }, "Det finns inga resultat som matchar din s\u00F6kning."))))))),
53
53
  React.createElement(PortalElement, { id: PortalNamespace.DefaultPortal })));
54
54
  };
@@ -10,7 +10,7 @@ import PhoneNumber from '../../components/PhoneNumber/index';
10
10
  import Map from '../../components/Map/index';
11
11
  import BranchModal from './BranchModal';
12
12
  import { formatPhonenumber } from '../../utils/phonenumbers';
13
- const Branch = ({ branch, loading }) => {
13
+ const Branch = ({ branch, loading, displayBranchName }) => {
14
14
  const [modal, setModal] = useState(false);
15
15
  const openModal = useCallback(() => setModal(true), []);
16
16
  const closeModal = useCallback(() => setModal(false), []);
@@ -25,9 +25,11 @@ const Branch = ({ branch, loading }) => {
25
25
  return (React.createElement(React.Fragment, null,
26
26
  modal && (React.createElement(BranchModal, { loading: loading, connections: branch?.connections, onClose: closeModal })),
27
27
  React.createElement(Repeat, null,
28
- React.createElement(H2, { noMargin: true }, branch?.location?.city
29
- ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
30
- : 'Kontakt')),
28
+ React.createElement(H2, { noMargin: true }, displayBranchName
29
+ ? `Den här bilen finns på ${branch.name}`
30
+ : branch?.location?.city
31
+ ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
32
+ : 'Kontakt')),
31
33
  React.createElement(Repeat, null,
32
34
  React.createElement(Map, { position: branch?.location?.position })),
33
35
  (branch?.connections?.length || 0) > 1 && (React.createElement(Repeat, null,
@@ -11,8 +11,8 @@ import Loader from '../../components/Loader/index';
11
11
  import { numberSeparator } from '../../utils/formats';
12
12
  import PubSub from '../../utils/pubsub/pubsub';
13
13
  import { regexPathGuid } from '../../utils/regex';
14
- const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
15
- const { loading, response, moreLikeThisUrl } = useRelatedSearch(id);
14
+ const Related = ({ id, hashRoute, pathRoute, authorizedReseller, displayBranchName, onClickSearchItem, }) => {
15
+ const { loading, response, moreLikeThisUrl } = useRelatedSearch(id, !!authorizedReseller);
16
16
  const onItemClicked = useCallback((id) => {
17
17
  PubSub.publish('ItemClicked', id);
18
18
  if (onClickSearchItem) {
@@ -43,7 +43,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
43
43
  ? window.location.pathname.replace(r, document._id)
44
44
  : `${window.location.pathname}${prefix}${document._id}`;
45
45
  return (React.createElement(OverflowGridItem, { key: document._id },
46
- React.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [
46
+ React.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, branchName: displayBranchName ? document.branches?.[0]?.name : undefined, uspList: [
47
47
  {
48
48
  title: document.modelYear,
49
49
  },
@@ -18,7 +18,6 @@ import { IconChevronLeft } from '../../components/Icon/index';
18
18
  import useSearchItem from '../../hooks/useSearchItem';
19
19
  import { notEmpty, numberSeparator, dateTimeFormat } from '../../utils/formats';
20
20
  import { PortalNamespace, PortalElement } from '../../components/Portal/index';
21
- import Modal from '../../components/Modal/index';
22
21
  import FinancialOptions from '../../components/FinancialOptions/index';
23
22
  import InsuranceOptions from '../../components/InsuranceOptions/index';
24
23
  import ManufacturerPackageOption from './ManufacturerPackagesOption';
@@ -34,7 +33,7 @@ import Property from './Property';
34
33
  import DemoCarModal from './DemoCarModal';
35
34
  import useSettings from '../../State/Settings/useSettings';
36
35
  import Documents from './Documents';
37
- const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
36
+ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, displayBranchName, onClickSearchItem, }) => {
38
37
  const { ecomSettings } = useSettings();
39
38
  const ecomContext = useRef();
40
39
  const { loading, data: result } = useSearchItem(id);
@@ -167,17 +166,12 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
167
166
  React.createElement(UspList, { items: options }))))),
168
167
  React.createElement(Documents, { documents: documents }),
169
168
  React.createElement(ProductPageMainSection, null,
170
- React.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
169
+ React.createElement(Branch, { branch: branch, displayBranchName: displayBranchName, loading: loadingCentralStorageVehicle }),
171
170
  ecommerce && ecommerce.enabled && (React.createElement(Repeat, null,
172
171
  React.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
173
172
  React.createElement(PackageOptions, { packageOptions: packageOptions }),
174
173
  React.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
175
- React.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
176
- false && (React.createElement(Modal, { title: "Modal", onClose: () => { } },
177
- React.createElement(Content, null,
178
- React.createElement("p", null,
179
- "Priset \u00E4r ett cirkapris och baserat p\u00E5 ditt avtals antal m\u00E5nader och din ber\u00E4knade \u00E5rliga k\u00F6rstr\u00E4cka. Kostnad f\u00F6r f\u00F6rs\u00E4kring och serviceavtal tillkommer. Kontakta s\u00E4ljare f\u00F6r komplett kostnadsf\u00F6rslag.",
180
- ' ')))),
174
+ React.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, authorizedReseller: !!branch?.flags?.authorizedReseller, displayBranchName: displayBranchName, onClickSearchItem: onClickSearchItem })),
181
175
  React.createElement(PortalElement, { id: PortalNamespace.DefaultPortal }),
182
176
  demoCarModal && React.createElement(DemoCarModal, { onClose: onToggleDemoCarModal })));
183
177
  };
@@ -43,6 +43,7 @@ const SEARCH_ITEM_BRANCH_QUERY = gql `
43
43
  mrf
44
44
  centralStorage
45
45
  ecommerce
46
+ authorizedReseller
46
47
  }
47
48
  logotype
48
49
  openingHours {
@@ -5,6 +5,8 @@ const SortOptionDisplayName = {
5
5
  Pricedesc: 'price-desc',
6
6
  ModelAsc: 'model-asc',
7
7
  Modeldesc: 'model-desc',
8
+ MileageAsc: 'mileage-asc',
9
+ Mileagedesc: 'mileage-desc',
8
10
  };
9
11
  export const getTranslatedSortOptionDisplayName = (str) => {
10
12
  switch (str) {
@@ -20,6 +22,10 @@ export const getTranslatedSortOptionDisplayName = (str) => {
20
22
  return 'Årsmodell äldst';
21
23
  case SortOptionDisplayName.Modeldesc:
22
24
  return 'Årsmodell nyast';
25
+ case SortOptionDisplayName.MileageAsc:
26
+ return 'Miltal lägst';
27
+ case SortOptionDisplayName.Mileagedesc:
28
+ return 'Miltal högst';
23
29
  default:
24
30
  return str;
25
31
  }
@@ -70,6 +70,8 @@ export const HINTS = Object.freeze({
70
70
  finish: '',
71
71
  fuelConsumptionCityDriving: 'Bränsleförbrukning vid stadskörning.',
72
72
  fuelConsumptionCountryRoadDriving: 'Bränsleförbrukning vid landsvägskörning.',
73
+ fuelConsumptionMixedDrivingNEDC: 'Bränsleförbrukning vid blandad körning.',
74
+ fuelConsumptionMixedDrivingWLTP: 'Bränsleförbrukning vid blandad körning.',
73
75
  fuelConsumptionMixedDriving: 'Bränsleförbrukning vid blandad körning. Dvs. stadskörning och landsvägskörning under en och samma färd.',
74
76
  fuelType: 'Vad bilen ska tankas med och drivs av.',
75
77
  gearboxName: '',
@@ -60,6 +60,7 @@ export declare type BranchConnection = {
60
60
  };
61
61
  export declare type BranchFlags = {
62
62
  __typename?: 'BranchFlags';
63
+ authorizedReseller?: Maybe<Scalars['Boolean']>;
63
64
  centralStorage?: Maybe<Scalars['Boolean']>;
64
65
  ecommerce?: Maybe<Scalars['Boolean']>;
65
66
  mrf?: Maybe<Scalars['Boolean']>;
@@ -345,3 +346,7 @@ export declare type VehicleFlags = {
345
346
  demoVersion?: Maybe<Scalars['Boolean']>;
346
347
  testDrive?: Maybe<Scalars['Boolean']>;
347
348
  };
349
+ export declare type _Service = {
350
+ __typename?: '_Service';
351
+ sdl: Scalars['String'];
352
+ };
@@ -1,2 +1,2 @@
1
- declare const useRelatedSearch: (id: string) => import("./RelatedSearchContext").RelatedSearchContextProps;
1
+ declare const useRelatedSearch: (id: string, authorizedReseller?: boolean) => import("./RelatedSearchContext").RelatedSearchContextProps;
2
2
  export default useRelatedSearch;
@@ -5,7 +5,8 @@ interface GridProps {
5
5
  hashRoute?: boolean;
6
6
  pathRoute?: string;
7
7
  placeholderImage?: string;
8
+ displayBranchName?: boolean;
8
9
  onClickItem?: (id: string) => void;
9
10
  }
10
- declare const Grid: ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }: GridProps) => JSX.Element | null;
11
+ declare const Grid: ({ documents, placeholderImage, hashRoute, pathRoute, displayBranchName, onClickItem, }: GridProps) => JSX.Element | null;
11
12
  export default Grid;
@@ -12,8 +12,9 @@ interface Props {
12
12
  price: string;
13
13
  leasingPrice?: string;
14
14
  oldPrice?: string;
15
+ branchName?: string;
15
16
  businessLeasingPrice?: string;
16
17
  onClick?: (id: string) => void;
17
18
  }
18
- declare const ProductCard: ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }: Props) => JSX.Element;
19
+ declare const ProductCard: ({ id, title, href, image, pathRoute, placeholderImage, branchName, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }: Props) => JSX.Element;
19
20
  export default ProductCard;
@@ -6,6 +6,7 @@ export declare const Img: import("styled-components").StyledComponent<"img", imp
6
6
  export declare const Content: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
7
  export declare const ContentBody: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
8
  export declare const ContentFooter: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
+ export declare const PreHeading: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
10
  export declare const Heading: import("styled-components").StyledComponent<"h1", import("styled-components").DefaultTheme, {
10
11
  className: "wayke__theme wayke__font--bold";
11
12
  }, "className">;
@@ -2,5 +2,5 @@
2
2
  import { WaykeSearchProps } from './search/index';
3
3
  import { WaykeSearchItemProps } from './searchItem/index';
4
4
  export declare type WaykeCompositeProps = Omit<WaykeSearchProps & WaykeSearchItemProps, 'id'>;
5
- declare const WaykeComposite: ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, }: WaykeCompositeProps) => JSX.Element;
5
+ declare const WaykeComposite: ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, displayBranchName, }: WaykeCompositeProps) => JSX.Element;
6
6
  export default WaykeComposite;
@@ -9,7 +9,8 @@ export interface WaykeSearchProps {
9
9
  hashRoute?: boolean;
10
10
  pathRoute?: string;
11
11
  modifyDocumentTitleSearch?: string;
12
+ displayBranchName?: boolean;
12
13
  onClickSearchItem?: (id: string) => void;
13
14
  }
14
- declare const WaykeSearch: ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, onClickSearchItem, }: WaykeSearchProps) => JSX.Element;
15
+ declare const WaykeSearch: ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, displayBranchName, onClickSearchItem, }: WaykeSearchProps) => JSX.Element;
15
16
  export default WaykeSearch;
@@ -3,6 +3,7 @@ import { Branch, Maybe } from '../../@types/codegen/types';
3
3
  interface BranchProps {
4
4
  branch?: Maybe<Branch>;
5
5
  loading: boolean;
6
+ displayBranchName?: boolean;
6
7
  }
7
- declare const Branch: ({ branch, loading }: BranchProps) => JSX.Element | null;
8
+ declare const Branch: ({ branch, loading, displayBranchName }: BranchProps) => JSX.Element | null;
8
9
  export default Branch;
@@ -3,7 +3,9 @@ interface RelatedProps {
3
3
  id: string;
4
4
  hashRoute?: boolean;
5
5
  pathRoute?: string;
6
+ authorizedReseller?: boolean;
7
+ displayBranchName?: boolean;
6
8
  onClickSearchItem?: (id: string) => void;
7
9
  }
8
- declare const Related: ({ id, hashRoute, pathRoute, onClickSearchItem }: RelatedProps) => JSX.Element | null;
10
+ declare const Related: ({ id, hashRoute, pathRoute, authorizedReseller, displayBranchName, onClickSearchItem, }: RelatedProps) => JSX.Element | null;
9
11
  export default Related;
@@ -6,7 +6,8 @@ export interface WaykeSearchItemProps {
6
6
  disableResetScrollOnInit?: boolean;
7
7
  placeholderImage?: string;
8
8
  modifyDocumentTitleItem?: boolean;
9
+ displayBranchName?: boolean;
9
10
  onClickSearchItem?: (id: string) => void;
10
11
  }
11
- declare const WaykeSearchItem: ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }: WaykeSearchItemProps) => JSX.Element;
12
+ declare const WaykeSearchItem: ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, displayBranchName, onClickSearchItem, }: WaykeSearchItemProps) => JSX.Element;
12
13
  export default WaykeSearchItem;
@@ -5,7 +5,9 @@ declare const SortOptionDisplayName: {
5
5
  Pricedesc: string;
6
6
  ModelAsc: string;
7
7
  Modeldesc: string;
8
+ MileageAsc: string;
9
+ Mileagedesc: string;
8
10
  };
9
- declare type SortOptionDisplayName = 'relevance' | 'published-asc' | 'published-desc' | 'price-asc' | 'price-desc' | 'model-asc' | 'model-desc';
11
+ declare type SortOptionDisplayName = 'relevance' | 'published-asc' | 'published-desc' | 'price-asc' | 'price-desc' | 'model-asc' | 'model-desc' | 'mileage-asc' | 'mileage-desc';
10
12
  export declare const getTranslatedSortOptionDisplayName: (str: string | SortOptionDisplayName) => string;
11
13
  export {};
package/dist-web/index.js CHANGED
@@ -665,6 +665,8 @@ const SortOptionDisplayName = {
665
665
  Pricedesc: 'price-desc',
666
666
  ModelAsc: 'model-asc',
667
667
  Modeldesc: 'model-desc',
668
+ MileageAsc: 'mileage-asc',
669
+ Mileagedesc: 'mileage-desc',
668
670
  };
669
671
  const getTranslatedSortOptionDisplayName = (str) => {
670
672
  switch (str) {
@@ -680,6 +682,10 @@ const getTranslatedSortOptionDisplayName = (str) => {
680
682
  return 'Årsmodell äldst';
681
683
  case SortOptionDisplayName.Modeldesc:
682
684
  return 'Årsmodell nyast';
685
+ case SortOptionDisplayName.MileageAsc:
686
+ return 'Miltal lägst';
687
+ case SortOptionDisplayName.Mileagedesc:
688
+ return 'Miltal högst';
683
689
  default:
684
690
  return str;
685
691
  }
@@ -1785,6 +1791,11 @@ const ContentFooter = styled.div `
1785
1791
  margin-top: auto;
1786
1792
  padding-top: ${size(1)};
1787
1793
  `;
1794
+ const PreHeading = styled.div `
1795
+ margin-bottom: ${size(0.25)};
1796
+ color: ${(props) => props.theme.color.textDarkLighten};
1797
+ font-size: 0.75rem;
1798
+ `;
1788
1799
  const Heading$2 = styled.h1.attrs(() => ({
1789
1800
  className: 'wayke__theme wayke__font--bold',
1790
1801
  })) `
@@ -1849,7 +1860,7 @@ const OldPrice = styled.div `
1849
1860
  `;
1850
1861
  const Label$3 = styled.label `
1851
1862
  color: ${(props) => props.theme.color.disabledText};
1852
- font-size: 0.875rem;
1863
+ font-size: 0.75rem;
1853
1864
  `;
1854
1865
 
1855
1866
  const Item$5 = styled.li `
@@ -1960,7 +1971,7 @@ const usePath = () => {
1960
1971
  return context;
1961
1972
  };
1962
1973
 
1963
- const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }) => {
1974
+ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, branchName, description, uspList, price, oldPrice, leasingPrice, businessLeasingPrice, onClick, }) => {
1964
1975
  const { pushState } = usePath();
1965
1976
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
1966
1977
  const onHrefClick = useCallback((e) => {
@@ -1981,6 +1992,7 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1981
1992
  React__default.createElement(Img, { src: placeholderImage || DEFAULT_PLACEHOLDER_IMAGE }))))),
1982
1993
  React__default.createElement(Content, null,
1983
1994
  React__default.createElement(ContentBody, null,
1995
+ branchName && React__default.createElement(PreHeading, null, branchName),
1984
1996
  React__default.createElement(Heading$2, null, href ? (React__default.createElement(Link, { onClick: onHrefClick, href: href, title: title, "aria-label": title }, title)) : (title)),
1985
1997
  description && React__default.createElement(Description$1, null, description),
1986
1998
  uspList && (React__default.createElement(Usp, null,
@@ -2005,7 +2017,7 @@ const resolveImage = (document) => {
2005
2017
  }
2006
2018
  return undefined;
2007
2019
  };
2008
- const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }) => {
2020
+ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, displayBranchName, onClickItem, }) => {
2009
2021
  if (!documents) {
2010
2022
  return null;
2011
2023
  }
@@ -2032,7 +2044,7 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
2032
2044
  */
2033
2045
  const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
2034
2046
  return (React__default.createElement(Item$4, { key: document._id },
2035
- React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
2047
+ React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, branchName: displayBranchName ? document.branches?.[0]?.name : undefined, uspList: [
2036
2048
  {
2037
2049
  title: document.modelYear,
2038
2050
  },
@@ -2432,7 +2444,7 @@ PubSub.publish = (eventName, ...args) => {
2432
2444
  }
2433
2445
  };
2434
2446
 
2435
- const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, onClickSearchItem, }) => {
2447
+ const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, removeSearchBar, placeholderImage, removeFilterOptions, modifyDocumentTitleSearch, displayBranchName, onClickSearchItem, }) => {
2436
2448
  const { error, documents, queryFilter, onFilterUpdate, onInitialize } = useSearch();
2437
2449
  useEffect(() => {
2438
2450
  if (modifyDocumentTitleSearch) {
@@ -2470,7 +2482,7 @@ const WaykeSearch = ({ filterList, initialQueryParams, hashRoute, pathRoute, rem
2470
2482
  React__default.createElement(Result, null,
2471
2483
  React__default.createElement(React__default.Fragment, null,
2472
2484
  error && (React__default.createElement(Snackbar, { severity: "error", icon: true, heading: "Ett fel har intr\u00E4ffat" }, "V\u00E4nligen f\u00F6rs\u00F6k igen.")),
2473
- !error && documents && documents.length > 0 && (React__default.createElement(Grid, { hashRoute: hashRoute, pathRoute: pathRoute, onClickItem: onItemClicked, documents: documents, placeholderImage: placeholderImage })),
2485
+ !error && documents && documents.length > 0 && (React__default.createElement(Grid, { hashRoute: hashRoute, pathRoute: pathRoute, onClickItem: onItemClicked, documents: documents, placeholderImage: placeholderImage, displayBranchName: displayBranchName })),
2474
2486
  !error && documents && documents.length === 0 && (React__default.createElement(Snackbar, { severity: "warning", icon: true, heading: "Inga resultat" }, "Det finns inga resultat som matchar din s\u00F6kning."))))))),
2475
2487
  React__default.createElement(PortalElement, { id: DefaultPortal })));
2476
2488
  };
@@ -5343,10 +5355,8 @@ const ManufacturerPackageOption = ({ packageOption }) => {
5343
5355
  React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true })))));
5344
5356
  };
5345
5357
 
5346
- const initialValue = {};
5347
- const getInitialValue = (title) => title && !!initialValue[title];
5348
5358
  const ToggleItem = ({ title, value, type, onClickVisible, onClickValue }) => {
5349
- const [visible, setVisible] = useState(() => getInitialValue(type));
5359
+ const [visible, setVisible] = useState(false);
5350
5360
  const _onClickValue = useCallback(() => {
5351
5361
  if (onClickValue) {
5352
5362
  onClickValue();
@@ -5354,7 +5364,6 @@ const ToggleItem = ({ title, value, type, onClickVisible, onClickValue }) => {
5354
5364
  }, []);
5355
5365
  const onClick = useCallback(() => {
5356
5366
  if (!visible) {
5357
- initialValue[type] = true;
5358
5367
  setVisible(true);
5359
5368
  if (onClickVisible) {
5360
5369
  onClickVisible();
@@ -5888,7 +5897,7 @@ const RelatedSearchContext = createContext({
5888
5897
  fetchRelated: (_) => { },
5889
5898
  });
5890
5899
 
5891
- const useRelatedSearch = (id) => {
5900
+ const useRelatedSearch = (id, authorizedReseller) => {
5892
5901
  const data = useContext(RelatedSearchContext);
5893
5902
  useEffect(() => {
5894
5903
  const searchParams = new URLSearchParams();
@@ -5896,6 +5905,9 @@ const useRelatedSearch = (id) => {
5896
5905
  if (data.moreLikeThisUrl && id) {
5897
5906
  searchParams.set('id', id);
5898
5907
  }
5908
+ if (authorizedReseller) {
5909
+ searchParams.set('isAuthorizedResellerForManufacturer', 'true');
5910
+ }
5899
5911
  data.fetchRelated(searchParams);
5900
5912
  }, [id]);
5901
5913
  return data;
@@ -5911,8 +5923,8 @@ const regexPathGuid = (path) => {
5911
5923
  return r;
5912
5924
  };
5913
5925
 
5914
- const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5915
- const { loading, response, moreLikeThisUrl } = useRelatedSearch(id);
5926
+ const Related = ({ id, hashRoute, pathRoute, authorizedReseller, displayBranchName, onClickSearchItem, }) => {
5927
+ const { loading, response, moreLikeThisUrl } = useRelatedSearch(id, !!authorizedReseller);
5916
5928
  const onItemClicked = useCallback((id) => {
5917
5929
  PubSub.publish('ItemClicked', id);
5918
5930
  if (onClickSearchItem) {
@@ -5943,7 +5955,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5943
5955
  ? window.location.pathname.replace(r, document._id)
5944
5956
  : `${window.location.pathname}${prefix}${document._id}`;
5945
5957
  return (React__default.createElement(OverflowGridItem, { key: document._id },
5946
- React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [
5958
+ React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, branchName: displayBranchName ? document.branches?.[0]?.name : undefined, uspList: [
5947
5959
  {
5948
5960
  title: document.modelYear,
5949
5961
  },
@@ -6174,7 +6186,7 @@ const StaticMap = ({ position }) => {
6174
6186
  React__default.createElement(ButtonContent, null, "Visa karta")))));
6175
6187
  };
6176
6188
 
6177
- const Branch = ({ branch, loading }) => {
6189
+ const Branch = ({ branch, loading, displayBranchName }) => {
6178
6190
  const [modal, setModal] = useState(false);
6179
6191
  const openModal = useCallback(() => setModal(true), []);
6180
6192
  const closeModal = useCallback(() => setModal(false), []);
@@ -6189,9 +6201,11 @@ const Branch = ({ branch, loading }) => {
6189
6201
  return (React__default.createElement(React__default.Fragment, null,
6190
6202
  modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch?.connections, onClose: closeModal })),
6191
6203
  React__default.createElement(Repeat, null,
6192
- React__default.createElement(H2, { noMargin: true }, branch?.location?.city
6193
- ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
6194
- : 'Kontakt')),
6204
+ React__default.createElement(H2, { noMargin: true }, displayBranchName
6205
+ ? `Den här bilen finns på ${branch.name}`
6206
+ : branch?.location?.city
6207
+ ? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
6208
+ : 'Kontakt')),
6195
6209
  React__default.createElement(Repeat, null,
6196
6210
  React__default.createElement(StaticMap, { position: branch?.location?.position })),
6197
6211
  (branch?.connections?.length || 0) > 1 && (React__default.createElement(Repeat, null,
@@ -6259,6 +6273,7 @@ const SEARCH_ITEM_BRANCH_QUERY = gql `
6259
6273
  mrf
6260
6274
  centralStorage
6261
6275
  ecommerce
6276
+ authorizedReseller
6262
6277
  }
6263
6278
  logotype
6264
6279
  openingHours {
@@ -6658,6 +6673,8 @@ const HINTS = Object.freeze({
6658
6673
  finish: '',
6659
6674
  fuelConsumptionCityDriving: 'Bränsleförbrukning vid stadskörning.',
6660
6675
  fuelConsumptionCountryRoadDriving: 'Bränsleförbrukning vid landsvägskörning.',
6676
+ fuelConsumptionMixedDrivingNEDC: 'Bränsleförbrukning vid blandad körning.',
6677
+ fuelConsumptionMixedDrivingWLTP: 'Bränsleförbrukning vid blandad körning.',
6661
6678
  fuelConsumptionMixedDriving: 'Bränsleförbrukning vid blandad körning. Dvs. stadskörning och landsvägskörning under en och samma färd.',
6662
6679
  fuelType: 'Vad bilen ska tankas med och drivs av.',
6663
6680
  gearboxName: '',
@@ -7225,7 +7242,7 @@ const Documents = ({ documents }) => {
7225
7242
  React__default.createElement(DocumentList, { documents: group.documents }))))));
7226
7243
  };
7227
7244
 
7228
- const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
7245
+ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, displayBranchName, onClickSearchItem, }) => {
7229
7246
  const { ecomSettings } = useSettings();
7230
7247
  const ecomContext = useRef();
7231
7248
  const { loading, data: result } = useSearchItem(id);
@@ -7358,13 +7375,12 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
7358
7375
  React__default.createElement(UspList, { items: options }))))),
7359
7376
  React__default.createElement(Documents, { documents: documents }),
7360
7377
  React__default.createElement(ProductPageMainSection, null,
7361
- React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
7378
+ React__default.createElement(Branch, { branch: branch, displayBranchName: displayBranchName, loading: loadingCentralStorageVehicle }),
7362
7379
  ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
7363
7380
  React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
7364
7381
  React__default.createElement(PackageOptions, { packageOptions: packageOptions }),
7365
7382
  React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
7366
- React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
7367
- false ,
7383
+ React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, authorizedReseller: !!branch?.flags?.authorizedReseller, displayBranchName: displayBranchName, onClickSearchItem: onClickSearchItem })),
7368
7384
  React__default.createElement(PortalElement, { id: DefaultPortal }),
7369
7385
  demoCarModal && React__default.createElement(DemoCarModal, { onClose: onToggleDemoCarModal })));
7370
7386
  };
@@ -7727,7 +7743,7 @@ const useHashGuid = () => {
7727
7743
  return id;
7728
7744
  };
7729
7745
 
7730
- const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, }) => {
7746
+ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, removeFilterOptions, disableResetScrollOnInit, placeholderImage, pathRoute, modifyDocumentTitleItem, modifyDocumentTitleSearch, displayBranchName, }) => {
7731
7747
  const hashId = useHashGuid();
7732
7748
  const { id: pathId } = usePath();
7733
7749
  useEffect(() => {
@@ -7741,7 +7757,7 @@ const WaykeComposite = ({ filterList, initialQueryParams, removeSearchBar, remov
7741
7757
  }
7742
7758
  }, [hashId]);
7743
7759
  const id = pathId || hashId;
7744
- return (React__default.createElement(React__default.Fragment, null, id ? (React__default.createElement(WaykeSearchItem, { id: id, hashRoute: !pathRoute, disableResetScrollOnInit: disableResetScrollOnInit, placeholderImage: placeholderImage, pathRoute: pathRoute, modifyDocumentTitleItem: modifyDocumentTitleItem })) : (React__default.createElement(WaykeSearch, { filterList: filterList, initialQueryParams: initialQueryParams, removeSearchBar: removeSearchBar, hashRoute: !pathRoute, placeholderImage: placeholderImage, pathRoute: pathRoute, removeFilterOptions: removeFilterOptions, modifyDocumentTitleSearch: modifyDocumentTitleSearch }))));
7760
+ return (React__default.createElement(React__default.Fragment, null, id ? (React__default.createElement(WaykeSearchItem, { id: id, hashRoute: !pathRoute, disableResetScrollOnInit: disableResetScrollOnInit, placeholderImage: placeholderImage, pathRoute: pathRoute, modifyDocumentTitleItem: modifyDocumentTitleItem, displayBranchName: displayBranchName })) : (React__default.createElement(WaykeSearch, { filterList: filterList, initialQueryParams: initialQueryParams, removeSearchBar: removeSearchBar, hashRoute: !pathRoute, placeholderImage: placeholderImage, pathRoute: pathRoute, removeFilterOptions: removeFilterOptions, modifyDocumentTitleSearch: modifyDocumentTitleSearch, displayBranchName: displayBranchName }))));
7745
7761
  };
7746
7762
 
7747
7763
  const WaykeCompositeWithProvider = ({ provider, composite }) => (React__default.createElement(WaykeProvider, { ...provider },