@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.
@@ -16,8 +16,8 @@ var LazyLoad = _interopDefault(require('react-lazyload'));
16
16
  var Slider$1 = _interopDefault(require('react-slick'));
17
17
  var scrollIntoView = _interopDefault(require('scroll-into-view-if-needed'));
18
18
  var client = require('@apollo/client');
19
- var EcomBase = _interopDefault(require('@wayke-se/ecom-react'));
20
19
  var marked = require('marked');
20
+ var EcomBase = _interopDefault(require('@wayke-se/ecom-react'));
21
21
  var core = require('libphonenumber-js/core');
22
22
 
23
23
  const _colors = {
@@ -2229,7 +2229,7 @@ const LogoBox = ({
2229
2229
 
2230
2230
  const Wrapper$c = styled__default.div.withConfig({
2231
2231
  displayName: "wrapper__Wrapper"
2232
- })(["font-size:1rem;line-height:1.5;h1,h2,h3,h4,h5,h6{margin-top:", ";margin-bottom:", ";:first-child{margin-top:0;}:last-child{margin-bottom:0;}& + p,& + table{margin-top:", ";}}p{margin:", " 0;:first-child{margin-top:0;}:last-child{margin-bottom:0;}}", ""], size(4), size(1), size(1), size(2), ({
2232
+ })(["font-size:1rem;line-height:1.5;h1,h2,h3,h4,h5,h6{margin-top:", ";margin-bottom:", ";:first-child{margin-top:0;}:last-child{margin-bottom:0;}& + p,& + table{margin-top:", ";}}p{margin:", " 0;:first-child{margin-top:0;}:last-child{margin-bottom:0;}}img{display:block;width:100%;}", ""], size(4), size(1), size(1), size(2), ({
2233
2233
  small
2234
2234
  }) => small && styled.css(["font-size:0.875rem;"]));
2235
2235
 
@@ -3510,10 +3510,17 @@ const SEARCH_ITEM_QUERY = client.gql`
3510
3510
  withHomeDelivery
3511
3511
  }
3512
3512
  insuranceOptions {
3513
- description
3513
+ insuranceHeader
3514
+ institute
3515
+ identifier
3514
3516
  logotype
3515
- url
3516
3517
  name
3518
+ description
3519
+ longDescription
3520
+ url
3521
+ insuranceText
3522
+ requiresPersonalNumber
3523
+ requiresDistance
3517
3524
  terms
3518
3525
  }
3519
3526
  financialOptions {
@@ -4232,10 +4239,16 @@ const ColumnRowItem = styled__default.div.withConfig({
4232
4239
  const INSURANCE_CALCULATION = client.gql`
4233
4240
  query InsuranceCalculation(
4234
4241
  $id: ID!
4242
+ $branch: ID
4235
4243
  $personalNumber: PersonalNumber!
4236
4244
  $drivingDistance: DrivingDistance!
4237
4245
  ) {
4238
- insurances(id: $id, personalNumber: $personalNumber, drivingDistance: $drivingDistance) {
4246
+ insurances(
4247
+ id: $id
4248
+ branch: $branch
4249
+ personalNumber: $personalNumber
4250
+ drivingDistance: $drivingDistance
4251
+ ) {
4239
4252
  name
4240
4253
  price
4241
4254
  unit
@@ -4263,13 +4276,14 @@ const INSURANCE_CALCULATION = client.gql`
4263
4276
  }
4264
4277
  `;
4265
4278
 
4266
- const useInsuranceCalculation = (id, personalNumber, drivingDistance) => client.useQuery(INSURANCE_CALCULATION, {
4279
+ const useInsuranceCalculation = (id, branchId, personalNumber, drivingDistance) => client.useQuery(INSURANCE_CALCULATION, {
4267
4280
  variables: {
4268
4281
  id,
4282
+ branch: branchId,
4269
4283
  personalNumber: personalNumber,
4270
4284
  drivingDistance: drivingDistance
4271
4285
  },
4272
- skip: personalNumber === undefined || drivingDistance === undefined
4286
+ skip: personalNumber === undefined || drivingDistance === undefined || branchId === undefined
4273
4287
  });
4274
4288
 
4275
4289
  const ssnIsValid = s => s ? /^\d{2,4}\d{2}\d{2}\-?\d{4}$/.test(s) : false;
@@ -4292,8 +4306,9 @@ var FinancialOptionInclusion;
4292
4306
  FinancialOptionInclusion["IncludesWintertires"] = "INCLUDES_WINTERTIRES";
4293
4307
  })(FinancialOptionInclusion || (FinancialOptionInclusion = {}));
4294
4308
 
4295
- const InsuranceOptionModal = ({
4309
+ const InsuranceModal = ({
4296
4310
  id,
4311
+ branch,
4297
4312
  onClose,
4298
4313
  insuranceOptions
4299
4314
  }) => {
@@ -4306,7 +4321,7 @@ const InsuranceOptionModal = ({
4306
4321
  loading,
4307
4322
  data,
4308
4323
  error
4309
- } = 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);
4324
+ } = 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);
4310
4325
  const onChangeSsn = React.useCallback(e => setForm(_objectSpread2(_objectSpread2({}, form), {}, {
4311
4326
  ssn: e.currentTarget.value
4312
4327
  })), [form]);
@@ -4393,8 +4408,9 @@ const InsuranceOptionModal = ({
4393
4408
  }, addon.description)), React__default.createElement(ColumnRowItem, null, React__default.createElement(UtilityTextBold, null, "+", addon.price, " ", addon.unit))))))))))));
4394
4409
  };
4395
4410
 
4396
- const InsuranceOptions = ({
4411
+ const Insurance = ({
4397
4412
  id,
4413
+ branch,
4398
4414
  insuranceOptions
4399
4415
  }) => {
4400
4416
  const [modal, setModal] = React.useState(false);
@@ -4404,8 +4420,9 @@ const InsuranceOptions = ({
4404
4420
  return null;
4405
4421
  }
4406
4422
 
4407
- return React__default.createElement(React__default.Fragment, null, modal && React__default.createElement(InsuranceOptionModal, {
4423
+ return React__default.createElement(React__default.Fragment, null, modal && React__default.createElement(InsuranceModal, {
4408
4424
  id: id,
4425
+ branch: branch,
4409
4426
  onClose: toggleModal,
4410
4427
  insuranceOptions: insuranceOptions[0]
4411
4428
  }), React__default.createElement(Repeat, null, React__default.createElement(RepeatTiny, null, React__default.createElement(VisualHeading, null, "V\u00E4lj till f\u00F6rs\u00E4kring")), React__default.createElement(RepeatTiny, null, React__default.createElement(React__default.Fragment, null, insuranceOptions.map((insuranceOption, index) => React__default.createElement(OptionBox, {
@@ -4417,6 +4434,82 @@ const InsuranceOptions = ({
4417
4434
  }, "Mer information")))))))));
4418
4435
  };
4419
4436
 
4437
+ const InsuranceFreeModal = ({
4438
+ onClose,
4439
+ insuranceOptions
4440
+ }) => {
4441
+ var _a;
4442
+
4443
+ return React__default.createElement(Modal, {
4444
+ title: (_a = insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.insuranceHeader) !== null && _a !== void 0 ? _a : 'Försäkring',
4445
+ onClose: onClose
4446
+ }, (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.longDescription) && React__default.createElement(Repeat, null, React__default.createElement(Content$2, {
4447
+ dangerouslySetInnerHTML: {
4448
+ __html: marked.marked(insuranceOptions.longDescription)
4449
+ }
4450
+ })), (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.url) && React__default.createElement(Repeat, null, React__default.createElement(ButtonInline, {
4451
+ as: "a",
4452
+ href: insuranceOptions.url,
4453
+ target: "_blank",
4454
+ rel: "noopener noreferrer"
4455
+ }, "L\u00E4s mer om f\u00F6rs\u00E4kringen (\u00D6ppnas i ett nytt f\u00F6nster)")), (insuranceOptions === null || insuranceOptions === void 0 ? void 0 : insuranceOptions.logotype) && React__default.createElement(Repeat, null, React__default.createElement(LogoBox, {
4456
+ logo: insuranceOptions.logotype,
4457
+ alt: insuranceOptions.name || 'Logotyp',
4458
+ wide: true
4459
+ })));
4460
+ };
4461
+
4462
+ const Insurance$1 = ({
4463
+ insuranceOptions
4464
+ }) => {
4465
+ var _a, _b;
4466
+
4467
+ const [modal, setModal] = React.useState(false);
4468
+ const toggleModal = React.useCallback(() => setModal(!modal), [modal]);
4469
+
4470
+ if (!insuranceOptions.length) {
4471
+ return null;
4472
+ }
4473
+
4474
+ return React__default.createElement(React__default.Fragment, null, modal && React__default.createElement(InsuranceFreeModal, {
4475
+ onClose: toggleModal,
4476
+ insuranceOptions: insuranceOptions[0]
4477
+ }), React__default.createElement(Repeat, null, React__default.createElement(RepeatTiny, null, 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')), React__default.createElement(RepeatTiny, null, React__default.createElement(React__default.Fragment, null, insuranceOptions.map((insuranceOption, index) => React__default.createElement(OptionBox, {
4478
+ key: `${insuranceOption.url}-${index}`,
4479
+ logo: insuranceOption.logotype || undefined,
4480
+ logoAlt: insuranceOption.name || 'Logotyp'
4481
+ }, insuranceOption.description && React__default.createElement(Content$2, {
4482
+ dangerouslySetInnerHTML: {
4483
+ __html: marked.marked(insuranceOption.description)
4484
+ }
4485
+ }), React__default.createElement(OptionBoxContent, null, React__default.createElement("p", null, React__default.createElement(ButtonInline, {
4486
+ onClick: toggleModal
4487
+ }, "Mer information")))))))));
4488
+ };
4489
+
4490
+ const InsuranceOptions = ({
4491
+ id,
4492
+ branch,
4493
+ insuranceOptions
4494
+ }) => {
4495
+ if (!insuranceOptions.length) {
4496
+ return null;
4497
+ }
4498
+
4499
+ if (insuranceOptions.length > 0) {
4500
+ if (insuranceOptions[0].requiresDistance && insuranceOptions[0].requiresPersonalNumber) return React__default.createElement(Insurance, {
4501
+ id: id,
4502
+ branch: branch,
4503
+ insuranceOptions: insuranceOptions
4504
+ });
4505
+ return React__default.createElement(Insurance$1, {
4506
+ insuranceOptions: insuranceOptions
4507
+ });
4508
+ }
4509
+
4510
+ return null;
4511
+ };
4512
+
4420
4513
  const SettingsContext = React.createContext({});
4421
4514
 
4422
4515
  const useSettings = () => React.useContext(SettingsContext);
@@ -5316,6 +5409,20 @@ const SEARCH_ITEM_BRANCH_QUERY = client.gql`
5316
5409
  title
5317
5410
  }
5318
5411
  }
5412
+ insuranceOptions {
5413
+ insuranceHeader
5414
+ institute
5415
+ identifier
5416
+ logotype
5417
+ name
5418
+ description
5419
+ longDescription
5420
+ url
5421
+ insuranceText
5422
+ requiresPersonalNumber
5423
+ requiresDistance
5424
+ terms
5425
+ }
5319
5426
  }
5320
5427
  }
5321
5428
  ${HoursOpen$1}
@@ -6207,13 +6314,13 @@ const WaykeSearchItem = ({
6207
6314
  description,
6208
6315
  price,
6209
6316
  financialOptions,
6210
- insuranceOptions,
6211
6317
  manufacturer,
6212
6318
  ecommerce,
6213
6319
  packageOptions,
6214
6320
  publishedAt,
6215
6321
  documents
6216
6322
  } = vehicle;
6323
+ const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions) ? centralStorageVehicle.insuranceOptions : vehicle.insuranceOptions;
6217
6324
  const {
6218
6325
  fuelType,
6219
6326
  mileage,
@@ -6272,6 +6379,7 @@ const WaykeSearchItem = ({
6272
6379
  financialOptions: financialOptions
6273
6380
  }), insuranceOptions.length > 0 && React__default.createElement(InsuranceOptions, {
6274
6381
  id: id,
6382
+ branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch,
6275
6383
  insuranceOptions: insuranceOptions
6276
6384
  })), React__default.createElement(ProductPageAsideSection, {
6277
6385
  mobileOrder: 5