@wayke-se/components-react 3.1.0 → 3.3.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.
@@ -19,6 +19,8 @@ var scrollIntoView = _interopDefault(require('scroll-into-view-if-needed'));
19
19
  var client = require('@apollo/client');
20
20
  var marked = require('marked');
21
21
  var core = require('libphonenumber-js/core');
22
+ var esm = require('date-fns/esm');
23
+ var sv = _interopDefault(require('date-fns/locale/sv'));
22
24
 
23
25
  const _colors = {
24
26
  black: '#000',
@@ -35,6 +37,7 @@ const _colors = {
35
37
  redLight: '#ffd0d0',
36
38
  red: '#c71f1f',
37
39
  yellowLight: '#fff4c7',
40
+ yellow: '#ffc700',
38
41
  blueLight: '#daf7fc'
39
42
  }
40
43
  };
@@ -57,6 +60,7 @@ const theme = {
57
60
  positiveLight: _colors.ui.greenLight,
58
61
  positive: _colors.ui.green,
59
62
  neutralLight: _colors.ui.yellowLight,
63
+ neutral: _colors.ui.yellow,
60
64
  negativeLight: _colors.ui.redLight,
61
65
  negative: _colors.ui.red,
62
66
  infoLight: _colors.ui.blueLight
@@ -3125,8 +3129,8 @@ const OldPrice$1 = styled__default.div`
3125
3129
 
3126
3130
  const PriceTable = ({
3127
3131
  price,
3128
- oldPrice
3129
- }) => React__default.createElement(List$6, null, React__default.createElement(Item$6, null, React__default.createElement(Label$5, null, React__default.createElement(VisualHeading, null, "Pris")), React__default.createElement(Value, null, React__default.createElement(Price$1, null, numberSeparator(price), " kr"))), oldPrice !== undefined && React__default.createElement(Item$6, null, React__default.createElement(Label$5, null), React__default.createElement(Value, null, React__default.createElement(OldPrice$1, null, numberSeparator(oldPrice), " kr"))));
3132
+ discount
3133
+ }) => React__default.createElement(List$6, null, React__default.createElement(Item$6, null, React__default.createElement(Label$5, null, React__default.createElement(VisualHeading, null, "Pris")), React__default.createElement(Value, null, React__default.createElement(Price$1, null, numberSeparator(price), " kr"))), discount !== undefined && React__default.createElement(Item$6, null, React__default.createElement(Label$5, null), React__default.createElement(Value, null, React__default.createElement(OldPrice$1, null, numberSeparator(price + discount), " kr"))));
3130
3134
 
3131
3135
  const Logo = styled__default.img`
3132
3136
  display: block;
@@ -5286,8 +5290,13 @@ const SEARCH_ITEM_QUERY = client.gql`
5286
5290
  postalCode
5287
5291
  }
5288
5292
  price
5293
+ discount
5289
5294
  shortDescription
5290
5295
  title
5296
+ availableFrom
5297
+ flags {
5298
+ demoVersion
5299
+ }
5291
5300
  }
5292
5301
  }
5293
5302
  ${HoursOpen}
@@ -6590,6 +6599,102 @@ const ActionList = ({
6590
6599
  }));
6591
6600
  };
6592
6601
 
6602
+ const Column = styled__default.div`
6603
+ flex: 0 1 auto;
6604
+
6605
+ ${({
6606
+ grow
6607
+ }) => grow && styled.css`
6608
+ flex-grow: 1;
6609
+ `}
6610
+
6611
+ ${({
6612
+ noShrink
6613
+ }) => noShrink && styled.css`
6614
+ flex-shrink: 0;
6615
+ `}
6616
+ `;
6617
+ const Columns = styled__default.div`
6618
+ display: flex;
6619
+ align-items: flex-start;
6620
+
6621
+ ${({
6622
+ valign
6623
+ }) => valign === 'end' ? styled.css`
6624
+ align-items: flex-end;
6625
+ ` : valign === 'center' ? styled.css`
6626
+ align-items: center;
6627
+ ` : styled.css`
6628
+ align-items: flex-start;
6629
+ `}
6630
+
6631
+ ${({
6632
+ align
6633
+ }) => align === 'end' ? styled.css`
6634
+ justify-content: flex-end;
6635
+ ` : align === 'center' ? styled.css`
6636
+ justify-content: center;
6637
+ ` : styled.css`
6638
+ justify-content: flex-start;
6639
+ `}
6640
+
6641
+ ${({
6642
+ $spacing
6643
+ }) => $spacing && styled.css`
6644
+ margin: ${size($spacing / -2)};
6645
+
6646
+ & > ${Column} {
6647
+ padding: ${size($spacing / 2)};
6648
+ }
6649
+ `}
6650
+
6651
+ ${({
6652
+ flexWrap
6653
+ }) => flexWrap && styled.css`
6654
+ flex-wrap: wrap;
6655
+ `}
6656
+
6657
+ ${({
6658
+ flexInline
6659
+ }) => flexInline && styled.css`
6660
+ display: inline-flex;
6661
+ `}
6662
+
6663
+ ${({
6664
+ clearLtSm
6665
+ }) => clearLtSm && styled.css`
6666
+ ${props => props.theme.breakpoint.LtSm} {
6667
+ display: block;
6668
+ }
6669
+ `}
6670
+
6671
+ ${({
6672
+ clearLtMd
6673
+ }) => clearLtMd && styled.css`
6674
+ ${props => props.theme.breakpoint.LtMd} {
6675
+ display: block;
6676
+ }
6677
+ `}
6678
+ `;
6679
+
6680
+ const StateIndicator = styled__default.div`
6681
+ width: ${size(1)};
6682
+ height: ${size(1)};
6683
+ border-radius: 50%;
6684
+
6685
+ ${({
6686
+ $tone
6687
+ }) => $tone === 'success' ? styled.css`
6688
+ background-color: ${props => props.theme.color.ui.positive};
6689
+ ` : $tone === 'pending' ? styled.css`
6690
+ background-color: ${props => props.theme.color.ui.neutral};
6691
+ ` : $tone === 'error' ? styled.css`
6692
+ background-color: ${props => props.theme.color.ui.negative};
6693
+ ` : styled.css`
6694
+ background-color: ${props => props.theme.color.textDarkLighten};
6695
+ `}
6696
+ `;
6697
+
6593
6698
  const List$8 = styled__default.ul`
6594
6699
  list-style: none;
6595
6700
  padding: 0;
@@ -6791,6 +6896,7 @@ const CheckList = ({
6791
6896
  ecommerce,
6792
6897
  branch,
6793
6898
  contact,
6899
+ availableFrom,
6794
6900
  toggleEcomModal,
6795
6901
  loadingCentralStorageVehicle
6796
6902
  }) => {
@@ -6813,7 +6919,26 @@ const CheckList = ({
6813
6919
  }), modal && React__default.createElement(PackageOptionModal, {
6814
6920
  packageOption: modal,
6815
6921
  onClose: onClose
6816
- }), React__default.createElement(Repeat, null, React__default.createElement(CheckMarkList, null, (packageOption === null || packageOption === void 0 ? void 0 : packageOption.title) && React__default.createElement(CheckMarkListItem, null, React__default.createElement(React__default.Fragment, null, "Inkl.", ' ', React__default.createElement(ButtonInline, {
6922
+ }), React__default.createElement(Repeat, null, ecommerce && ecommerce.enabled && React__default.createElement(RepeatTiny, null, React__default.createElement(ButtonPrimary, {
6923
+ disabled: !!ecommerce.reserved,
6924
+ fullWidth: true,
6925
+ onClick: toggleEcomModal
6926
+ }, React__default.createElement(ButtonContent, null, "K\u00F6p bilen online"))), (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.reserved) && React__default.createElement(RepeatTiny, null, React__default.createElement(SwitchBar, {
6927
+ title: "Bilen \u00E4r reserverad",
6928
+ body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare."
6929
+ }, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare.")))), React__default.createElement(ActionList, {
6930
+ branch: branch,
6931
+ contact: contact
6932
+ })), React__default.createElement(Repeat, null, availableFrom && new Date(availableFrom).valueOf() > new Date().valueOf() && React__default.createElement(RepeatTiny, null, React__default.createElement(Columns, {
6933
+ "$spacing": 1,
6934
+ valign: "center"
6935
+ }, React__default.createElement(Column, {
6936
+ noShrink: true
6937
+ }, React__default.createElement(StateIndicator, {
6938
+ "$tone": "pending"
6939
+ })), React__default.createElement(Column, null, React__default.createElement(UtilityFontSizeSmall, null, "Tillg\u00E4nglig fr\u00E5n ", esm.format(new Date(availableFrom), 'dd MMMM yyyy', {
6940
+ locale: sv
6941
+ }))))), React__default.createElement(RepeatTiny, null, React__default.createElement(CheckMarkList, null, (packageOption === null || packageOption === void 0 ? void 0 : packageOption.title) && React__default.createElement(CheckMarkListItem, null, React__default.createElement(React__default.Fragment, null, "Inkl.", ' ', React__default.createElement(ButtonInline, {
6817
6942
  onClick: () => onOpen({
6818
6943
  title: packageOption === null || packageOption === void 0 ? void 0 : packageOption.title,
6819
6944
  image: packageOption === null || packageOption === void 0 ? void 0 : packageOption.image,
@@ -6829,17 +6954,7 @@ const CheckList = ({
6829
6954
  description: packageOption === null || packageOption === void 0 ? void 0 : packageOption.description,
6830
6955
  link: packageOption === null || packageOption === void 0 ? void 0 : packageOption.link
6831
6956
  })
6832
- }, packageOption.title)))), (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.withHomeDelivery) && React__default.createElement(CheckMarkListItem, null, "Hemleverans"))), React__default.createElement(Repeat, null, ecommerce && ecommerce.enabled && React__default.createElement(RepeatTiny, null, React__default.createElement(ButtonPrimary, {
6833
- disabled: !!ecommerce.reserved,
6834
- fullWidth: true,
6835
- onClick: toggleEcomModal
6836
- }, React__default.createElement(ButtonContent, null, "K\u00F6p bilen online"))), (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.reserved) && React__default.createElement(RepeatTiny, null, React__default.createElement(SwitchBar, {
6837
- title: "Bilen \u00E4r reserverad",
6838
- body: "Denna bil \u00E4r reserverad av en annan k\u00F6pare."
6839
- }, React__default.createElement(Content$2, null, React__default.createElement("p", null, "Denna bil \u00E4r reserverad av en annan k\u00F6pare.")))), React__default.createElement(ActionList, {
6840
- branch: branch,
6841
- contact: contact
6842
- })), ((branch === null || branch === void 0 ? void 0 : branch.connections.length) || 0) > 1 && React__default.createElement(Repeat, null, React__default.createElement(SwitchBar, {
6957
+ }, packageOption.title)))), (ecommerce === null || ecommerce === void 0 ? void 0 : ecommerce.withHomeDelivery) && React__default.createElement(CheckMarkListItem, null, "Hemleverans")))), ((branch === null || branch === void 0 ? void 0 : branch.connections.length) || 0) > 1 && React__default.createElement(Repeat, null, React__default.createElement(SwitchBar, {
6843
6958
  title: "Centrallagerbil",
6844
6959
  actionTitle: "Byt anl\u00E4ggning",
6845
6960
  onClick: openModalBranch
@@ -8287,6 +8402,13 @@ const PropertySet = ({
8287
8402
  })));
8288
8403
  };
8289
8404
 
8405
+ const DemoCarModal = ({
8406
+ onClose
8407
+ }) => React__default.createElement(Modal, {
8408
+ title: "Demobil",
8409
+ onClose: onClose
8410
+ }, React__default.createElement(Content$2, null, React__default.createElement("p", null, "En demobil \u00E4r en bil som st\u00E5tt i utst\u00E4llning eller som p\u00E5 annat s\u00E4tt anv\u00E4nts f\u00F6r att visa upp en viss modell. Bilarna \u00E4r ofta v\u00E4lutrustade och har blivit v\u00E4l omh\u00E4ndertagna. Dessutom har de vanligtvis g\u00E5tt f\u00E5 mil och har fortfarande nybilsgarantierna kvar.")));
8411
+
8290
8412
  const PdfListItem = styled__default.li.attrs(() => ({
8291
8413
  className: 'wayke__theme wayke__color--primary-text'
8292
8414
  }))`
@@ -8380,6 +8502,8 @@ const WaykeSearchItem = ({
8380
8502
  vehicle: centralStorageVehicle,
8381
8503
  loading: loadingCentralStorageVehicle
8382
8504
  } = useCentralStorage(result === null || result === void 0 ? void 0 : result.vehicle);
8505
+ const [demoCarModal, setDemoCarModal] = React.useState(false);
8506
+ const onToggleDemoCarModal = React.useCallback(() => setDemoCarModal(!demoCarModal), [demoCarModal]);
8383
8507
  React.useEffect(() => {
8384
8508
  if (ecomSettings) {
8385
8509
  ecomContext.current = new WaykeEcomWeb({
@@ -8452,12 +8576,15 @@ const WaykeSearchItem = ({
8452
8576
  media,
8453
8577
  description,
8454
8578
  price,
8579
+ discount,
8455
8580
  financialOptions,
8456
8581
  manufacturer,
8457
8582
  ecommerce,
8458
8583
  packageOptions,
8459
8584
  publishedAt,
8460
- documents
8585
+ documents,
8586
+ availableFrom,
8587
+ flags
8461
8588
  } = vehicle;
8462
8589
  const insuranceOptions = centralStorageVehicle !== null && centralStorageVehicle !== void 0 && centralStorageVehicle.insuranceOptions ? centralStorageVehicle.insuranceOptions : vehicle.insuranceOptions;
8463
8590
  const {
@@ -8469,10 +8596,19 @@ const WaykeSearchItem = ({
8469
8596
  } = vehicle.data;
8470
8597
  const uspList = [{
8471
8598
  title: modelYear
8472
- }, {
8473
- title: `${numberSeparator(mileage)} mil`
8474
8599
  }];
8475
8600
 
8601
+ if (flags !== null && flags !== void 0 && flags.demoVersion) {
8602
+ uspList.push({
8603
+ title: 'Demobil',
8604
+ onClick: onToggleDemoCarModal
8605
+ });
8606
+ }
8607
+
8608
+ uspList.push({
8609
+ title: `${numberSeparator(mileage)} mil`
8610
+ });
8611
+
8476
8612
  if (gearbox) {
8477
8613
  uspList.push({
8478
8614
  title: gearbox
@@ -8506,7 +8642,8 @@ const WaykeSearchItem = ({
8506
8642
  })))), React__default.createElement(ProductPageAsideSection, {
8507
8643
  mobileOrder: 2
8508
8644
  }, React__default.createElement(PriceTable, {
8509
- price: price
8645
+ price: price,
8646
+ discount: discount || undefined
8510
8647
  })), (financialOptions.length > 0 || insuranceOptions.length > 0) && React__default.createElement(ProductPageAsideSection, {
8511
8648
  mobileOrder: 4
8512
8649
  }, financialOptions.length > 0 && React__default.createElement(FinancialOptions, {
@@ -8525,6 +8662,7 @@ const WaykeSearchItem = ({
8525
8662
  branch: branch,
8526
8663
  contact: centralStorageVehicle === null || centralStorageVehicle === void 0 ? void 0 : centralStorageVehicle.contact,
8527
8664
  loadingCentralStorageVehicle: loadingCentralStorageVehicle,
8665
+ availableFrom: availableFrom,
8528
8666
  toggleEcomModal: () => {
8529
8667
  var _ecomContext$current;
8530
8668
 
@@ -8577,6 +8715,8 @@ const WaykeSearchItem = ({
8577
8715
  onClickSearchItem: onClickSearchItem
8578
8716
  })), false , React__default.createElement(PortalElement, {
8579
8717
  id: DefaultPortal
8718
+ }), demoCarModal && React__default.createElement(DemoCarModal, {
8719
+ onClose: onToggleDemoCarModal
8580
8720
  }));
8581
8721
  };
8582
8722