@bytebrand/fe-ui-core 4.2.251 → 4.3.1

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 (125) hide show
  1. package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +2 -4
  2. package/common.ts +2 -6
  3. package/package.json +2 -3
  4. package/source/components/AccordionWidget/AccordionWidget.tsx +3 -1
  5. package/source/components/Breadcrumbs/Breadcrumbs.tsx +3 -3
  6. package/source/components/Checkout/CheckoutStepper/CheckoutStepper.styl +190 -2
  7. package/source/components/Checkout/CheckoutStepper/CheckoutStepper.tsx +16 -15
  8. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.styl +2 -2
  9. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.tsx +3 -3
  10. package/source/components/FormattedNumber/FormattedNumber.tsx +3 -2
  11. package/source/components/InfoBlocks/FirstInfoBlock/FirstInfoBlockItem/FirstInfoBlockItem.styl +6 -4
  12. package/source/components/OfferDetailedSection/partials/PanelConfig.tsx +3 -0
  13. package/source/components/OfferPanel/MuiOfferPeriod/{MuiOfferPeriod.theme.tsx → MuiOfferPeriod.theme.js} +13 -8
  14. package/source/components/OfferPanel/MuiOfferPeriod/MuiOfferPeriod.tsx +4 -28
  15. package/source/components/OfferPanel/OfferCheckboxGroup/CheckboxContainer.tsx +12 -6
  16. package/source/components/OfferPanel/OfferCheckboxGroup/OfferCheckboxGroup.tsx +1 -1
  17. package/source/components/OfferPanel/OfferPanel.tsx +1 -1
  18. package/source/components/OfferPanel/OfferPeriod/OfferPeriod.tsx +4 -0
  19. package/source/components/OfferPanel/RangeGroup/RangeGroup.tsx +4 -6
  20. package/source/components/PriceRatingDetailed/PriceRatingDetailed.tsx +2 -6
  21. package/source/components/SearchFilters/filters/AlternativeID.tsx +53 -42
  22. package/source/components/SearchFilters/filters/DriveType.tsx +1 -1
  23. package/source/components/SearchFilters/filters/EmissionSticker.tsx +1 -1
  24. package/source/components/SearchFilters/filters/FirstRegistration.tsx +1 -0
  25. package/source/components/SearchFilters/filters/InteriorColor.tsx +1 -1
  26. package/source/components/SearchFilters/filters/InteriorMaterial.tsx +1 -2
  27. package/source/components/SearchFilters/filters/Mileage.tsx +1 -1
  28. package/source/components/SearchFilters/filters/Power.tsx +17 -36
  29. package/source/components/SearchFilters/filters/StateOptions.tsx +1 -0
  30. package/source/components/SearchFilters/filters/Transmission.tsx +1 -1
  31. package/source/components/SearchPage/SearchChips/SearchChips.tsx +1 -1
  32. package/source/components/SearchPageMobile/FiltersDetailed/BodyType.tsx +3 -3
  33. package/source/components/SearchPageMobile/FiltersDetailed/Consumption.tsx +2 -2
  34. package/source/components/SearchPageMobile/FiltersDetailed/Doors.tsx +1 -1
  35. package/source/components/SearchPageMobile/FiltersDetailed/MakeModel.tsx +1 -1
  36. package/source/components/SearchWidget/ColorWidget/BodyColorWidget.tsx +3 -3
  37. package/source/components/SearchWidget/EnvironmentWidget/EnvironmentWidget.tsx +3 -3
  38. package/source/components/SearchWidget/HighlightsWidget/HighlightsWidget.tsx +2 -2
  39. package/source/components/SearchWidget/StateWidget/StateWidget.tsx +2 -1
  40. package/source/components/SearchWidgetsMobile/BasicDataWidgetMobile/BasicDataWidgetMobile.tsx +4 -4
  41. package/source/components/SearchWidgetsMobile/EquipmentsWidget/EquipmentsWidget.tsx +16 -16
  42. package/source/components/SearchWidgetsMobile/HighlightsWidgetMobile/HighlightsWidgetMobile.tsx +1 -1
  43. package/source/components/SearchWidgetsMobile/InteriorWidget/InteriorWidget.tsx +1 -1
  44. package/source/components/SearchWidgetsMobile/SafetyWidget/SafetyWidget.tsx +6 -6
  45. package/source/components/Stepper/Stepper.tsx +3 -4
  46. package/source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo.styl +2 -11
  47. package/source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo.tsx +5 -5
  48. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCar.tsx +38 -57
  49. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCard.tsx +2 -2
  50. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.tsx +101 -183
  51. package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.tsx +7 -5
  52. package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.tsx +7 -33
  53. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.styl +2 -10
  54. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +14 -54
  55. package/source/components/VehicleDetailedSidebar/partials/Price.styl +1 -5
  56. package/source/components/VehicleDetailedSidebar/partials/Price.tsx +1 -2
  57. package/source/components/VehicleDetailedSidebar/partials/PriceContent.styl +5 -16
  58. package/source/components/VehicleDetailedSidebar/partials/PriceContent.tsx +4 -9
  59. package/source/components/VehicleDetailedSidebar/partials/Properties.tsx +1 -1
  60. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.styl +0 -45
  61. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +42 -121
  62. package/source/components/VehicleDetailedSlider/partials/PriceData.styl +1 -4
  63. package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +1 -8
  64. package/source/components/VehicleDetailedSlider/partials/Stats.tsx +2 -2
  65. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +7 -9
  66. package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +1 -35
  67. package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.tsx +3 -9
  68. package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.styl +2 -11
  69. package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -2
  70. package/source/components/VehicleSmallCard/VehicleSmallCard.styl +1 -3
  71. package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +7 -3
  72. package/source/components/_common/Badge/Badge.styl +0 -3
  73. package/source/components/_common/Badge/Badge.tsx +1 -1
  74. package/source/components/_common/Button/Button.tsx +4 -5
  75. package/source/components/_common/Checkbox/FormCheckbox.tsx +4 -4
  76. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.tsx +1 -1
  77. package/source/components/_common/Chip/Chip.tsx +3 -1
  78. package/source/components/_common/ExpansionPanel/ExpansionPanel.tsx +3 -3
  79. package/source/components/_common/IconSVG/IconSVGConfig.tsx +0 -2
  80. package/source/components/_common/IconSVG/SVG/flags/SK.tsx +1 -0
  81. package/source/components/_common/IconSVG/SVG/slider/360New.tsx +1 -1
  82. package/source/components/_common/MaterialAccordion/MaterialAccordion.tsx +30 -22
  83. package/source/components/_common/MaterialAutocomplete/MaterialAutocomplete.styled.tsx +8 -8
  84. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.styled.tsx +1 -0
  85. package/source/components/_common/MaterialSelect/MaterialSelect.styled.tsx +15 -12
  86. package/source/components/_common/MaterialSelect/MaterialSelect.tsx +3 -3
  87. package/source/components/_common/MaterialSwitch/MaterialSwitch.tsx +1 -3
  88. package/source/components/_common/MaterialTooltip/MaterialTooltip.styled.tsx +1 -1
  89. package/source/components/_common/MaterialTooltip/MaterialTooltip.tsx +3 -3
  90. package/source/components/_common/Modal/CookieModal.tsx +3 -1
  91. package/source/components/_common/Modal/Modal.styled.tsx +1 -2
  92. package/source/components/_common/Modal/Modal.tsx +5 -1
  93. package/source/components/_common/Modal/ModalsConfig.tsx +1 -5
  94. package/source/components/_common/Modal/modals/ManageCookieModal/ManageCookieModal.styl +7 -23
  95. package/source/components/_common/Modal/modals/ManageCookieModal/ManageCookieModal.tsx +36 -84
  96. package/source/components/_common/Modal/modals/PreviewCookieModal/PreviewCookieModal.styl +14 -29
  97. package/source/components/_common/Modal/modals/PreviewCookieModal/PreviewCookieModal.tsx +10 -17
  98. package/source/components/_common/OfferRequestButtonWrapper/OfferRequestButtonWrapper.tsx +4 -12
  99. package/source/components/_common/Range/Range.tsx +16 -26
  100. package/source/components/_common/UserMenu/MaterialMenu.styled.tsx +1 -0
  101. package/source/components/_common/UserMenu/MaterialMenu.tsx +3 -3
  102. package/source/components/_common/UserMenu/MaterialMenuItem.tsx +20 -42
  103. package/source/components/_common/UserMenu/NestedMenu.tsx +1 -1
  104. package/source/components/_common/withStats/withStats.styl +0 -3
  105. package/source/components/_common/withStats/withStats.tsx +16 -19
  106. package/source/components/containers/SearchPage/FiltersContainer/FiltersContainer.styl +1 -14
  107. package/source/components/containers/SearchPage/FiltersContainer/FiltersContainer.tsx +42 -78
  108. package/source/framework/constants/common.ts +60 -89
  109. package/source/framework/constants/highlights.ts +1 -1
  110. package/source/framework/constants.ts +1 -1
  111. package/source/framework/types/types.ts +4 -9
  112. package/source/framework/utils/CommonUtils.ts +62 -73
  113. package/source/framework/utils/DateUtils.ts +2 -10
  114. package/source/framework/vehiclesProps/decoratedLightProps.tsx +2 -1
  115. package/source/framework/vehiclesProps/decoratedProps.tsx +2 -1
  116. package/source/locales/data.ts +2 -2
  117. package/tslint.json +2 -1
  118. package/utils.ts +0 -2
  119. package/__tests__/components/UserDasboardPage/sections/CheckoutSection/CheckoutSection.test.tsx +0 -613
  120. package/__tests__/components/UserDasboardPage/sections/FavoriteSection/FavoriteSection.test.tsx +0 -335
  121. package/source/components/UserDashboardPage/sections/CheckoutSection/CheckoutSection.styl +0 -38
  122. package/source/components/UserDashboardPage/sections/CheckoutSection/CheckoutSection.tsx +0 -120
  123. package/source/components/UserDashboardPage/sections/FavoriteSection/FavoriteSection.styl +0 -22
  124. package/source/components/UserDashboardPage/sections/FavoriteSection/FavoriteSection.tsx +0 -84
  125. package/source/components/_common/IconSVG/SVG/slider/YoutubeButton.tsx +0 -26
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { memo } from 'react';
2
2
  import InteriorColor from '../../SearchFilters/filters/InteriorColor';
3
3
  import InteriorMaterial from '../../SearchFilters/filters/InteriorMaterial';
4
4
 
@@ -22,7 +22,7 @@ export interface ISafetyWidget {
22
22
  const AIRBAG_KEY = 'AIRBAG';
23
23
 
24
24
  const SafetyWidget = (props: ISafetyWidget) => {
25
- const { ASSISTANTS, AIRBAG, PARKING_ASSISTANTS, THEFT_PROTECTION, HIGHLIGHTS, onFilterChange, t } = props;
25
+ const { ASSISTANTS, AIRBAG, PARKING_ASSISTANTS, THEFT_PROTECTION, HIGHLIGHTS, onFilterChange, onDropDownFocus, t } = props;
26
26
  const onCheckboxClick = (fieldName: string, categoryName: string, values: string[]) => {
27
27
  const index = values.indexOf(fieldName);
28
28
 
@@ -40,11 +40,11 @@ const SafetyWidget = (props: ISafetyWidget) => {
40
40
  return onFilterChange(AIRBAG_KEY, values);
41
41
  };
42
42
 
43
- // const onDropdownFocus = () => {
44
- // if (onDropDownFocus) {
45
- // onDropDownFocus(AIRBAG_KEY);
46
- // }
47
- // };
43
+ const onDropdownFocus = () => {
44
+ if (onDropDownFocus) {
45
+ onDropDownFocus(AIRBAG_KEY);
46
+ }
47
+ };
48
48
 
49
49
  const getOptions = (_: string, options: any) => {
50
50
  const { aggregation } = AIRBAG;
@@ -12,15 +12,14 @@ export interface IProps {
12
12
  children: React.ReactElement<IStepProps>[];
13
13
  onStepChange?: (nextStep: number) => void;
14
14
  className?: string;
15
- completed?: boolean;
16
15
  }
17
16
 
18
17
  const defaultStepsDivider: React.ReactElement<IStepsDividerProps> = <StepsDivider/>;
19
18
 
20
19
  const Stepper: React.FunctionComponent<IProps> = ({ currentStep, nonLinear, stepsDivider = defaultStepsDivider, onStepChange, children, className }) => {
21
- const childrenArray: any | { props: IStepProps }[] = React.Children.toArray(children);
22
- const steps = childrenArray.map((child: { props: IStepProps }, index: number) => {
23
- if (!React.isValidElement<IStepProps>(child)) {
20
+ const childrenArray: React.ReactElement<IStepProps>[] = React.Children.toArray<React.ReactElement<IStepProps>>(children);
21
+ const steps = childrenArray.map((child, index) => {
22
+ if (!React.isValidElement(child)) {
24
23
  throw new Error('Stepper component has invalid child');
25
24
  }
26
25
 
@@ -2,7 +2,7 @@
2
2
  @import '../../../../theme/mixins.styl'
3
3
 
4
4
  .container
5
- padding: 8px 8px 0px
5
+ padding: 8px 8px 16px
6
6
  border-top: 1px solid rgba(76,78,100,0.12);
7
7
 
8
8
  +media-tablet-landscape-up()
@@ -28,10 +28,6 @@
28
28
  top: 0;
29
29
  left: -16px;
30
30
 
31
- .overallRate
32
- border-top: 1px solid rgba(76,78,100,0.12)
33
- padding-top: 15px
34
-
35
31
  .labelText
36
32
  color: $black50
37
33
  font-size: 14px
@@ -44,7 +40,6 @@
44
40
  padding-bottom: 8px
45
41
  grid-area: addresses
46
42
  display: grid
47
- row-gap: 12px
48
43
 
49
44
  .orderPriceSection
50
45
  grid-area: orderPrice
@@ -93,8 +88,4 @@
93
88
  font-size: 14px
94
89
 
95
90
  .montlyUnit
96
- font-size: 8px
97
-
98
- .priceValue
99
- text-align: right
100
- min-width 100px
91
+ font-size: 8px
@@ -5,7 +5,7 @@ import VehicleFormattedPrice from '../../../Vehicle/VehicleFormattedPrice/Vehicl
5
5
  import Button from '../../../_common/Button/Button';
6
6
  import classNames from 'classnames';
7
7
 
8
- import { ITFunction } from '../../../../framework/types/types';
8
+ import { TFunction } from '../../../../framework/types/types';
9
9
 
10
10
  interface IAdditionalOrderData {
11
11
  addressData: ({ value: string; label: string; })[];
@@ -14,7 +14,7 @@ interface IAdditionalOrderData {
14
14
  }
15
15
 
16
16
  interface IAdditionalOrderInfo {
17
- t: ITFunction;
17
+ t: TFunction;
18
18
  additionalOrderData: IAdditionalOrderData;
19
19
  redirectToUrl: (url: string) => void;
20
20
  buyingType: string;
@@ -29,8 +29,8 @@ const AdditionalOrderInfo = ({ t, additionalOrderData, redirectToUrl, buyingType
29
29
 
30
30
  const supportSectionClassnames = classNames(
31
31
  styles.customerSuport,
32
- { [styles.supportSectionBorder]: addressData.length > 0 }
33
- );
32
+ {[styles.supportSectionBorder]: addressData.length > 0}
33
+ )
34
34
 
35
35
  return (
36
36
  <div className={styles.container}>
@@ -55,7 +55,7 @@ const AdditionalOrderInfo = ({ t, additionalOrderData, redirectToUrl, buyingType
55
55
  return (
56
56
  <div key={label} className={styles.flexContainer}>
57
57
  <div className={styles.labelText}>{label}</div>
58
- <div className={classNames(styles.labelText, styles.priceValue)}>{value}</div>
58
+ <div className={styles.labelText}>{value}</div>
59
59
  </div>
60
60
  );
61
61
  }
@@ -1,12 +1,11 @@
1
1
  import React, { useRef, useEffect, useState } from 'react';
2
2
  import styles from './OrderStatusSection.styl';
3
3
  import OrderStatusCard from './OrderStatusCard';
4
- // import Image from '../../../_common/Image/Image';
4
+ import Image from '../../../_common/Image/Image';
5
5
  import { getFormattedPrice } from '../../../../framework/utils/CommonUtils';
6
- import AdditionalOrderInfo from './AdditionalOrderInfo';
7
6
 
8
7
  // tslint:disable-next-line:interface-name
9
- interface ITFunction {
8
+ interface TFunction {
10
9
  <T = string>(key: string, options?: object): T;
11
10
  <T = string>(keys: string[], options?: object): T;
12
11
  }
@@ -21,16 +20,11 @@ interface IOrderStatusCar {
21
20
  paybackPeriod?: number;
22
21
  monthlyInstallment?: number;
23
22
  status?: string;
24
- t: ITFunction;
23
+ t: TFunction;
25
24
  request: string;
26
25
  registration: boolean;
27
26
  currentSalesPrice: number;
28
27
  onClick: () => void;
29
- isFinishedOrder?: boolean;
30
- additionalOrderInfoProps?: any;
31
- wonStatus?: string;
32
- transformedDeliveryDate?: string | null;
33
- delivery?: boolean;
34
28
  }
35
29
 
36
30
  const OrderStatusCar = ({
@@ -47,11 +41,7 @@ const OrderStatusCar = ({
47
41
  request,
48
42
  registration,
49
43
  currentSalesPrice,
50
- onClick,
51
- additionalOrderInfoProps,
52
- wonStatus,
53
- transformedDeliveryDate,
54
- delivery
44
+ onClick
55
45
  }: IOrderStatusCar) => {
56
46
  const ref = useRef(null);
57
47
  const [activeStep, setActiveStep] = useState(0); // 0 - when we have no active steps
@@ -60,16 +50,11 @@ const OrderStatusCar = ({
60
50
  { icon: 'orderReceivedDashboard', selector: 'selector_status_order_received' },
61
51
  { icon: 'preparaionDashboard', selector: 'selector_status_preparation' },
62
52
  { icon: 'registrationDashboard', selector: 'selector_status_registration' },
63
- selfPickup || !delivery ? { icon: 'pickupDashboard', selector: 'selector_status_pick_up' }
53
+ selfPickup ? { icon: 'pickupDashboard', selector: 'selector_status_pick_up' }
64
54
  : { icon: 'deliveryDashboard', selector: 'selector_status_delivery' },
65
55
  { icon: 'handingOverDashboard', selector: 'selector_status_handing_over' }
66
56
  ];
67
57
 
68
- const steps = cardItems.map((step) => {
69
- const { selector } = step;
70
- return selector;
71
- })
72
-
73
58
  useEffect(
74
59
  () => {
75
60
  cardItems.map((step, index) => {
@@ -78,12 +63,13 @@ const OrderStatusCar = ({
78
63
  setActiveStep(index + 1);
79
64
  }
80
65
  });
81
- if (!!ref && !!ref.current && typeof ref.current.scrollBy === 'function') {
82
- ref.current.scrollBy({
83
- behavior: 'smooth',
84
- left: 156 * steps.indexOf(status)
85
- })
86
- }
66
+ // if (!!ref && !!ref.current) { TODO: fix scroll for active element for mobile
67
+ // ref.current.scrollBy({
68
+ // top: 0,
69
+ // left: 156 * activeStep,
70
+ // behavior: 'smooth'
71
+ // });
72
+ // }
87
73
  },
88
74
  []
89
75
  );
@@ -104,43 +90,38 @@ const OrderStatusCar = ({
104
90
  <img data-testid='car-image' src={imageUrl}/>
105
91
  </div>
106
92
  <div className={styles.requestId}>{request}</div>
107
- <div className={styles.carPayment}>
108
- {wonStatus === 'won' && !!transformedDeliveryDate ? transformedDeliveryDate
109
- : <>
110
- {t(`buyingType.${buyingType}`)},&nbsp;
111
- {buyingType !== 'buy' && `${t('paybackPeriod', { paybackPeriod })},`}&nbsp;
112
- {buyingType === 'buy' ?
113
- t('currentSalesPrice', { currentSalesPrice: getFormattedPrice(currentSalesPrice) })
114
- : t('monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f') })
115
- }
116
- </>
93
+ <div className={styles.carPayment} >
94
+ {t(`buyingType.${buyingType}`)},&nbsp;
95
+ {buyingType !== 'buy' && `${t('paybackPeriod', { paybackPeriod })},`}&nbsp;
96
+ {buyingType === 'buy' ?
97
+ t('currentSalesPrice', { currentSalesPrice: getFormattedPrice(currentSalesPrice) })
98
+ : t('monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f') })
117
99
  }
118
100
  </div>
119
101
  </div>
120
102
  </div>
121
- {wonStatus === 'won' ? <AdditionalOrderInfo { ...additionalOrderInfoProps } />
122
- : <div className={styles.cardsSection} ref={ref}>
123
- {cardItems.map((card, index) => {
124
- const { icon, selector } = card;
103
+ <div className={styles.cardsSection}>
104
+ {cardItems.map((card, index) => {
105
+ const { icon, selector } = card;
125
106
 
126
- const statusDescription = !registration && index === 2 ?
127
- t('orderStatus.independentRegistration') :
128
- t(`orderStatus.${selector}_desc`);
107
+ const statusDescription = !registration && index === 2 ?
108
+ t('orderStatus.independentRegistration') :
109
+ t(`orderStatus.${selector}_desc`);
129
110
 
130
- return (
131
- <OrderStatusCard
132
- title={t(`orderStatus.${selector}`)}
133
- description={statusDescription}
134
- icon={icon}
135
- key={index}
136
- isActive={index + 1 === activeStep}
137
- isDisabled={index + 1 > activeStep}
138
- isDone={index + 1 < activeStep}
139
- />
140
- );
141
- })}
142
- </div>
143
- }
111
+ return (
112
+ <OrderStatusCard
113
+ cardRef={selector === status ? ref : null}
114
+ title={t(`orderStatus.${selector}`)}
115
+ description={statusDescription}
116
+ icon={icon}
117
+ key={index}
118
+ isActive={index + 1 === activeStep}
119
+ isDisabled={index + 1 > activeStep}
120
+ isDone={index + 1 < activeStep}
121
+ />
122
+ );
123
+ })}
124
+ </div>
144
125
  </div>
145
126
  </div>
146
127
  );
@@ -13,7 +13,7 @@ interface IOrderStatusCard {
13
13
  isDone?: boolean;
14
14
  }
15
15
 
16
- const OrderStatusCard = ({ icon, title, description, isDisabled, isActive, isDone }: IOrderStatusCard) => {
16
+ const OrderStatusCard = ({ icon, title, description, isDisabled, cardRef, isActive, isDone }: IOrderStatusCard) => {
17
17
  const orderReceivedCardClasses = classnames(
18
18
  styles.orderReceivedCard,
19
19
  { [styles.cardInProgress]: isActive }
@@ -27,7 +27,7 @@ const OrderStatusCard = ({ icon, title, description, isDisabled, isActive, isDon
27
27
 
28
28
  return (
29
29
  <div className={styles.orderReceivedCardContainer}>
30
- <div data-testid='orderStatusCard' className={orderReceivedCardClasses}>
30
+ <div data-testid='orderStatusCard' className={orderReceivedCardClasses} ref={cardRef}>
31
31
  <div className={styles.cardIcon}>
32
32
  <IconSVG disabled={isDisabled} customDimensions name={icon} width={87}/>
33
33
  </div>
@@ -7,9 +7,8 @@ import styles from './OrderStatusSection.styl';
7
7
  import { Skeleton } from '@mui/material';
8
8
 
9
9
  import { getFormattedPrice } from '../../../../framework/utils/CommonUtils';
10
- import { fromUTCToDateString } from '../../../../framework/utils/DateUtils';
11
10
 
12
- interface ITFunction {
11
+ interface TFunction {
13
12
  <T = string>(key: string, options?: object): T;
14
13
  <T = string>(keys: string[], options?: object): T;
15
14
  }
@@ -17,19 +16,17 @@ interface ITFunction {
17
16
  interface IOrderStatusSection {
18
17
  getSupportedImageFormat: (id: string, mainImageId: string, size: 'small' | 'medium' | 'large') => string;
19
18
  redirectToUrl: (url: string) => void;
20
- t: ITFunction;
19
+ t: TFunction;
21
20
  isFetching: boolean;
22
21
  withAdditionalInfo?: boolean; // for using on /account/my-order.
23
22
  orderedCars: any[]; // TODO: create interface for orderedCars, when the object is formatted by the backend
24
- wonCars?: any[];
25
23
  }
26
24
 
27
25
  const OrderStatusSection = ({
28
26
  getSupportedImageFormat,
29
27
  t,
30
- redirectToUrl,
28
+ redirectToUrl,
31
29
  orderedCars,
32
- wonCars,
33
30
  isFetching,
34
31
  withAdditionalInfo = false
35
32
  }: IOrderStatusSection) => {
@@ -44,202 +41,126 @@ const OrderStatusSection = ({
44
41
  if (!!addressObj) {
45
42
  Object.keys(addressObj).forEach((key) => {
46
43
  switch (key) {
47
- case 'firstname':
48
- case 'lastname':
44
+ case 'customerFirstname':
45
+ case 'customerLastname':
49
46
  addressString = `${addressString} ${addressObj[key]}`;
50
47
  break;
51
- case 'partner':
52
- case 'street':
53
- case 'zip':
54
- case 'number':
48
+ case 'deliveryPartner':
49
+ case 'customerStreet':
50
+ case 'deliveryStreet':
51
+ case 'customerZip':
52
+ case 'deliveryZip':
55
53
  if (!!addressString) {
56
54
  addressString = `${addressString}, ${addressObj[key]}`;
57
55
  } else {
58
56
  addressString = `${addressString} ${addressObj[key]}`;
59
57
  }
60
58
  break;
61
- case 'city':
59
+ case 'customerCity':
60
+ case 'deliveryCity':
62
61
  addressString = `${addressString} ${addressObj[key]}`;
63
62
  break;
64
- default: addressString = `${addressString} ${addressObj[key]}`;
65
63
  }
66
- });
64
+ })
67
65
  }
68
66
  return addressString;
69
67
  };
70
68
 
71
69
  const getDataPriceItem = (value: number, label: string): {value: string, label: string} | [] => {
72
70
  if (!!value && value !== 0) {
73
- return { label, value: getFormattedPrice(value, '$,.2f', ' €') };
74
- }
75
- };
76
-
77
- const defaultCarProps = {
78
- car: {
79
- _id: '',
80
- mainData: {
81
- make: '',
82
- model: '',
83
- subModel: ''
84
- },
85
- metaData: {
86
- mainImageId: ''
87
- }
88
- },
89
- buyingType: '',
90
- selfPickup: false,
91
- paybackPeriod: 0,
92
- monthlyInstallment: 0,
93
- status: '',
94
- request: '',
95
- registration: false,
96
- currentSalesPrice: 0,
97
- deposit: 0,
98
- preparationCost: 0,
99
- licensePlateCost: 0,
100
- registrationCost: 0,
101
- transportationCost: 0,
102
- customerAddress: {
103
- customerFirstname: '',
104
- customerLastname: '',
105
- customerStreet: '',
106
- customerZip: ''
107
- },
108
- deliveryAddress: {
109
- deliveryPartner: '',
110
- deliveryStreet: '',
111
- deliveryZip: '',
112
- deliveryCity: ''
71
+ return { value: getFormattedPrice(value, '$,.2f', ' €'), label };
113
72
  }
114
73
  }
115
74
 
116
- const carPriceWithWarrantyTitle = (warranty: { warrantyPackage: string, warrantyCost: number, warrantyPeriod: number }) => {
117
- if (!warranty || !warranty.warrantyCost) {
118
- return t('MyOrderPage:carPrice');
119
- }
120
- const warrantyPackage = t(`MyOrderPage:${warranty.warrantyPackage}`);
121
- const warrantyPeriod = t(`MyOrderPage:${warranty.warrantyPeriod}year`, { warrantyPeriod: warranty.warrantyPeriod });
122
- const carPriceIncWarrantyTitle =
123
- `${t('MyOrderPage:carPrice')} ${t('MyOrderPage:incWarranty', { warrantyPackage, warrantyPeriod })}`;
124
- return carPriceIncWarrantyTitle;
125
- };
126
-
127
- const renderRequestedCars = (cars: any[] = []) => {
75
+ const renderRequestedCars = () => {
128
76
  return (
129
77
  <>
130
- {!!cars && cars.map((orderedCarData: any, index: number) => {
131
- if (orderedCarData && typeof orderedCarData.car === 'object') {
132
- const orderedCar = { ...defaultCarProps, ...orderedCarData };
133
- const { car: { _id } } = orderedCar;
134
- const { car: { mainData: { make, model, subModel } } } = orderedCar;
135
- const { car: { metaData: { mainImageId } } } = orderedCar;
136
- const {
137
- buyingType,
138
- selfPickup,
139
- paybackPeriod,
140
- monthlyInstallment,
141
- status,
142
- request,
143
- registration,
144
- currentSalesPrice,
145
- totalPrice,
146
- deposit,
147
- preparationCost,
148
- licensePlateCost,
149
- registrationCost,
150
- transportationCost,
151
- customerAddress,
152
- deliveryAddress,
153
- firstRate,
154
- paymentProtectionInsuranceCost,
155
- wonStatus,
156
- warranty,
157
- deliveryDate,
158
- isLicensePlateFee,
159
- delivery,
160
- extrasSumCost
161
- } = orderedCar;
78
+ {!!orderedCars && orderedCars.map((orderedCar: any, index: number) => {
79
+ const { car: { _id } } = orderedCar;
80
+ const { car: { mainData: { make, model, subModel } } } = orderedCar;
81
+ const { car: { metaData: { mainImageId } }} = orderedCar;
82
+ const {
83
+ buyingType,
84
+ selfPickup,
85
+ paybackPeriod,
86
+ monthlyInstallment,
87
+ status,
88
+ request,
89
+ registration,
90
+ currentSalesPrice,
91
+ deposit,
92
+ preparationCost,
93
+ licensePlateCost,
94
+ registrationCost,
95
+ transportationCost,
96
+ customerAddress,
97
+ deliveryAddress
98
+ } = orderedCar;
99
+
100
+ const additionalOrderData = {
101
+ addressData: [
102
+ ...customerAddress ? [{ label: t('MyOrderPage:billingAddress'), value: getTransformAddressToString(customerAddress) }] : [],
103
+ ...deliveryAddress ? [{ label: t('MyOrderPage:vehicleDelivery'), value: getTransformAddressToString(deliveryAddress) }] : []
104
+ ],
105
+ carPriceData: [
106
+ ...currentSalesPrice ? [getDataPriceItem(currentSalesPrice, t('MyOrderPage:carPrice'))] : [],
107
+ ...preparationCost ? [getDataPriceItem(preparationCost, t('MyOrderPage:preparationCost'))] : [],
108
+ ...registrationCost ? [getDataPriceItem(registrationCost, t('MyOrderPage:vehicleRegistration'))] : [],
109
+ ...licensePlateCost ? [getDataPriceItem(licensePlateCost, t('MyOrderPage:licensePlates'))] : [],
110
+ ...transportationCost ? [getDataPriceItem(transportationCost, t('MyOrderPage:delivery'))] : [],
111
+ ...buyingType !== 'buy' ? [
112
+ ...monthlyInstallment ? [
113
+ {
114
+ label: t(`MyOrderPage:${buyingType}Rate`),
115
+ value: t('MyOrderPage:monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f', '', '€') })
116
+ }] : [],
117
+ ...paybackPeriod ? [{ label: t('MyOrderPage:runningTime'), value: t('MyOrderPage:paybackPeriod', { paybackPeriod })}] : [],
118
+ ...deposit ? [getDataPriceItem(deposit, t('MyOrderPage:deposit'))] : []
119
+ ] : []
120
+ ],
121
+ overallRate: {
122
+ label: t('MyOrderPage:yourOverallRate'),
123
+ value: buyingType === 'buy' ? currentSalesPrice : monthlyInstallment
124
+ }
125
+ };
126
+
127
+ const additionalOrderInfoProps = {
128
+ t,
129
+ additionalOrderData,
130
+ redirectToUrl,
131
+ buyingType
132
+ };
133
+
134
+ const imageUrl = getSupportedImageFormat(_id, mainImageId, 'small');
135
+
136
+ const orderStatusCarProps = {
137
+ make,
138
+ model,
139
+ subModel,
140
+ buyingType,
141
+ imageUrl,
142
+ selfPickup,
143
+ paybackPeriod,
144
+ monthlyInstallment,
145
+ status,
146
+ t,
147
+ request,
148
+ registration,
149
+ currentSalesPrice,
150
+ onClick: () => onDetailsClick(_id)
151
+ };
162
152
 
163
- const transformedDeliveryDate = !!deliveryDate ? `${t('MyOrderPage:deliveredOn')} ${fromUTCToDateString(deliveryDate)}` : null;
153
+ const title = <span>
154
+ {t('orderStatus.title')}:&nbsp;
155
+ <span className={styles.orderStatus}>{t(`orderStatus.${status}`)}</span>
156
+ </span>;
164
157
 
165
- const currentSalesPriceWithWarranty = !!warranty && !!warranty.warrantyCost ? currentSalesPrice + warranty.warrantyCost : currentSalesPrice;
166
-
167
- const additionalOrderData = {
168
- addressData: [
169
- ...customerAddress ? [{ label: t('MyOrderPage:billingAddress'), value: getTransformAddressToString(customerAddress) }] : [],
170
- ...deliveryAddress ? [{ label: t('MyOrderPage:vehicleDelivery'), value: selfPickup ? t('MyOrderPage:selfPickup') : getTransformAddressToString(deliveryAddress) }] : []
171
- ],
172
- carPriceData: [
173
- ...currentSalesPrice ? [getDataPriceItem(currentSalesPriceWithWarranty, carPriceWithWarrantyTitle(warranty))] : [],
174
- ...preparationCost ? [getDataPriceItem(preparationCost, t('MyOrderPage:preparationCost'))] : [],
175
- ...extrasSumCost ? [getDataPriceItem(extrasSumCost, t('MyOrderPage:extrasSumCost'))] : [],
176
- ...registrationCost && registration ? [getDataPriceItem(registrationCost, t('MyOrderPage:vehicleRegistration'))] : [],
177
- ...licensePlateCost && isLicensePlateFee ? [getDataPriceItem(licensePlateCost, t('MyOrderPage:licensePlates'))] : [],
178
- ...!!transportationCost && delivery ? [getDataPriceItem(transportationCost, t('MyOrderPage:delivery'))] : [],
179
- ...paymentProtectionInsuranceCost ? [getDataPriceItem(paymentProtectionInsuranceCost, t('MyOrderPage:paymentProtectionInsuranceCost'))]: [],
180
- ...firstRate ? [getDataPriceItem(firstRate, t('MyOrderPage:firstRate'))] : [],
181
- ...buyingType !== 'buy' ? [
182
- ...monthlyInstallment ? [
183
- {
184
- label: t(`MyOrderPage:${buyingType}Rate`),
185
- value: t('MyOrderPage:monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f', '', '€') })
186
- }] : [],
187
- ...paybackPeriod ? [{ label: t('MyOrderPage:runningTime'), value: t('MyOrderPage:paybackPeriod', { paybackPeriod }) }] : [],
188
- ...deposit ? [getDataPriceItem(deposit, t('MyOrderPage:deposit'))] : []
189
- ] : []
190
- ],
191
- overallRate: {
192
- label: (buyingType === 'buy' || wonStatus === 'won') ? t('MyOrderPage:yourOverallPrice') : t('MyOrderPage:yourOverallRate'),
193
- value: buyingType === 'buy' || wonStatus === 'won' ? totalPrice : monthlyInstallment
194
- }
195
- };
196
-
197
- const additionalOrderInfoProps = {
198
- t,
199
- additionalOrderData,
200
- redirectToUrl,
201
- buyingType
202
- };
203
-
204
- const imageUrl = getSupportedImageFormat(_id, mainImageId, 'small');
205
-
206
- const orderStatusCarProps = {
207
- make,
208
- model,
209
- subModel,
210
- buyingType,
211
- imageUrl,
212
- selfPickup,
213
- paybackPeriod,
214
- monthlyInstallment,
215
- status,
216
- t,
217
- request,
218
- registration,
219
- currentSalesPrice,
220
- onClick: () => onDetailsClick(_id),
221
- additionalOrderInfoProps,
222
- wonStatus,
223
- transformedDeliveryDate,
224
- delivery
225
- };
226
-
227
- const title = wonStatus === 'pending' ? <span>
228
- {t('orderStatus.title')}:&nbsp;
229
- <span className={styles.orderStatus}>{t(`orderStatus.${status}`)}</span>
230
- </span>
231
- : <span>{t('orderStatus.myOrder')}</span>;
232
-
233
- return (
234
- <DashboardSection key={index} title={title}>
235
- <OrderStatusCar { ...orderStatusCarProps } />
236
- {withAdditionalInfo && wonStatus === 'pending' ?
237
- <AdditionalOrderInfo { ...additionalOrderInfoProps } />
238
- : null
239
- }
240
- </DashboardSection>
241
- );
242
- }
158
+ return (
159
+ <DashboardSection key={index} title={title}>
160
+ <OrderStatusCar { ...orderStatusCarProps } />
161
+ {withAdditionalInfo ? <AdditionalOrderInfo { ...additionalOrderInfoProps } /> : null}
162
+ </DashboardSection>
163
+ );
243
164
  })}
244
165
  </>
245
166
  );
@@ -247,14 +168,11 @@ const OrderStatusSection = ({
247
168
 
248
169
  return (
249
170
  <>
250
- {isFetching ?
171
+ {isFetching ?
251
172
  <div className={styles.skeletonBlock}>
252
173
  <Skeleton animation='wave' variant='rectangular' width='100%' />
253
174
  </div>
254
- : <>
255
- {renderRequestedCars(orderedCars)}
256
- {renderRequestedCars(wonCars)}
257
- </>
175
+ : renderRequestedCars()
258
176
  }
259
177
  </>
260
178
  );