@driveflux/api-functions 0.0.7-next.0 → 0.0.7-next.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.
- package/dist/auth/confirm.js +73 -327
- package/dist/auth/emails.js +43 -210
- package/dist/auth/formatter.js +11 -11
- package/dist/auth/otp.js +122 -392
- package/dist/auth/register.js +100 -396
- package/dist/auth/tokens.js +115 -430
- package/dist/auth/verifications.js +177 -583
- package/dist/constants.js +5 -4
- package/dist/mailjet/calls/manage-contacts-in-list.js +22 -166
- package/dist/mailjet/calls/manage-subscription-status.js +13 -153
- package/dist/mailjet/calls/request-service.js +18 -183
- package/dist/mailjet/refresh-email-preferences.js +26 -225
- package/dist/mailjet/set-contact.js +23 -214
- package/dist/mailjet/types.js +2 -1
- package/dist/mailjet/utils/convert-to-array.js +9 -58
- package/dist/mailjet/utils/extract-email-preferences.js +41 -217
- package/dist/mailjet/utils/lists.js +30 -249
- package/dist/mailjet/utils/update-email-references.js +27 -208
- package/dist/notion/client.js +48 -197
- package/dist/notion/helpful.js +29 -170
- package/dist/notion/schemas/block.js +49 -43
- package/dist/notion/schemas/common.js +17 -14
- package/dist/notion/schemas/database.js +125 -159
- package/dist/notion/schemas/emoji.js +3 -2
- package/dist/notion/schemas/file.js +10 -10
- package/dist/notion/schemas/kb.js +9 -8
- package/dist/notion/schemas/page.js +126 -171
- package/dist/notion/schemas/parent.js +9 -8
- package/dist/notion/schemas/user.js +21 -20
- package/dist/reservation/agree.js +19 -158
- package/dist/reservation/checks.js +23 -178
- package/dist/reservation/display-vehicle.js +142 -514
- package/dist/reservation/fetch-or-create.js +197 -482
- package/dist/reservation/invoice.js +198 -496
- package/dist/reservation/payer.js +28 -177
- package/dist/reservation/reserve.js +31 -191
- package/dist/reservation/types.js +2 -1
- package/dist/reservation/vehicle.js +24 -186
- package/dist/slack.js +67 -273
- package/dist/validation.js +81 -139
- package/dist/vehicle/vehicle-pricing/constants.js +33 -36
- package/dist/vehicle/vehicle-pricing/index.js +99 -257
- package/dist/vehicle/vehicle-pricing/types.js +2 -1
- package/package.json +9 -9
|
@@ -1,381 +1,73 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
|
-
function _array_without_holes(arr) {
|
|
10
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
-
}
|
|
12
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
-
try {
|
|
14
|
-
var info = gen[key](arg);
|
|
15
|
-
var value = info.value;
|
|
16
|
-
} catch (error) {
|
|
17
|
-
reject(error);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (info.done) {
|
|
21
|
-
resolve(value);
|
|
22
|
-
} else {
|
|
23
|
-
Promise.resolve(value).then(_next, _throw);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function _async_to_generator(fn) {
|
|
27
|
-
return function() {
|
|
28
|
-
var self = this, args = arguments;
|
|
29
|
-
return new Promise(function(resolve, reject) {
|
|
30
|
-
var gen = fn.apply(self, args);
|
|
31
|
-
function _next(value) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
-
}
|
|
34
|
-
function _throw(err) {
|
|
35
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
-
}
|
|
37
|
-
_next(undefined);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function _define_property(obj, key, value) {
|
|
42
|
-
if (key in obj) {
|
|
43
|
-
Object.defineProperty(obj, key, {
|
|
44
|
-
value: value,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
obj[key] = value;
|
|
51
|
-
}
|
|
52
|
-
return obj;
|
|
53
|
-
}
|
|
54
|
-
function _iterable_to_array(iter) {
|
|
55
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
56
|
-
}
|
|
57
|
-
function _iterable_to_array_limit(arr, i) {
|
|
58
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
59
|
-
if (_i == null) return;
|
|
60
|
-
var _arr = [];
|
|
61
|
-
var _n = true;
|
|
62
|
-
var _d = false;
|
|
63
|
-
var _s, _e;
|
|
64
|
-
try {
|
|
65
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
66
|
-
_arr.push(_s.value);
|
|
67
|
-
if (i && _arr.length === i) break;
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
_d = true;
|
|
71
|
-
_e = err;
|
|
72
|
-
} finally{
|
|
73
|
-
try {
|
|
74
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
75
|
-
} finally{
|
|
76
|
-
if (_d) throw _e;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return _arr;
|
|
80
|
-
}
|
|
81
|
-
function _non_iterable_rest() {
|
|
82
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
83
|
-
}
|
|
84
|
-
function _non_iterable_spread() {
|
|
85
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
|
-
}
|
|
87
|
-
function _object_spread(target) {
|
|
88
|
-
for(var i = 1; i < arguments.length; i++){
|
|
89
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
90
|
-
var ownKeys = Object.keys(source);
|
|
91
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
92
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
93
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
ownKeys.forEach(function(key) {
|
|
97
|
-
_define_property(target, key, source[key]);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return target;
|
|
101
|
-
}
|
|
102
|
-
function ownKeys(object, enumerableOnly) {
|
|
103
|
-
var keys = Object.keys(object);
|
|
104
|
-
if (Object.getOwnPropertySymbols) {
|
|
105
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
106
|
-
if (enumerableOnly) {
|
|
107
|
-
symbols = symbols.filter(function(sym) {
|
|
108
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
keys.push.apply(keys, symbols);
|
|
112
|
-
}
|
|
113
|
-
return keys;
|
|
114
|
-
}
|
|
115
|
-
function _object_spread_props(target, source) {
|
|
116
|
-
source = source != null ? source : {};
|
|
117
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
118
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
119
|
-
} else {
|
|
120
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
121
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return target;
|
|
125
|
-
}
|
|
126
|
-
function _sliced_to_array(arr, i) {
|
|
127
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
128
|
-
}
|
|
129
|
-
function _to_consumable_array(arr) {
|
|
130
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
131
|
-
}
|
|
132
|
-
function _type_of(obj) {
|
|
133
|
-
"@swc/helpers - typeof";
|
|
134
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
135
|
-
}
|
|
136
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
137
|
-
if (!o) return;
|
|
138
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
139
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
140
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
141
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
142
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
143
|
-
}
|
|
144
|
-
function _ts_generator(thisArg, body) {
|
|
145
|
-
var f, y, t, _ = {
|
|
146
|
-
label: 0,
|
|
147
|
-
sent: function() {
|
|
148
|
-
if (t[0] & 1) throw t[1];
|
|
149
|
-
return t[1];
|
|
150
|
-
},
|
|
151
|
-
trys: [],
|
|
152
|
-
ops: []
|
|
153
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
154
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
155
|
-
return this;
|
|
156
|
-
}), g;
|
|
157
|
-
function verb(n) {
|
|
158
|
-
return function(v) {
|
|
159
|
-
return step([
|
|
160
|
-
n,
|
|
161
|
-
v
|
|
162
|
-
]);
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function step(op) {
|
|
166
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
167
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
168
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
169
|
-
if (y = 0, t) op = [
|
|
170
|
-
op[0] & 2,
|
|
171
|
-
t.value
|
|
172
|
-
];
|
|
173
|
-
switch(op[0]){
|
|
174
|
-
case 0:
|
|
175
|
-
case 1:
|
|
176
|
-
t = op;
|
|
177
|
-
break;
|
|
178
|
-
case 4:
|
|
179
|
-
_.label++;
|
|
180
|
-
return {
|
|
181
|
-
value: op[1],
|
|
182
|
-
done: false
|
|
183
|
-
};
|
|
184
|
-
case 5:
|
|
185
|
-
_.label++;
|
|
186
|
-
y = op[1];
|
|
187
|
-
op = [
|
|
188
|
-
0
|
|
189
|
-
];
|
|
190
|
-
continue;
|
|
191
|
-
case 7:
|
|
192
|
-
op = _.ops.pop();
|
|
193
|
-
_.trys.pop();
|
|
194
|
-
continue;
|
|
195
|
-
default:
|
|
196
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
197
|
-
_ = 0;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
201
|
-
_.label = op[1];
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
205
|
-
_.label = t[1];
|
|
206
|
-
t = op;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
if (t && _.label < t[2]) {
|
|
210
|
-
_.label = t[2];
|
|
211
|
-
_.ops.push(op);
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
if (t[2]) _.ops.pop();
|
|
215
|
-
_.trys.pop();
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
op = body.call(thisArg, _);
|
|
219
|
-
} catch (e) {
|
|
220
|
-
op = [
|
|
221
|
-
6,
|
|
222
|
-
e
|
|
223
|
-
];
|
|
224
|
-
y = 0;
|
|
225
|
-
} finally{
|
|
226
|
-
f = t = 0;
|
|
227
|
-
}
|
|
228
|
-
if (op[0] & 5) throw op[1];
|
|
229
|
-
return {
|
|
230
|
-
value: op[0] ? op[1] : void 0,
|
|
231
|
-
done: true
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
1
|
import { config } from '@driveflux/config/backend';
|
|
236
|
-
import { prisma } from '@driveflux/db';
|
|
2
|
+
import { prisma, } from '@driveflux/db';
|
|
237
3
|
import { generateId } from '@driveflux/db/id';
|
|
238
4
|
import { createPricingController } from '@driveflux/db/models/vehicle';
|
|
239
|
-
import { getFluxExcessMileage, getFluxPiceMatrix, getHostExcessMileage, getHostsMatrix, getRecommendedMotorcycleDeposit, getStartFeeMatrix } from '../vehicle/vehicle-pricing';
|
|
240
|
-
export
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
switch(_state.label){
|
|
245
|
-
case 0:
|
|
246
|
-
if (!(typeof displayVehicle === 'string')) return [
|
|
247
|
-
3,
|
|
248
|
-
2
|
|
249
|
-
];
|
|
250
|
-
return [
|
|
251
|
-
4,
|
|
252
|
-
prisma.displayVehicle.findFirst({
|
|
253
|
-
where: {
|
|
254
|
-
id: displayVehicle
|
|
255
|
-
}
|
|
256
|
-
})
|
|
257
|
-
];
|
|
258
|
-
case 1:
|
|
259
|
-
_tmp = _state.sent();
|
|
260
|
-
return [
|
|
261
|
-
3,
|
|
262
|
-
3
|
|
263
|
-
];
|
|
264
|
-
case 2:
|
|
265
|
-
_tmp = displayVehicle;
|
|
266
|
-
_state.label = 3;
|
|
267
|
-
case 3:
|
|
268
|
-
return [
|
|
269
|
-
2,
|
|
270
|
-
_tmp
|
|
271
|
-
];
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
})();
|
|
5
|
+
import { getFluxExcessMileage, getFluxPiceMatrix, getHostExcessMileage, getHostsMatrix, getRecommendedMotorcycleDeposit, getStartFeeMatrix, } from '../vehicle/vehicle-pricing';
|
|
6
|
+
export const fetchDisplayVehicle = async (displayVehicle) => {
|
|
7
|
+
return typeof displayVehicle === 'string'
|
|
8
|
+
? await prisma.displayVehicle.findFirst({ where: { id: displayVehicle } })
|
|
9
|
+
: displayVehicle;
|
|
275
10
|
};
|
|
276
|
-
export
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
},
|
|
311
|
-
displayVehicle: {
|
|
312
|
-
connect: {
|
|
313
|
-
id: dv.id
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
return [
|
|
318
|
-
4,
|
|
319
|
-
prisma.vehicle.create({
|
|
320
|
-
data: vehicleData,
|
|
321
|
-
include: {
|
|
322
|
-
host: true
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
];
|
|
326
|
-
case 2:
|
|
327
|
-
return [
|
|
328
|
-
2,
|
|
329
|
-
_state.sent()
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
})();
|
|
11
|
+
export const createVehicleFromDisplayVehicle = async (displayVehicle, selectedColor) => {
|
|
12
|
+
const dv = await fetchDisplayVehicle(displayVehicle);
|
|
13
|
+
if (!dv || typeof dv !== 'object')
|
|
14
|
+
return;
|
|
15
|
+
if (!dv.details)
|
|
16
|
+
return;
|
|
17
|
+
const mainImage = dv.images.main.find((m) => m.variant === selectedColor)?.url;
|
|
18
|
+
const vehicleData = {
|
|
19
|
+
id: generateId('Vehicle'),
|
|
20
|
+
...transformBasicVehicleData(dv),
|
|
21
|
+
images: [
|
|
22
|
+
...(mainImage ? [transfromSingleImage(mainImage)] : []),
|
|
23
|
+
...transformImages(dv.images),
|
|
24
|
+
],
|
|
25
|
+
...transformBasePrices(dv.pricing),
|
|
26
|
+
pricing: transformPriceMatrix(dv.type, dv.pricing),
|
|
27
|
+
details: transformDetails(dv.details, selectedColor),
|
|
28
|
+
host: {
|
|
29
|
+
connect: {
|
|
30
|
+
id: dv.defaultHostId,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
displayVehicle: {
|
|
34
|
+
connect: {
|
|
35
|
+
id: dv.id,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return await prisma.vehicle.create({
|
|
40
|
+
data: vehicleData,
|
|
41
|
+
include: {
|
|
42
|
+
host: true,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
334
45
|
};
|
|
335
|
-
export
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
_object_spread_props(_object_spread(_object_spread_props(_object_spread({
|
|
359
|
-
id: dv.id
|
|
360
|
-
}, transformBasicVehicleData(dv)), {
|
|
361
|
-
images: _to_consumable_array(mainImage ? [
|
|
362
|
-
transfromSingleImage(mainImage)
|
|
363
|
-
] : []).concat(_to_consumable_array(transformImages(dv.images)))
|
|
364
|
-
}), transformBasePrices(dv.pricing)), {
|
|
365
|
-
pricing: transformPriceMatrix(dv.type, dv.pricing),
|
|
366
|
-
details: transformDetails(dv.details, selectedColor),
|
|
367
|
-
host: {
|
|
368
|
-
address: {
|
|
369
|
-
state: 'Kuala Lumpur'
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
})
|
|
373
|
-
];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
})();
|
|
46
|
+
export const transfromVehicleDisplayToVehicle = async (displayVehicle, selectedColor) => {
|
|
47
|
+
const dv = await fetchDisplayVehicle(displayVehicle);
|
|
48
|
+
if (!dv || typeof dv !== 'object')
|
|
49
|
+
return;
|
|
50
|
+
if (!dv.details)
|
|
51
|
+
return;
|
|
52
|
+
const mainImage = dv.images.main.find((m) => m.variant === selectedColor)?.url;
|
|
53
|
+
return {
|
|
54
|
+
id: dv.id,
|
|
55
|
+
...transformBasicVehicleData(dv),
|
|
56
|
+
images: [
|
|
57
|
+
...(mainImage ? [transfromSingleImage(mainImage)] : []),
|
|
58
|
+
...transformImages(dv.images),
|
|
59
|
+
],
|
|
60
|
+
...transformBasePrices(dv.pricing),
|
|
61
|
+
pricing: transformPriceMatrix(dv.type, dv.pricing),
|
|
62
|
+
details: transformDetails(dv.details, selectedColor),
|
|
63
|
+
host: {
|
|
64
|
+
address: {
|
|
65
|
+
state: 'Kuala Lumpur',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
377
69
|
};
|
|
378
|
-
export
|
|
70
|
+
export const transformBasicVehicleData = (dv) => {
|
|
379
71
|
return {
|
|
380
72
|
registrationNumber: null,
|
|
381
73
|
featured: false,
|
|
@@ -391,20 +83,19 @@ export var transformBasicVehicleData = function(dv) {
|
|
|
391
83
|
variant: dv.variant,
|
|
392
84
|
year: dv.year,
|
|
393
85
|
type: dv.type,
|
|
394
|
-
niceName:
|
|
395
|
-
niceNameShort:
|
|
396
|
-
appliedCoupon: dv.appliedCoupon
|
|
86
|
+
niceName: `${dv.make} ${dv.vehicleModel} ${dv.variant} ${dv.year}`,
|
|
87
|
+
niceNameShort: `${dv.make} ${dv.vehicleModel}`,
|
|
88
|
+
appliedCoupon: dv.appliedCoupon,
|
|
397
89
|
};
|
|
398
90
|
};
|
|
399
|
-
export
|
|
91
|
+
export const transformImages = (images) => {
|
|
400
92
|
return [
|
|
401
93
|
transfromSingleImage(images.exterior[0].url, 'exterior'),
|
|
402
|
-
transfromSingleImage(images.interior[0].url, 'interior')
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})));
|
|
94
|
+
transfromSingleImage(images.interior[0].url, 'interior'),
|
|
95
|
+
...images.gallery.map((i) => transfromSingleImage(i.url)),
|
|
96
|
+
];
|
|
406
97
|
};
|
|
407
|
-
|
|
98
|
+
const transfromSingleImage = (imageUrl, inspectionType) => {
|
|
408
99
|
return {
|
|
409
100
|
default: imageUrl,
|
|
410
101
|
blurBase64: null,
|
|
@@ -415,51 +106,53 @@ var transfromSingleImage = function(imageUrl, inspectionType) {
|
|
|
415
106
|
description: null,
|
|
416
107
|
inspection: !!inspectionType,
|
|
417
108
|
inspectionType: inspectionType || null,
|
|
418
|
-
notActualPhoto: true
|
|
109
|
+
notActualPhoto: true,
|
|
419
110
|
};
|
|
420
111
|
};
|
|
421
|
-
|
|
112
|
+
const transformBasePrices = (pricing) => {
|
|
422
113
|
return {
|
|
423
114
|
basePrice: pricing.matrix.plan36.lite,
|
|
424
115
|
basePricePlan1: pricing.matrix.plan1.lite,
|
|
425
116
|
basePricePlan12: pricing.matrix.plan12.lite,
|
|
426
117
|
basePricePlan24: pricing.matrix.plan24.lite,
|
|
427
118
|
basePricePlan36: pricing.matrix.plan36.lite,
|
|
428
|
-
basePricePlan60: pricing.matrix.plan60.lite
|
|
119
|
+
basePricePlan60: pricing.matrix.plan60.lite,
|
|
429
120
|
};
|
|
430
121
|
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
122
|
+
const transformPriceMatrix = (vehicleType, pricing) => {
|
|
123
|
+
const baseline = pricing?.matrix.plan36.lite;
|
|
124
|
+
const ultraTier = 'tier1';
|
|
125
|
+
const fluxPriceCoefficient = 25;
|
|
126
|
+
const priceMatrix = pricing.matrix;
|
|
127
|
+
const flatPricing = false;
|
|
128
|
+
const bought = false;
|
|
129
|
+
const tmv = pricing.tmv;
|
|
130
|
+
const gfv = null;
|
|
131
|
+
const gfvNotApplicable = true;
|
|
132
|
+
const { availablePlans, availableMileagePackages } = getNonZeroKeys(priceMatrix);
|
|
133
|
+
const pricingController = createPricingController({
|
|
443
134
|
coefficient: fluxPriceCoefficient,
|
|
444
|
-
vehicleType
|
|
135
|
+
vehicleType,
|
|
445
136
|
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
137
|
+
const startFeeMatrix = excludeServiceFeesFrom(getStartFeeMatrix(pricingController, baseline, flatPricing));
|
|
138
|
+
const hostMatrix = excludeServiceFeesFrom(getHostsMatrix(pricingController, baseline, ultraTier, flatPricing));
|
|
139
|
+
const hostExcessMileage = getHostExcessMileage(pricingController, baseline);
|
|
140
|
+
const fluxPriceMatrix = excludeServiceFeesFrom(getFluxPiceMatrix(pricingController, vehicleType, baseline, hostMatrix, ultraTier, flatPricing));
|
|
141
|
+
const fluxExcessMileage = getFluxExcessMileage(pricingController, baseline);
|
|
142
|
+
const recommendedDeposit = pricing.refundableDeposit || vehicleType === 'motorcycle'
|
|
143
|
+
? getRecommendedMotorcycleDeposit(baseline)
|
|
144
|
+
: null;
|
|
452
145
|
return {
|
|
453
|
-
tmv
|
|
454
|
-
gfv
|
|
455
|
-
gfvNotApplicable
|
|
456
|
-
ultraTier
|
|
146
|
+
tmv,
|
|
147
|
+
gfv,
|
|
148
|
+
gfvNotApplicable,
|
|
149
|
+
ultraTier,
|
|
457
150
|
baseline: baseline,
|
|
458
|
-
recommendedDeposit
|
|
459
|
-
availableMileagePackages
|
|
460
|
-
availablePlans
|
|
461
|
-
bought
|
|
462
|
-
flatPricing
|
|
151
|
+
recommendedDeposit,
|
|
152
|
+
availableMileagePackages,
|
|
153
|
+
availablePlans,
|
|
154
|
+
bought,
|
|
155
|
+
flatPricing,
|
|
463
156
|
fluxPrice: {
|
|
464
157
|
coefficient: fluxPriceCoefficient,
|
|
465
158
|
matrix: fluxPriceMatrix,
|
|
@@ -467,150 +160,85 @@ var transformPriceMatrix = function(vehicleType, pricing) {
|
|
|
467
160
|
excessMileage: fluxExcessMileage,
|
|
468
161
|
originalExcessMileage: fluxExcessMileage,
|
|
469
162
|
matrixComments: null,
|
|
470
|
-
add: null
|
|
163
|
+
add: null,
|
|
471
164
|
},
|
|
472
165
|
hostTake: {
|
|
473
166
|
matrix: hostMatrix,
|
|
474
167
|
originalMatrix: hostMatrix,
|
|
475
168
|
excessMileage: hostExcessMileage,
|
|
476
169
|
originalExcessMileage: hostExcessMileage,
|
|
477
|
-
matrixComments: null
|
|
170
|
+
matrixComments: null,
|
|
478
171
|
},
|
|
479
172
|
startFee: {
|
|
480
173
|
matrix: startFeeMatrix,
|
|
481
174
|
originalMatrix: startFeeMatrix,
|
|
482
|
-
matrixComments: null
|
|
483
|
-
}
|
|
175
|
+
matrixComments: null,
|
|
176
|
+
},
|
|
484
177
|
};
|
|
485
178
|
};
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
});
|
|
498
|
-
if (hasNonZero) {
|
|
499
|
-
planKeys.add(plan);
|
|
500
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
501
|
-
try {
|
|
502
|
-
for(var _iterator1 = entries[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
503
|
-
var _step_value1 = _sliced_to_array(_step1.value, 2), mileage = _step_value1[0], value = _step_value1[1];
|
|
504
|
-
if ((value !== null && value !== void 0 ? value : 0) > 0) {
|
|
505
|
-
mileageKeys.add(mileage);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
} catch (err) {
|
|
509
|
-
_didIteratorError1 = true;
|
|
510
|
-
_iteratorError1 = err;
|
|
511
|
-
} finally{
|
|
512
|
-
try {
|
|
513
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
514
|
-
_iterator1.return();
|
|
515
|
-
}
|
|
516
|
-
} finally{
|
|
517
|
-
if (_didIteratorError1) {
|
|
518
|
-
throw _iteratorError1;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
179
|
+
const getNonZeroKeys = (matrix) => {
|
|
180
|
+
const planKeys = new Set();
|
|
181
|
+
const mileageKeys = new Set();
|
|
182
|
+
for (const [plan, mileageMap] of Object.entries(matrix)) {
|
|
183
|
+
const entries = Object.entries(mileageMap ?? {});
|
|
184
|
+
const hasNonZero = entries.some(([_, value]) => (value ?? 0) > 0);
|
|
185
|
+
if (hasNonZero) {
|
|
186
|
+
planKeys.add(plan);
|
|
187
|
+
for (const [mileage, value] of entries) {
|
|
188
|
+
if ((value ?? 0) > 0) {
|
|
189
|
+
mileageKeys.add(mileage);
|
|
521
190
|
}
|
|
522
191
|
}
|
|
523
192
|
}
|
|
524
|
-
} catch (err) {
|
|
525
|
-
_didIteratorError = true;
|
|
526
|
-
_iteratorError = err;
|
|
527
|
-
} finally{
|
|
528
|
-
try {
|
|
529
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
530
|
-
_iterator.return();
|
|
531
|
-
}
|
|
532
|
-
} finally{
|
|
533
|
-
if (_didIteratorError) {
|
|
534
|
-
throw _iteratorError;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
193
|
}
|
|
538
194
|
return {
|
|
539
195
|
availablePlans: Array.from(planKeys),
|
|
540
|
-
availableMileagePackages: Array.from(mileageKeys)
|
|
196
|
+
availableMileagePackages: Array.from(mileageKeys),
|
|
541
197
|
};
|
|
542
198
|
};
|
|
543
|
-
|
|
199
|
+
const _getInspection = () => {
|
|
544
200
|
return {
|
|
545
201
|
exterior: 5,
|
|
546
202
|
interior: 5,
|
|
547
203
|
engine: 5,
|
|
548
204
|
frame: 5,
|
|
549
205
|
total: 5,
|
|
550
|
-
comment: 'COMMENT HERE'
|
|
206
|
+
comment: 'COMMENT HERE',
|
|
551
207
|
};
|
|
552
208
|
};
|
|
553
|
-
|
|
554
|
-
|
|
209
|
+
const transformDetails = (details, selectColor) => {
|
|
210
|
+
const color = selectColor || details.colors[0].name || '';
|
|
555
211
|
return {
|
|
556
212
|
numberOfSeats: details.numberOfSeats,
|
|
557
213
|
doors: details.doors,
|
|
558
214
|
bodyType: details.bodyType,
|
|
559
215
|
transmission: details.transmission,
|
|
560
216
|
engineType: details.fuelType,
|
|
561
|
-
engineCapacity: details.fuelType === 'electric'
|
|
217
|
+
engineCapacity: details.fuelType === 'electric'
|
|
218
|
+
? details.batteryCapacity
|
|
219
|
+
: details.engineCapacity,
|
|
562
220
|
drivetrain: details.drivetrain,
|
|
563
221
|
accelerationTo100km: details.accelerationTo100km,
|
|
564
222
|
fuelConsumptionLitersPer100Km: details.fuelConsumptionLitersPer100Km,
|
|
565
|
-
color
|
|
223
|
+
color,
|
|
566
224
|
features: details.features,
|
|
567
|
-
condition: 'new'
|
|
225
|
+
condition: 'new',
|
|
568
226
|
};
|
|
569
227
|
};
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
var _step_value1 = _sliced_to_array(_step1.value, 2), mileageKey = _step_value1[0], price = _step_value1[1];
|
|
582
|
-
if (typeof price === 'number') {
|
|
583
|
-
matrix[planKey][mileageKey] = price / (1 + config.serviceRate);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
} catch (err) {
|
|
587
|
-
_didIteratorError1 = true;
|
|
588
|
-
_iteratorError1 = err;
|
|
589
|
-
} finally{
|
|
590
|
-
try {
|
|
591
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
592
|
-
_iterator1.return();
|
|
593
|
-
}
|
|
594
|
-
} finally{
|
|
595
|
-
if (_didIteratorError1) {
|
|
596
|
-
throw _iteratorError1;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
} catch (err) {
|
|
602
|
-
_didIteratorError = true;
|
|
603
|
-
_iteratorError = err;
|
|
604
|
-
} finally{
|
|
605
|
-
try {
|
|
606
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
607
|
-
_iterator.return();
|
|
608
|
-
}
|
|
609
|
-
} finally{
|
|
610
|
-
if (_didIteratorError) {
|
|
611
|
-
throw _iteratorError;
|
|
228
|
+
const excludeServiceFeesFrom = (originalMatrix) => {
|
|
229
|
+
const matrix = {};
|
|
230
|
+
for (const [planKey, planValue] of Object.entries(originalMatrix)) {
|
|
231
|
+
if (!planValue)
|
|
232
|
+
continue;
|
|
233
|
+
if (!matrix[planKey])
|
|
234
|
+
matrix[planKey] = {};
|
|
235
|
+
for (const [mileageKey, price] of Object.entries(planValue)) {
|
|
236
|
+
if (typeof price === 'number') {
|
|
237
|
+
matrix[planKey][mileageKey] =
|
|
238
|
+
price / (1 + config.serviceRate);
|
|
612
239
|
}
|
|
613
240
|
}
|
|
614
241
|
}
|
|
615
242
|
return matrix;
|
|
616
243
|
};
|
|
244
|
+
//# sourceMappingURL=display-vehicle.js.map
|