@wayke-se/components-react 2.13.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.
Files changed (29) hide show
  1. package/dist-node/index.js +171 -15
  2. package/dist-node/index.js.map +1 -1
  3. package/dist-src/components/Content/wrapper.js +5 -0
  4. package/dist-src/components/InsuranceOptions/Insurance.js +26 -0
  5. package/dist-src/components/InsuranceOptions/InsuranceFree.js +31 -0
  6. package/dist-src/components/InsuranceOptions/InsuranceFreeModal.js +20 -0
  7. package/dist-src/components/InsuranceOptions/{InsuranceOptionModal.js → InsuranceModal.js} +3 -3
  8. package/dist-src/components/InsuranceOptions/index.js +10 -21
  9. package/dist-src/components/Pdf/index.js +11 -0
  10. package/dist-src/components/Pdf/wrapper.js +55 -0
  11. package/dist-src/hooks/useInsurance.js +3 -2
  12. package/dist-src/layouts/searchItem/MetadataItem.js +2 -2
  13. package/dist-src/layouts/searchItem/index.js +14 -2
  14. package/dist-src/queries/INSURANCE_CALCULATION.js +7 -1
  15. package/dist-src/queries/SEARCH_ITEM_BRANCH_QUERY.js +14 -0
  16. package/dist-src/queries/SEARCH_ITEM_QUERY.js +10 -2
  17. package/dist-types/@types/codegen/types.d.ts +66 -42
  18. package/dist-types/components/InsuranceOptions/Insurance.d.ts +9 -0
  19. package/dist-types/components/InsuranceOptions/InsuranceFree.d.ts +7 -0
  20. package/dist-types/components/InsuranceOptions/InsuranceFreeModal.d.ts +8 -0
  21. package/dist-types/components/InsuranceOptions/InsuranceModal.d.ts +10 -0
  22. package/dist-types/components/InsuranceOptions/index.d.ts +3 -2
  23. package/dist-types/components/Pdf/index.d.ts +11 -0
  24. package/dist-types/components/Pdf/wrapper.d.ts +11 -0
  25. package/dist-types/hooks/useInsurance.d.ts +1 -1
  26. package/dist-web/index.js +168 -13
  27. package/dist-web/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist-types/components/InsuranceOptions/InsuranceOptionModal.d.ts +0 -9
@@ -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
 
@@ -3370,6 +3370,7 @@ const SEARCH_ITEM_QUERY = client.gql`
3370
3370
  query SearchItem($id: ID!) {
3371
3371
  vehicle(id: $id) {
3372
3372
  id
3373
+ documents
3373
3374
  contact {
3374
3375
  name
3375
3376
  email
@@ -3509,10 +3510,17 @@ const SEARCH_ITEM_QUERY = client.gql`
3509
3510
  withHomeDelivery
3510
3511
  }
3511
3512
  insuranceOptions {
3512
- description
3513
+ insuranceHeader
3514
+ institute
3515
+ identifier
3513
3516
  logotype
3514
- url
3515
3517
  name
3518
+ description
3519
+ longDescription
3520
+ url
3521
+ insuranceText
3522
+ requiresPersonalNumber
3523
+ requiresDistance
3516
3524
  terms
3517
3525
  }
3518
3526
  financialOptions {
@@ -4231,10 +4239,16 @@ const ColumnRowItem = styled__default.div.withConfig({
4231
4239
  const INSURANCE_CALCULATION = client.gql`
4232
4240
  query InsuranceCalculation(
4233
4241
  $id: ID!
4242
+ $branch: ID
4234
4243
  $personalNumber: PersonalNumber!
4235
4244
  $drivingDistance: DrivingDistance!
4236
4245
  ) {
4237
- insurances(id: $id, personalNumber: $personalNumber, drivingDistance: $drivingDistance) {
4246
+ insurances(
4247
+ id: $id
4248
+ branch: $branch
4249
+ personalNumber: $personalNumber
4250
+ drivingDistance: $drivingDistance
4251
+ ) {
4238
4252
  name
4239
4253
  price
4240
4254
  unit
@@ -4262,13 +4276,14 @@ const INSURANCE_CALCULATION = client.gql`
4262
4276
  }
4263
4277
  `;
4264
4278
 
4265
- const useInsuranceCalculation = (id, personalNumber, drivingDistance) => client.useQuery(INSURANCE_CALCULATION, {
4279
+ const useInsuranceCalculation = (id, branchId, personalNumber, drivingDistance) => client.useQuery(INSURANCE_CALCULATION, {
4266
4280
  variables: {
4267
4281
  id,
4282
+ branch: branchId,
4268
4283
  personalNumber: personalNumber,
4269
4284
  drivingDistance: drivingDistance
4270
4285
  },
4271
- skip: personalNumber === undefined || drivingDistance === undefined
4286
+ skip: personalNumber === undefined || drivingDistance === undefined || branchId === undefined
4272
4287
  });
4273
4288
 
4274
4289
  const ssnIsValid = s => s ? /^\d{2,4}\d{2}\d{2}\-?\d{4}$/.test(s) : false;
@@ -4291,8 +4306,9 @@ var FinancialOptionInclusion;
4291
4306
  FinancialOptionInclusion["IncludesWintertires"] = "INCLUDES_WINTERTIRES";
4292
4307
  })(FinancialOptionInclusion || (FinancialOptionInclusion = {}));
4293
4308
 
4294
- const InsuranceOptionModal = ({
4309
+ const InsuranceModal = ({
4295
4310
  id,
4311
+ branch,
4296
4312
  onClose,
4297
4313
  insuranceOptions
4298
4314
  }) => {
@@ -4305,7 +4321,7 @@ const InsuranceOptionModal = ({
4305
4321
  loading,
4306
4322
  data,
4307
4323
  error
4308
- } = 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);
4309
4325
  const onChangeSsn = React.useCallback(e => setForm(_objectSpread2(_objectSpread2({}, form), {}, {
4310
4326
  ssn: e.currentTarget.value
4311
4327
  })), [form]);
@@ -4392,8 +4408,9 @@ const InsuranceOptionModal = ({
4392
4408
  }, addon.description)), React__default.createElement(ColumnRowItem, null, React__default.createElement(UtilityTextBold, null, "+", addon.price, " ", addon.unit))))))))))));
4393
4409
  };
4394
4410
 
4395
- const InsuranceOptions = ({
4411
+ const Insurance = ({
4396
4412
  id,
4413
+ branch,
4397
4414
  insuranceOptions
4398
4415
  }) => {
4399
4416
  const [modal, setModal] = React.useState(false);
@@ -4403,8 +4420,9 @@ const InsuranceOptions = ({
4403
4420
  return null;
4404
4421
  }
4405
4422
 
4406
- 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, {
4407
4424
  id: id,
4425
+ branch: branch,
4408
4426
  onClose: toggleModal,
4409
4427
  insuranceOptions: insuranceOptions[0]
4410
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, {
@@ -4416,6 +4434,82 @@ const InsuranceOptions = ({
4416
4434
  }, "Mer information")))))))));
4417
4435
  };
4418
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
+
4419
4513
  const SettingsContext = React.createContext({});
4420
4514
 
4421
4515
  const useSettings = () => React.useContext(SettingsContext);
@@ -5315,6 +5409,20 @@ const SEARCH_ITEM_BRANCH_QUERY = client.gql`
5315
5409
  title
5316
5410
  }
5317
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
+ }
5318
5426
  }
5319
5427
  }
5320
5428
  ${HoursOpen$1}
@@ -5982,7 +6090,7 @@ const MetadataItem = ({
5982
6090
  const [foldout, setFoldout] = React.useState(false);
5983
6091
  const onToggleFoldout = React.useCallback(() => setFoldout(!foldout), [foldout]);
5984
6092
  const presentedValue = formatValue(value, unit);
5985
- return React__default.createElement(TableListItem, null, React__default.createElement(TableListKey, null, hint ? React__default.createElement(ButtonInlinePrimary, {
6093
+ return React__default.createElement(TableListItem, null, React__default.createElement(TableListKey, null, hint ? React__default.createElement(ButtonInline, {
5986
6094
  onClick: onToggleFoldout,
5987
6095
  title: `Mer information om ${name}`
5988
6096
  }, name) : name), React__default.createElement(TableListValue, null, value !== undefined ? presentedValue : 'Uppgift saknas'), hint && foldout && React__default.createElement(Modal, {
@@ -6096,6 +6204,48 @@ const PropertySet = ({
6096
6204
  })));
6097
6205
  };
6098
6206
 
6207
+ const PdfListItem = styled__default.li.attrs(() => ({
6208
+ className: 'wayke__theme wayke__color--primary-text'
6209
+ })).withConfig({
6210
+ displayName: "wrapper__PdfListItem"
6211
+ })(["flex:0 0 50%;padding:", ";", "{flex:0 0 100%;}"], size(1), ({
6212
+ theme
6213
+ }) => theme.breakpoint.LtSm);
6214
+ const PdfContainer = styled__default.ul.withConfig({
6215
+ displayName: "wrapper__PdfContainer"
6216
+ })(["list-style:none;padding:0;display:flex;flex-wrap:wrap;margin:", ";"], size(-1));
6217
+ const PdfLink = styled__default.a.attrs(() => ({
6218
+ className: 'wayke__theme wayke__color--primary-text wayke__font--bold'
6219
+ })).withConfig({
6220
+ displayName: "wrapper__PdfLink"
6221
+ })(["text-decoration:none;font-size:0.875rem;&:after{content:'';position:absolute;top:0;left:0;width:100%;height:100%;}"]);
6222
+ const PdfTitle = styled__default.div.withConfig({
6223
+ displayName: "wrapper__PdfTitle"
6224
+ })(["color:", ";"], props => props.theme.color.textDark);
6225
+ const PdfSubtitle = styled__default.div.withConfig({
6226
+ displayName: "wrapper__PdfSubtitle"
6227
+ })(["color:", ";"], props => props.theme.color.textDarkLighten);
6228
+ const PdfColumn = styled__default.div.withConfig({
6229
+ displayName: "wrapper__PdfColumn"
6230
+ })(["flex 0 0 auto;&:first-child{flex:1 1 auto;}"]);
6231
+ const PdfListInner = styled__default.div.withConfig({
6232
+ displayName: "wrapper__PdfListInner"
6233
+ })(["position:relative;border:1px solid ", ";padding:", ";display:flex;align-items:center;:hover{background-color:", ";}"], props => props.theme.color.border, size(1.5), props => props.theme.color.hoverOverlay);
6234
+
6235
+ const PdfDownloadItem = ({
6236
+ document
6237
+ }) => React__default.createElement(PdfListItem, null, React__default.createElement(PdfListInner, null, React__default.createElement(PdfColumn, null, React__default.createElement(PdfTitle, null, document.name), React__default.createElement(PdfSubtitle, null, document.contentType)), React__default.createElement(PdfColumn, null, React__default.createElement(PdfLink, {
6238
+ href: document.url,
6239
+ rel: "noopener noreferrer nofollow",
6240
+ target: "_blank"
6241
+ }, "\u00D6ppna"))));
6242
+ const PdfDownloadContainer = ({
6243
+ documents
6244
+ }) => React__default.createElement(PdfContainer, null, documents.map((document, i) => React__default.createElement(PdfDownloadItem, {
6245
+ key: `${document.url}-${i}`,
6246
+ document: document
6247
+ })));
6248
+
6099
6249
  const WaykeSearchItem = ({
6100
6250
  id,
6101
6251
  hashRoute,
@@ -6164,12 +6314,13 @@ const WaykeSearchItem = ({
6164
6314
  description,
6165
6315
  price,
6166
6316
  financialOptions,
6167
- insuranceOptions,
6168
6317
  manufacturer,
6169
6318
  ecommerce,
6170
6319
  packageOptions,
6171
- publishedAt
6320
+ publishedAt,
6321
+ documents
6172
6322
  } = vehicle;
6323
+ const insuranceOptions = (centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.insuranceOptions) ? centralStorageVehicle.insuranceOptions : vehicle.insuranceOptions;
6173
6324
  const {
6174
6325
  fuelType,
6175
6326
  mileage,
@@ -6228,6 +6379,7 @@ const WaykeSearchItem = ({
6228
6379
  financialOptions: financialOptions
6229
6380
  }), insuranceOptions.length > 0 && React__default.createElement(InsuranceOptions, {
6230
6381
  id: id,
6382
+ branch: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.branch,
6231
6383
  insuranceOptions: insuranceOptions
6232
6384
  })), React__default.createElement(ProductPageAsideSection, {
6233
6385
  mobileOrder: 5
@@ -6260,7 +6412,11 @@ const WaykeSearchItem = ({
6260
6412
  onClick: onShowMoreOptionsClick
6261
6413
  }, React__default.createElement(UspList, {
6262
6414
  items: options
6263
- })))), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
6415
+ })))), (documents.length || 0) > 0 && React__default.createElement(ProductPageMainSection, null, React__default.createElement(Repeat, null, React__default.createElement(H2, {
6416
+ noMargin: true
6417
+ }, "Dokument")), React__default.createElement(Repeat, null, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Tillh\u00F6rande dokument f\u00F6r bilen."))), React__default.createElement(Repeat, null, React__default.createElement(PdfDownloadContainer, {
6418
+ documents: documents
6419
+ }))), React__default.createElement(ProductPageMainSection, null, React__default.createElement(Branch, {
6264
6420
  branch: branch,
6265
6421
  loading: loadingCentralStorageVehicle
6266
6422
  }), ecommerce && ecommerce.enabled && React__default.createElement(Repeat, null, React__default.createElement(ButtonPrimary, {