@driveflux/pdf 1.0.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.
Files changed (130) hide show
  1. package/.eslintrc +3 -0
  2. package/.swcrc +14 -0
  3. package/.turbo/turbo-build.log +6 -0
  4. package/CHANGELOG.md +69 -0
  5. package/dist/__mocks__/subscription.d.ts +3 -0
  6. package/dist/__mocks__/subscription.d.ts.map +1 -0
  7. package/dist/__mocks__/subscription.js +1069 -0
  8. package/dist/cjs/__mocks__/subscription.js +1079 -0
  9. package/dist/cjs/components/FluxLogo.js +76 -0
  10. package/dist/cjs/components/StandardPage.js +129 -0
  11. package/dist/cjs/debug.js +202 -0
  12. package/dist/cjs/index.js +20 -0
  13. package/dist/cjs/package.json +3 -0
  14. package/dist/cjs/templates/SubscriptionAgreement/Confirmation.js +95 -0
  15. package/dist/cjs/templates/SubscriptionAgreement/CoverPage.js +110 -0
  16. package/dist/cjs/templates/SubscriptionAgreement/CoverPageSection.js +35 -0
  17. package/dist/cjs/templates/SubscriptionAgreement/Details.js +161 -0
  18. package/dist/cjs/templates/SubscriptionAgreement/Footer.js +68 -0
  19. package/dist/cjs/templates/SubscriptionAgreement/Header.js +61 -0
  20. package/dist/cjs/templates/SubscriptionAgreement/LabelValue.js +39 -0
  21. package/dist/cjs/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +48 -0
  22. package/dist/cjs/templates/SubscriptionAgreement/TermsOfUse.js +72 -0
  23. package/dist/cjs/templates/SubscriptionAgreement/TermsOfUseSubSection.js +108 -0
  24. package/dist/cjs/templates/SubscriptionAgreement/index.js +276 -0
  25. package/dist/cjs/templates/SubscriptionAgreement/translations.js +666 -0
  26. package/dist/cjs/templates/SubscriptionAgreement/utils.js +14 -0
  27. package/dist/cjs/templates/index.js +18 -0
  28. package/dist/cjs/theme/colors.js +147 -0
  29. package/dist/cjs/theme/index.js +18 -0
  30. package/dist/cjs/types.js +4 -0
  31. package/dist/cjs/utils.js +165 -0
  32. package/dist/cjs/watch.js +20 -0
  33. package/dist/components/FluxLogo.d.ts +3 -0
  34. package/dist/components/FluxLogo.d.ts.map +1 -0
  35. package/dist/components/FluxLogo.js +66 -0
  36. package/dist/components/StandardPage.d.ts +6 -0
  37. package/dist/components/StandardPage.d.ts.map +1 -0
  38. package/dist/components/StandardPage.js +114 -0
  39. package/dist/debug.d.ts +2 -0
  40. package/dist/debug.d.ts.map +1 -0
  41. package/dist/debug.js +198 -0
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +3 -0
  45. package/dist/templates/SubscriptionAgreement/Confirmation.d.ts +10 -0
  46. package/dist/templates/SubscriptionAgreement/Confirmation.d.ts.map +1 -0
  47. package/dist/templates/SubscriptionAgreement/Confirmation.js +80 -0
  48. package/dist/templates/SubscriptionAgreement/CoverPage.d.ts +12 -0
  49. package/dist/templates/SubscriptionAgreement/CoverPage.d.ts.map +1 -0
  50. package/dist/templates/SubscriptionAgreement/CoverPage.js +95 -0
  51. package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts +7 -0
  52. package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts.map +1 -0
  53. package/dist/templates/SubscriptionAgreement/CoverPageSection.js +25 -0
  54. package/dist/templates/SubscriptionAgreement/Details.d.ts +10 -0
  55. package/dist/templates/SubscriptionAgreement/Details.d.ts.map +1 -0
  56. package/dist/templates/SubscriptionAgreement/Details.js +146 -0
  57. package/dist/templates/SubscriptionAgreement/Footer.d.ts +10 -0
  58. package/dist/templates/SubscriptionAgreement/Footer.d.ts.map +1 -0
  59. package/dist/templates/SubscriptionAgreement/Footer.js +58 -0
  60. package/dist/templates/SubscriptionAgreement/Header.d.ts +10 -0
  61. package/dist/templates/SubscriptionAgreement/Header.d.ts.map +1 -0
  62. package/dist/templates/SubscriptionAgreement/Header.js +46 -0
  63. package/dist/templates/SubscriptionAgreement/LabelValue.d.ts +8 -0
  64. package/dist/templates/SubscriptionAgreement/LabelValue.d.ts.map +1 -0
  65. package/dist/templates/SubscriptionAgreement/LabelValue.js +29 -0
  66. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts +10 -0
  67. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts.map +1 -0
  68. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +33 -0
  69. package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts +8 -0
  70. package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts.map +1 -0
  71. package/dist/templates/SubscriptionAgreement/TermsOfUse.js +57 -0
  72. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts +12 -0
  73. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts.map +1 -0
  74. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js +98 -0
  75. package/dist/templates/SubscriptionAgreement/index.d.ts +14 -0
  76. package/dist/templates/SubscriptionAgreement/index.d.ts.map +1 -0
  77. package/dist/templates/SubscriptionAgreement/index.js +261 -0
  78. package/dist/templates/SubscriptionAgreement/translations.d.ts +72 -0
  79. package/dist/templates/SubscriptionAgreement/translations.d.ts.map +1 -0
  80. package/dist/templates/SubscriptionAgreement/translations.js +656 -0
  81. package/dist/templates/SubscriptionAgreement/utils.d.ts +3 -0
  82. package/dist/templates/SubscriptionAgreement/utils.d.ts.map +1 -0
  83. package/dist/templates/SubscriptionAgreement/utils.js +4 -0
  84. package/dist/templates/index.d.ts +2 -0
  85. package/dist/templates/index.d.ts.map +1 -0
  86. package/dist/templates/index.js +1 -0
  87. package/dist/theme/colors.d.ts +148 -0
  88. package/dist/theme/colors.d.ts.map +1 -0
  89. package/dist/theme/colors.js +137 -0
  90. package/dist/theme/index.d.ts +2 -0
  91. package/dist/theme/index.d.ts.map +1 -0
  92. package/dist/theme/index.js +1 -0
  93. package/dist/types.d.ts +2 -0
  94. package/dist/types.d.ts.map +1 -0
  95. package/dist/types.js +1 -0
  96. package/dist/utils.d.ts +4 -0
  97. package/dist/utils.d.ts.map +1 -0
  98. package/dist/utils.js +150 -0
  99. package/dist/watch.d.ts +2 -0
  100. package/dist/watch.d.ts.map +1 -0
  101. package/dist/watch.js +11 -0
  102. package/index.cjs +1 -0
  103. package/index.d.ts +1 -0
  104. package/package.json +43 -0
  105. package/src/__mocks__/subscription.ts +803 -0
  106. package/src/components/FluxLogo.tsx +52 -0
  107. package/src/components/StandardPage.tsx +32 -0
  108. package/src/debug.ts +36 -0
  109. package/src/index.ts +3 -0
  110. package/src/templates/SubscriptionAgreement/Confirmation.tsx +49 -0
  111. package/src/templates/SubscriptionAgreement/CoverPage.tsx +52 -0
  112. package/src/templates/SubscriptionAgreement/CoverPageSection.tsx +25 -0
  113. package/src/templates/SubscriptionAgreement/Details.tsx +127 -0
  114. package/src/templates/SubscriptionAgreement/Footer.tsx +37 -0
  115. package/src/templates/SubscriptionAgreement/Header.tsx +37 -0
  116. package/src/templates/SubscriptionAgreement/LabelValue.tsx +19 -0
  117. package/src/templates/SubscriptionAgreement/SubscriptionAgreementPage.tsx +24 -0
  118. package/src/templates/SubscriptionAgreement/TermsOfUse.tsx +30 -0
  119. package/src/templates/SubscriptionAgreement/TermsOfUseSubSection.tsx +44 -0
  120. package/src/templates/SubscriptionAgreement/index.tsx +66 -0
  121. package/src/templates/SubscriptionAgreement/translations.ts +664 -0
  122. package/src/templates/SubscriptionAgreement/utils.ts +7 -0
  123. package/src/templates/index.ts +1 -0
  124. package/src/theme/colors.ts +180 -0
  125. package/src/theme/index.ts +1 -0
  126. package/src/types.ts +1 -0
  127. package/src/utils.ts +10 -0
  128. package/src/watch.ts +16 -0
  129. package/tsconfig.json +13 -0
  130. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,261 @@
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 _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _object_spread_props(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ function _ts_generator(thisArg, body) {
83
+ var f, y, t, g, _ = {
84
+ label: 0,
85
+ sent: function() {
86
+ if (t[0] & 1) throw t[1];
87
+ return t[1];
88
+ },
89
+ trys: [],
90
+ ops: []
91
+ };
92
+ return g = {
93
+ next: verb(0),
94
+ "throw": verb(1),
95
+ "return": verb(2)
96
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
97
+ return this;
98
+ }), g;
99
+ function verb(n) {
100
+ return function(v) {
101
+ return step([
102
+ n,
103
+ v
104
+ ]);
105
+ };
106
+ }
107
+ function step(op) {
108
+ if (f) throw new TypeError("Generator is already executing.");
109
+ while(_)try {
110
+ 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;
111
+ if (y = 0, t) op = [
112
+ op[0] & 2,
113
+ t.value
114
+ ];
115
+ switch(op[0]){
116
+ case 0:
117
+ case 1:
118
+ t = op;
119
+ break;
120
+ case 4:
121
+ _.label++;
122
+ return {
123
+ value: op[1],
124
+ done: false
125
+ };
126
+ case 5:
127
+ _.label++;
128
+ y = op[1];
129
+ op = [
130
+ 0
131
+ ];
132
+ continue;
133
+ case 7:
134
+ op = _.ops.pop();
135
+ _.trys.pop();
136
+ continue;
137
+ default:
138
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
139
+ _ = 0;
140
+ continue;
141
+ }
142
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
143
+ _.label = op[1];
144
+ break;
145
+ }
146
+ if (op[0] === 6 && _.label < t[1]) {
147
+ _.label = t[1];
148
+ t = op;
149
+ break;
150
+ }
151
+ if (t && _.label < t[2]) {
152
+ _.label = t[2];
153
+ _.ops.push(op);
154
+ break;
155
+ }
156
+ if (t[2]) _.ops.pop();
157
+ _.trys.pop();
158
+ continue;
159
+ }
160
+ op = body.call(thisArg, _);
161
+ } catch (e) {
162
+ op = [
163
+ 6,
164
+ e
165
+ ];
166
+ y = 0;
167
+ } finally{
168
+ f = t = 0;
169
+ }
170
+ if (op[0] & 5) throw op[1];
171
+ return {
172
+ value: op[0] ? op[1] : void 0,
173
+ done: true
174
+ };
175
+ }
176
+ }
177
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
178
+ import { Document } from '@react-pdf/renderer';
179
+ import { useMemo } from 'react';
180
+ import { toPdf } from '../../utils.js';
181
+ import Confirmation from './Confirmation.js';
182
+ import CoverPage from './CoverPage.js';
183
+ import Details from './Details.js';
184
+ import SubscriptionAgreementPage from './SubscriptionAgreementPage.js';
185
+ import TermsOfUse from './TermsOfUse.js';
186
+ import { useTranslations } from './translations.js';
187
+ export var generateSubscriptionAgreementPdf = function() {
188
+ var _ref = _async_to_generator(function(param, fileName) {
189
+ var _param_locale, locale, subscription;
190
+ return _ts_generator(this, function(_state) {
191
+ switch(_state.label){
192
+ case 0:
193
+ _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, subscription = param.subscription;
194
+ if (!subscription.signature) {
195
+ throw new Error('Signature not found');
196
+ }
197
+ return [
198
+ 4,
199
+ toPdf(/*#__PURE__*/ _jsx(SubscriptionAgreement, {
200
+ locale: locale,
201
+ signature: subscription.signature,
202
+ subscription: subscription
203
+ }), fileName)
204
+ ];
205
+ case 1:
206
+ return [
207
+ 2,
208
+ _state.sent()
209
+ ];
210
+ }
211
+ });
212
+ });
213
+ return function generateSubscriptionAgreementPdf(_, fileName) {
214
+ return _ref.apply(this, arguments);
215
+ };
216
+ }();
217
+ var SubscriptionAgreement = function(param) {
218
+ var _param_locale = param.locale, locale = _param_locale === void 0 ? 'en' : _param_locale, signature = param.signature, subscription = param.subscription;
219
+ if (!signature.signedAt) {
220
+ throw new Error("Missing 'signature.signedAt'");
221
+ }
222
+ var pageProps = useMemo(function() {
223
+ return {
224
+ t: useTranslations(locale),
225
+ userId: subscription.userId,
226
+ subscriptionId: subscription.id
227
+ };
228
+ }, []);
229
+ var t = pageProps.t;
230
+ return /*#__PURE__*/ _jsxs(Document, {
231
+ title: t.title,
232
+ language: locale,
233
+ children: [
234
+ /*#__PURE__*/ _jsx(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
235
+ children: /*#__PURE__*/ _jsx(CoverPage, {
236
+ tTitle: t.title,
237
+ tCover: t.cover,
238
+ signedAt: signature.signedAt,
239
+ user: subscription.user
240
+ })
241
+ })),
242
+ /*#__PURE__*/ _jsx(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
243
+ children: /*#__PURE__*/ _jsx(TermsOfUse, {
244
+ t: t.termsOfUse
245
+ })
246
+ })),
247
+ /*#__PURE__*/ _jsxs(SubscriptionAgreementPage, _object_spread_props(_object_spread({}, pageProps), {
248
+ children: [
249
+ /*#__PURE__*/ _jsx(Details, {
250
+ tDetails: t.details,
251
+ subscription: subscription
252
+ }),
253
+ /*#__PURE__*/ _jsx(Confirmation, {
254
+ tConfirmation: t.confirmation,
255
+ subscription: subscription
256
+ })
257
+ ]
258
+ }))
259
+ ]
260
+ });
261
+ };
@@ -0,0 +1,72 @@
1
+ declare const enTranslation: {
2
+ title: string;
3
+ computerGenerated: string;
4
+ page: string;
5
+ of: string;
6
+ cover: {
7
+ effectiveDate: string;
8
+ of: string;
9
+ agreementBetween: string;
10
+ and: string;
11
+ name: string;
12
+ idOrPassportNo: string;
13
+ };
14
+ termsOfUse: {
15
+ title: string;
16
+ content: ({
17
+ title: string;
18
+ subSections: (string | {
19
+ paragraph: string;
20
+ subSections: (string | {
21
+ paragraph: string;
22
+ subSections: string[];
23
+ })[];
24
+ })[];
25
+ } | {
26
+ title: string;
27
+ subSections: (string | {
28
+ paragraph: string;
29
+ subSections: string[];
30
+ } | {
31
+ paragraph: string;
32
+ subSections: {
33
+ paragraph: string;
34
+ subSections: (string | {
35
+ paragraph: string;
36
+ subSections: string[];
37
+ })[];
38
+ }[];
39
+ })[];
40
+ })[];
41
+ };
42
+ details: {
43
+ agreement: string;
44
+ member: {
45
+ name: string;
46
+ idOrPassportNo: string;
47
+ };
48
+ vehicle: {
49
+ make: string;
50
+ model: string;
51
+ year: string;
52
+ plateNo: string;
53
+ };
54
+ subscription: {
55
+ subscriptionPlan: string;
56
+ mileagePackage: string;
57
+ startDate: string;
58
+ endDate: string;
59
+ };
60
+ };
61
+ confirmation: {
62
+ title: string;
63
+ agreementText: (userType: 'member' | 'business') => string;
64
+ name: string;
65
+ idOrPassportNo: string;
66
+ date: string;
67
+ };
68
+ };
69
+ export type SubscriptionAgreementTranslation = typeof enTranslation;
70
+ export declare const useTranslations: (locale: 'en') => SubscriptionAgreementTranslation;
71
+ export {};
72
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/templates/SubscriptionAgreement/translations.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAwoBW,QAAQ,GAAG,UAAU;;;;;CAMlD,CAAA;AACD,MAAM,MAAM,gCAAgC,GAAG,OAAO,aAAa,CAAA;AAEnE,eAAO,MAAM,eAAe,WAAY,IAAI,KAAG,gCAK9C,CAAA"}