@bytebrand/fe-ui-core 4.2.73 → 4.2.75

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/common.ts CHANGED
@@ -30,6 +30,7 @@ export { default as VehicleSliderForSRL } from './source/components/_common/Vehi
30
30
  export { default as VehicleSmallCard } from './source/components/VehicleSmallCard/VehicleSmallCard';
31
31
  export { default as OfferPanel } from './source/components/OfferPanel/OfferPanel';
32
32
 
33
+ export { default as FormTextField } from './source/components/_common/TextField/FormTextField';
33
34
  export { default as Tooltip } from './source/components/_common/Tooltip/Tooltip';
34
35
  export { default as TextField } from './source/components/_common/TextField/TextField';
35
36
  export { default as FormattedNumber } from './source/components/FormattedNumber/FormattedNumber';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.73",
3
+ "version": "4.2.75",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -33,6 +33,9 @@
33
33
  font-size: 14px
34
34
  line-height: 20px
35
35
 
36
+ .adressDataValue
37
+ margin-top: 16px
38
+
36
39
  .orderInfoAddresses
37
40
  padding-bottom: 8px
38
41
  grid-area: addresses
@@ -62,11 +65,13 @@
62
65
  @extend .labelText
63
66
  text-align: center
64
67
  padding: 16px 24px
65
- border-top: 1px solid rgba(76,78,100,0.12)
66
68
  grid-area: customerSuport
67
69
 
70
+ .supportSectionBorder
71
+ border-top: 1px solid rgba(76,78,100,0.12)
72
+
68
73
  .customerSuportButton
69
- margin-top: 8px
74
+ margin-top: 8px !important
70
75
  color: #26C6F9 !important
71
76
  border-color: #26C6F9 !important
72
77
  border-radius: 8px !important
@@ -8,8 +8,8 @@ import classNames from 'classnames';
8
8
  import { TFunction } from '../../../../framework/types/types';
9
9
 
10
10
  interface IAdditionalOrderData {
11
- addressData: { label: string, value: string }[];
12
- carPriceData: { label: string, value: string | number }[];
11
+ addressData: ({ value: string; label: string; })[];
12
+ carPriceData: ({ value: string; label: string; })[] | any;
13
13
  overallRate: { label: string, value: number };
14
14
  }
15
15
 
@@ -27,29 +27,38 @@ const AdditionalOrderInfo = ({ t, additionalOrderData, redirectToUrl, buyingType
27
27
  return redirectToUrl('/account/kontakt');
28
28
  };
29
29
 
30
+ const supportSectionClassnames = classNames(
31
+ styles.customerSuport,
32
+ {[styles.supportSectionBorder]: addressData.length > 0}
33
+ )
34
+
30
35
  return (
31
36
  <div className={styles.container}>
32
37
  <div className={styles.orderInfoAddresses}>
33
38
  {addressData.map((data) => {
34
39
  const { value, label } = data;
35
- return (
36
- <div key={label}>
37
- <div className={styles.labelText}>{label}</div>
38
- <div className={styles.labelText}>{value}</div>
39
- </div>
40
- );
40
+ if (!!value) {
41
+ return (
42
+ <div key={label}>
43
+ <div className={styles.labelText}>{label}</div>
44
+ <div className={classNames(styles.labelText, styles.adressDataValue)}>{value}</div>
45
+ </div>
46
+ );
47
+ }
41
48
  })}
42
49
  </div>
43
50
  <div className={styles.orderPriceSection}>
44
51
  <div className={styles.orderInfoPrice}>
45
- {carPriceData.map((data) => {
52
+ {carPriceData.map((data: { value: string, label: string }) => {
46
53
  const { value, label } = data;
47
- return (
48
- <div key={label} className={styles.flexContainer}>
49
- <div className={styles.labelText}>{label}</div>
50
- <div className={styles.labelText}>{value}</div>
51
- </div>
52
- );
54
+ if (!!value) {
55
+ return (
56
+ <div key={label} className={styles.flexContainer}>
57
+ <div className={styles.labelText}>{label}</div>
58
+ <div className={styles.labelText}>{value}</div>
59
+ </div>
60
+ );
61
+ }
53
62
  })}
54
63
  </div>
55
64
  <div className={styles.orderInfoFinancing}>
@@ -70,9 +79,9 @@ const AdditionalOrderInfo = ({ t, additionalOrderData, redirectToUrl, buyingType
70
79
  </div>
71
80
  </div>
72
81
  </div>
73
- <div className={styles.customerSuport}>
74
- <div>{t('customerSupportText')}</div>
75
- <Button onClick={redirectToContactPage} className={styles.customerSuportButton} variant='outlined'>{t('customerSupport')}</Button>
82
+ <div className={supportSectionClassnames}>
83
+ <div>{t('MyOrderPage:customerSupportText')}</div>
84
+ <Button onClick={redirectToContactPage} className={styles.customerSuportButton} variant='outlined'>{t('MyOrderPage:customerSupport')}</Button>
76
85
  </div>
77
86
  </div>
78
87
  );
@@ -35,6 +35,43 @@ const OrderStatusSection = ({
35
35
  return redirectToUrl(`/search/vehicle/${carId}`);
36
36
  };
37
37
 
38
+ // transforming address object to string
39
+ const getTransformAddressToString = (addressObj: {[key: string]: string}) => {
40
+ let addressString = '';
41
+ if (!!addressObj) {
42
+ Object.keys(addressObj).forEach((key) => {
43
+ switch (key) {
44
+ case 'customerFirstname':
45
+ case 'customerLastname':
46
+ addressString = `${addressString} ${addressObj[key]}`;
47
+ break;
48
+ case 'deliveryPartner':
49
+ case 'customerStreet':
50
+ case 'deliveryStreet':
51
+ case 'customerZip':
52
+ case 'deliveryZip':
53
+ if (!!addressString) {
54
+ addressString = `${addressString}, ${addressObj[key]}`;
55
+ } else {
56
+ addressString = `${addressString} ${addressObj[key]}`;
57
+ }
58
+ break;
59
+ case 'customerCity':
60
+ case 'deliveryCity':
61
+ addressString = `${addressString} ${addressObj[key]}`;
62
+ break;
63
+ }
64
+ })
65
+ }
66
+ return addressString;
67
+ };
68
+
69
+ const getDataPriceItem = (value: number, label: string): {value: string, label: string} | [] => {
70
+ if (!!value && value !== 0) {
71
+ return { value: getFormattedPrice(value, '$,.2f', ' €'), label };
72
+ }
73
+ }
74
+
38
75
  const renderRequestedCars = () => {
39
76
  return (
40
77
  <>
@@ -56,31 +93,33 @@ const OrderStatusSection = ({
56
93
  licensePlateCost,
57
94
  registrationCost,
58
95
  transportationCost,
59
- customerAddress: {
60
- customerFirstname = '',
61
- customerLastname = ''
62
- } = {}
96
+ customerAddress,
97
+ deliveryAddress
63
98
  } = orderedCar;
64
99
 
65
100
  const additionalOrderData = {
66
101
  addressData: [
67
- { label: 'Billing address:', value: `${customerFirstname} ${customerLastname}` },
68
- { label: 'Vehicle delivery:', value: 'Hannes Käther, Wittenberger Str. 81, 04129 Leipzig' }
102
+ ...customerAddress ? [{ label: t('MyOrderPage:billingAddress'), value: getTransformAddressToString(customerAddress) }] : [],
103
+ ...deliveryAddress ? [{ label: t('MyOrderPage:vehicleDelivery'), value: getTransformAddressToString(deliveryAddress) }] : []
69
104
  ],
70
105
  carPriceData: [
71
- { label: 'Car price', value: getFormattedPrice(currentSalesPrice, '$,.2f', ' €') },
72
- { label: 'Preparation cost', value: getFormattedPrice(preparationCost, '$,.2f', ' €')},
73
- { label: 'vehicle registration', value: getFormattedPrice(registrationCost, '$,.2f', ' €') },
74
- { label: 'license plates', value: getFormattedPrice(licensePlateCost, '$,.2f', ' €') },
75
- { label: 'Delivery', value: getFormattedPrice(transportationCost, '$,.2f', ' €') },
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'))] : [],
76
111
  ...buyingType !== 'buy' ? [
77
- { label: `${buyingType} rate`, value: `${getFormattedPrice(monthlyInstallment, '$,.2f', '', '€')} per month` },
78
- { label: 'Running time (months)', value: `${paybackPeriod} months` },
79
- { label: 'Deposit', value: getFormattedPrice(deposit, '$,.2f', ' €') }
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'))] : []
80
119
  ] : []
81
120
  ],
82
121
  overallRate: {
83
- label: 'Your overall rate',
122
+ label: t('MyOrderPage:yourOverallRate'),
84
123
  value: buyingType === 'buy' ? currentSalesPrice : monthlyInstallment
85
124
  }
86
125
  };
@@ -4,8 +4,7 @@ import classnames from 'classnames';
4
4
  import styles from './FormDropDown.styl';
5
5
 
6
6
  import DropDown from './DropDown';
7
-
8
- type ErrorPositionType = 'TopRight' | 'TopLeft' | 'BottomRight' | 'BottomLeft';
7
+ import { ErrorPositionType } from '../TextField/FormTextField';
9
8
 
10
9
  interface IFormDropDownProps {
11
10
  // mobx form field instance
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
+ import { observer } from 'mobx-react';
3
4
 
4
5
  import RadioGroup from './RadioGroup';
5
6
  import styles from './FormRadioGroup.styl';
@@ -7,19 +8,16 @@ import styles from './FormRadioGroup.styl';
7
8
  interface IFormRadioGroupProps {
8
9
  children: any;
9
10
  className?: string;
11
+
12
+ // mobx form field instance
10
13
  field: any;
14
+
11
15
  containerClassName?: string;
12
16
  childClassName?: string;
13
17
  }
14
18
 
15
- interface IFormRadioGroupState {
16
- field: {
17
- name?: string;
18
- value?: string;
19
- };
20
- }
21
-
22
- class FormRadioGroup extends React.Component<IFormRadioGroupProps, IFormRadioGroupState> {
19
+ @observer
20
+ class FormRadioGroup extends React.Component<IFormRadioGroupProps> {
23
21
  static defaultProps = {
24
22
  className: '',
25
23
  label: false,
@@ -27,39 +25,16 @@ class FormRadioGroup extends React.Component<IFormRadioGroupProps, IFormRadioGro
27
25
  childClassName: ''
28
26
  };
29
27
 
30
- constructor(props: IFormRadioGroupProps) {
31
- super(props);
32
- this.state = {
33
- field: {
34
- name: '',
35
- value: ''
36
- }
37
- };
38
- }
39
-
40
- handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>, value?: any) => {
41
- const { name, onChange } = this.props.field;
42
- this.setState(() => ({
43
- field: {
44
- name,
45
- value
46
- }
47
- }));
48
- onChange(event, value);
49
- };
50
-
51
28
  render() {
52
- const { className, containerClassName, childClassName, field } = this.props;
53
- const { name, value } = this.state.field;
29
+ const { field, className, containerClassName, childClassName } = this.props;
30
+
54
31
  const hasError = field.hasError;
55
32
  const error = field.error;
56
33
 
57
34
  const _props = {
58
- name,
59
- value,
35
+ ...field.bind(),
60
36
  containerClassName,
61
37
  childClassName,
62
- onChange: this.handleRadioChange,
63
38
  error: hasError
64
39
  };
65
40
 
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+
3
+ import { storiesOf } from '@storybook/react';
4
+ import FormTextField from './FormTextField';
5
+
6
+
7
+ const field = {
8
+ error: 'Something went wrong',
9
+ hasError: true,
10
+ bind: () => {
11
+ const { bind, ...rest } = field;
12
+ return rest;
13
+ }
14
+ };
15
+
16
+ storiesOf('_Common_UI', module)
17
+ .add('FormTextField', () => (
18
+ <div>
19
+ <FormTextField errorPosition='BottomRight' field={field}/>
20
+ </div>
21
+ ));
@@ -0,0 +1,35 @@
1
+ .field
2
+ position: relative
3
+
4
+ .errorText
5
+ position: absolute
6
+ display: block
7
+ width: 100%
8
+ z-index: 1
9
+ font-family: "Arial Standard", Arial
10
+ font-weight: 400;
11
+ font-style: normal
12
+ font-size: 10px
13
+ color: rgb(204, 51, 51)
14
+ overflow: hidden
15
+ text-overflow: ellipsis
16
+ white-space: nowrap
17
+ box-sizing border-box
18
+ padding: 0 2px
19
+
20
+ .errorBottomLeft,
21
+ .errorTopLeft
22
+ text-align: left
23
+
24
+ .errorBottomRight,
25
+ .errorTopRight
26
+ text-align: right
27
+
28
+ .errorBottomLeft,
29
+ .errorBottomRight
30
+ bottom: -15px
31
+
32
+ .errorTopLeft,
33
+ .errorTopRight
34
+ top: -15px
35
+
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import { observer } from 'mobx-react';
4
+
5
+ import styles from './FormTextField.styl';
6
+ import TextField from './TextField';
7
+
8
+ export type ErrorPositionType = 'TopRight' | 'TopLeft' | 'BottomRight' | 'BottomLeft';
9
+
10
+ interface IFormTextFieldProps {
11
+ errorPosition?: ErrorPositionType;
12
+ className?: string;
13
+ // TODO: change this when mobx-react-form supports typescript
14
+ field: any;
15
+ type?: string;
16
+
17
+ min?: number;
18
+ step?: number;
19
+ max?: number;
20
+
21
+ onKeyPress?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
22
+ }
23
+
24
+ @observer
25
+ class FormTextField extends React.Component<IFormTextFieldProps, {}> {
26
+ static defaultProps = {
27
+ className: '',
28
+ errorPosition: 'BottomLeft',
29
+ t: () => ''
30
+ };
31
+
32
+ render() {
33
+ const { className, errorPosition, field, type, min, step, max, onKeyPress } = this.props;
34
+ const errorClassName = classnames(styles.errorText, styles[`error${errorPosition}`]);
35
+
36
+ const hasError = field.hasError;
37
+ const error = field.error;
38
+
39
+ const props = {
40
+ ...field.bind(),
41
+ min, step, max,
42
+ onKeyPress
43
+ };
44
+
45
+ return (
46
+ <div className={classnames(styles.field, className)}>
47
+ <TextField error={hasError && error} {...props} type={type || field.type} />
48
+ {hasError && error ? (<span className={errorClassName}>{error}</span>) : false}
49
+ </div>
50
+ );
51
+ }
52
+ }
53
+
54
+ export default FormTextField;