@wayke-se/components-react 2.15.0 → 2.16.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 +120 -12
- package/dist-node/index.js.map +1 -1
- package/dist-src/components/Content/wrapper.js +5 -0
- package/dist-src/components/InsuranceOptions/Insurance.js +26 -0
- package/dist-src/components/InsuranceOptions/InsuranceFree.js +31 -0
- package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +20 -0
- package/dist-src/components/InsuranceOptions/{InsuranceOptionModal.js → InsuranceModal.js} +3 -3
- package/dist-src/components/InsuranceOptions/index.js +10 -21
- package/dist-src/hooks/useInsurance.js +3 -2
- package/dist-src/layouts/searchItem/index.js +5 -2
- package/dist-src/queries/INSURANCE_CALCULATION.js +7 -1
- package/dist-src/queries/SEARCH_ITEM_BRANCH_QUERY.js +14 -0
- package/dist-src/queries/SEARCH_ITEM_QUERY.js +9 -2
- package/dist-types/@types/codegen/types.d.ts +9 -0
- package/dist-types/components/InsuranceOptions/Insurance.d.ts +9 -0
- package/dist-types/components/InsuranceOptions/InsuranceFree.d.ts +7 -0
- package/dist-types/components/InsuranceOptions/InsuranceFreeModal.d.ts +8 -0
- package/dist-types/components/InsuranceOptions/InsuranceModal.d.ts +10 -0
- package/dist-types/components/InsuranceOptions/index.d.ts +3 -2
- package/dist-types/hooks/useInsurance.d.ts +1 -1
- package/dist-web/index.js +95 -12
- package/dist-web/index.js.map +1 -1
- package/package.json +1 -1
- package/dist-types/components/InsuranceOptions/InsuranceOptionModal.d.ts +0 -9
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { Repeat, RepeatTiny } from '../Repeat/index';
|
|
3
|
+
import { VisualHeading } from '../Heading/index';
|
|
4
|
+
import OptionBox from '../OptionBox/index';
|
|
5
|
+
import { OptionBoxHeading, OptionBoxContent } from '../OptionBox/wrapper';
|
|
6
|
+
import { ButtonInline } from '../Button/index';
|
|
7
|
+
import InsuranceModal from './InsuranceModal';
|
|
8
|
+
const Insurance = ({ id, branch, insuranceOptions }) => {
|
|
9
|
+
const [modal, setModal] = useState(false);
|
|
10
|
+
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
11
|
+
if (!insuranceOptions.length) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return (React.createElement(React.Fragment, null,
|
|
15
|
+
modal && (React.createElement(InsuranceModal, { id: id, branch: branch, onClose: toggleModal, insuranceOptions: insuranceOptions[0] })),
|
|
16
|
+
React.createElement(Repeat, null,
|
|
17
|
+
React.createElement(RepeatTiny, null,
|
|
18
|
+
React.createElement(VisualHeading, null, "V\u00E4lj till f\u00F6rs\u00E4kring")),
|
|
19
|
+
React.createElement(RepeatTiny, null,
|
|
20
|
+
React.createElement(React.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
|
|
21
|
+
React.createElement(OptionBoxHeading, null, "F\u00E5 prisf\u00F6rslag"),
|
|
22
|
+
React.createElement(OptionBoxContent, null,
|
|
23
|
+
React.createElement("p", null,
|
|
24
|
+
React.createElement(ButtonInline, { onClick: toggleModal }, "Mer information")))))))))));
|
|
25
|
+
};
|
|
26
|
+
export default Insurance;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { Repeat, RepeatTiny } from '../Repeat/index';
|
|
3
|
+
import { VisualHeading } from '../Heading/index';
|
|
4
|
+
import OptionBox from '../OptionBox/index';
|
|
5
|
+
import { OptionBoxContent } from '../OptionBox/wrapper';
|
|
6
|
+
import Content from '../Content/index';
|
|
7
|
+
import { marked } from 'marked';
|
|
8
|
+
import { ButtonInline } from '../Button/index';
|
|
9
|
+
import InsuranceFreeModal from './InsuranceFreeModal';
|
|
10
|
+
const Insurance = ({ insuranceOptions }) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const [modal, setModal] = useState(false);
|
|
13
|
+
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
14
|
+
if (!insuranceOptions.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (React.createElement(React.Fragment, null,
|
|
18
|
+
modal && React.createElement(InsuranceFreeModal, { onClose: toggleModal, insuranceOptions: insuranceOptions[0] }),
|
|
19
|
+
React.createElement(Repeat, null,
|
|
20
|
+
React.createElement(RepeatTiny, null,
|
|
21
|
+
React.createElement(VisualHeading, null, (_b = (_a = insuranceOptions[0]) === null || _a === void 0 ? void 0 : _a.insuranceHeader) !== null && _b !== void 0 ? _b : 'Försäkring')),
|
|
22
|
+
React.createElement(RepeatTiny, null,
|
|
23
|
+
React.createElement(React.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
|
|
24
|
+
insuranceOption.description && (React.createElement(Content, { dangerouslySetInnerHTML: {
|
|
25
|
+
__html: marked(insuranceOption.description),
|
|
26
|
+
} })),
|
|
27
|
+
React.createElement(OptionBoxContent, null,
|
|
28
|
+
React.createElement("p", null,
|
|
29
|
+
React.createElement(ButtonInline, { onClick: toggleModal }, "Mer information")))))))))));
|
|
30
|
+
};
|
|
31
|
+
export default Insurance;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Modal from '../Modal/index';
|
|
3
|
+
import Content from '../Content/index';
|
|
4
|
+
import { Repeat } from '../Repeat/index';
|
|
5
|
+
import { ButtonInline } from '../Button/index';
|
|
6
|
+
import LogoBox from '../LogoBox/index';
|
|
7
|
+
import { marked } from 'marked';
|
|
8
|
+
const InsuranceFreeModal = ({ onClose, insuranceOptions }) => {
|
|
9
|
+
var _a;
|
|
10
|
+
return (React.createElement(Modal, { title: (_a = insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.insuranceHeader) !== null && _a !== void 0 ? _a : 'Försäkring', onClose: onClose },
|
|
11
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && (React.createElement(Repeat, null,
|
|
12
|
+
React.createElement(Content, { dangerouslySetInnerHTML: {
|
|
13
|
+
__html: marked(insuranceOptions.longDescription),
|
|
14
|
+
} }))),
|
|
15
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.url) && (React.createElement(Repeat, null,
|
|
16
|
+
React.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)"))),
|
|
17
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype) && (React.createElement(Repeat, null,
|
|
18
|
+
React.createElement(LogoBox, { logo: insuranceOptions.logotype, alt: insuranceOptions.name || 'Logotyp', wide: true })))));
|
|
19
|
+
};
|
|
20
|
+
export default InsuranceFreeModal;
|
|
@@ -22,13 +22,13 @@ import Loader from '../Loader/index';
|
|
|
22
22
|
import { numberSeparator } from '../../utils/formats';
|
|
23
23
|
import { DrivingDistance } from '../../@types/codegen/types';
|
|
24
24
|
import PubSub from '../../utils/pubsub/pubsub';
|
|
25
|
-
const
|
|
25
|
+
const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
|
|
26
26
|
const [form, setForm] = useState({
|
|
27
27
|
ssn: '',
|
|
28
28
|
drivingDistance: DrivingDistance.Between0And1000,
|
|
29
29
|
});
|
|
30
30
|
const [payload, setPayload] = useState();
|
|
31
|
-
const { loading, data, error } = useInsuranceCalculation(id, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
|
|
31
|
+
const { loading, data, error } = useInsuranceCalculation(id, (branch === null || branch === void 0 ? void 0 : branch.id) ? branch === null || branch === void 0 ? void 0 : branch.id : undefined, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
|
|
32
32
|
const onChangeSsn = useCallback((e) => setForm({ ...form, ssn: e.currentTarget.value }), [form]);
|
|
33
33
|
const onChangeDrivingDistance = useCallback((e) => setForm({ ...form, drivingDistance: e.currentTarget.value }), [form]);
|
|
34
34
|
const onShowInsurances = useCallback(() => {
|
|
@@ -102,4 +102,4 @@ const InsuranceOptionModal = ({ id, onClose, insuranceOptions }) => {
|
|
|
102
102
|
" ",
|
|
103
103
|
addon.unit)))))))))))))))));
|
|
104
104
|
};
|
|
105
|
-
export default
|
|
105
|
+
export default InsuranceModal;
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { OptionBoxHeading, OptionBoxContent } from '../OptionBox/wrapper';
|
|
6
|
-
import { ButtonInline } from '../Button/index';
|
|
7
|
-
import InsuranceOptionModal from './InsuranceOptionModal';
|
|
8
|
-
const InsuranceOptions = ({ id, insuranceOptions }) => {
|
|
9
|
-
const [modal, setModal] = useState(false);
|
|
10
|
-
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Insurance from './Insurance';
|
|
3
|
+
import InsuranceFree from './InsuranceFree';
|
|
4
|
+
const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
|
|
11
5
|
if (!insuranceOptions.length) {
|
|
12
6
|
return null;
|
|
13
7
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
React.createElement(React.Fragment, null, insuranceOptions.map((insuranceOption, index) => (React.createElement(OptionBox, { key: `${insuranceOption.url}-${index}`, logo: insuranceOption.logotype || undefined, logoAlt: insuranceOption.name || 'Logotyp' },
|
|
21
|
-
React.createElement(OptionBoxHeading, null, "F\u00E5 prisf\u00F6rslag"),
|
|
22
|
-
React.createElement(OptionBoxContent, null,
|
|
23
|
-
React.createElement("p", null,
|
|
24
|
-
React.createElement(ButtonInline, { onClick: toggleModal }, "Mer information")))))))))));
|
|
8
|
+
if (insuranceOptions.length > 0) {
|
|
9
|
+
if (insuranceOptions[0].requiresDistance && insuranceOptions[0].requiresPersonalNumber)
|
|
10
|
+
return React.createElement(Insurance, { id: id, branch: branch, insuranceOptions: insuranceOptions });
|
|
11
|
+
return React.createElement(InsuranceFree, { insuranceOptions: insuranceOptions });
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
25
14
|
};
|
|
26
15
|
export default InsuranceOptions;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client';
|
|
2
2
|
import INSURANCE_CALCULATION from '../queries/INSURANCE_CALCULATION';
|
|
3
|
-
const useInsuranceCalculation = (id, personalNumber, drivingDistance) => useQuery(INSURANCE_CALCULATION, {
|
|
3
|
+
const useInsuranceCalculation = (id, branchId, personalNumber, drivingDistance) => useQuery(INSURANCE_CALCULATION, {
|
|
4
4
|
variables: {
|
|
5
5
|
id,
|
|
6
|
+
branch: branchId,
|
|
6
7
|
personalNumber: personalNumber,
|
|
7
8
|
drivingDistance: drivingDistance,
|
|
8
9
|
},
|
|
9
|
-
skip: personalNumber === undefined || drivingDistance === undefined,
|
|
10
|
+
skip: personalNumber === undefined || drivingDistance === undefined || branchId === undefined,
|
|
10
11
|
});
|
|
11
12
|
export default useInsuranceCalculation;
|
|
@@ -62,7 +62,10 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
62
62
|
const { vehicle } = result;
|
|
63
63
|
const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
|
|
64
64
|
const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
|
|
65
|
-
const { title, shortDescription, media, description, price, financialOptions,
|
|
65
|
+
const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
|
|
66
|
+
const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
|
|
67
|
+
? centralStorageVehicle.insuranceOptions
|
|
68
|
+
: vehicle.insuranceOptions;
|
|
66
69
|
const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
|
|
67
70
|
const uspList = [
|
|
68
71
|
{
|
|
@@ -105,7 +108,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
105
108
|
React.createElement(PriceTable, { price: price })),
|
|
106
109
|
(financialOptions.length > 0 || insuranceOptions.length > 0) && (React.createElement(ProductPageAsideSection, { mobileOrder: 4 },
|
|
107
110
|
financialOptions.length > 0 && (React.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
|
|
108
|
-
insuranceOptions.length > 0 && (React.createElement(InsuranceOptions, { id: id, insuranceOptions: insuranceOptions })))),
|
|
111
|
+
insuranceOptions.length > 0 && (React.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch, insuranceOptions: insuranceOptions })))),
|
|
109
112
|
React.createElement(ProductPageAsideSection, { mobileOrder: 5 },
|
|
110
113
|
React.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: toggleEcomModal }))),
|
|
111
114
|
React.createElement(ProductPageMain, null,
|
|
@@ -2,10 +2,16 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
const INSURANCE_CALCULATION = gql `
|
|
3
3
|
query InsuranceCalculation(
|
|
4
4
|
$id: ID!
|
|
5
|
+
$branch: ID
|
|
5
6
|
$personalNumber: PersonalNumber!
|
|
6
7
|
$drivingDistance: DrivingDistance!
|
|
7
8
|
) {
|
|
8
|
-
insurances(
|
|
9
|
+
insurances(
|
|
10
|
+
id: $id
|
|
11
|
+
branch: $branch
|
|
12
|
+
personalNumber: $personalNumber
|
|
13
|
+
drivingDistance: $drivingDistance
|
|
14
|
+
) {
|
|
9
15
|
name
|
|
10
16
|
price
|
|
11
17
|
unit
|
|
@@ -96,6 +96,20 @@ const SEARCH_ITEM_BRANCH_QUERY = gql `
|
|
|
96
96
|
title
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
insuranceOptions {
|
|
100
|
+
insuranceHeader
|
|
101
|
+
institute
|
|
102
|
+
identifier
|
|
103
|
+
logotype
|
|
104
|
+
name
|
|
105
|
+
description
|
|
106
|
+
longDescription
|
|
107
|
+
url
|
|
108
|
+
insuranceText
|
|
109
|
+
requiresPersonalNumber
|
|
110
|
+
requiresDistance
|
|
111
|
+
terms
|
|
112
|
+
}
|
|
99
113
|
}
|
|
100
114
|
}
|
|
101
115
|
${HoursOpen}
|
|
@@ -158,10 +158,17 @@ const SEARCH_ITEM_QUERY = gql `
|
|
|
158
158
|
withHomeDelivery
|
|
159
159
|
}
|
|
160
160
|
insuranceOptions {
|
|
161
|
-
|
|
161
|
+
insuranceHeader
|
|
162
|
+
institute
|
|
163
|
+
identifier
|
|
162
164
|
logotype
|
|
163
|
-
url
|
|
164
165
|
name
|
|
166
|
+
description
|
|
167
|
+
longDescription
|
|
168
|
+
url
|
|
169
|
+
insuranceText
|
|
170
|
+
requiresPersonalNumber
|
|
171
|
+
requiresDistance
|
|
165
172
|
terms
|
|
166
173
|
}
|
|
167
174
|
financialOptions {
|
|
@@ -161,8 +161,16 @@ export declare type InsuranceLegality = {
|
|
|
161
161
|
export declare type InsuranceOption = {
|
|
162
162
|
__typename?: 'InsuranceOption';
|
|
163
163
|
description?: Maybe<Scalars['String']>;
|
|
164
|
+
identifier?: Maybe<Scalars['String']>;
|
|
165
|
+
institute?: Maybe<Scalars['String']>;
|
|
166
|
+
insuranceHeader?: Maybe<Scalars['String']>;
|
|
167
|
+
insuranceText?: Maybe<Scalars['String']>;
|
|
164
168
|
logotype?: Maybe<Scalars['URL']>;
|
|
169
|
+
longDescription?: Maybe<Scalars['String']>;
|
|
165
170
|
name?: Maybe<Scalars['String']>;
|
|
171
|
+
requiresDistance?: Maybe<Scalars['Boolean']>;
|
|
172
|
+
requiresPersonalNumber?: Maybe<Scalars['Boolean']>;
|
|
173
|
+
/** @deprecated No longer supported */
|
|
166
174
|
terms?: Maybe<Scalars['URL']>;
|
|
167
175
|
url?: Maybe<Scalars['URL']>;
|
|
168
176
|
};
|
|
@@ -253,6 +261,7 @@ export declare type QueryBranchArgs = {
|
|
|
253
261
|
id: Scalars['ID'];
|
|
254
262
|
};
|
|
255
263
|
export declare type QueryInsurancesArgs = {
|
|
264
|
+
branch?: InputMaybe<Scalars['ID']>;
|
|
256
265
|
drivingDistance: DrivingDistance;
|
|
257
266
|
id: Scalars['ID'];
|
|
258
267
|
personalNumber: Scalars['PersonalNumber'];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InsuranceOption, Branch } from '../../@types/codegen/types';
|
|
3
|
+
interface InsuranceOptions {
|
|
4
|
+
id: string;
|
|
5
|
+
branch?: Branch | null;
|
|
6
|
+
insuranceOptions: InsuranceOption[];
|
|
7
|
+
}
|
|
8
|
+
declare const Insurance: ({ id, branch, insuranceOptions }: InsuranceOptions) => JSX.Element | null;
|
|
9
|
+
export default Insurance;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InsuranceOption } from '../../@types/codegen/types';
|
|
3
|
+
interface InsuranceOptions {
|
|
4
|
+
insuranceOptions: InsuranceOption[];
|
|
5
|
+
}
|
|
6
|
+
declare const Insurance: ({ insuranceOptions }: InsuranceOptions) => JSX.Element | null;
|
|
7
|
+
export default Insurance;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InsuranceOption } from '../../@types/codegen/types';
|
|
3
|
+
interface InsuranceFreeModal {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
insuranceOptions: InsuranceOption;
|
|
6
|
+
}
|
|
7
|
+
declare const InsuranceFreeModal: ({ onClose, insuranceOptions }: InsuranceFreeModal) => JSX.Element;
|
|
8
|
+
export default InsuranceFreeModal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InsuranceOption, Branch } from '../../@types/codegen/types';
|
|
3
|
+
interface InsuranceModal {
|
|
4
|
+
id: string;
|
|
5
|
+
branch?: Branch | null;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
insuranceOptions: InsuranceOption;
|
|
8
|
+
}
|
|
9
|
+
declare const InsuranceModal: ({ id, branch, onClose, insuranceOptions }: InsuranceModal) => JSX.Element;
|
|
10
|
+
export default InsuranceModal;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { InsuranceOption } from '../../@types/codegen/types';
|
|
2
|
+
import { InsuranceOption, Branch } from '../../@types/codegen/types';
|
|
3
3
|
interface InsuranceOptions {
|
|
4
4
|
id: string;
|
|
5
|
+
branch?: Branch | null;
|
|
5
6
|
insuranceOptions: InsuranceOption[];
|
|
6
7
|
}
|
|
7
|
-
declare const InsuranceOptions: ({ id, insuranceOptions }: InsuranceOptions) => JSX.Element | null;
|
|
8
|
+
declare const InsuranceOptions: ({ id, branch, insuranceOptions }: InsuranceOptions) => JSX.Element | null;
|
|
8
9
|
export default InsuranceOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { QueryResult } from '@apollo/client';
|
|
2
2
|
import { DrivingDistance, QueryInsurancesArgs, Query } from '../@types/codegen/types';
|
|
3
|
-
declare const useInsuranceCalculation: (id: string, personalNumber?: string | undefined, drivingDistance?: DrivingDistance | undefined) => QueryResult<Query, QueryInsurancesArgs>;
|
|
3
|
+
declare const useInsuranceCalculation: (id: string, branchId?: string | undefined, personalNumber?: string | undefined, drivingDistance?: DrivingDistance | undefined) => QueryResult<Query, QueryInsurancesArgs>;
|
|
4
4
|
export default useInsuranceCalculation;
|
package/dist-web/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import LazyLoad from 'react-lazyload';
|
|
|
8
8
|
import Slider$2 from 'react-slick';
|
|
9
9
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
10
10
|
import { gql, useQuery, ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
11
|
-
import EcomBase from '@wayke-se/ecom-react';
|
|
12
11
|
import { marked } from 'marked';
|
|
12
|
+
import EcomBase from '@wayke-se/ecom-react';
|
|
13
13
|
import { parsePhoneNumberFromString } from 'libphonenumber-js/core';
|
|
14
14
|
|
|
15
15
|
const _colors = {
|
|
@@ -2547,6 +2547,11 @@ const Wrapper$c = styled.div `
|
|
|
2547
2547
|
}
|
|
2548
2548
|
}
|
|
2549
2549
|
|
|
2550
|
+
img {
|
|
2551
|
+
display: block;
|
|
2552
|
+
width: 100%;
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2550
2555
|
${({ small }) => small &&
|
|
2551
2556
|
css `
|
|
2552
2557
|
font-size: 0.875rem;
|
|
@@ -4238,10 +4243,17 @@ const SEARCH_ITEM_QUERY = gql `
|
|
|
4238
4243
|
withHomeDelivery
|
|
4239
4244
|
}
|
|
4240
4245
|
insuranceOptions {
|
|
4241
|
-
|
|
4246
|
+
insuranceHeader
|
|
4247
|
+
institute
|
|
4248
|
+
identifier
|
|
4242
4249
|
logotype
|
|
4243
|
-
url
|
|
4244
4250
|
name
|
|
4251
|
+
description
|
|
4252
|
+
longDescription
|
|
4253
|
+
url
|
|
4254
|
+
insuranceText
|
|
4255
|
+
requiresPersonalNumber
|
|
4256
|
+
requiresDistance
|
|
4245
4257
|
terms
|
|
4246
4258
|
}
|
|
4247
4259
|
financialOptions {
|
|
@@ -5077,10 +5089,16 @@ const ColumnRowItem = styled.div `
|
|
|
5077
5089
|
const INSURANCE_CALCULATION = gql `
|
|
5078
5090
|
query InsuranceCalculation(
|
|
5079
5091
|
$id: ID!
|
|
5092
|
+
$branch: ID
|
|
5080
5093
|
$personalNumber: PersonalNumber!
|
|
5081
5094
|
$drivingDistance: DrivingDistance!
|
|
5082
5095
|
) {
|
|
5083
|
-
insurances(
|
|
5096
|
+
insurances(
|
|
5097
|
+
id: $id
|
|
5098
|
+
branch: $branch
|
|
5099
|
+
personalNumber: $personalNumber
|
|
5100
|
+
drivingDistance: $drivingDistance
|
|
5101
|
+
) {
|
|
5084
5102
|
name
|
|
5085
5103
|
price
|
|
5086
5104
|
unit
|
|
@@ -5108,13 +5126,14 @@ const INSURANCE_CALCULATION = gql `
|
|
|
5108
5126
|
}
|
|
5109
5127
|
`;
|
|
5110
5128
|
|
|
5111
|
-
const useInsuranceCalculation = (id, personalNumber, drivingDistance) => useQuery(INSURANCE_CALCULATION, {
|
|
5129
|
+
const useInsuranceCalculation = (id, branchId, personalNumber, drivingDistance) => useQuery(INSURANCE_CALCULATION, {
|
|
5112
5130
|
variables: {
|
|
5113
5131
|
id,
|
|
5132
|
+
branch: branchId,
|
|
5114
5133
|
personalNumber: personalNumber,
|
|
5115
5134
|
drivingDistance: drivingDistance,
|
|
5116
5135
|
},
|
|
5117
|
-
skip: personalNumber === undefined || drivingDistance === undefined,
|
|
5136
|
+
skip: personalNumber === undefined || drivingDistance === undefined || branchId === undefined,
|
|
5118
5137
|
});
|
|
5119
5138
|
|
|
5120
5139
|
const ssnIsValid = (s) => (s ? /^\d{2,4}\d{2}\d{2}\-?\d{4}$/.test(s) : false);
|
|
@@ -5134,13 +5153,13 @@ var FinancialOptionInclusion;
|
|
|
5134
5153
|
FinancialOptionInclusion["IncludesWintertires"] = "INCLUDES_WINTERTIRES";
|
|
5135
5154
|
})(FinancialOptionInclusion || (FinancialOptionInclusion = {}));
|
|
5136
5155
|
|
|
5137
|
-
const
|
|
5156
|
+
const InsuranceModal = ({ id, branch, onClose, insuranceOptions }) => {
|
|
5138
5157
|
const [form, setForm] = useState({
|
|
5139
5158
|
ssn: '',
|
|
5140
5159
|
drivingDistance: DrivingDistance.Between0And1000,
|
|
5141
5160
|
});
|
|
5142
5161
|
const [payload, setPayload] = useState();
|
|
5143
|
-
const { loading, data, error } = useInsuranceCalculation(id, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
|
|
5162
|
+
const { loading, data, error } = useInsuranceCalculation(id, (branch === null || branch === void 0 ? void 0 : branch.id) ? branch === null || branch === void 0 ? void 0 : branch.id : undefined, ssnIsValid(payload === null || payload === void 0 ? void 0 : payload.ssn) ? payload === null || payload === void 0 ? void 0 : payload.ssn : undefined, payload === null || payload === void 0 ? void 0 : payload.drivingDistance);
|
|
5144
5163
|
const onChangeSsn = useCallback((e) => setForm({ ...form, ssn: e.currentTarget.value }), [form]);
|
|
5145
5164
|
const onChangeDrivingDistance = useCallback((e) => setForm({ ...form, drivingDistance: e.currentTarget.value }), [form]);
|
|
5146
5165
|
const onShowInsurances = useCallback(() => {
|
|
@@ -5214,14 +5233,14 @@ const InsuranceOptionModal = ({ id, onClose, insuranceOptions }) => {
|
|
|
5214
5233
|
addon.unit)))))))))))))))));
|
|
5215
5234
|
};
|
|
5216
5235
|
|
|
5217
|
-
const
|
|
5236
|
+
const Insurance = ({ id, branch, insuranceOptions }) => {
|
|
5218
5237
|
const [modal, setModal] = useState(false);
|
|
5219
5238
|
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
5220
5239
|
if (!insuranceOptions.length) {
|
|
5221
5240
|
return null;
|
|
5222
5241
|
}
|
|
5223
5242
|
return (React__default.createElement(React__default.Fragment, null,
|
|
5224
|
-
modal && (React__default.createElement(
|
|
5243
|
+
modal && (React__default.createElement(InsuranceModal, { id: id, branch: branch, onClose: toggleModal, insuranceOptions: insuranceOptions[0] })),
|
|
5225
5244
|
React__default.createElement(Repeat, null,
|
|
5226
5245
|
React__default.createElement(RepeatTiny, null,
|
|
5227
5246
|
React__default.createElement(VisualHeading, null, "V\u00E4lj till f\u00F6rs\u00E4kring")),
|
|
@@ -5233,6 +5252,53 @@ const InsuranceOptions = ({ id, insuranceOptions }) => {
|
|
|
5233
5252
|
React__default.createElement(ButtonInline, { onClick: toggleModal }, "Mer information")))))))))));
|
|
5234
5253
|
};
|
|
5235
5254
|
|
|
5255
|
+
const InsuranceFreeModal = ({ onClose, insuranceOptions }) => {
|
|
5256
|
+
var _a;
|
|
5257
|
+
return (React__default.createElement(Modal, { title: (_a = insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.insuranceHeader) !== null && _a !== void 0 ? _a : 'Försäkring', onClose: onClose },
|
|
5258
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && (React__default.createElement(Repeat, null,
|
|
5259
|
+
React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
|
|
5260
|
+
__html: marked(insuranceOptions.longDescription),
|
|
5261
|
+
} }))),
|
|
5262
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.url) && (React__default.createElement(Repeat, null,
|
|
5263
|
+
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
|
+
(insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype) && (React__default.createElement(Repeat, null,
|
|
5265
|
+
React__default.createElement(LogoBox, { logo: insuranceOptions.logotype, alt: insuranceOptions.name || 'Logotyp', wide: true })))));
|
|
5266
|
+
};
|
|
5267
|
+
|
|
5268
|
+
const Insurance$1 = ({ insuranceOptions }) => {
|
|
5269
|
+
var _a, _b;
|
|
5270
|
+
const [modal, setModal] = useState(false);
|
|
5271
|
+
const toggleModal = useCallback(() => setModal(!modal), [modal]);
|
|
5272
|
+
if (!insuranceOptions.length) {
|
|
5273
|
+
return null;
|
|
5274
|
+
}
|
|
5275
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
5276
|
+
modal && React__default.createElement(InsuranceFreeModal, { onClose: toggleModal, insuranceOptions: insuranceOptions[0] }),
|
|
5277
|
+
React__default.createElement(Repeat, null,
|
|
5278
|
+
React__default.createElement(RepeatTiny, null,
|
|
5279
|
+
React__default.createElement(VisualHeading, null, (_b = (_a = insuranceOptions[0]) === null || _a === void 0 ? void 0 : _a.insuranceHeader) !== null && _b !== void 0 ? _b : 'Försäkring')),
|
|
5280
|
+
React__default.createElement(RepeatTiny, null,
|
|
5281
|
+
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
|
+
insuranceOption.description && (React__default.createElement(Content$2, { dangerouslySetInnerHTML: {
|
|
5283
|
+
__html: marked(insuranceOption.description),
|
|
5284
|
+
} })),
|
|
5285
|
+
React__default.createElement(OptionBoxContent, null,
|
|
5286
|
+
React__default.createElement("p", null,
|
|
5287
|
+
React__default.createElement(ButtonInline, { onClick: toggleModal }, "Mer information")))))))))));
|
|
5288
|
+
};
|
|
5289
|
+
|
|
5290
|
+
const InsuranceOptions = ({ id, branch, insuranceOptions }) => {
|
|
5291
|
+
if (!insuranceOptions.length) {
|
|
5292
|
+
return null;
|
|
5293
|
+
}
|
|
5294
|
+
if (insuranceOptions.length > 0) {
|
|
5295
|
+
if (insuranceOptions[0].requiresDistance && insuranceOptions[0].requiresPersonalNumber)
|
|
5296
|
+
return React__default.createElement(Insurance, { id: id, branch: branch, insuranceOptions: insuranceOptions });
|
|
5297
|
+
return React__default.createElement(Insurance$1, { insuranceOptions: insuranceOptions });
|
|
5298
|
+
}
|
|
5299
|
+
return null;
|
|
5300
|
+
};
|
|
5301
|
+
|
|
5236
5302
|
const SettingsContext = createContext({});
|
|
5237
5303
|
|
|
5238
5304
|
const useSettings = () => useContext(SettingsContext);
|
|
@@ -6163,6 +6229,20 @@ const SEARCH_ITEM_BRANCH_QUERY = gql `
|
|
|
6163
6229
|
title
|
|
6164
6230
|
}
|
|
6165
6231
|
}
|
|
6232
|
+
insuranceOptions {
|
|
6233
|
+
insuranceHeader
|
|
6234
|
+
institute
|
|
6235
|
+
identifier
|
|
6236
|
+
logotype
|
|
6237
|
+
name
|
|
6238
|
+
description
|
|
6239
|
+
longDescription
|
|
6240
|
+
url
|
|
6241
|
+
insuranceText
|
|
6242
|
+
requiresPersonalNumber
|
|
6243
|
+
requiresDistance
|
|
6244
|
+
terms
|
|
6245
|
+
}
|
|
6166
6246
|
}
|
|
6167
6247
|
}
|
|
6168
6248
|
${HoursOpen$1}
|
|
@@ -7040,7 +7120,10 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7040
7120
|
const { vehicle } = result;
|
|
7041
7121
|
const contact = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact;
|
|
7042
7122
|
const branch = centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch;
|
|
7043
|
-
const { title, shortDescription, media, description, price, financialOptions,
|
|
7123
|
+
const { title, shortDescription, media, description, price, financialOptions, manufacturer, ecommerce, packageOptions, publishedAt, documents, } = vehicle;
|
|
7124
|
+
const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions)
|
|
7125
|
+
? centralStorageVehicle.insuranceOptions
|
|
7126
|
+
: vehicle.insuranceOptions;
|
|
7044
7127
|
const { fuelType, mileage, gearbox, modelYear, propertySet } = vehicle.data;
|
|
7045
7128
|
const uspList = [
|
|
7046
7129
|
{
|
|
@@ -7083,7 +7166,7 @@ const WaykeSearchItem = ({ id, hashRoute, pathRoute, disableResetScrollOnInit, p
|
|
|
7083
7166
|
React__default.createElement(PriceTable, { price: price })),
|
|
7084
7167
|
(financialOptions.length > 0 || insuranceOptions.length > 0) && (React__default.createElement(ProductPageAsideSection, { mobileOrder: 4 },
|
|
7085
7168
|
financialOptions.length > 0 && (React__default.createElement(FinancialOptions, { id: id, financialOptions: financialOptions })),
|
|
7086
|
-
insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, insuranceOptions: insuranceOptions })))),
|
|
7169
|
+
insuranceOptions.length > 0 && (React__default.createElement(InsuranceOptions, { id: id, branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch, insuranceOptions: insuranceOptions })))),
|
|
7087
7170
|
React__default.createElement(ProductPageAsideSection, { mobileOrder: 5 },
|
|
7088
7171
|
React__default.createElement(CheckList, { manufacturer: manufacturer, packageOptions: packageOptions, ecommerce: ecommerce, branch: branch, contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact, loadingCentralStorageVehicle: loadingCentralStorageVehicle, toggleEcomModal: toggleEcomModal }))),
|
|
7089
7172
|
React__default.createElement(ProductPageMain, null,
|