@wayke-se/components-react 3.0.0-beta.9 → 3.0.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/dist-node/index.js +3204 -1021
- package/dist-node/index.js.map +1 -1
- package/dist-src/State/CentralStorage/useCentralStorage.js +7 -8
- package/dist-src/State/Path/PathProvider.js +1 -1
- package/dist-src/State/RelatedSearch/RelatedSearchProvider.js +1 -1
- package/dist-src/State/Search/SearchProvider.js +7 -10
- package/dist-src/components/ActionList/index.js +2 -3
- package/dist-src/components/Checklist/index.js +1 -1
- package/dist-src/components/ExtendContent/index.js +1 -1
- package/dist-src/components/Filter/index.js +10 -7
- package/dist-src/components/FilterPanel/checkListFacet.js +1 -1
- package/dist-src/components/FilterPanel/colorFacet.js +1 -1
- package/dist-src/components/FilterPanel/index.js +1 -1
- package/dist-src/components/FilterPanel/rangeFacet.js +14 -16
- package/dist-src/components/FinancialOptions/LoanModal.js +27 -29
- package/dist-src/components/FinancialOptions/leasing.js +6 -6
- package/dist-src/components/FinancialOptions/loan.js +5 -6
- package/dist-src/components/Gallery/index.js +11 -16
- package/dist-src/components/Grid/index.js +2 -3
- package/dist-src/components/InputSelect/index.js +1 -1
- package/dist-src/components/InsuranceOptions/InsuranceFree.js +1 -2
- package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +4 -5
- package/dist-src/components/InsuranceOptions/InsuranceModal.js +3 -3
- package/dist-src/components/Lightbox/index.js +1 -1
- package/dist-src/components/OpeningHours/index.js +9 -9
- package/dist-src/components/RangeSlider/SliderWithLabel.js +1 -1
- package/dist-src/components/Result/index.js +7 -6
- package/dist-src/components/Video/EmbededVideo.js +1 -1
- package/dist-src/components/Video/QuickNavEmbeded.js +2 -2
- package/dist-src/components/Video/useThumbnail.js +1 -1
- package/dist-src/components/Video/utils.js +2 -2
- package/dist-src/hooks/useFetch.js +1 -1
- package/dist-src/hooks/useVimeoThumbnail.js +1 -1
- package/dist-src/layouts/searchItem/Branch.js +9 -10
- package/dist-src/layouts/searchItem/BranchModal.js +1 -1
- package/dist-src/layouts/searchItem/CheckList.js +16 -16
- package/dist-src/layouts/searchItem/ManufacturerPackagesOption.js +1 -2
- package/dist-src/layouts/searchItem/PackageOptionModal.js +7 -10
- package/dist-src/layouts/searchItem/PackageOptions.js +11 -14
- package/dist-src/layouts/searchItem/Property.js +4 -6
- package/dist-src/layouts/searchItem/Related.js +3 -4
- package/dist-src/layouts/searchItem/index.js +15 -17
- package/dist-src/utils/phonenumbers.js +1 -1
- package/dist-src/utils/specification.js +9 -13
- package/dist-src/utils/vehicle-properties/property-tree-creator.js +5 -5
- package/dist-types/components/InputSearch/index.d.ts +5 -3
- package/dist-types/components/RangeSlider/handle.d.ts +2 -2
- package/dist-types/components/RangeSlider/track.d.ts +2 -2
- package/dist-web/index.js +206 -233
- package/dist-web/index.js.map +1 -1
- package/package.json +18 -24
package/dist-web/index.js
CHANGED
|
@@ -679,14 +679,15 @@ const getTranslatedSortOptionDisplayName = (str) => {
|
|
|
679
679
|
};
|
|
680
680
|
|
|
681
681
|
const Result = ({ children }) => {
|
|
682
|
-
var _a;
|
|
683
682
|
const { loading, response, documents, queryFilter, onLoadMore, onFilterUpdate } = useSearch();
|
|
684
683
|
const onSortOptionChange = useCallback((e) => onFilterUpdate(e.currentTarget.value), []);
|
|
685
|
-
const numberOfDocuments =
|
|
686
|
-
const numberOfHits =
|
|
687
|
-
const useSkeletons = !!
|
|
688
|
-
const selectedSortOption =
|
|
689
|
-
const sortOptions = response
|
|
684
|
+
const numberOfDocuments = documents?.length || 0;
|
|
685
|
+
const numberOfHits = response?.documentList.numberOfHits || 0;
|
|
686
|
+
const useSkeletons = !!queryFilter?.concatResult;
|
|
687
|
+
const selectedSortOption = response?.documentList.sortOptions.find((x) => x.selected)?.query;
|
|
688
|
+
const sortOptions = response?.documentList.sortOptions
|
|
689
|
+
.filter((x) => x.displayName !== 'relevance')
|
|
690
|
+
.map((so) => ({
|
|
690
691
|
value: so.query,
|
|
691
692
|
displayName: getTranslatedSortOptionDisplayName(so.displayName),
|
|
692
693
|
}));
|
|
@@ -1196,7 +1197,7 @@ const ChecklistItem = ({ label, onClick, active, radio }) => (React__default.cre
|
|
|
1196
1197
|
active && React__default.createElement(ActionIcon, null, radio ? React__default.createElement(IconRadio, { block: true }) : React__default.createElement(IconCheck, { block: true })),
|
|
1197
1198
|
React__default.createElement(ActionLabel, { className: active ? 'wayke__theme wayke__font--bold wayke__color--primary-text' : '' }, label))));
|
|
1198
1199
|
const Checklist = ({ items, radio }) => {
|
|
1199
|
-
if (!
|
|
1200
|
+
if (!items?.length) {
|
|
1200
1201
|
return null;
|
|
1201
1202
|
}
|
|
1202
1203
|
return (React__default.createElement(List$2, null, items.map((item) => (React__default.createElement(ChecklistItem, { key: item.label, label: item.label, onClick: item.onClick, active: item.active, radio: radio })))));
|
|
@@ -1231,7 +1232,7 @@ const ChecklistFacet = ({ facet }) => {
|
|
|
1231
1232
|
.map((f) => ({
|
|
1232
1233
|
label: f.displayName,
|
|
1233
1234
|
onClick: () => onClick(f),
|
|
1234
|
-
active:
|
|
1235
|
+
active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
|
|
1235
1236
|
})) })));
|
|
1236
1237
|
};
|
|
1237
1238
|
|
|
@@ -1369,7 +1370,7 @@ const ColorSelectFacet = ({ facet }) => {
|
|
|
1369
1370
|
.map((f) => ({
|
|
1370
1371
|
label: f.displayName,
|
|
1371
1372
|
onClick: () => onClick(f),
|
|
1372
|
-
active:
|
|
1373
|
+
active: selected?.[f.displayName] !== undefined ? selected[f.displayName] : f.selected,
|
|
1373
1374
|
hex: [getHexColorFromDisplayName(f.displayName)],
|
|
1374
1375
|
})) }));
|
|
1375
1376
|
};
|
|
@@ -1514,9 +1515,9 @@ const RangeSlider = ({ loading, values, domain, steps, unit, formatValues, maxPr
|
|
|
1514
1515
|
|
|
1515
1516
|
const getInitialValues = (domain, facet, searchParams) => {
|
|
1516
1517
|
const facetMin = domain[0]; //parseInt(facet.filters[0].displayName, 10);
|
|
1517
|
-
const _queryMin =
|
|
1518
|
+
const _queryMin = searchParams?.get(`${facet.id}.min`) || null;
|
|
1518
1519
|
const facetMax = domain[domain.length - 1]; //parseInt(facet.filters[facet.filters.length - 1].displayName, 10);
|
|
1519
|
-
const _queryMax =
|
|
1520
|
+
const _queryMax = searchParams?.get(`${facet.id}.max`) || null;
|
|
1520
1521
|
const queryMin = parseInt(_queryMin === null ? `${facetMin}` : _queryMin, 10);
|
|
1521
1522
|
const min = facetMin > queryMin ? facetMin : queryMin;
|
|
1522
1523
|
const queryMax = parseInt(_queryMax === null ? `${facetMax}` : _queryMax, 10);
|
|
@@ -1538,41 +1539,39 @@ const getSteps$1 = (initialAllValues) => {
|
|
|
1538
1539
|
return initialAllValues;
|
|
1539
1540
|
};
|
|
1540
1541
|
const RangeFacet = ({ facet, unit, formatValues }) => {
|
|
1541
|
-
var _a, _b, _c;
|
|
1542
1542
|
const { loading, queryFilter, initialFacets, onFilterUpdate } = useSearch();
|
|
1543
|
-
const initialFacet = initialFacets
|
|
1544
|
-
const maxPrefix =
|
|
1543
|
+
const initialFacet = initialFacets?.find((x) => x.id === facet.id);
|
|
1544
|
+
const maxPrefix = initialFacet?.filters[initialFacet?.filters.length - 1]?.displayName?.includes('+');
|
|
1545
1545
|
const [state, setValues] = useState(undefined);
|
|
1546
1546
|
useEffect(() => {
|
|
1547
|
-
const _initialAllValues =
|
|
1547
|
+
const _initialAllValues = initialFacet?.filters.map((f) => parseInt(f.displayName.replace(/[\<\>+-]+/g, ''), 10)) || [1, 2];
|
|
1548
1548
|
const _steps = getSteps$1(_initialAllValues);
|
|
1549
1549
|
const domain = [_steps[0], _steps[_steps.length - 1]];
|
|
1550
1550
|
setValues({
|
|
1551
|
-
id: initialFacet
|
|
1551
|
+
id: initialFacet?.id,
|
|
1552
1552
|
steps: _steps,
|
|
1553
1553
|
domain: [_steps[0], _steps[_steps.length - 1]],
|
|
1554
|
-
values:
|
|
1554
|
+
values: initialFacet?.filters.length
|
|
1555
1555
|
? getInitialValues(domain, initialFacet, queryFilter.searchParams)
|
|
1556
1556
|
: [0, 0],
|
|
1557
1557
|
});
|
|
1558
|
-
}, [initialFacet
|
|
1558
|
+
}, [initialFacet?.id]);
|
|
1559
1559
|
useEffect(() => {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
const init = (initialFacet === null || initialFacet === void 0 ? void 0 : initialFacet.filters.length)
|
|
1560
|
+
if (state?.id) {
|
|
1561
|
+
const init = initialFacet?.filters.length
|
|
1563
1562
|
? getInitialValues(state.domain, initialFacet, queryFilter.searchParams)
|
|
1564
1563
|
: [0, 0];
|
|
1565
|
-
const minStr =
|
|
1566
|
-
const maxStr =
|
|
1564
|
+
const minStr = queryFilter.searchParams?.get(`${facet.id}.min`);
|
|
1565
|
+
const maxStr = queryFilter.searchParams?.get(`${facet.id}.max`);
|
|
1567
1566
|
const min = minStr ? parseFloat(minStr) : init[0];
|
|
1568
1567
|
const max = maxStr ? parseFloat(maxStr) : init[1];
|
|
1569
1568
|
if (min !== state.values[0] || max !== state.values[1]) {
|
|
1570
1569
|
onChange([min, max]);
|
|
1571
1570
|
}
|
|
1572
1571
|
}
|
|
1573
|
-
}, [
|
|
1572
|
+
}, [queryFilter.searchParams?.toString()]);
|
|
1574
1573
|
const onChange = useCallback((nextValues) => {
|
|
1575
|
-
if (state
|
|
1574
|
+
if (state?.id) {
|
|
1576
1575
|
if (state.values[0] !== nextValues[0] || state.values[1] !== nextValues[1]) {
|
|
1577
1576
|
setValues({ ...state, values: nextValues.slice() });
|
|
1578
1577
|
const query = new URLSearchParams(queryFilter.searchParams);
|
|
@@ -1631,7 +1630,7 @@ const FilterPanel = ({ facet, filteredFacets, numberOfHits, loading, onFilterUpd
|
|
|
1631
1630
|
React__default.createElement(ButtonContent, null, `Visa ${numberOfHits} ${numberOfHits === 1 ? 'bil' : 'bilar'}`))))) },
|
|
1632
1631
|
React__default.createElement(Accordion, null, filteredFacets
|
|
1633
1632
|
.filter((x) => x.filters.length)
|
|
1634
|
-
.map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id ===
|
|
1633
|
+
.map((f) => (React__default.createElement(AccordionItem, { key: f.displayName, heading: f.displayName, isActive: f.id === facet?.id },
|
|
1635
1634
|
React__default.createElement(Repeat, null,
|
|
1636
1635
|
React__default.createElement(FacetSelector, { facet: f }))))))));
|
|
1637
1636
|
};
|
|
@@ -1647,9 +1646,8 @@ const isSelected = (f, searchParams) => {
|
|
|
1647
1646
|
}
|
|
1648
1647
|
};
|
|
1649
1648
|
const Filter = ({ filterList }) => {
|
|
1650
|
-
var _a;
|
|
1651
1649
|
const { queryFilter, initialFacets, loading, response, onFilterUpdate } = useSearch();
|
|
1652
|
-
const facets = response
|
|
1650
|
+
const facets = response?.facets;
|
|
1653
1651
|
const [facet, setFacet] = useState();
|
|
1654
1652
|
const onSelectFacet = useCallback((nextFacet) => setFacet(nextFacet), []);
|
|
1655
1653
|
const onClose = useCallback(() => setFacet(undefined), []);
|
|
@@ -1657,12 +1655,16 @@ const Filter = ({ filterList }) => {
|
|
|
1657
1655
|
return null;
|
|
1658
1656
|
}
|
|
1659
1657
|
const filterNames = filterList ? filterList.map((x) => x.filterName) : undefined;
|
|
1660
|
-
const filteredFacets =
|
|
1658
|
+
const filteredFacets = facets
|
|
1659
|
+
?.filter((x) => x.id !== 'segment')
|
|
1660
|
+
?.filter((f) => (filterNames ? filterNames.includes(f.id) : true))
|
|
1661
|
+
.sort((a, b) => filterNames
|
|
1661
1662
|
? filterNames.indexOf(a.id) -
|
|
1662
1663
|
filterNames.indexOf(b.id)
|
|
1663
|
-
: 0)
|
|
1664
|
-
|
|
1665
|
-
|
|
1664
|
+
: 0)
|
|
1665
|
+
.map((x) => {
|
|
1666
|
+
const match = filterList?.find((y) => y.filterName === x.id);
|
|
1667
|
+
if (match?.displayName) {
|
|
1666
1668
|
return {
|
|
1667
1669
|
...x,
|
|
1668
1670
|
displayName: match.displayName,
|
|
@@ -1674,7 +1676,7 @@ const Filter = ({ filterList }) => {
|
|
|
1674
1676
|
};
|
|
1675
1677
|
});
|
|
1676
1678
|
return (React__default.createElement(React__default.Fragment, null,
|
|
1677
|
-
initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits:
|
|
1679
|
+
initialFacets && facet && (React__default.createElement(FilterPanel, { filterList: filterList, facet: facet, loading: loading, filteredFacets: filteredFacets, numberOfHits: response?.documentList.numberOfHits || 0, onFilterUpdate: onFilterUpdate, onClose: onClose })),
|
|
1678
1680
|
React__default.createElement(List, null, filteredFacets
|
|
1679
1681
|
.filter((x) => x.filters.length)
|
|
1680
1682
|
.map((f) => {
|
|
@@ -1983,8 +1985,7 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
|
|
|
1983
1985
|
};
|
|
1984
1986
|
|
|
1985
1987
|
const resolveImage = (document) => {
|
|
1986
|
-
|
|
1987
|
-
const img = (_c = (_b = (_a = document.featuredImage) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url;
|
|
1988
|
+
const img = document.featuredImage?.files?.[0]?.url;
|
|
1988
1989
|
if (img) {
|
|
1989
1990
|
return `${img}?w=567&q=72`;
|
|
1990
1991
|
}
|
|
@@ -1996,7 +1997,7 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
|
|
|
1996
1997
|
}
|
|
1997
1998
|
return (React__default.createElement(Wrapper$7, null,
|
|
1998
1999
|
React__default.createElement(List$4, null, documents.map((document) => {
|
|
1999
|
-
const _path = pathRoute
|
|
2000
|
+
const _path = pathRoute?.replace(/^\/|\/$/g, '');
|
|
2000
2001
|
const prefix = _path ? `/${_path}/` : '/';
|
|
2001
2002
|
const pathRouteUrl = window.location.pathname === '/'
|
|
2002
2003
|
? `${prefix}${document._id}`
|
|
@@ -2668,7 +2669,7 @@ const ExtendContent = ({ children, actionTitle, onClick }) => {
|
|
|
2668
2669
|
}
|
|
2669
2670
|
}, []);
|
|
2670
2671
|
const onRef = (ref) => {
|
|
2671
|
-
const refHeight =
|
|
2672
|
+
const refHeight = ref?.clientHeight || 0;
|
|
2672
2673
|
if (refHeight < 207) {
|
|
2673
2674
|
setExtend(true);
|
|
2674
2675
|
}
|
|
@@ -3082,7 +3083,7 @@ const getYoutubeThumbnail = (url) => {
|
|
|
3082
3083
|
};
|
|
3083
3084
|
};
|
|
3084
3085
|
const onImageLoad = (e, thumbnail) => {
|
|
3085
|
-
if (
|
|
3086
|
+
if (thumbnail?.length === 2 &&
|
|
3086
3087
|
e.currentTarget.src === thumbnail[0] &&
|
|
3087
3088
|
e.currentTarget.naturalWidth === 120 &&
|
|
3088
3089
|
e.currentTarget.naturalHeight === 90) {
|
|
@@ -3090,7 +3091,7 @@ const onImageLoad = (e, thumbnail) => {
|
|
|
3090
3091
|
}
|
|
3091
3092
|
};
|
|
3092
3093
|
const onImageError = (e, thumbnail) => {
|
|
3093
|
-
if (
|
|
3094
|
+
if (thumbnail?.length === 2) {
|
|
3094
3095
|
e.currentTarget.src = thumbnail[1];
|
|
3095
3096
|
}
|
|
3096
3097
|
};
|
|
@@ -3570,7 +3571,7 @@ const Lightbox = ({ index, media, onClose }) => {
|
|
|
3570
3571
|
onClose();
|
|
3571
3572
|
}
|
|
3572
3573
|
};
|
|
3573
|
-
return (React__default.createElement(Wrapper$h, { ref: (ref) => ref
|
|
3574
|
+
return (React__default.createElement(Wrapper$h, { ref: (ref) => ref?.focus(), onKeyDown: onKeyDown, tabIndex: 0 },
|
|
3574
3575
|
React__default.createElement(UiBlock$1, { onClick: onClose, "aria-hidden": true }),
|
|
3575
3576
|
media.map((m, i) => (React__default.createElement(Item$8, { key: i, ref: index === i ? onRef : undefined },
|
|
3576
3577
|
m.type === 'image' && (React__default.createElement(Img$1, { id: `lightbox-image-${i}`, src: m.files[0].url, alt: `Bild ${i + 1}` })),
|
|
@@ -3582,7 +3583,7 @@ const Lightbox = ({ index, media, onClose }) => {
|
|
|
3582
3583
|
};
|
|
3583
3584
|
|
|
3584
3585
|
const cache = {};
|
|
3585
|
-
const getCachedResult = (key) =>
|
|
3586
|
+
const getCachedResult = (key) => cache?.[key] || undefined;
|
|
3586
3587
|
const setCachedResult = (key, value) => {
|
|
3587
3588
|
cache[key] = value;
|
|
3588
3589
|
};
|
|
@@ -3653,7 +3654,7 @@ const useVimeoThumbnail = (id, small) => {
|
|
|
3653
3654
|
const [thumbnail, setThumbnail] = useState();
|
|
3654
3655
|
const { data } = useFetch(`http://vimeo.com/api/v2/video/${id}.json`, {}, !id || !!thumbnail, true);
|
|
3655
3656
|
useEffect(() => {
|
|
3656
|
-
if (data
|
|
3657
|
+
if (data?.[0]) {
|
|
3657
3658
|
if (small && data[0].thumbnail_small) {
|
|
3658
3659
|
setThumbnail(data[0].thumbnail_small);
|
|
3659
3660
|
}
|
|
@@ -3666,7 +3667,7 @@ const useVimeoThumbnail = (id, small) => {
|
|
|
3666
3667
|
};
|
|
3667
3668
|
|
|
3668
3669
|
const useThumbnail = (url, small) => {
|
|
3669
|
-
if (url
|
|
3670
|
+
if (url?.toLowerCase().endsWith('.mp4'))
|
|
3670
3671
|
return;
|
|
3671
3672
|
const [thumbnail, setThumbnail] = useState();
|
|
3672
3673
|
const vimeoId = url ? getVimeoId(url) : undefined;
|
|
@@ -3825,7 +3826,7 @@ const GalleryEmbed = ({ src, index }) => {
|
|
|
3825
3826
|
const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
|
|
3826
3827
|
const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
|
|
3827
3828
|
const customVideo = src.toLowerCase().endsWith('.mp4');
|
|
3828
|
-
if (
|
|
3829
|
+
if (thumbnail?.length && !customVideo) {
|
|
3829
3830
|
return (React__default.createElement(React__default.Fragment, null,
|
|
3830
3831
|
React__default.createElement(ImageFull, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }),
|
|
3831
3832
|
React__default.createElement(MediaButton, { text: "Spela video", onClick: onClick }),
|
|
@@ -3845,8 +3846,8 @@ const QuickNavEmbeded = ({ src, index }) => {
|
|
|
3845
3846
|
const thumbnail = useThumbnail(src);
|
|
3846
3847
|
const onError = useCallback((e) => onImageError(e, thumbnail), [thumbnail]);
|
|
3847
3848
|
const onLoad = useCallback((e) => onImageLoad(e, thumbnail), [thumbnail]);
|
|
3848
|
-
const customVideo = src
|
|
3849
|
-
if (
|
|
3849
|
+
const customVideo = src?.toLowerCase().endsWith('.mp4');
|
|
3850
|
+
if (thumbnail?.length && !customVideo)
|
|
3850
3851
|
return (React__default.createElement(QuickNavImg, { onLoad: onLoad, src: thumbnail[0], onError: onError, alt: `Bild ${index + 1}` }));
|
|
3851
3852
|
if (customVideo)
|
|
3852
3853
|
return React__default.createElement(CustomPlayer, { key: index, url: src, ratio: "66.66%" });
|
|
@@ -3907,8 +3908,7 @@ const Gallery = ({ media, placeholderImage }) => {
|
|
|
3907
3908
|
const [lightbox, setLightbox] = useState(false);
|
|
3908
3909
|
const [navigationDisabled, setNavigationDisabled] = useState(false);
|
|
3909
3910
|
const beforeChange = useCallback((_, newIndex) => {
|
|
3910
|
-
|
|
3911
|
-
const element = (_b = (_a = quickNavRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('li')) === null || _b === void 0 ? void 0 : _b[newIndex];
|
|
3911
|
+
const element = quickNavRef.current?.querySelectorAll('li')?.[newIndex];
|
|
3912
3912
|
if (element) {
|
|
3913
3913
|
scrollIntoView(element, { scrollMode: 'if-needed', block: 'nearest', inline: 'nearest' });
|
|
3914
3914
|
}
|
|
@@ -3926,7 +3926,7 @@ const Gallery = ({ media, placeholderImage }) => {
|
|
|
3926
3926
|
}, []);
|
|
3927
3927
|
const onClick = useCallback(() => {
|
|
3928
3928
|
PubSub.publish('ImagesClick');
|
|
3929
|
-
if (!isDragging.current && !lightbox && !!
|
|
3929
|
+
if (!isDragging.current && !lightbox && !!media?.length) {
|
|
3930
3930
|
setLightbox(true);
|
|
3931
3931
|
}
|
|
3932
3932
|
}, [lightbox, media]);
|
|
@@ -3961,20 +3961,17 @@ const Gallery = ({ media, placeholderImage }) => {
|
|
|
3961
3961
|
setNavigationDisabled(false);
|
|
3962
3962
|
};
|
|
3963
3963
|
const onToggleLightbox = useCallback(() => setLightbox(!lightbox), [lightbox]);
|
|
3964
|
-
const mediaLength =
|
|
3964
|
+
const mediaLength = media?.length || 0;
|
|
3965
3965
|
const placeholder = useMemo(() => placeholderImage || DEFAULT_PLACEHOLDER_IMAGE, [placeholderImage]);
|
|
3966
3966
|
return (React__default.createElement(React__default.Fragment, null,
|
|
3967
3967
|
React__default.createElement(Wrapper$g, null,
|
|
3968
3968
|
React__default.createElement(Main, null,
|
|
3969
3969
|
React__default.createElement(SliderWrapper, { onMouseDown: onMouseDown, onMouseMove: onMouseMove, onClick: onClick },
|
|
3970
|
-
React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
|
|
3976
|
-
m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled }))));
|
|
3977
|
-
})) : (React__default.createElement(Item$7, { key: placeholder },
|
|
3970
|
+
React__default.createElement(Slider$2, { ...sliderSettings, swipe: !navigationDisabled, touchMove: !navigationDisabled, swipeToSlide: !navigationDisabled, ref: slider, beforeChange: beforeChange }, !!media?.length ? (media.map((m, i) => (React__default.createElement(Item$7, { key: m.files[0].url || i },
|
|
3971
|
+
m.type === 'image' && (React__default.createElement(Image$1, { src: m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')?.url, alt: `Bild ${i + 1}` })),
|
|
3972
|
+
m.type === 'threesixty' && (React__default.createElement(ThreeSixty, { urls: m.files.map((x) => x.url), visible: i === index, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })),
|
|
3973
|
+
m.type === 'embedded' && React__default.createElement(GalleryEmbed, { src: m.files[0].url, index: i + 1 }),
|
|
3974
|
+
m.type === 'sphere' && (React__default.createElement(Sphere, { visible: i === index, url: m.files[0].url, preview: m.files[0].url, onDisableNavigation: onDisableNavigation, navigationDisabled: navigationDisabled })))))) : (React__default.createElement(Item$7, { key: placeholder },
|
|
3978
3975
|
React__default.createElement(Image$1, { src: placeholder, alt: `Bild 1` })))),
|
|
3979
3976
|
navigationDisabled && mediaLength > 1 && (React__default.createElement(EnableNavigationButton, null,
|
|
3980
3977
|
React__default.createElement(ButtonSecondary, { onClick: onEnableNavigation, title: "St\u00E4ng" },
|
|
@@ -3985,9 +3982,8 @@ const Gallery = ({ media, placeholderImage }) => {
|
|
|
3985
3982
|
React__default.createElement(ArrowRight, { onClick: nextImage, title: "N\u00E4sta bild" },
|
|
3986
3983
|
React__default.createElement(IconChevronRight, { block: true }))))),
|
|
3987
3984
|
React__default.createElement(Alt, null,
|
|
3988
|
-
React__default.createElement(QuickNav, { ref: quickNavRef }, !!
|
|
3989
|
-
|
|
3990
|
-
const src = ((_a = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')) === null || _a === void 0 ? void 0 : _a.url) ||
|
|
3985
|
+
React__default.createElement(QuickNav, { ref: quickNavRef }, !!media?.length ? (media.map((m, i) => {
|
|
3986
|
+
const src = m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')?.url ||
|
|
3991
3987
|
m.files[0].url;
|
|
3992
3988
|
return (React__default.createElement(QuickNavItem, { key: src || i, active: index === i },
|
|
3993
3989
|
React__default.createElement(QuickNavBtn, { onClick: () => goTo(i), title: `Gå till bild ${i + 1}` },
|
|
@@ -3998,7 +3994,7 @@ const Gallery = ({ media, placeholderImage }) => {
|
|
|
3998
3994
|
})) : (React__default.createElement(QuickNavItem, { key: placeholder, active: true },
|
|
3999
3995
|
React__default.createElement(QuickNavBtn, { onClick: () => goTo(0), title: `Gå till bild 0` },
|
|
4000
3996
|
React__default.createElement(QuickNavImg, { src: placeholder, alt: `Bild 1` }))))))),
|
|
4001
|
-
lightbox && !!
|
|
3997
|
+
lightbox && !!media?.length && (React__default.createElement(Lightbox, { media: media, index: index, onClose: onToggleLightbox }))));
|
|
4002
3998
|
};
|
|
4003
3999
|
|
|
4004
4000
|
const ProductPage = styled.div `
|
|
@@ -4418,11 +4414,11 @@ const Leasing = ({ financialOption }) => {
|
|
|
4418
4414
|
},
|
|
4419
4415
|
{
|
|
4420
4416
|
label: 'Bindningstid',
|
|
4421
|
-
value: `${duration
|
|
4417
|
+
value: `${duration?.current} månader`,
|
|
4422
4418
|
},
|
|
4423
4419
|
{
|
|
4424
4420
|
label: 'Årlig körsträcka',
|
|
4425
|
-
value: `${numberSeparator(
|
|
4421
|
+
value: `${numberSeparator(mileage?.current || 0)} mil/år`,
|
|
4426
4422
|
},
|
|
4427
4423
|
] }))))),
|
|
4428
4424
|
React__default.createElement(OptionBox, null,
|
|
@@ -4431,14 +4427,14 @@ const Leasing = ({ financialOption }) => {
|
|
|
4431
4427
|
React__default.createElement("p", null,
|
|
4432
4428
|
"Privatleasing",
|
|
4433
4429
|
' ',
|
|
4434
|
-
|
|
4430
|
+
mileage?.current && duration?.current && (React__default.createElement(React__default.Fragment, null,
|
|
4435
4431
|
React__default.createElement(UtilityTextPrimary, null,
|
|
4436
|
-
numberSeparator(mileage
|
|
4432
|
+
numberSeparator(mileage?.current),
|
|
4437
4433
|
" mil/\u00E5r"),
|
|
4438
4434
|
' ',
|
|
4439
4435
|
"i ",
|
|
4440
|
-
React__default.createElement(UtilityTextPrimary, null,
|
|
4441
|
-
duration
|
|
4436
|
+
React__default.createElement(UtilityTextPrimary, null,
|
|
4437
|
+
duration?.current,
|
|
4442
4438
|
" m\u00E5n"),
|
|
4443
4439
|
".",
|
|
4444
4440
|
' '))),
|
|
@@ -4569,7 +4565,7 @@ const SliderWithLabel = ({ label, values, domain, steps, loading, unit, formatVa
|
|
|
4569
4565
|
}, [loading]);
|
|
4570
4566
|
return (React__default.createElement(React__default.Fragment, null,
|
|
4571
4567
|
React__default.createElement(RepeatTiny, null,
|
|
4572
|
-
React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator(
|
|
4568
|
+
React__default.createElement(RangeSliderLabel, { label: label, value: `${numberSeparator(local?.[0] || values[0])}${unit ? ` ${unit}` : ''}` })),
|
|
4573
4569
|
React__default.createElement(RepeatTiny, null,
|
|
4574
4570
|
React__default.createElement(RangeSliderSimple, { loading: loading, values: values, domain: domain, steps: steps, onChange: onChange, onUpdate: onUpdate, unit: unit, formatValues: formatValues }))));
|
|
4575
4571
|
};
|
|
@@ -4585,7 +4581,6 @@ const stepGenerator = (step, max, steps = [], current) => {
|
|
|
4585
4581
|
return stepGenerator(step, max, steps, nextCurrent);
|
|
4586
4582
|
};
|
|
4587
4583
|
const LoanModal = ({ id, financialOption, onClose }) => {
|
|
4588
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
4589
4584
|
const [tmp, setTmp] = useState();
|
|
4590
4585
|
const [extend, setExtend] = React__default.useState(false);
|
|
4591
4586
|
const onToggleExtend = React__default.useCallback(() => {
|
|
@@ -4595,60 +4590,59 @@ const LoanModal = ({ id, financialOption, onClose }) => {
|
|
|
4595
4590
|
setExtend(!extend);
|
|
4596
4591
|
}, [extend]);
|
|
4597
4592
|
const [variables, setVariables] = useState({
|
|
4598
|
-
duration:
|
|
4599
|
-
downPayment:
|
|
4600
|
-
residual:
|
|
4593
|
+
duration: financialOption.duration?.current,
|
|
4594
|
+
downPayment: financialOption.downPayment?.current,
|
|
4595
|
+
residual: financialOption.residual?.current,
|
|
4601
4596
|
});
|
|
4602
4597
|
const { duration, downPayment, residual } = variables;
|
|
4603
4598
|
const { loading, data } = useLoanCalculation(id, duration, downPayment, residual);
|
|
4604
4599
|
useEffect(() => {
|
|
4605
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4606
4600
|
if (data) {
|
|
4607
4601
|
setTmp(data);
|
|
4608
4602
|
setVariables({
|
|
4609
|
-
duration:
|
|
4610
|
-
downPayment:
|
|
4611
|
-
residual:
|
|
4603
|
+
duration: data?.loan?.duration?.current || 0,
|
|
4604
|
+
downPayment: data?.loan?.downPayment?.current || 0,
|
|
4605
|
+
residual: data?.loan?.residual?.current || 0,
|
|
4612
4606
|
});
|
|
4613
4607
|
}
|
|
4614
4608
|
}, [data]);
|
|
4615
|
-
const loan =
|
|
4616
|
-
const downPaymentCurrent =
|
|
4617
|
-
const downPaymentMin =
|
|
4618
|
-
const downPaymentMax =
|
|
4619
|
-
const downPaymentStep =
|
|
4609
|
+
const loan = data?.loan || tmp?.loan;
|
|
4610
|
+
const downPaymentCurrent = loan?.downPayment?.current || 0;
|
|
4611
|
+
const downPaymentMin = loan?.downPayment?.min || 0;
|
|
4612
|
+
const downPaymentMax = loan?.downPayment?.max || 0;
|
|
4613
|
+
const downPaymentStep = loan?.downPayment?.step || 0;
|
|
4620
4614
|
const downPaymentSteps = stepGenerator(downPaymentStep, downPaymentMax);
|
|
4621
4615
|
const onDownPaymentChange = useCallback((values) => {
|
|
4622
4616
|
PubSub.publish('FinanceInterest');
|
|
4623
4617
|
setVariables({ ...variables, downPayment: values[0] });
|
|
4624
4618
|
}, [variables]);
|
|
4625
|
-
const durationCurrent =
|
|
4626
|
-
const durationMin =
|
|
4627
|
-
const durationMax =
|
|
4628
|
-
const durationStep =
|
|
4619
|
+
const durationCurrent = loan?.duration?.current || 0;
|
|
4620
|
+
const durationMin = loan?.duration?.min || 0;
|
|
4621
|
+
const durationMax = loan?.duration?.max || 0;
|
|
4622
|
+
const durationStep = loan?.duration?.step || 0;
|
|
4629
4623
|
const durationSteps = stepGenerator(durationStep, durationMax);
|
|
4630
4624
|
const onDurationChange = useCallback((values) => {
|
|
4631
4625
|
PubSub.publish('FinanceInterest');
|
|
4632
4626
|
setVariables({ ...variables, duration: values[0] });
|
|
4633
4627
|
}, [variables]);
|
|
4634
|
-
const residualCurrent = (
|
|
4635
|
-
const residualMin = (
|
|
4636
|
-
const residualMax = (
|
|
4637
|
-
const residualStep = (
|
|
4628
|
+
const residualCurrent = (loan?.residual?.current || 0) * 100 || 0;
|
|
4629
|
+
const residualMin = (loan?.residual?.min || 0) * 100 || 0;
|
|
4630
|
+
const residualMax = (loan?.residual?.max || 0) * 100 || 0;
|
|
4631
|
+
const residualStep = (loan?.residual?.step || 0) * 100 || 0;
|
|
4638
4632
|
const residualSteps = stepGenerator(residualStep, residualMax);
|
|
4639
4633
|
const onResidualChange = useCallback((values) => {
|
|
4640
4634
|
PubSub.publish('FinanceInterest');
|
|
4641
4635
|
setVariables({ ...variables, residual: values[0] / 100 });
|
|
4642
4636
|
}, [variables]);
|
|
4643
|
-
const interestText = ((
|
|
4644
|
-
const effectiveInterestText = ((
|
|
4637
|
+
const interestText = ((loan?.interest || 0) * 100).toFixed(2);
|
|
4638
|
+
const effectiveInterestText = ((loan?.effectiveInterest || 0) * 100).toFixed(2);
|
|
4645
4639
|
return (React__default.createElement(Modal, { title: "L\u00E5nealternativ", onClose: onClose },
|
|
4646
4640
|
React__default.createElement(Repeat, null,
|
|
4647
4641
|
React__default.createElement(ContentLogo, null,
|
|
4648
|
-
|
|
4642
|
+
financialOption?.description && (React__default.createElement(ContentLogoText, null,
|
|
4649
4643
|
React__default.createElement(Content$2, null,
|
|
4650
4644
|
React__default.createElement("p", null, financialOption.description)))),
|
|
4651
|
-
|
|
4645
|
+
financialOption?.image && (React__default.createElement(ContentLogoMedia, null,
|
|
4652
4646
|
React__default.createElement(LogoBox, { logo: financialOption.image, alt: financialOption.name || 'Logotyp', wide: true }))))),
|
|
4653
4647
|
React__default.createElement(Repeat, null,
|
|
4654
4648
|
React__default.createElement(RepeatSmall, null,
|
|
@@ -4660,7 +4654,7 @@ const LoanModal = ({ id, financialOption, onClose }) => {
|
|
|
4660
4654
|
React__default.createElement(RepeatSmall, null,
|
|
4661
4655
|
React__default.createElement(RepeatTiny, null,
|
|
4662
4656
|
React__default.createElement(Content$2, { small: true },
|
|
4663
|
-
React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${
|
|
4657
|
+
React__default.createElement("p", null, `*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${loan?.mileage !== null ? `och en årlig körsträcka om ${loan?.mileage} mil.` : ''}`)))),
|
|
4664
4658
|
React__default.createElement(RepeatSmall, null,
|
|
4665
4659
|
React__default.createElement(ButtonClear, { onClick: onToggleExtend, title: extend ? 'Visa mindre information' : 'Visa mer information' },
|
|
4666
4660
|
React__default.createElement(ButtonContent, null, extend ? 'Mindre information' : 'Mer information'))),
|
|
@@ -4677,28 +4671,27 @@ const LoanModal = ({ id, financialOption, onClose }) => {
|
|
|
4677
4671
|
},
|
|
4678
4672
|
{
|
|
4679
4673
|
label: 'Uppläggningskostnad',
|
|
4680
|
-
value: `${numberSeparator(
|
|
4674
|
+
value: `${numberSeparator(financialOption?.setupFee || 0)} kr`,
|
|
4681
4675
|
},
|
|
4682
4676
|
{
|
|
4683
4677
|
label: 'Administrativa avgifter',
|
|
4684
|
-
value: `${numberSeparator(
|
|
4678
|
+
value: `${numberSeparator(financialOption?.administrationFee || 0)} kr/mån`,
|
|
4685
4679
|
},
|
|
4686
4680
|
{
|
|
4687
4681
|
label: 'Total kreditkostnad',
|
|
4688
|
-
value: `${numberSeparator(
|
|
4682
|
+
value: `${numberSeparator(loan?.totalCreditCost || 0)} kr`,
|
|
4689
4683
|
},
|
|
4690
4684
|
] }))))))));
|
|
4691
4685
|
};
|
|
4692
4686
|
|
|
4693
4687
|
const Loan = ({ id, financialOption }) => {
|
|
4694
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4695
4688
|
const [modal, setModal] = useState(false);
|
|
4696
4689
|
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
4697
|
-
const { data } = useLoanCalculation(id,
|
|
4698
|
-
const interest =
|
|
4699
|
-
const duration =
|
|
4700
|
-
const monthlyCost =
|
|
4701
|
-
const logo =
|
|
4690
|
+
const { data } = useLoanCalculation(id, financialOption.duration?.current, financialOption.downPayment?.current, financialOption.residual?.current);
|
|
4691
|
+
const interest = data?.loan?.interest;
|
|
4692
|
+
const duration = data?.loan?.duration?.current;
|
|
4693
|
+
const monthlyCost = data?.loan?.monthlyCost;
|
|
4694
|
+
const logo = financialOption?.logotype || 'https://placehold.it/67x10';
|
|
4702
4695
|
// Skeleton?
|
|
4703
4696
|
if (financialOption.loanAmount === undefined ||
|
|
4704
4697
|
financialOption.loanAmount === null ||
|
|
@@ -5044,7 +5037,7 @@ const Icon$4 = styled.div `
|
|
|
5044
5037
|
`;
|
|
5045
5038
|
|
|
5046
5039
|
const InputSelect = ({ value, options, onChange, unit, title }) => (React__default.createElement(Wrapper$s, null,
|
|
5047
|
-
React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options
|
|
5040
|
+
React__default.createElement(Select$1, { value: value, onChange: onChange, title: title, "aria-label": title }, options?.map((option) => (React__default.createElement(Option$1, { key: option.value, value: option.value },
|
|
5048
5041
|
option.displayName || option.value,
|
|
5049
5042
|
unit ? ` ${unit}` : '')))),
|
|
5050
5043
|
React__default.createElement(Icon$4, null,
|
|
@@ -5159,7 +5152,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
|
|
|
5159
5152
|
drivingDistance: DrivingDistance.Between0And1000,
|
|
5160
5153
|
});
|
|
5161
5154
|
const [payload, setPayload] = useState();
|
|
5162
|
-
const { loading, data, error } = useInsuranceCalculation(id,
|
|
5155
|
+
const { loading, data, error } = useInsuranceCalculation(id, branch?.id ? branch?.id : undefined, ssnIsValid(payload?.ssn) ? payload?.ssn : undefined, payload?.drivingDistance);
|
|
5163
5156
|
const onChangeSsn = useCallback((e) => setForm({ ...form, ssn: e.currentTarget.value }), [form]);
|
|
5164
5157
|
const onChangeDrivingDistance = useCallback((e) => setForm({ ...form, drivingDistance: e.currentTarget.value }), [form]);
|
|
5165
5158
|
const onShowInsurances = useCallback(() => {
|
|
@@ -5179,7 +5172,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
|
|
|
5179
5172
|
{ value: DrivingDistance.Over2500, displayName: '2500+' },
|
|
5180
5173
|
];
|
|
5181
5174
|
return (React__default.createElement(Modal, { title: "F\u00F6rs\u00E4kring", onClose: onClose },
|
|
5182
|
-
(
|
|
5175
|
+
(insuranceOptions?.description || insuranceOptions?.logotype) && (React__default.createElement(Repeat, null,
|
|
5183
5176
|
React__default.createElement(ContentLogo, null,
|
|
5184
5177
|
insuranceOptions.description && (React__default.createElement(ContentLogoText, null,
|
|
5185
5178
|
React__default.createElement(Content$2, null,
|
|
@@ -5207,7 +5200,7 @@ const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
|
|
|
5207
5200
|
React__default.createElement(Loader, null))),
|
|
5208
5201
|
error && (React__default.createElement(Repeat, null,
|
|
5209
5202
|
React__default.createElement(Snackbar, { severity: "error", icon: true, heading: "Ett fel har intr\u00E4ffat" }, "Kunde inte h\u00E4mta f\u00F6rs\u00E4kringar. V\u00E4nligen f\u00F6rs\u00F6k igen."))),
|
|
5210
|
-
React__default.createElement(React__default.Fragment, null,
|
|
5203
|
+
React__default.createElement(React__default.Fragment, null, data?.insurances && (React__default.createElement(Repeat, null, data?.insurances.map((insurance) => (React__default.createElement(Repeat, { key: insurance.name },
|
|
5211
5204
|
React__default.createElement(DetailBox, { heading: `${numberSeparator(insurance.price)} ${insurance.unit}`, description: insurance.name },
|
|
5212
5205
|
React__default.createElement(Repeat, null,
|
|
5213
5206
|
React__default.createElement(React__default.Fragment, null, insurance.description && (React__default.createElement(RepeatTiny, null,
|
|
@@ -5253,20 +5246,18 @@ const Insurance = ({ id, branch, insuranceOptions }) => {
|
|
|
5253
5246
|
};
|
|
5254
5247
|
|
|
5255
5248
|
const InsuranceFreeModal = ({ onClose, insuranceOptions }) => {
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && (React__default.createElement(Repeat, null,
|
|
5249
|
+
return (React__default.createElement(Modal, { title: insuranceOptions?.insuranceHeader ?? 'Försäkring', onClose: onClose },
|
|
5250
|
+
insuranceOptions?.longDescription && (React__default.createElement(Repeat, null,
|
|
5259
5251
|
React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
|
|
5260
5252
|
__html: marked(insuranceOptions.longDescription),
|
|
5261
5253
|
} }))),
|
|
5262
|
-
|
|
5254
|
+
insuranceOptions?.url && (React__default.createElement(Repeat, null,
|
|
5263
5255
|
React__default.createElement(ButtonInline, { as: "a", href: insuranceOptions.url, target: "_blank", rel: "noopener noreferrer" }, "L\u00E4s mer om f\u00F6rs\u00E4kringen (\u00D6ppnas i ett nytt f\u00F6nster)"))),
|
|
5264
|
-
|
|
5256
|
+
insuranceOptions?.logotype && (React__default.createElement(Repeat, null,
|
|
5265
5257
|
React__default.createElement(LogoBox, { logo: insuranceOptions.logotype, alt: insuranceOptions.name || 'Logotyp', wide: true })))));
|
|
5266
5258
|
};
|
|
5267
5259
|
|
|
5268
5260
|
const Insurance$1 = ({ insuranceOptions }) => {
|
|
5269
|
-
var _a, _b;
|
|
5270
5261
|
const [modal, setModal] = useState(false);
|
|
5271
5262
|
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
5272
5263
|
if (!insuranceOptions.length) {
|
|
@@ -5276,7 +5267,7 @@ const Insurance$1 = ({ insuranceOptions }) => {
|
|
|
5276
5267
|
modal && React__default.createElement(InsuranceFreeModal, { onClose: toggleModal, insuranceOptions: insuranceOptions[0] }),
|
|
5277
5268
|
React__default.createElement(Repeat, null,
|
|
5278
5269
|
React__default.createElement(RepeatTiny, null,
|
|
5279
|
-
React__default.createElement(VisualHeading, null,
|
|
5270
|
+
React__default.createElement(VisualHeading, null, insuranceOptions[0]?.insuranceHeader ?? 'Försäkring')),
|
|
5280
5271
|
React__default.createElement(RepeatTiny, null,
|
|
5281
5272
|
React__default.createElement(React__default.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React__default.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
|
|
5282
5273
|
insuranceOption.description && (React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
|
|
@@ -5300,7 +5291,6 @@ const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
|
|
|
5300
5291
|
};
|
|
5301
5292
|
|
|
5302
5293
|
const ManufacturerPackageOption = ({ packageOption }) => {
|
|
5303
|
-
var _a;
|
|
5304
5294
|
if (!packageOption) {
|
|
5305
5295
|
return null;
|
|
5306
5296
|
}
|
|
@@ -5309,7 +5299,7 @@ const ManufacturerPackageOption = ({ packageOption }) => {
|
|
|
5309
5299
|
React__default.createElement(H2, { noMargin: true }, packageOption.title)),
|
|
5310
5300
|
packageOption.description && (React__default.createElement(Repeat, null,
|
|
5311
5301
|
React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
|
|
5312
|
-
|
|
5302
|
+
packageOption.link?.url && (React__default.createElement(Repeat, null,
|
|
5313
5303
|
React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
|
|
5314
5304
|
? packageOption.link.title
|
|
5315
5305
|
: 'Läs mer (Öppnas i ett nytt fönster)'))),
|
|
@@ -5431,7 +5421,7 @@ const typedMetadata = Metadata;
|
|
|
5431
5421
|
const formatPhonenumber = (text) => {
|
|
5432
5422
|
try {
|
|
5433
5423
|
const parsed = parsePhoneNumberFromString(text.replace('-', '').replace(/ /g, ''), typedMetadata);
|
|
5434
|
-
return
|
|
5424
|
+
return parsed?.formatNational() || text;
|
|
5435
5425
|
}
|
|
5436
5426
|
catch (e) {
|
|
5437
5427
|
return text;
|
|
@@ -5439,9 +5429,8 @@ const formatPhonenumber = (text) => {
|
|
|
5439
5429
|
};
|
|
5440
5430
|
|
|
5441
5431
|
const ActionList = ({ contact, branch }) => {
|
|
5442
|
-
|
|
5443
|
-
const
|
|
5444
|
-
const phonenumber = (contact === null || contact === void 0 ? void 0 : contact.phonenumber) || ((_b = branch === null || branch === void 0 ? void 0 : branch.contact) === null || _b === void 0 ? void 0 : _b.phonenumber);
|
|
5432
|
+
const email = contact?.email || branch?.contact?.email;
|
|
5433
|
+
const phonenumber = contact?.phonenumber || branch?.contact?.phonenumber;
|
|
5445
5434
|
const onClickMailVisible = useCallback(() => PubSub.publish('MailVisible'), []);
|
|
5446
5435
|
const onClickPhoneVisible = useCallback(() => PubSub.publish('PhonenumberVisible'), []);
|
|
5447
5436
|
const onClickPhoneValue = useCallback(() => PubSub.publish('PhonenumberCall'), []);
|
|
@@ -5594,7 +5583,7 @@ const BranchModal = ({ loading, connections, onClose }) => {
|
|
|
5594
5583
|
React__default.createElement("p", null, "V\u00E4lj den anl\u00E4ggning du vill visa kontaktuppgifter f\u00F6r."))),
|
|
5595
5584
|
React__default.createElement(RepeatTiny, null,
|
|
5596
5585
|
React__default.createElement(InputLabel, null, "V\u00E4lj anl\u00E4ggning"),
|
|
5597
|
-
React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections
|
|
5586
|
+
React__default.createElement(InputSelect, { value: localValue, onChange: onChange, options: connections?.map((x) => ({
|
|
5598
5587
|
value: x.id,
|
|
5599
5588
|
displayName: x.name,
|
|
5600
5589
|
})), title: "V\u00E4lj anl\u00E4ggning" }))),
|
|
@@ -5603,16 +5592,13 @@ const BranchModal = ({ loading, connections, onClose }) => {
|
|
|
5603
5592
|
React__default.createElement(ButtonContent, null, "V\u00E4lj")))));
|
|
5604
5593
|
};
|
|
5605
5594
|
|
|
5606
|
-
const PackageOptionModal = ({ packageOption, onClose }) => {
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
((_a = packageOption.link) === null || _a === void 0 ? void 0 : _a.href) && packageOption.link.title && (React__default.createElement(Repeat, null,
|
|
5614
|
-
React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
|
|
5615
|
-
};
|
|
5595
|
+
const PackageOptionModal = ({ packageOption, onClose }) => (React__default.createElement(Modal, { title: packageOption.title || '', onClose: onClose },
|
|
5596
|
+
packageOption.image && (React__default.createElement(Repeat, null,
|
|
5597
|
+
React__default.createElement(LogoBox, { logo: packageOption.image, alt: packageOption.title || undefined, wide: true }))),
|
|
5598
|
+
packageOption.description && (React__default.createElement(Repeat, null,
|
|
5599
|
+
React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
|
|
5600
|
+
packageOption.link?.href && packageOption.link.title && (React__default.createElement(Repeat, null,
|
|
5601
|
+
React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.href, target: "_blank", rel: "noopener noreferrer nofollow" }, packageOption.link.title)))));
|
|
5616
5602
|
|
|
5617
5603
|
const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, toggleEcomModal, loadingCentralStorageVehicle, }) => {
|
|
5618
5604
|
const [modalBranch, setModalBranch] = useState(false);
|
|
@@ -5626,45 +5612,45 @@ const CheckList = ({ manufacturer, packageOptions, ecommerce, branch, contact, t
|
|
|
5626
5612
|
setModalBranch(false);
|
|
5627
5613
|
}
|
|
5628
5614
|
}, [branch, contact]);
|
|
5629
|
-
const packageOption = manufacturer
|
|
5615
|
+
const packageOption = manufacturer?.packageOption;
|
|
5630
5616
|
return (React__default.createElement(React__default.Fragment, null,
|
|
5631
|
-
modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch
|
|
5617
|
+
modalBranch && (React__default.createElement(BranchModal, { loading: loadingCentralStorageVehicle, connections: branch?.connections, onClose: closeModalBranch })),
|
|
5632
5618
|
modal && React__default.createElement(PackageOptionModal, { packageOption: modal, onClose: onClose }),
|
|
5633
5619
|
React__default.createElement(Repeat, null,
|
|
5634
5620
|
React__default.createElement(CheckMarkList, null,
|
|
5635
|
-
|
|
5621
|
+
packageOption?.title && (React__default.createElement(CheckMarkListItem, null,
|
|
5636
5622
|
React__default.createElement(React__default.Fragment, null,
|
|
5637
5623
|
"Inkl.",
|
|
5638
5624
|
' ',
|
|
5639
5625
|
React__default.createElement(ButtonInline, { onClick: () => onOpen({
|
|
5640
|
-
title: packageOption
|
|
5641
|
-
image: packageOption
|
|
5642
|
-
description: packageOption
|
|
5643
|
-
link: packageOption
|
|
5626
|
+
title: packageOption?.title,
|
|
5627
|
+
image: packageOption?.image,
|
|
5628
|
+
description: packageOption?.description,
|
|
5629
|
+
link: packageOption?.link,
|
|
5644
5630
|
}) }, packageOption.title),
|
|
5645
5631
|
' ',
|
|
5646
|
-
"begagnatgaranti"))),
|
|
5647
|
-
packageOptions
|
|
5632
|
+
"begagnatgaranti"))),
|
|
5633
|
+
packageOptions?.map((packageOption, index) => (React__default.createElement(CheckMarkListItem, { key: packageOption.title || index },
|
|
5648
5634
|
React__default.createElement(React__default.Fragment, null,
|
|
5649
5635
|
"Inkl.",
|
|
5650
5636
|
' ',
|
|
5651
5637
|
React__default.createElement(ButtonInline, { onClick: () => onOpen({
|
|
5652
|
-
title: packageOption
|
|
5653
|
-
image: packageOption
|
|
5654
|
-
description: packageOption
|
|
5655
|
-
link: packageOption
|
|
5638
|
+
title: packageOption?.title,
|
|
5639
|
+
image: packageOption?.image,
|
|
5640
|
+
description: packageOption?.description,
|
|
5641
|
+
link: packageOption?.link,
|
|
5656
5642
|
}) }, packageOption.title))))),
|
|
5657
|
-
|
|
5643
|
+
ecommerce?.withHomeDelivery && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))),
|
|
5658
5644
|
React__default.createElement(Repeat, null,
|
|
5659
5645
|
ecommerce && ecommerce.enabled && (React__default.createElement(RepeatTiny, null,
|
|
5660
5646
|
React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, fullWidth: true, onClick: toggleEcomModal },
|
|
5661
5647
|
React__default.createElement(ButtonContent, null, "K\u00F6p bilen online")))),
|
|
5662
|
-
|
|
5648
|
+
ecommerce?.reserved && (React__default.createElement(RepeatTiny, null,
|
|
5663
5649
|
React__default.createElement(SwitchBar, { title: "Bilen \u00E4r reserverad", body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare." },
|
|
5664
5650
|
React__default.createElement(Content$2, null,
|
|
5665
5651
|
React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare."))))),
|
|
5666
5652
|
React__default.createElement(ActionList, { branch: branch, contact: contact })),
|
|
5667
|
-
(
|
|
5653
|
+
(branch?.connections.length || 0) > 1 && (React__default.createElement(Repeat, null,
|
|
5668
5654
|
React__default.createElement(SwitchBar, { title: "Centrallagerbil", actionTitle: "Byt anl\u00E4ggning", onClick: openModalBranch },
|
|
5669
5655
|
React__default.createElement(Content$2, null,
|
|
5670
5656
|
React__default.createElement("p", null, "Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar. Byt anl\u00E4ggning f\u00F6r att visa kontaktuppgifter till just den anl\u00E4ggningen.")))))));
|
|
@@ -5791,7 +5777,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
|
|
|
5791
5777
|
onClickSearchItem(id);
|
|
5792
5778
|
}
|
|
5793
5779
|
}, []);
|
|
5794
|
-
if (!
|
|
5780
|
+
if (!response?.documentList.documents.length || response?.documentList.documents.length === 0) {
|
|
5795
5781
|
return null;
|
|
5796
5782
|
}
|
|
5797
5783
|
if (loading) {
|
|
@@ -5806,8 +5792,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
|
|
|
5806
5792
|
React__default.createElement(H2, { noMargin: true }, "Senast inkomna")))),
|
|
5807
5793
|
React__default.createElement(Repeat, null,
|
|
5808
5794
|
React__default.createElement(OverflowGrid, null,
|
|
5809
|
-
React__default.createElement(OverflowGridList, null, response
|
|
5810
|
-
var _a, _b, _c;
|
|
5795
|
+
React__default.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
|
|
5811
5796
|
const prefix = pathRoute ? `/${pathRoute}` : '/';
|
|
5812
5797
|
const r = regexPathGuid(pathRoute);
|
|
5813
5798
|
const pathRouteUrl = window.location.pathname === '/'
|
|
@@ -5816,7 +5801,7 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
|
|
|
5816
5801
|
? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
|
|
5817
5802
|
: `${window.location.pathname}${prefix}${document._id}`;
|
|
5818
5803
|
return (React__default.createElement(OverflowGridItem, { key: document._id },
|
|
5819
|
-
React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image:
|
|
5804
|
+
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: [
|
|
5820
5805
|
{
|
|
5821
5806
|
title: document.modelYear,
|
|
5822
5807
|
},
|
|
@@ -5839,20 +5824,17 @@ const PackageOptions = ({ packageOptions }) => {
|
|
|
5839
5824
|
if (!packageOptions) {
|
|
5840
5825
|
return null;
|
|
5841
5826
|
}
|
|
5842
|
-
return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => {
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
packageOption.image && (React__default.createElement(Repeat, null,
|
|
5854
|
-
React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true })))));
|
|
5855
|
-
})));
|
|
5827
|
+
return (React__default.createElement(React__default.Fragment, null, packageOptions.map((packageOption, index) => (React__default.createElement(ProductPageMainSection, { key: packageOption.title || index },
|
|
5828
|
+
React__default.createElement(Repeat, null,
|
|
5829
|
+
React__default.createElement(H2, { noMargin: true }, packageOption.title)),
|
|
5830
|
+
packageOption.description && (React__default.createElement(Repeat, null,
|
|
5831
|
+
React__default.createElement(Content$2, { dangerouslySetInnerHTML: { __html: marked(packageOption.description) } }))),
|
|
5832
|
+
packageOption.link?.url && (React__default.createElement(Repeat, null,
|
|
5833
|
+
React__default.createElement(ButtonInline, { as: "a", href: packageOption.link.url, target: "_blank", rel: "noopener noreferrer" }, packageOption.link.title
|
|
5834
|
+
? packageOption.link.title
|
|
5835
|
+
: 'Läs mer (Öppnas i ett nytt fönster)'))),
|
|
5836
|
+
packageOption.image && (React__default.createElement(Repeat, null,
|
|
5837
|
+
React__default.createElement(LogoBox, { logo: packageOption.image, alt: "Logotyp", wide: true }))))))));
|
|
5856
5838
|
};
|
|
5857
5839
|
|
|
5858
5840
|
const TableColumn = styled.div `
|
|
@@ -5923,15 +5905,15 @@ const arr = [];
|
|
|
5923
5905
|
const GetOpeningHours = (o) => KeyOrder.reduce((prev, current) => {
|
|
5924
5906
|
const title = TranslateWeekDays(current);
|
|
5925
5907
|
const item = o[current];
|
|
5926
|
-
const previous = prev
|
|
5927
|
-
if (previous && previous.from ==
|
|
5908
|
+
const previous = prev?.[prev.length - 1];
|
|
5909
|
+
if (previous && previous.from == item?.from && previous.until === item?.until) {
|
|
5928
5910
|
prev[prev.length - 1].titleTo = title;
|
|
5929
5911
|
}
|
|
5930
5912
|
else {
|
|
5931
5913
|
prev.push({
|
|
5932
5914
|
titleFrom: title,
|
|
5933
|
-
from: item
|
|
5934
|
-
until: item
|
|
5915
|
+
from: item?.from,
|
|
5916
|
+
until: item?.until,
|
|
5935
5917
|
});
|
|
5936
5918
|
}
|
|
5937
5919
|
return prev;
|
|
@@ -5942,8 +5924,8 @@ const GetOpeningHoursToday = (o) => {
|
|
|
5942
5924
|
const current = o[day];
|
|
5943
5925
|
return {
|
|
5944
5926
|
title: current ? 'Öppetider idag' : 'Stängt idag',
|
|
5945
|
-
from: current
|
|
5946
|
-
until: current
|
|
5927
|
+
from: current?.from,
|
|
5928
|
+
until: current?.until,
|
|
5947
5929
|
};
|
|
5948
5930
|
};
|
|
5949
5931
|
const valuOfDateString = (s) => {
|
|
@@ -5954,7 +5936,7 @@ const OpeningHours = ({ openingHours }) => {
|
|
|
5954
5936
|
const today = useMemo(() => (openingHours ? GetOpeningHoursToday(openingHours) : null), [openingHours]);
|
|
5955
5937
|
const currentlyOpen = useMemo(() => {
|
|
5956
5938
|
try {
|
|
5957
|
-
if (
|
|
5939
|
+
if (today?.from && today?.until) {
|
|
5958
5940
|
const currentDate = new Date().valueOf();
|
|
5959
5941
|
const from = valuOfDateString(today.from);
|
|
5960
5942
|
const until = valuOfDateString(today.until);
|
|
@@ -5976,9 +5958,9 @@ const OpeningHours = ({ openingHours }) => {
|
|
|
5976
5958
|
React__default.createElement(TableColumn, null,
|
|
5977
5959
|
React__default.createElement(TableColumnRow, null,
|
|
5978
5960
|
React__default.createElement(TableColumnCell, null,
|
|
5979
|
-
React__default.createElement(UtilityTextBold, null, today
|
|
5961
|
+
React__default.createElement(UtilityTextBold, null, today?.title)),
|
|
5980
5962
|
React__default.createElement(TableColumnCell, null,
|
|
5981
|
-
React__default.createElement(UtilityTextBold, null,
|
|
5963
|
+
React__default.createElement(UtilityTextBold, null, today?.from ? `${today.from}-${today.until}` : 'Stängt'))),
|
|
5982
5964
|
oh.map((o) => (React__default.createElement(TableColumnRow, { key: o.titleFrom },
|
|
5983
5965
|
React__default.createElement(TableColumnCell, null, o.titleTo ? `${o.titleFrom}-${o.titleTo}` : o.titleFrom),
|
|
5984
5966
|
React__default.createElement(TableColumnCell, null, o.from ? `${o.from}-${o.until}` : 'Stängt'))))))));
|
|
@@ -6047,7 +6029,6 @@ const StaticMap = ({ position }) => {
|
|
|
6047
6029
|
};
|
|
6048
6030
|
|
|
6049
6031
|
const Branch = ({ branch, loading }) => {
|
|
6050
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
6051
6032
|
const [modal, setModal] = useState(false);
|
|
6052
6033
|
const openModal = useCallback(() => setModal(true), []);
|
|
6053
6034
|
const closeModal = useCallback(() => setModal(false), []);
|
|
@@ -6060,14 +6041,14 @@ const Branch = ({ branch, loading }) => {
|
|
|
6060
6041
|
return null;
|
|
6061
6042
|
}
|
|
6062
6043
|
return (React__default.createElement(React__default.Fragment, null,
|
|
6063
|
-
modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch
|
|
6044
|
+
modal && (React__default.createElement(BranchModal, { loading: loading, connections: branch?.connections, onClose: closeModal })),
|
|
6064
6045
|
React__default.createElement(Repeat, null,
|
|
6065
|
-
React__default.createElement(H2, { noMargin: true },
|
|
6066
|
-
? `Den här bilen finns på vår anläggning i ${
|
|
6046
|
+
React__default.createElement(H2, { noMargin: true }, branch?.location?.city
|
|
6047
|
+
? `Den här bilen finns på vår anläggning i ${branch?.location?.city}`
|
|
6067
6048
|
: 'Kontakt')),
|
|
6068
6049
|
React__default.createElement(Repeat, null,
|
|
6069
|
-
React__default.createElement(StaticMap, { position:
|
|
6070
|
-
(
|
|
6050
|
+
React__default.createElement(StaticMap, { position: branch?.location?.position })),
|
|
6051
|
+
(branch?.connections?.length || 0) > 1 && (React__default.createElement(Repeat, null,
|
|
6071
6052
|
React__default.createElement(Content$2, null,
|
|
6072
6053
|
React__default.createElement("p", null,
|
|
6073
6054
|
"Denna bil tillh\u00F6r ett centrallager och g\u00E5r att k\u00F6pa genom flera anl\u00E4ggningar.",
|
|
@@ -6078,13 +6059,13 @@ const Branch = ({ branch, loading }) => {
|
|
|
6078
6059
|
React__default.createElement(ProductPageContentLimit, null,
|
|
6079
6060
|
React__default.createElement(Repeat, null,
|
|
6080
6061
|
React__default.createElement(TableColumn, null,
|
|
6081
|
-
|
|
6062
|
+
branch?.location?.streetAddress && branch?.location?.city && (React__default.createElement(TableColumnRow, null,
|
|
6082
6063
|
React__default.createElement(TableColumnCell, null, "Adress"),
|
|
6083
6064
|
React__default.createElement(TableColumnCell, null,
|
|
6084
6065
|
React__default.createElement(ButtonInlineBold, null,
|
|
6085
|
-
React__default.createElement(ButtonContent, null, `${
|
|
6086
|
-
|
|
6087
|
-
|
|
6066
|
+
React__default.createElement(ButtonContent, null, `${branch?.location?.streetAddress}, ${branch?.location?.city}`))))),
|
|
6067
|
+
branch?.contact?.phonenumber && (React__default.createElement(PhoneNumber, { phoneNumber: formatPhonenumber(branch.contact.phonenumber) })))),
|
|
6068
|
+
branch?.openingHours && (React__default.createElement(Repeat, null,
|
|
6088
6069
|
React__default.createElement(OpeningHours, { openingHours: branch.openingHours })))))));
|
|
6089
6070
|
};
|
|
6090
6071
|
|
|
@@ -6210,20 +6191,19 @@ const useSearchItemBranch = (id, branch) => useQuery(SEARCH_ITEM_BRANCH_QUERY, {
|
|
|
6210
6191
|
});
|
|
6211
6192
|
|
|
6212
6193
|
const useCentralStorage = (vehicle) => {
|
|
6213
|
-
var _a, _b;
|
|
6214
6194
|
const { centralStorageId, setCentralStorageId } = useContext(CentralStorageContext);
|
|
6215
|
-
const connections =
|
|
6195
|
+
const connections = vehicle?.branch?.connections;
|
|
6216
6196
|
const branchId = centralStorageId
|
|
6217
|
-
?
|
|
6197
|
+
? connections?.find((x) => x.id === centralStorageId)?.id
|
|
6218
6198
|
: undefined;
|
|
6219
|
-
const { data, loading } = useSearchItemBranch(vehicle
|
|
6199
|
+
const { data, loading } = useSearchItemBranch(vehicle?.id, branchId);
|
|
6220
6200
|
useEffect(() => {
|
|
6221
|
-
if ((
|
|
6201
|
+
if ((connections?.length || 0) > 0) {
|
|
6222
6202
|
const match = centralStorageId
|
|
6223
|
-
? connections
|
|
6203
|
+
? connections?.find((x) => x.id === centralStorageId)
|
|
6224
6204
|
: undefined;
|
|
6225
6205
|
if (!match) {
|
|
6226
|
-
const first = connections
|
|
6206
|
+
const first = connections?.[0];
|
|
6227
6207
|
if (first) {
|
|
6228
6208
|
setCentralStorageId(first.id);
|
|
6229
6209
|
}
|
|
@@ -6231,7 +6211,7 @@ const useCentralStorage = (vehicle) => {
|
|
|
6231
6211
|
}
|
|
6232
6212
|
}, [connections]);
|
|
6233
6213
|
return {
|
|
6234
|
-
vehicle: (
|
|
6214
|
+
vehicle: (connections?.length || 0) > 0 ? data?.vehicle : vehicle,
|
|
6235
6215
|
loading,
|
|
6236
6216
|
};
|
|
6237
6217
|
};
|
|
@@ -6248,14 +6228,14 @@ const PageLoading = () => (React__default.createElement(Page, null,
|
|
|
6248
6228
|
|
|
6249
6229
|
class PropertyTreeCreator {
|
|
6250
6230
|
constructor(properties) {
|
|
6251
|
-
this.propertiesWithCategory = (propertyKey) =>
|
|
6231
|
+
this.propertiesWithCategory = (propertyKey) => !!this.properties[propertyKey].category?.id;
|
|
6252
6232
|
this.propertiesWithoutCategory = (propertyKey) => !this.propertiesWithCategory(propertyKey);
|
|
6253
6233
|
this.isList = (property) => property.type === PropertyTreeCreator.TEXT_LIST_TYPE;
|
|
6254
6234
|
this.isNonList = (property) => !this.isList(property);
|
|
6255
|
-
this.hasCategoryWithId = (propertyKey, categoryId) =>
|
|
6256
|
-
this.propertiesWithSubCategory = (propertyKey) =>
|
|
6235
|
+
this.hasCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.id === categoryId;
|
|
6236
|
+
this.propertiesWithSubCategory = (propertyKey) => !!this.properties[propertyKey].category?.subCategory?.id;
|
|
6257
6237
|
this.propertiesWithoutSubCategory = (propertyKey) => !this.propertiesWithSubCategory(propertyKey);
|
|
6258
|
-
this.hasSubCategoryWithId = (propertyKey, categoryId) =>
|
|
6238
|
+
this.hasSubCategoryWithId = (propertyKey, categoryId) => this.properties[propertyKey].category?.subCategory?.id === categoryId;
|
|
6259
6239
|
this.properties = properties;
|
|
6260
6240
|
}
|
|
6261
6241
|
create() {
|
|
@@ -6322,7 +6302,7 @@ class PropertyTreeCreator {
|
|
|
6322
6302
|
const categories = Object.keys(this.properties)
|
|
6323
6303
|
.filter((key) => this.hasCategoryWithId(key, id))
|
|
6324
6304
|
.filter(this.propertiesWithSubCategory)
|
|
6325
|
-
.map((key) =>
|
|
6305
|
+
.map((key) => this.properties[key].category?.subCategory)
|
|
6326
6306
|
.filter(PropertyTreeCreator.distinctCategories);
|
|
6327
6307
|
return categories;
|
|
6328
6308
|
}
|
|
@@ -6951,7 +6931,6 @@ const MetadataCategory = ({ properties, subCategories }) => (React__default.crea
|
|
|
6951
6931
|
!!subCategories.length &&
|
|
6952
6932
|
subCategories.map((subCategory, index) => (React__default.createElement(MetadataSubCategory, { name: subCategory.name, properties: subCategory.properties, key: `${subCategory.name}-${index}` })))));
|
|
6953
6933
|
const PropertySet = ({ propertySet, vehicleData }) => {
|
|
6954
|
-
var _a, _b;
|
|
6955
6934
|
const [activeCategoryId, setActiveCategoryId] = useState(-1);
|
|
6956
6935
|
const mappedProperties = useMemo(() => {
|
|
6957
6936
|
if (!propertySet) {
|
|
@@ -6965,20 +6944,19 @@ const PropertySet = ({ propertySet, vehicleData }) => {
|
|
|
6965
6944
|
return tree;
|
|
6966
6945
|
}, [propertySet]);
|
|
6967
6946
|
useEffect(() => {
|
|
6968
|
-
|
|
6969
|
-
const categories = ((_a = mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories) === null || _a === void 0 ? void 0 : _a.length) !== undefined ? mappedProperties === null || mappedProperties === void 0 ? void 0 : mappedProperties.categories : undefined;
|
|
6947
|
+
const categories = mappedProperties?.categories?.length !== undefined ? mappedProperties?.categories : undefined;
|
|
6970
6948
|
if (activeCategoryId < 0 && categories !== undefined && categories.length > 0) {
|
|
6971
6949
|
setActiveCategoryId(categories[0].id);
|
|
6972
6950
|
}
|
|
6973
6951
|
}, [mappedProperties]);
|
|
6974
6952
|
const onTab = useCallback((id) => setActiveCategoryId(parseInt(id, 10)), []);
|
|
6975
|
-
const activeCategory =
|
|
6953
|
+
const activeCategory = mappedProperties?.categories?.find((category) => category.id === activeCategoryId);
|
|
6976
6954
|
return (React__default.createElement(React__default.Fragment, null,
|
|
6977
6955
|
React__default.createElement(Repeat, null,
|
|
6978
|
-
React__default.createElement(Tabs, { tabs:
|
|
6956
|
+
React__default.createElement(Tabs, { tabs: mappedProperties?.categories?.map((category) => ({
|
|
6979
6957
|
name: `${category.id}`,
|
|
6980
6958
|
displayName: category.name,
|
|
6981
|
-
}))
|
|
6959
|
+
})) || [], active: `${activeCategoryId}`, onClick: onTab })),
|
|
6982
6960
|
activeCategory && (React__default.createElement(Repeat, null,
|
|
6983
6961
|
React__default.createElement(MetadataCategory, { properties: activeCategory.properties, subCategories: activeCategory.subCategories })))));
|
|
6984
6962
|
};
|
|
@@ -7047,11 +7025,10 @@ const PdfDownloadItem = ({ document }) => (React__default.createElement(PdfListI
|
|
|
7047
7025
|
const PdfDownloadContainer = ({ documents }) => (React__default.createElement(PdfContainer, null, documents.map((document, i) => (React__default.createElement(PdfDownloadItem, { key: `${document.url}-${i}`, document: document })))));
|
|
7048
7026
|
|
|
7049
7027
|
const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, placeholderImage, modifyDocumentTitleItem, onClickSearchItem, }) => {
|
|
7050
|
-
var _a, _b, _c;
|
|
7051
7028
|
const { ecomSettings } = useSettings();
|
|
7052
7029
|
const ecomContext = useRef();
|
|
7053
7030
|
const { loading, data: result } = useSearchItem(id);
|
|
7054
|
-
const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result
|
|
7031
|
+
const { vehicle: centralStorageVehicle, loading: loadingCentralStorageVehicle } = useCentralStorage(result?.vehicle);
|
|
7055
7032
|
useEffect(() => {
|
|
7056
7033
|
if (ecomSettings) {
|
|
7057
7034
|
ecomContext.current = new WaykeEcomWeb({
|
|
@@ -7060,7 +7037,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7060
7037
|
api: {
|
|
7061
7038
|
address: ecomSettings.url,
|
|
7062
7039
|
},
|
|
7063
|
-
bankIdThumbprint: ecomSettings
|
|
7040
|
+
bankIdThumbprint: ecomSettings?.bankIdThumbprint,
|
|
7064
7041
|
},
|
|
7065
7042
|
logo: ecomSettings.serviceLogotypeUrl,
|
|
7066
7043
|
logoX2: ecomSettings.serviceLogotypeUrl,
|
|
@@ -7081,26 +7058,25 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7081
7058
|
}
|
|
7082
7059
|
}, []);
|
|
7083
7060
|
useEffect(() => {
|
|
7084
|
-
|
|
7085
|
-
if (((_a = result === null || result === void 0 ? void 0 : result.vehicle) === null || _a === void 0 ? void 0 : _a.data) && modifyDocumentTitleItem) {
|
|
7061
|
+
if (result?.vehicle?.data && modifyDocumentTitleItem) {
|
|
7086
7062
|
const { vehicle } = result;
|
|
7087
7063
|
const { registrationNumber } = vehicle.data;
|
|
7088
7064
|
document.title = `${registrationNumber} | ${vehicle.title} | ${vehicle.shortDescription}`;
|
|
7089
7065
|
}
|
|
7090
7066
|
}, [result]);
|
|
7091
|
-
const options = useMemo(() =>
|
|
7067
|
+
const options = useMemo(() => result?.vehicle?.data?.options?.filter(notEmpty).map((opt) => ({ title: opt })), [result?.vehicle?.data?.options]);
|
|
7092
7068
|
const onShowMoreOptionsClick = useCallback(() => PubSub.publish('OptionsClick'), []);
|
|
7093
7069
|
if (loading) {
|
|
7094
7070
|
return React__default.createElement(PageLoading, null);
|
|
7095
7071
|
}
|
|
7096
|
-
if (!
|
|
7072
|
+
if (!result?.vehicle?.data) {
|
|
7097
7073
|
return React__default.createElement(Page404, null);
|
|
7098
7074
|
}
|
|
7099
7075
|
const { vehicle } = result;
|
|
7100
|
-
const contact = centralStorageVehicle
|
|
7101
|
-
const branch = centralStorageVehicle
|
|
7076
|
+
const contact = centralStorageVehicle?.contact;
|
|
7077
|
+
const branch = centralStorageVehicle?.branch;
|
|
7102
7078
|
const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
|
|
7103
|
-
const insuranceOptions =
|
|
7079
|
+
const insuranceOptions = centralStorageVehicle?.insuranceOptions
|
|
7104
7080
|
? centralStorageVehicle.insuranceOptions
|
|
7105
7081
|
: vehicle.insuranceOptions;
|
|
7106
7082
|
const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
|
|
@@ -7131,7 +7107,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7131
7107
|
React__default.createElement(ButtonContent, null,
|
|
7132
7108
|
React__default.createElement(IconChevronLeft, { block: true })),
|
|
7133
7109
|
React__default.createElement(ButtonContent, null, "Tillbaka till bils\u00F6k"))))) : null,
|
|
7134
|
-
|
|
7110
|
+
manufacturer?.logotype && (React__default.createElement(Repeat, null,
|
|
7135
7111
|
React__default.createElement(LogoBox, { logo: manufacturer.logotype, alt: manufacturer.name }))),
|
|
7136
7112
|
React__default.createElement(Repeat, null,
|
|
7137
7113
|
React__default.createElement(RepeatSmall, null,
|
|
@@ -7144,9 +7120,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7144
7120
|
React__default.createElement(PriceTable, { price: price })),
|
|
7145
7121
|
(financialOptions.length > 0 || insuranceOptions.length > 0) && (React__default.createElement(ProductPageAsideSection, { mobileOrder: 4 },
|
|
7146
7122
|
financialOptions.length > 0 && (React__default.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
|
|
7147
|
-
insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle
|
|
7123
|
+
insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle?.branch, insuranceOptions: insuranceOptions })))),
|
|
7148
7124
|
React__default.createElement(ProductPageAsideSection, { mobileOrder: 5 },
|
|
7149
|
-
React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle
|
|
7125
|
+
React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle?.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: () => ecomContext.current?.start() }))),
|
|
7150
7126
|
React__default.createElement(ProductPageMain, null,
|
|
7151
7127
|
React__default.createElement(ProductPageAsideSection, { mobileOrder: 3 },
|
|
7152
7128
|
React__default.createElement(Gallery, { media: media, placeholderImage: placeholderImage })),
|
|
@@ -7161,8 +7137,8 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7161
7137
|
description && (React__default.createElement(ProductPageMainSection, null,
|
|
7162
7138
|
React__default.createElement(Blockquote, { author: contact && contact.name ? contact.name : null, date: publishedAt
|
|
7163
7139
|
? dateTimeFormat.format(publishedAt, dateTimeFormat.DayMonth)
|
|
7164
|
-
: undefined, avatar:
|
|
7165
|
-
(
|
|
7140
|
+
: undefined, avatar: contact?.avatar || undefined }, !!description && React__default.createElement("p", null, description)))),
|
|
7141
|
+
(options?.length || 0) > 0 && (React__default.createElement(ProductPageMainSection, null,
|
|
7166
7142
|
React__default.createElement(Repeat, null,
|
|
7167
7143
|
React__default.createElement(H2, { noMargin: true }, "Utrustning")),
|
|
7168
7144
|
React__default.createElement(Repeat, null,
|
|
@@ -7182,9 +7158,9 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7182
7158
|
React__default.createElement(ProductPageMainSection, null,
|
|
7183
7159
|
React__default.createElement(Branch, { branch: branch, loading: loadingCentralStorageVehicle }),
|
|
7184
7160
|
ecommerce && ecommerce.enabled && (React__default.createElement(Repeat, null,
|
|
7185
|
-
React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () =>
|
|
7161
|
+
React__default.createElement(ButtonPrimary, { disabled: !!ecommerce.reserved, title: "K\u00F6p bilen online", onClick: () => ecomContext.current?.start() }, "K\u00F6p bilen online")))),
|
|
7186
7162
|
React__default.createElement(PackageOptions, { packageOptions: packageOptions }),
|
|
7187
|
-
React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer
|
|
7163
|
+
React__default.createElement(ManufacturerPackageOption, { packageOption: manufacturer?.packageOption }))))),
|
|
7188
7164
|
React__default.createElement(Related, { id: id, hashRoute: hashRoute, pathRoute: pathRoute, onClickSearchItem: onClickSearchItem })),
|
|
7189
7165
|
false ,
|
|
7190
7166
|
React__default.createElement(PortalElement, { id: DefaultPortal })));
|
|
@@ -7224,7 +7200,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7224
7200
|
'x-api-key': apiKey,
|
|
7225
7201
|
}
|
|
7226
7202
|
: {},
|
|
7227
|
-
}, !initialize || !!
|
|
7203
|
+
}, !initialize || !!queryFilter?.block);
|
|
7228
7204
|
const popStateEvent = (event) => {
|
|
7229
7205
|
const { currentTarget } = event;
|
|
7230
7206
|
if (currentTarget) {
|
|
@@ -7267,7 +7243,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7267
7243
|
const nextSearch = nextSearchParams.toString() ? `?${nextSearchParams}` : '';
|
|
7268
7244
|
if (initialize) {
|
|
7269
7245
|
if (window.location.search.localeCompare(nextSearch) !== 0) {
|
|
7270
|
-
const _path = pathRoute
|
|
7246
|
+
const _path = pathRoute?.replace(/^\/|\/$/g, '');
|
|
7271
7247
|
const prefix = _path ? `/${_path}/` : '/';
|
|
7272
7248
|
const index = _path ? window.location.pathname.indexOf(prefix) : -1;
|
|
7273
7249
|
let pathname = window.location.pathname;
|
|
@@ -7280,12 +7256,11 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7280
7256
|
}
|
|
7281
7257
|
}, [queryFilter, initialize, useQueryParamsFromUrl]);
|
|
7282
7258
|
useEffect(() => {
|
|
7283
|
-
var _a;
|
|
7284
7259
|
if (response) {
|
|
7285
7260
|
if (!initialFacets && !useQueryParamsFromUrl) {
|
|
7286
7261
|
setInitialFacets(response.facets);
|
|
7287
7262
|
}
|
|
7288
|
-
if (useQueryParamsFromUrl &&
|
|
7263
|
+
if (useQueryParamsFromUrl && response.query?.parameters) {
|
|
7289
7264
|
const nextSearchParams = new URLSearchParams(response.query.parameters);
|
|
7290
7265
|
nextSearchParams.delete('hits');
|
|
7291
7266
|
nextSearchParams.delete('offset');
|
|
@@ -7298,7 +7273,7 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7298
7273
|
});
|
|
7299
7274
|
}
|
|
7300
7275
|
}
|
|
7301
|
-
if (queryFilter
|
|
7276
|
+
if (queryFilter?.concatResult) {
|
|
7302
7277
|
setDocuments([...(documents || []), ...(response.documentList.documents || [])]);
|
|
7303
7278
|
}
|
|
7304
7279
|
else {
|
|
@@ -7317,10 +7292,9 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7317
7292
|
}
|
|
7318
7293
|
}, [initialize]);
|
|
7319
7294
|
const onLoadMore = useCallback(() => {
|
|
7320
|
-
var _a;
|
|
7321
7295
|
if (response) {
|
|
7322
7296
|
setQueryFilter({
|
|
7323
|
-
searchParams: new URLSearchParams(
|
|
7297
|
+
searchParams: new URLSearchParams(response?.documentList.pagination.nextPage?.query),
|
|
7324
7298
|
concatResult: true,
|
|
7325
7299
|
});
|
|
7326
7300
|
}
|
|
@@ -7333,9 +7307,8 @@ const SearchProvider = ({ url, apiKey, useQueryParamsFromUrl, pathRoute, childre
|
|
|
7333
7307
|
: _initialQueryParams;
|
|
7334
7308
|
if (useQueryParamsFromUrl && _initialQueryParams) {
|
|
7335
7309
|
_initialQueryParams.forEach((value, key) => {
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
initialQueryParams === null || initialQueryParams === void 0 ? void 0 : initialQueryParams.append(key, value);
|
|
7310
|
+
if (!initialQueryParams?.getAll(key)?.some((v) => v === value)) {
|
|
7311
|
+
initialQueryParams?.append(key, value);
|
|
7339
7312
|
}
|
|
7340
7313
|
});
|
|
7341
7314
|
}
|
|
@@ -7397,7 +7370,7 @@ const SettingsProvider = ({ googleMapsApiKey, googleMapsMarker, ecomSettings, ch
|
|
|
7397
7370
|
|
|
7398
7371
|
const RelatedSearchProvider = ({ url, urlMlt, apiKey, children }) => {
|
|
7399
7372
|
const [queryFilter, setQueryFilter] = useState();
|
|
7400
|
-
const query = queryFilter
|
|
7373
|
+
const query = queryFilter?.searchParams.toString();
|
|
7401
7374
|
const { loading, data: response, error, } = useFetch(`${urlMlt || url}${query ? `?${query}` : ''}`, {
|
|
7402
7375
|
headers: apiKey
|
|
7403
7376
|
? {
|
|
@@ -7502,7 +7475,7 @@ const PathProvider = ({ children }) => {
|
|
|
7502
7475
|
}
|
|
7503
7476
|
dispatch({ type: SET_PATH, path });
|
|
7504
7477
|
}, []);
|
|
7505
|
-
const id = useMemo(() =>
|
|
7478
|
+
const id = useMemo(() => state.path.match(regexGuidAnyWhere)?.pop(), [state.path]);
|
|
7506
7479
|
const value = useMemo(() => ({
|
|
7507
7480
|
...state,
|
|
7508
7481
|
previousPath,
|