@bytebrand/fe-ui-core 4.2.153 → 4.2.154

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.2.153",
3
+ "version": "4.2.154",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -73,95 +73,137 @@ const OrderStatusSection = ({
73
73
  }
74
74
  };
75
75
 
76
+ const defaultCarProps = {
77
+ car: {
78
+ _id: '',
79
+ mainData: {
80
+ make: '',
81
+ model: '',
82
+ subModel: ''
83
+ },
84
+ metaData: {
85
+ mainImageId: ''
86
+ }
87
+ },
88
+ buyingType: '',
89
+ selfPickup: false,
90
+ paybackPeriod: 0,
91
+ monthlyInstallment: 0,
92
+ status: '',
93
+ request: '',
94
+ registration: false,
95
+ currentSalesPrice: 0,
96
+ deposit: 0,
97
+ preparationCost: 0,
98
+ licensePlateCost: 0,
99
+ registrationCost: 0,
100
+ transportationCost: 0,
101
+ customerAddress: {
102
+ customerFirstname: '',
103
+ customerLastname: '',
104
+ customerStreet: '',
105
+ customerZip: ''
106
+ },
107
+ deliveryAddress: {
108
+ deliveryPartner: '',
109
+ deliveryStreet: '',
110
+ deliveryZip: '',
111
+ deliveryCity: ''
112
+ }
113
+ }
114
+
76
115
  const renderRequestedCars = () => {
77
116
  return (
78
117
  <>
79
- {!!orderedCars && orderedCars.map((orderedCar: any, index: number) => {
80
- const { car: { _id } } = orderedCar;
81
- const { car: { mainData: { make, model, subModel } } } = orderedCar;
82
- const { car: { metaData: { mainImageId } } } = orderedCar;
83
- const {
84
- buyingType,
85
- selfPickup,
86
- paybackPeriod,
87
- monthlyInstallment,
88
- status,
89
- request,
90
- registration,
91
- currentSalesPrice,
92
- deposit,
93
- preparationCost,
94
- licensePlateCost,
95
- registrationCost,
96
- transportationCost,
97
- customerAddress,
98
- deliveryAddress
99
- } = orderedCar;
100
-
101
- const additionalOrderData = {
102
- addressData: [
103
- ...customerAddress ? [{ label: t('MyOrderPage:billingAddress'), value: getTransformAddressToString(customerAddress) }] : [],
104
- ...deliveryAddress ? [{ label: t('MyOrderPage:vehicleDelivery'), value: getTransformAddressToString(deliveryAddress) }] : []
105
- ],
106
- carPriceData: [
107
- ...currentSalesPrice ? [getDataPriceItem(currentSalesPrice, t('MyOrderPage:carPrice'))] : [],
108
- ...preparationCost ? [getDataPriceItem(preparationCost, t('MyOrderPage:preparationCost'))] : [],
109
- ...registrationCost ? [getDataPriceItem(registrationCost, t('MyOrderPage:vehicleRegistration'))] : [],
110
- ...licensePlateCost ? [getDataPriceItem(licensePlateCost, t('MyOrderPage:licensePlates'))] : [],
111
- ...transportationCost ? [getDataPriceItem(transportationCost, t('MyOrderPage:delivery'))] : [],
112
- ...buyingType !== 'buy' ? [
113
- ...monthlyInstallment ? [
114
- {
115
- label: t(`MyOrderPage:${buyingType}Rate`),
116
- value: t('MyOrderPage:monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f', '', '€') })
117
- }] : [],
118
- ...paybackPeriod ? [{ label: t('MyOrderPage:runningTime'), value: t('MyOrderPage:paybackPeriod', { paybackPeriod }) }] : [],
119
- ...deposit ? [getDataPriceItem(deposit, t('MyOrderPage:deposit'))] : []
120
- ] : []
121
- ],
122
- overallRate: {
123
- label: t('MyOrderPage:yourOverallRate'),
124
- value: buyingType === 'buy' ? currentSalesPrice : monthlyInstallment
125
- }
126
- };
127
-
128
- const additionalOrderInfoProps = {
129
- t,
130
- additionalOrderData,
131
- redirectToUrl,
132
- buyingType
133
- };
134
-
135
- const imageUrl = getSupportedImageFormat(_id, mainImageId, 'small');
136
-
137
- const orderStatusCarProps = {
138
- make,
139
- model,
140
- subModel,
141
- buyingType,
142
- imageUrl,
143
- selfPickup,
144
- paybackPeriod,
145
- monthlyInstallment,
146
- status,
147
- t,
148
- request,
149
- registration,
150
- currentSalesPrice,
151
- onClick: () => onDetailsClick(_id)
152
- };
153
-
154
- const title = <span>
155
- {t('orderStatus.title')}:&nbsp;
156
- <span className={styles.orderStatus}>{t(`orderStatus.${status}`)}</span>
157
- </span>;
158
-
159
- return (
160
- <DashboardSection key={index} title={title}>
161
- <OrderStatusCar { ...orderStatusCarProps } />
162
- {withAdditionalInfo ? <AdditionalOrderInfo { ...additionalOrderInfoProps } /> : null}
163
- </DashboardSection>
164
- );
118
+ {!!orderedCars && orderedCars.map((orderedCarData: any, index: number) => {
119
+ if (orderedCarData && typeof orderedCarData.car === 'object') {
120
+ const orderedCar = { ...defaultCarProps, ...orderedCarData };
121
+ const { car: { _id } } = orderedCar;
122
+ const { car: { mainData: { make, model, subModel } } } = orderedCar;
123
+ const { car: { metaData: { mainImageId } } } = orderedCar;
124
+ const {
125
+ buyingType,
126
+ selfPickup,
127
+ paybackPeriod,
128
+ monthlyInstallment,
129
+ status,
130
+ request,
131
+ registration,
132
+ currentSalesPrice,
133
+ deposit,
134
+ preparationCost,
135
+ licensePlateCost,
136
+ registrationCost,
137
+ transportationCost,
138
+ customerAddress,
139
+ deliveryAddress
140
+ } = orderedCar;
141
+
142
+ const additionalOrderData = {
143
+ addressData: [
144
+ ...customerAddress ? [{ label: t('MyOrderPage:billingAddress'), value: getTransformAddressToString(customerAddress) }] : [],
145
+ ...deliveryAddress ? [{ label: t('MyOrderPage:vehicleDelivery'), value: getTransformAddressToString(deliveryAddress) }] : []
146
+ ],
147
+ carPriceData: [
148
+ ...currentSalesPrice ? [getDataPriceItem(currentSalesPrice, t('MyOrderPage:carPrice'))] : [],
149
+ ...preparationCost ? [getDataPriceItem(preparationCost, t('MyOrderPage:preparationCost'))] : [],
150
+ ...registrationCost ? [getDataPriceItem(registrationCost, t('MyOrderPage:vehicleRegistration'))] : [],
151
+ ...licensePlateCost ? [getDataPriceItem(licensePlateCost, t('MyOrderPage:licensePlates'))] : [],
152
+ ...transportationCost ? [getDataPriceItem(transportationCost, t('MyOrderPage:delivery'))] : [],
153
+ ...buyingType !== 'buy' ? [
154
+ ...monthlyInstallment ? [
155
+ {
156
+ label: t(`MyOrderPage:${buyingType}Rate`),
157
+ value: t('MyOrderPage:monthlyInstallment', { monthlyInstallment: getFormattedPrice(monthlyInstallment, '$,.2f', '', '€') })
158
+ }] : [],
159
+ ...paybackPeriod ? [{ label: t('MyOrderPage:runningTime'), value: t('MyOrderPage:paybackPeriod', { paybackPeriod }) }] : [],
160
+ ...deposit ? [getDataPriceItem(deposit, t('MyOrderPage:deposit'))] : []
161
+ ] : []
162
+ ],
163
+ overallRate: {
164
+ label: t('MyOrderPage:yourOverallRate'),
165
+ value: buyingType === 'buy' ? currentSalesPrice : monthlyInstallment
166
+ }
167
+ };
168
+
169
+ const additionalOrderInfoProps = {
170
+ t,
171
+ additionalOrderData,
172
+ redirectToUrl,
173
+ buyingType
174
+ };
175
+
176
+ const imageUrl = getSupportedImageFormat(_id, mainImageId, 'small');
177
+
178
+ const orderStatusCarProps = {
179
+ make,
180
+ model,
181
+ subModel,
182
+ buyingType,
183
+ imageUrl,
184
+ selfPickup,
185
+ paybackPeriod,
186
+ monthlyInstallment,
187
+ status,
188
+ t,
189
+ request,
190
+ registration,
191
+ currentSalesPrice,
192
+ onClick: () => onDetailsClick(_id)
193
+ };
194
+
195
+ const title = <span>
196
+ {t('orderStatus.title')}:&nbsp;
197
+ <span className={styles.orderStatus}>{t(`orderStatus.${status}`)}</span>
198
+ </span>;
199
+
200
+ return (
201
+ <DashboardSection key={index} title={title}>
202
+ <OrderStatusCar { ...orderStatusCarProps } />
203
+ {withAdditionalInfo ? <AdditionalOrderInfo { ...additionalOrderInfoProps } /> : null}
204
+ </DashboardSection>
205
+ );
206
+ }
165
207
  })}
166
208
  </>
167
209
  );