@bytebrand/fe-ui-core 4.8.22 → 4.8.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.8.22",
3
+ "version": "4.8.24",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,31 +1,40 @@
1
1
  import * as React from 'react';
2
2
  import _get from 'lodash/get';
3
3
  import { Visible } from 'react-grid-system';
4
- import { Link } from 'react-scroll';
4
+ import { scroller } from 'react-scroll';
5
5
  import AccordionWidget from '../AccordionWidget/AccordionWidget';
6
6
  import { IAccardionSectionProps } from '../../framework/types/types';
7
7
  import styles from './AccardionSection.styl';
8
8
  import { vehicleProps } from '../../locales/data';
9
9
 
10
10
  const AccardionSection: React.FunctionComponent<IAccardionSectionProps> = (props) => {
11
+ const [expanded, setExpanded] = React.useState<string | boolean>('overview')
12
+
13
+ const handleChange =
14
+ (panel: string) => (_: React.SyntheticEvent, isExpanded: boolean) => {
15
+ setExpanded(isExpanded ? panel : false);
16
+ };
17
+
18
+ const handleChangeByLink = (panel: string) => {
19
+ setExpanded(panel);
20
+
21
+ setTimeout(() => {
22
+ scroller.scrollTo(panel, {
23
+ duration: 400,
24
+ offset: -50,
25
+ smooth: true,
26
+ dynamic: true
27
+ });
28
+ }, 300);
29
+ }
30
+
11
31
  const renderPropertyLinks = (): React.ReactNode => {
32
+
12
33
  const links = ['overview', 'highlights', 'details'];
13
34
 
14
35
  return <div className={styles.propertyLinks}>
15
36
  {links.map((to: string) => {
16
- const _props = {
17
- to,
18
- key: to,
19
- duration: 500,
20
- offset: -40,
21
- activeClass: styles.active,
22
- className: styles.item,
23
- spy: false,
24
- smooth: true,
25
- isDynamic: true,
26
- absolute: false
27
- };
28
- return <Link {..._props} className={styles.propertyLink}>{props.t(`sidebar.${to}`)}</Link>;
37
+ return <span onClick={() => handleChangeByLink(to)} className={styles.propertyLink}>{props.t(`sidebar.${to}`)}</span>;
29
38
  })}
30
39
  </div>;
31
40
  };
@@ -35,7 +44,7 @@ const AccardionSection: React.FunctionComponent<IAccardionSectionProps> = (props
35
44
  <Visible xs sm md>
36
45
  {renderPropertyLinks()}
37
46
  </Visible>
38
- <AccordionWidget {...props} />
47
+ <AccordionWidget {...props} expanded={expanded} handleChange={handleChange} />
39
48
  </div>
40
49
  );
41
50
  };
@@ -20,24 +20,13 @@ import IconSVG from '../_common/IconSVG/IconSVG';
20
20
  import { getActualHighlights } from '../../framework/constants/highlights';
21
21
  import styles from './AccordionWidget.styl';
22
22
 
23
- interface IAccardionSectionState {
24
- expanded: boolean | string;
25
- }
26
- class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardionSectionState> {
23
+ class AccordionWidget extends React.Component<IAccardionSectionProps> {
27
24
 
28
25
  constructor(props: any) {
29
26
  super(props);
30
27
 
31
- this.state = {
32
- expanded: 'overview'
33
- };
34
28
  }
35
29
 
36
- handleChange =
37
- (panel: string) => (_: React.SyntheticEvent, isExpanded: boolean) => {
38
- this.setState({ expanded: isExpanded ? panel : false });
39
- };
40
-
41
30
  renderPropsBlock = (data: ICarPropElement[]): React.ReactNode => {
42
31
  return (
43
32
  <div className={styles.propertyContainer}>
@@ -157,7 +146,7 @@ class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardion
157
146
  };
158
147
 
159
148
  render(): React.ReactNode {
160
- const { car, activeIndex, onItemClick, t } = this.props;
149
+ const { car, activeIndex, onItemClick, t, expanded, handleChange } = this.props;
161
150
 
162
151
  if (!car || !('_id' in car)) return null;
163
152
  const {
@@ -195,8 +184,8 @@ class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardion
195
184
  key={section.name}
196
185
  title={t(`accordion.${section.title}`)}
197
186
  reactScrollName={section.name}
198
- onChange={this.handleChange}
199
- expanded={this.state.expanded}
187
+ onChange={handleChange}
188
+ expanded={expanded}
200
189
  >
201
190
  {section.component}
202
191
  </ExpansionPanel>
@@ -210,8 +199,8 @@ class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardion
210
199
  key={section.title}
211
200
  title={t(`accordion.${section.title}`)}
212
201
  reactScrollName={section.name}
213
- onChange={this.handleChange}
214
- expanded={this.state.expanded}
202
+ onChange={handleChange}
203
+ expanded={expanded}
215
204
  defaultExpanded={section.expanded}
216
205
  >
217
206
  {section.component}
@@ -67,7 +67,7 @@ const VehicleTitle: React.FC<IVehicleTitleProps> = ({
67
67
  return (
68
68
  <div className={infoSectionClassName}>
69
69
  <div className={wrapTitlesClassName}>
70
- <h4 className={styles.manufacturerModel}>{make || model ? `${makeText} ${modelText}` : 'n/a'}</h4>
70
+ <h2 className={styles.manufacturerModel}>{make || model ? `${makeText} ${modelText}` : 'n/a'}</h2>
71
71
  <div className={optionTitleClassName}>
72
72
  <p className={styles.subModel}>{subModelText}&nbsp;</p>
73
73
  <span className={styles.option}>{option}</span>
@@ -64,7 +64,7 @@ export const transformDataForDecoratedCar = (car: any) => {
64
64
  length: _get(car, 'sizeVolumeWeight.length', null),
65
65
  base: _get(car, 'driveSuspension.wheelBase', null),
66
66
  fuelCapacity: _get(car, 'sizeVolumeWeight.fuelCapacity', null),
67
- maximumWeightCapacity: _get(car, 'sizeVolumeWeight.cargoCapacity', null),
67
+ maximumWeightCapacity: _get(car, 'sizeVolumeWeight.maxWeight', null),
68
68
  tareWeight: _get(car, 'sizeVolumeWeight.emptyWeight', null),
69
69
  bootCapacity: _get(car, 'sizeVolumeWeight.cargoCapacity', null),
70
70
  capacityLoad: _get(car, 'sizeVolumeWeight.completeCapacity', null),
@@ -287,6 +287,8 @@ export interface IAccardionSectionProps {
287
287
  detailsText?: string | null;
288
288
  OfferRequestButtonWrapper?: React.ComponentType<IOfferRequestButtonWrapper>;
289
289
  onShowOfferDetails?(event?: React.ChangeEvent<{}>, car?: any, priceTabActiveIndex?: number): void;
290
+ expanded?: boolean | string;
291
+ handleChange?: any;
290
292
  }
291
293
 
292
294
  export interface ICar {
@@ -848,7 +848,7 @@ const getDecoratedProps = (
848
848
  ? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
849
849
  : null;
850
850
  const wltpCo2PluginValue = Number.isFinite(wltpCo2)
851
- ? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
851
+ ? t('vehicleProps:value.wltpCo2WtdCombined', { co2: wltpCo2.toLocaleString(language) })
852
852
  : null;
853
853
  const hybridPlugin = car.engineData.hybridPlugin;
854
854
 
@@ -993,8 +993,10 @@ const getDecoratedProps = (
993
993
 
994
994
  if (moment.utc(offerAvailabilityTimestamp, 'X').isBefore()) {
995
995
  offerAvailability = t('cbd:selector_availabilityMode_always');
996
- } else {
996
+ } else if (!!offerAvailabilityTimestamp) {
997
997
  offerAvailability = t('vehicleProps:value.fromDate', { date: humanViewTime });
998
+ } else {
999
+ offerAvailability = t('vehicleProps:value.onRequest'); // case when "availabilityFrom" is undefined
998
1000
  }
999
1001
  break;
1000
1002
 
@@ -78,7 +78,7 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
78
78
  base: `${getFormattedPrice(vehicleOption.base)} mm`,
79
79
  topSpeed: `${vehicleOption.topSpeed} km/h`,
80
80
  fuelCapacity: `${getFormattedPrice(vehicleOption.fuelCapacity)} l`,
81
- maximumWeightCapacity: `${getFormattedPrice(vehicleOption.maximumWeightCapacity)} l`,
81
+ maximumWeightCapacity: `${getFormattedPrice(vehicleOption.maximumWeightCapacity)} kg`,
82
82
  tareWeight: `${getFormattedPrice(vehicleOption.tareWeight)} kg`,
83
83
  bootCapacity: `${vehicleOption.bootCapacity} l`,
84
84
  capacityLoad: `${vehicleOption.capacityLoad} l`,
@@ -1050,7 +1050,7 @@ export const modalsTranslate = () => {
1050
1050
  annualMileage: 'Laufleistung / Jahr',
1051
1051
  requestOffer: 'Angebot anfragen',
1052
1052
  successfullyRequested: 'Erfolgreich angefragt',
1053
- info: 'Für Ihre Finanzierungswünsche stellen wir eine Bonitätsanfrage. Bonität vorausgesetzt, dies ist ein Berechnungsbeispiel gem. Ihrer Angaben, welches 2/3 aller Kunden erhalten. Dieses freibleibende Angebot der {{financialInstitution}} wird vermittelt durch die auto.de Media GmbH, Thomaskirchhof 20, 04109 Leipzig, die als ungebundener Vermittler nicht beratend tätig ist. Irrtümer vorbehalten. Preise ggf. inkl. MwSt.'
1053
+ info: 'Für Ihre Finanzierungswünsche stellen wir eine Bonitätsanfrage. Bonität vorausgesetzt, dies ist ein Berechnungsbeispiel gem. Ihrer Angaben, welches 2/3 aller Kunden erhalten. Dieses freibleibende Angebot der {{financialInstitution}} wird vermittelt durch die auto.de Media GmbH, Zwickauer Str. 127 b, 04279 Leipzig, die als ungebundener Vermittler nicht beratend tätig ist. Irrtümer vorbehalten. Preise ggf. inkl. MwSt.'
1054
1054
  }
1055
1055
  }
1056
1056
  };