@driveflux/pdf 4.0.26 → 4.0.27

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 (39) hide show
  1. package/dist/__mocks__/quotation.js +11 -10
  2. package/dist/__mocks__/subscription.js +121 -379
  3. package/dist/__mocks__/tou.js +10 -9
  4. package/dist/components/FluxLogo.js +3 -62
  5. package/dist/components/StandardPage.js +10 -99
  6. package/dist/debug.js +26 -205
  7. package/dist/index.js +1 -0
  8. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js +27 -145
  9. package/dist/templates/QuotationPdf/GFV.js +12 -49
  10. package/dist/templates/QuotationPdf/Header.js +5 -63
  11. package/dist/templates/QuotationPdf/Pricing.js +201 -573
  12. package/dist/templates/QuotationPdf/QuotationPdfPage.js +3 -23
  13. package/dist/templates/QuotationPdf/SectionBoxNew.js +4 -34
  14. package/dist/templates/QuotationPdf/TermsSection.js +5 -42
  15. package/dist/templates/QuotationPdf/VehiclePhotos.js +24 -54
  16. package/dist/templates/QuotationPdf/index.js +10 -189
  17. package/dist/templates/QuotationPdf/translations.js +22 -34
  18. package/dist/templates/QuotationPdf/utils.js +29 -58
  19. package/dist/templates/SubscriptionAgreement/Confirmation.js +10 -65
  20. package/dist/templates/SubscriptionAgreement/CoverPage.js +10 -93
  21. package/dist/templates/SubscriptionAgreement/CoverPageSection.js +5 -16
  22. package/dist/templates/SubscriptionAgreement/Details.js +51 -129
  23. package/dist/templates/SubscriptionAgreement/Footer.js +6 -48
  24. package/dist/templates/SubscriptionAgreement/Header.js +5 -35
  25. package/dist/templates/SubscriptionAgreement/LabelValue.js +3 -25
  26. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +3 -26
  27. package/dist/templates/SubscriptionAgreement/TermsOfUse.js +8 -94
  28. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js +11 -97
  29. package/dist/templates/SubscriptionAgreement/index.js +15 -245
  30. package/dist/templates/SubscriptionAgreement/translations.js +194 -195
  31. package/dist/templates/SubscriptionAgreement/types.js +2 -1
  32. package/dist/templates/SubscriptionAgreement/utils.js +11 -16
  33. package/dist/templates/index.js +1 -0
  34. package/dist/theme/colors.js +63 -44
  35. package/dist/theme/index.js +1 -0
  36. package/dist/types.js +2 -1
  37. package/dist/utils.js +16 -159
  38. package/dist/watch.js +4 -3
  39. package/package.json +2 -2
@@ -3,28 +3,8 @@ import { View } from '@react-pdf/renderer';
3
3
  import { format } from 'date-fns';
4
4
  import StandardPage from '../../components/StandardPage.js';
5
5
  import Header from './Header.js';
6
- var QuotationPdfPage = function(param) {
7
- var quotation = param.quotation, children = param.children;
8
- return /*#__PURE__*/ _jsxs(StandardPage, {
9
- style: {
10
- padding: 40,
11
- fontSize: 10,
12
- gap: 16
13
- },
14
- children: [
15
- /*#__PURE__*/ _jsx(Header, {
16
- tTitle: 'Quotation',
17
- quotationId: quotation.id,
18
- quotationDate: format(quotation.createdAt, 'dd-MM-yyyy')
19
- }),
20
- /*#__PURE__*/ _jsx(View, {
21
- style: {
22
- flex: 1,
23
- rowGap: 24
24
- },
25
- children: children
26
- })
27
- ]
28
- });
6
+ const QuotationPdfPage = ({ quotation, children, }) => {
7
+ return (_jsxs(StandardPage, { style: { padding: 40, fontSize: 10, gap: 16 }, children: [_jsx(Header, { tTitle: 'Quotation', quotationId: quotation.id, quotationDate: format(quotation.createdAt, 'dd-MM-yyyy') }), _jsx(View, { style: { flex: 1, rowGap: 24 }, children: children })] }));
29
8
  };
30
9
  export default QuotationPdfPage;
10
+ //# sourceMappingURL=QuotationPdfPage.js.map
@@ -1,38 +1,8 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { View } from '@react-pdf/renderer';
3
3
  import { colors } from '../../theme/colors.js';
4
- var SectionBoxNew = function(param) {
5
- var topContent = param.topContent, bottomContent = param.bottomContent, children = param.children;
6
- return /*#__PURE__*/ _jsxs(View, {
7
- style: {
8
- border: "1px solid ".concat(colors.primary2)
9
- },
10
- children: [
11
- /*#__PURE__*/ _jsx(View, {
12
- style: {
13
- padding: 16,
14
- rowGap: 16
15
- },
16
- children: topContent
17
- }),
18
- bottomContent && /*#__PURE__*/ _jsxs(_Fragment, {
19
- children: [
20
- /*#__PURE__*/ _jsx(View, {
21
- style: {
22
- borderBottom: "1px solid ".concat(colors.primary2)
23
- }
24
- }),
25
- /*#__PURE__*/ _jsx(View, {
26
- style: {
27
- padding: 16,
28
- rowGap: 16
29
- },
30
- children: bottomContent
31
- })
32
- ]
33
- }),
34
- children
35
- ]
36
- });
4
+ const SectionBoxNew = ({ topContent, bottomContent, children }) => {
5
+ return (_jsxs(View, { style: { border: `1px solid ${colors.primary2}` }, children: [_jsx(View, { style: { padding: 16, rowGap: 16 }, children: topContent }), bottomContent && (_jsxs(_Fragment, { children: [_jsx(View, { style: { borderBottom: `1px solid ${colors.primary2}` } }), _jsx(View, { style: { padding: 16, rowGap: 16 }, children: bottomContent })] })), children] }));
37
6
  };
38
7
  export default SectionBoxNew;
8
+ //# sourceMappingURL=SectionBoxNew.js.map
@@ -1,50 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Text, View } from '@react-pdf/renderer';
3
3
  import { colors } from '../../theme/colors.js';
4
- var TermsSection = function(param) {
5
- var t = param.t;
6
- return /*#__PURE__*/ _jsxs(View, {
7
- style: {
8
- gap: 16
9
- },
10
- children: [
11
- /*#__PURE__*/ _jsx(Text, {
12
- style: {
4
+ const TermsSection = ({ t }) => {
5
+ return (_jsxs(View, { style: { gap: 16 }, children: [_jsx(Text, { style: {
13
6
  fontWeight: 'bold',
14
7
  color: colors.black,
15
8
  letterSpacing: 1,
16
- textTransform: 'uppercase'
17
- },
18
- children: t === null || t === void 0 ? void 0 : t.title
19
- }),
20
- /*#__PURE__*/ _jsx(View, {
21
- children: t.content.map(function(line, _i) {
22
- return /*#__PURE__*/ _jsxs(View, {
23
- style: {
24
- flexDirection: 'row',
25
- alignItems: 'flex-start'
26
- },
27
- children: [
28
- /*#__PURE__*/ _jsx(Text, {
29
- style: {
30
- marginRight: 4,
31
- fontSize: 8
32
- },
33
- children: "•"
34
- }),
35
- /*#__PURE__*/ _jsx(Text, {
36
- style: {
37
- color: colors.primary3,
38
- letterSpacing: 1,
39
- fontSize: 8
40
- },
41
- children: line
42
- })
43
- ]
44
- }, line);
45
- })
46
- })
47
- ]
48
- });
9
+ textTransform: 'uppercase',
10
+ }, children: t?.title }), _jsx(View, { children: t.content.map((line, _i) => (_jsxs(View, { style: { flexDirection: 'row', alignItems: 'flex-start' }, children: [_jsx(Text, { style: { marginRight: 4, fontSize: 8 }, children: "\u2022" }), _jsx(Text, { style: { color: colors.primary3, letterSpacing: 1, fontSize: 8 }, children: line })] }, line))) })] }));
49
11
  };
50
12
  export default TermsSection;
13
+ //# sourceMappingURL=TermsSection.js.map
@@ -2,65 +2,35 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Image, Text, View } from '@react-pdf/renderer';
3
3
  import { colors } from '../../theme/colors.js';
4
4
  import { getInspectionTypeTranslation } from './utils.js';
5
- var VehiclePhotos = function(param) {
6
- var quotation = param.quotation, t = param.t;
7
- var images = quotation.images;
8
- return /*#__PURE__*/ _jsxs(View, {
9
- style: {
10
- border: "1px solid ".concat(colors.primary2),
11
- padding: 16
12
- },
13
- children: [
14
- /*#__PURE__*/ _jsx(Text, {
15
- style: {
5
+ const VehiclePhotos = ({ quotation, t }) => {
6
+ const images = quotation.images;
7
+ return (_jsxs(View, { style: { border: `1px solid ${colors.primary2}`, padding: 16 }, children: [_jsx(Text, { style: {
16
8
  textTransform: 'uppercase',
17
9
  fontSize: 12,
18
10
  fontWeight: 'bold',
19
- marginBottom: 16
20
- },
21
- children: t === null || t === void 0 ? void 0 : t.title
22
- }),
23
- /*#__PURE__*/ _jsx(View, {
24
- style: {
11
+ marginBottom: 16,
12
+ }, children: t?.title }), _jsx(View, { style: {
25
13
  display: 'flex',
26
14
  flexDirection: 'row',
27
15
  flexWrap: 'wrap',
28
- gap: 15
29
- },
30
- children: images.map(function(image) {
31
- return /*#__PURE__*/ _jsx(_Fragment, {
32
- children: /*#__PURE__*/ _jsxs(View, {
33
- style: {
34
- overflow: 'hidden',
35
- alignItems: 'center',
36
- gap: 4
37
- },
38
- children: [
39
- /*#__PURE__*/ _jsx(View, {
40
- children: /*#__PURE__*/ _jsx(Image, {
41
- // @ts-expect-error
42
- source: image.default,
43
- style: {
44
- objectFit: 'cover',
45
- height: 90,
46
- width: 150
47
- }
48
- })
49
- }),
50
- image.inspectionType && /*#__PURE__*/ _jsx(Text, {
51
- style: {
52
- color: colors.black,
53
- fontSize: 10,
54
- textAlign: 'center'
55
- },
56
- children: getInspectionTypeTranslation(image.inspectionType)
57
- })
58
- ]
59
- }, image.default)
60
- });
61
- })
62
- })
63
- ]
64
- });
16
+ gap: 15,
17
+ }, children: images.map((image) => (_jsx(_Fragment, { children: _jsxs(View, { style: {
18
+ overflow: 'hidden',
19
+ alignItems: 'center',
20
+ gap: 4,
21
+ }, children: [_jsx(View, { children: _jsx(Image
22
+ // @ts-expect-error
23
+ , {
24
+ // @ts-expect-error
25
+ source: image.default, style: {
26
+ objectFit: 'cover',
27
+ height: 90,
28
+ width: 150,
29
+ } }) }), image.inspectionType && (_jsx(Text, { style: {
30
+ color: colors.black,
31
+ fontSize: 10,
32
+ textAlign: 'center',
33
+ }, children: getInspectionTypeTranslation(image.inspectionType) }))] }, image.default) }))) })] }));
65
34
  };
66
35
  export default VehiclePhotos;
36
+ //# sourceMappingURL=VehiclePhotos.js.map
@@ -1,123 +1,3 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _ts_generator(thisArg, body) {
31
- var f, y, t, _ = {
32
- label: 0,
33
- sent: function() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
41
- return this;
42
- }), g;
43
- function verb(n) {
44
- return function(v) {
45
- return step([
46
- n,
47
- v
48
- ]);
49
- };
50
- }
51
- function step(op) {
52
- if (f) throw new TypeError("Generator is already executing.");
53
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
54
- 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;
55
- if (y = 0, t) op = [
56
- op[0] & 2,
57
- t.value
58
- ];
59
- switch(op[0]){
60
- case 0:
61
- case 1:
62
- t = op;
63
- break;
64
- case 4:
65
- _.label++;
66
- return {
67
- value: op[1],
68
- done: false
69
- };
70
- case 5:
71
- _.label++;
72
- y = op[1];
73
- op = [
74
- 0
75
- ];
76
- continue;
77
- case 7:
78
- op = _.ops.pop();
79
- _.trys.pop();
80
- continue;
81
- default:
82
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
- _ = 0;
84
- continue;
85
- }
86
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
- _.label = op[1];
88
- break;
89
- }
90
- if (op[0] === 6 && _.label < t[1]) {
91
- _.label = t[1];
92
- t = op;
93
- break;
94
- }
95
- if (t && _.label < t[2]) {
96
- _.label = t[2];
97
- _.ops.push(op);
98
- break;
99
- }
100
- if (t[2]) _.ops.pop();
101
- _.trys.pop();
102
- continue;
103
- }
104
- op = body.call(thisArg, _);
105
- } catch (e) {
106
- op = [
107
- 6,
108
- e
109
- ];
110
- y = 0;
111
- } finally{
112
- f = t = 0;
113
- }
114
- if (op[0] & 5) throw op[1];
115
- return {
116
- value: op[0] ? op[1] : void 0,
117
- done: true
118
- };
119
- }
120
- }
121
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
122
2
  import { Document } from '@react-pdf/renderer';
123
3
  import { useMemo } from 'react';
@@ -130,77 +10,18 @@ import QuotationPdfPage from './QuotationPdfPage.js';
130
10
  import TermsSection from './TermsSection.js';
131
11
  import { useTranslations } from './translations.js';
132
12
  import VehiclePhotos from './VehiclePhotos.js';
133
- export var generateQuotationPdf = function(param, fileName) {
134
- var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, quotation = param.quotation;
135
- return _async_to_generator(function() {
136
- return _ts_generator(this, function(_state) {
137
- switch(_state.label){
138
- case 0:
139
- return [
140
- 4,
141
- toPdf(/*#__PURE__*/ _jsx(QuotationPDF, {
142
- locale: locale,
143
- quotation: quotation
144
- }), fileName)
145
- ];
146
- case 1:
147
- return [
148
- 2,
149
- _state.sent()
150
- ];
151
- }
152
- });
153
- })();
13
+ export const generateQuotationPdf = async ({ locale = 'en', quotation }, fileName) => {
14
+ return await toPdf(_jsx(QuotationPDF, { locale: locale, quotation: quotation }), fileName);
154
15
  };
155
- var QuotationPDF = function(param) {
156
- var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, quotation = param.quotation;
157
- var th = useTranslations(locale);
158
- var pageProps = useMemo(function() {
16
+ const QuotationPDF = ({ locale = 'en', quotation }) => {
17
+ const th = useTranslations(locale);
18
+ const pageProps = useMemo(() => {
159
19
  return {
160
20
  t: th,
161
- quotation: quotation
21
+ quotation: quotation,
162
22
  };
163
- }, [
164
- th,
165
- quotation
166
- ]);
167
- var t = pageProps.t;
168
- return /*#__PURE__*/ _jsxs(Document, {
169
- language: locale,
170
- children: [
171
- /*#__PURE__*/ _jsxs(QuotationPdfPage, {
172
- quotation: quotation,
173
- children: [
174
- /*#__PURE__*/ _jsx(CustomerSubscriptionSection, {
175
- quotation: quotation,
176
- t: t
177
- }),
178
- /*#__PURE__*/ _jsx(Pricing, {
179
- quotation: quotation,
180
- t: t.pricing
181
- }),
182
- quotation.fees.gfv && /*#__PURE__*/ _jsx(GFV, {
183
- quotation: quotation,
184
- t: t.pricing
185
- })
186
- ]
187
- }),
188
- /*#__PURE__*/ _jsxs(StandardPage, {
189
- style: {
190
- padding: 40,
191
- fontSize: 10,
192
- gap: 16
193
- },
194
- children: [
195
- /*#__PURE__*/ _jsx(VehiclePhotos, {
196
- quotation: quotation,
197
- t: t.vehiclePhotos
198
- }),
199
- /*#__PURE__*/ _jsx(TermsSection, {
200
- t: t.terms
201
- })
202
- ]
203
- })
204
- ]
205
- });
23
+ }, [th, quotation]);
24
+ const { t } = pageProps;
25
+ return (_jsxs(Document, { language: locale, children: [_jsxs(QuotationPdfPage, { quotation: quotation, children: [_jsx(CustomerSubscriptionSection, { quotation: quotation, t: t }), _jsx(Pricing, { quotation: quotation, t: t.pricing }), quotation.fees.gfv && _jsx(GFV, { quotation: quotation, t: t.pricing })] }), _jsxs(StandardPage, { style: { padding: 40, fontSize: 10, gap: 16 }, children: [_jsx(VehiclePhotos, { quotation: quotation, t: t.vehiclePhotos }), _jsx(TermsSection, { t: t.terms })] })] }));
206
26
  };
27
+ //# sourceMappingURL=index.js.map
@@ -1,17 +1,17 @@
1
- var enTranslation = {
1
+ const enTranslation = {
2
2
  quotation: 'Quotation',
3
3
  date: 'Date',
4
4
  customer: {
5
5
  title: 'Customer',
6
6
  name: 'Name',
7
7
  email: 'Email',
8
- address: 'Address'
8
+ address: 'Address',
9
9
  },
10
10
  subscription: {
11
11
  title: 'Subscription',
12
12
  vehicleName: 'Vehicle',
13
13
  plan: 'Subscription Plan',
14
- mileagePackage: 'Mileage Package'
14
+ mileagePackage: 'Mileage Package',
15
15
  },
16
16
  subIncludes: {
17
17
  title: "What's Included:",
@@ -25,14 +25,12 @@ var enTranslation = {
25
25
  '24/7 nationwide roadside assistance',
26
26
  'Theft recovery services',
27
27
  'Independently rated vehicle inspection',
28
- 'Option to purchase the vehicle at the end of the subscription'
28
+ 'Option to purchase the vehicle at the end of the subscription',
29
29
  ],
30
30
  excessMileage: {
31
31
  title: 'Excess Mileage Fees',
32
- description: function(excessMileage) {
33
- return "If usage exceeds chosen mileage package, excess mileage fees for this vehicle is RM".concat(excessMileage, " per KM.");
34
- }
35
- }
32
+ description: (excessMileage) => `If usage exceeds chosen mileage package, excess mileage fees for this vehicle is RM${excessMileage} per KM.`,
33
+ },
36
34
  },
37
35
  pricing: {
38
36
  title: 'Pricing',
@@ -41,39 +39,28 @@ var enTranslation = {
41
39
  upfront: {
42
40
  title: 'Upfront Fees',
43
41
  content: [
44
- {
45
- title: 'Booking Fee',
46
- key: 'reservationFee'
47
- },
48
- {
49
- title: 'Refundable Deposit*',
50
- key: 'deposit'
51
- }
42
+ { title: 'Booking Fee', key: 'reservationFee' },
43
+ { title: 'Refundable Deposit*', key: 'deposit' },
52
44
  ],
53
- depositDisclaimer: '* The deposit will be refunded to you once the finalization upon your FLUX car is done excluding any service fee, tax, damages, fines, penalties or excess mileage charges that have incurred'
45
+ depositDisclaimer: '* The deposit will be refunded to you once the finalization upon your FLUX car is done excluding any service fee, tax, damages, fines, penalties or excess mileage charges that have incurred',
54
46
  },
55
47
  monthly: {
56
48
  title: 'Monthly Fees',
57
- content: [
58
- {
59
- title: 'Subscription Fee',
60
- key: 'subscriptionFee'
61
- }
62
- ]
49
+ content: [{ title: 'Subscription Fee', key: 'subscriptionFee' }],
63
50
  },
64
51
  dueToday: {
65
52
  title: 'Due Today',
66
53
  description: 'Grand Total is due before your subscription start. Monthly fee is due on the first day of every cycle period.',
67
54
  subTotal: 'Upfront Fees + Monthly Fee',
68
- grandTotal: 'Grand Total'
55
+ grandTotal: 'Grand Total',
69
56
  },
70
57
  extraCharge: 'Extra Charge',
71
58
  promo: 'Promo',
72
59
  gfv: {
73
- title: 'Guaranteed Future Value (GFV)'
60
+ title: 'Guaranteed Future Value (GFV)',
74
61
  },
75
- totalDiscount: 'Total Discount'
76
- }
62
+ totalDiscount: 'Total Discount',
63
+ },
77
64
  },
78
65
  terms: {
79
66
  title: 'Terms',
@@ -86,16 +73,17 @@ var enTranslation = {
86
73
  'The upfront fees are billed one-time per subscription, before the subscription starts.',
87
74
  'All monthly recurring fees are billed on the same date as the delivery of the vehicle.',
88
75
  'Scheduling delivery will only commence Grand Total is fully paid, 7 - 30+ days after payment and subject to vehicle availability.',
89
- 'Guaranteed Future Value prices are not inclusive of processing fees'
90
- ]
76
+ 'Guaranteed Future Value prices are not inclusive of processing fees',
77
+ ],
91
78
  },
92
79
  vehiclePhotos: {
93
- title: 'Vehicle Photos'
94
- }
80
+ title: 'Vehicle Photos',
81
+ },
95
82
  };
96
- export var useTranslations = function(locale) {
97
- var translation = {
98
- en: enTranslation
83
+ export const useTranslations = (locale) => {
84
+ const translation = {
85
+ en: enTranslation,
99
86
  };
100
87
  return translation[locale];
101
88
  };
89
+ //# sourceMappingURL=translations.js.map
@@ -1,43 +1,13 @@
1
- function _object_without_properties(source, excluded) {
2
- if (source == null) return {};
3
- var target = _object_without_properties_loose(source, excluded);
4
- var key, i;
5
- if (Object.getOwnPropertySymbols) {
6
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
7
- for(i = 0; i < sourceSymbolKeys.length; i++){
8
- key = sourceSymbolKeys[i];
9
- if (excluded.indexOf(key) >= 0) continue;
10
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
11
- target[key] = source[key];
12
- }
13
- }
14
- return target;
15
- }
16
- function _object_without_properties_loose(source, excluded) {
17
- if (source == null) return {};
18
- var target = {};
19
- var sourceKeys = Object.keys(source);
20
- var key, i;
21
- for(i = 0; i < sourceKeys.length; i++){
22
- key = sourceKeys[i];
23
- if (excluded.indexOf(key) >= 0) continue;
24
- target[key] = source[key];
25
- }
26
- return target;
27
- }
28
1
  import { formatMoney } from '@driveflux/format-money';
29
- export var formatAddress = function(originalAddress) {
30
- var coordinates = originalAddress.coordinates, address = _object_without_properties(originalAddress, [
31
- "coordinates"
32
- ]);
33
- return Object.keys(address).filter(function(key) {
34
- return key !== 'name' && !!address[key];
35
- }).map(function(a) {
36
- return address[a];
37
- }).join(', ');
2
+ export const formatAddress = (originalAddress) => {
3
+ const { coordinates, ...address } = originalAddress;
4
+ return Object.keys(address)
5
+ .filter((key) => key !== 'name' && !!address[key])
6
+ .map((a) => address[a])
7
+ .join(', ');
38
8
  };
39
- export var getSimplifiedPlanTranslation = function(plan) {
40
- switch(plan){
9
+ export const getSimplifiedPlanTranslation = (plan) => {
10
+ switch (plan) {
41
11
  case 'plan60':
42
12
  return '60 Months';
43
13
  case 'plan36':
@@ -54,8 +24,8 @@ export var getSimplifiedPlanTranslation = function(plan) {
54
24
  return 'Unknown Plan';
55
25
  }
56
26
  };
57
- export var getMileagePackageTranslation = function(mileagePackage) {
58
- switch(mileagePackage){
27
+ export const getMileagePackageTranslation = (mileagePackage) => {
28
+ switch (mileagePackage) {
59
29
  case 'lite':
60
30
  return 'Lite';
61
31
  case 'standard':
@@ -68,8 +38,8 @@ export var getMileagePackageTranslation = function(mileagePackage) {
68
38
  return 'Unknown Mileage Package';
69
39
  }
70
40
  };
71
- export var getFullMileagePackageTranslation = function(plan) {
72
- switch(plan){
41
+ export const getFullMileagePackageTranslation = (plan) => {
42
+ switch (plan) {
73
43
  case 'lite':
74
44
  return 'Lite - 1,250KM';
75
45
  case 'standard':
@@ -82,25 +52,25 @@ export var getFullMileagePackageTranslation = function(plan) {
82
52
  return 'Unknown Mileage Package';
83
53
  }
84
54
  };
85
- export var getPromoNotes = function(amount, discount) {
86
- var discountType = discount.discountType, discountValue = discount.discountValue, maxRedemptions = discount.maxRedemptions;
87
- switch(discountType){
55
+ export const getPromoNotes = (amount, discount) => {
56
+ const { discountType, discountValue, maxRedemptions } = discount;
57
+ switch (discountType) {
88
58
  case 'percentage':
89
- return "Enjoy ".concat(discountValue * 100, "% off for ").concat(maxRedemptions, " month(s) for this vehicle.");
90
- case 'fixed':
91
- {
92
- var money = formatMoney(discountValue);
93
- return amount <= 0 ? "Enjoy free for ".concat(maxRedemptions, " month(s).") : "Enjoy ".concat(money, " off for the first ").concat(maxRedemptions, " month(s), then your subscription will switch to the regular price.");
94
- }
95
- case 'forceAmount':
96
- {
97
- var money1 = formatMoney(Math.min(amount, discountValue));
98
- return "Enjoy only ".concat(money1, " for ").concat(maxRedemptions, " month(s), then your subscription will switch to the regular price.");
99
- }
59
+ return `Enjoy ${discountValue * 100}% off for ${maxRedemptions} month(s) for this vehicle.`;
60
+ case 'fixed': {
61
+ const money = formatMoney(discountValue);
62
+ return amount <= 0
63
+ ? `Enjoy free for ${maxRedemptions} month(s).`
64
+ : `Enjoy ${money} off for the first ${maxRedemptions} month(s), then your subscription will switch to the regular price.`;
65
+ }
66
+ case 'forceAmount': {
67
+ const money = formatMoney(Math.min(amount, discountValue));
68
+ return `Enjoy only ${money} for ${maxRedemptions} month(s), then your subscription will switch to the regular price.`;
69
+ }
100
70
  }
101
71
  };
102
- export var getInspectionTypeTranslation = function(inspectionType) {
103
- switch(inspectionType){
72
+ export const getInspectionTypeTranslation = (inspectionType) => {
73
+ switch (inspectionType) {
104
74
  case 'exterior':
105
75
  return 'Exterior';
106
76
  case 'interior':
@@ -115,3 +85,4 @@ export var getInspectionTypeTranslation = function(inspectionType) {
115
85
  return inspectionType;
116
86
  }
117
87
  };
88
+ //# sourceMappingURL=utils.js.map