swoop-common 2.1.34 → 2.1.36

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.
@@ -49,6 +49,7 @@ export type { PackageItem } from './index';
49
49
  export type { PackageSpan } from './index';
50
50
  export type { Page } from './index';
51
51
  export type { Pagination } from './index';
52
+ export type { QuoteOptions } from './index';
52
53
  export { regionParam } from './index';
53
54
  export { regionRequired } from './index';
54
55
  export type { search } from './index';
@@ -51,6 +51,7 @@ export type { PackageItem } from './models/PackageItem';
51
51
  export type { PackageSpan } from './models/PackageSpan';
52
52
  export type { Page } from './models/Page';
53
53
  export type { Pagination } from './models/Pagination';
54
+ export type { QuoteOptions } from './models/QuoteOptions';
54
55
  export { regionParam } from './models/regionParam';
55
56
  export { regionRequired } from './models/regionRequired';
56
57
  export type { search } from './models/search';
@@ -1,8 +1,10 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
+ import type { QuoteOptions } from './QuoteOptions';
3
4
  export type DTOItineraryCreate = {
4
5
  enquiryId: string;
5
6
  title: string;
6
7
  componentInstances: Array<ComponentInstance>;
7
8
  fees: Array<Fee>;
9
+ quoteOption?: QuoteOptions;
8
10
  };
@@ -1,6 +1,7 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
3
  import type { Metadata } from './Metadata';
4
+ import type { QuoteOptions } from './QuoteOptions';
4
5
  export type DTOItineraryEntity = {
5
6
  id: string;
6
7
  revisionGroupId: string;
@@ -10,4 +11,5 @@ export type DTOItineraryEntity = {
10
11
  title: string;
11
12
  componentInstances: Array<ComponentInstance>;
12
13
  fees: Array<Fee>;
14
+ quoteOption?: QuoteOptions;
13
15
  };
@@ -1,6 +1,7 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
3
  import type { Metadata } from './Metadata';
4
+ import type { QuoteOptions } from './QuoteOptions';
4
5
  export type DTOItineraryRead = {
5
6
  id: string;
6
7
  revisionGroupId: string;
@@ -10,4 +11,5 @@ export type DTOItineraryRead = {
10
11
  title: string;
11
12
  componentInstances: Array<ComponentInstance>;
12
13
  fees: Array<Fee>;
14
+ quoteOption?: QuoteOptions;
13
15
  };
@@ -1,8 +1,10 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
+ import type { QuoteOptions } from './QuoteOptions';
3
4
  export type DTOItineraryUpdate = {
4
5
  enquiryId: string;
5
6
  title: string;
6
7
  componentInstances: Array<ComponentInstance>;
7
8
  fees: Array<Fee>;
9
+ quoteOption?: QuoteOptions;
8
10
  };
@@ -0,0 +1,8 @@
1
+ export type QuoteOptions = {
2
+ showAllPrice?: boolean;
3
+ includePaymentLinks?: boolean;
4
+ urgencyCta?: string;
5
+ quoteExpiredDate?: string;
6
+ priceRange?: string;
7
+ savingMade?: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -51,6 +51,7 @@ export type { PackageItem } from './models/PackageItem';
51
51
  export type { PackageSpan } from './models/PackageSpan';
52
52
  export type { Page } from './models/Page';
53
53
  export type { Pagination } from './models/Pagination';
54
+ export type { QuoteOptions } from './models/QuoteOptions';
54
55
  export { regionParam } from './models/regionParam';
55
56
  export { regionRequired } from './models/regionRequired';
56
57
  export type { search } from './models/search';
@@ -1,8 +1,10 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
+ import type { QuoteOptions } from './QuoteOptions';
3
4
  export type DTOItineraryCreate = {
4
5
  enquiryId: string;
5
6
  title: string;
6
7
  componentInstances: Array<ComponentInstance>;
7
8
  fees: Array<Fee>;
9
+ quoteOption?: QuoteOptions;
8
10
  };
@@ -1,6 +1,7 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
3
  import type { Metadata } from './Metadata';
4
+ import type { QuoteOptions } from './QuoteOptions';
4
5
  export type DTOItineraryEntity = {
5
6
  id: string;
6
7
  revisionGroupId: string;
@@ -10,4 +11,5 @@ export type DTOItineraryEntity = {
10
11
  title: string;
11
12
  componentInstances: Array<ComponentInstance>;
12
13
  fees: Array<Fee>;
14
+ quoteOption?: QuoteOptions;
13
15
  };
@@ -1,6 +1,7 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
3
  import type { Metadata } from './Metadata';
4
+ import type { QuoteOptions } from './QuoteOptions';
4
5
  export type DTOItineraryRead = {
5
6
  id: string;
6
7
  revisionGroupId: string;
@@ -10,4 +11,5 @@ export type DTOItineraryRead = {
10
11
  title: string;
11
12
  componentInstances: Array<ComponentInstance>;
12
13
  fees: Array<Fee>;
14
+ quoteOption?: QuoteOptions;
13
15
  };
@@ -1,8 +1,10 @@
1
1
  import type { ComponentInstance } from './ComponentInstance';
2
2
  import type { Fee } from './Fee';
3
+ import type { QuoteOptions } from './QuoteOptions';
3
4
  export type DTOItineraryUpdate = {
4
5
  enquiryId: string;
5
6
  title: string;
6
7
  componentInstances: Array<ComponentInstance>;
7
8
  fees: Array<Fee>;
9
+ quoteOption?: QuoteOptions;
8
10
  };
@@ -0,0 +1,8 @@
1
+ export type QuoteOptions = {
2
+ showAllPrice?: boolean;
3
+ includePaymentLinks?: boolean;
4
+ urgencyCta?: string;
5
+ quoteExpiredDate?: string;
6
+ priceRange?: string;
7
+ savingMade?: string;
8
+ };
@@ -7,18 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import React, { useEffect, useMemo, useState } from 'react';
10
+ import React, { useEffect, useState } from 'react';
11
11
  import { Paper, Button } from '@mui/material';
12
12
  import { useLocalErrors } from '../hooks/errors';
13
13
  import { ComponentPool } from '../registry/types';
14
14
  import { registerComponent } from '../registry/components';
15
15
  import { CoreService } from '../../api/generated/core';
16
16
  import { useComponentPicker } from '../contexts/ComponentPickerContext';
17
- const FormComponentPicker = ({ components, selectedComponent, onChange, templateIds, getError, label, enabled }) => {
18
- const selected = components.find(c => c.id === selectedComponent) || null;
17
+ import { InternalServices } from '../../api/init';
18
+ const FormComponentPicker = ({ selectedComponent, onChange, templateIds, getError, label, enabled }) => {
19
+ const [selected, setSelected] = useState();
19
20
  const { get } = useComponentPicker();
21
+ useEffect(() => {
22
+ if (selectedComponent)
23
+ InternalServices.CoreService.componentGet(selectedComponent).then(setSelected);
24
+ else
25
+ setSelected(undefined);
26
+ }, [selectedComponent]);
20
27
  return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
21
- React.createElement(Button, { onClick: () => {
28
+ React.createElement(Button, { disabled: !enabled, onClick: () => {
22
29
  get(templateIds)
23
30
  .then((comp) => {
24
31
  onChange(comp.id);
@@ -42,29 +49,10 @@ const FormComponentPicker = ({ components, selectedComponent, onChange, template
42
49
  } }, selectedComponent ? selected === null || selected === void 0 ? void 0 : selected.name : "Select " + label + " Component")));
43
50
  };
44
51
  const FormRendererComponentPicker = ({ data, handleChange, path, label, enabled, schema }) => {
45
- const [components, setComponents] = useState([]);
46
52
  const getError = useLocalErrors(path);
47
- console.log("STINKY", JSON.stringify(schema, null, 2));
48
- const templateIds = useMemo(() =>
49
- // @ts-ignore
50
- schema['x-templateIds'] || [], [schema]);
51
- useEffect(() => {
52
- const load = () => __awaiter(void 0, void 0, void 0, function* () {
53
- try {
54
- const fetched = yield fetchComponents();
55
- let filtered = fetched.data;
56
- if (templateIds.length > 0) {
57
- filtered = filtered.filter(c => templateIds.includes(c.templateId));
58
- }
59
- setComponents(filtered);
60
- }
61
- catch (err) {
62
- console.error('Error loading components:', err);
63
- }
64
- });
65
- load();
66
- }, [templateIds]);
67
- return (React.createElement(FormComponentPicker, { components: components, selectedComponent: data || null, onChange: (id) => handleChange(path, id), templateIds: templateIds, getError: getError, label: label, enabled: enabled }));
53
+ // @ts-expect-error
54
+ const templateIds = schema['x-templateIds'];
55
+ return (React.createElement(FormComponentPicker, { selectedComponent: data || null, onChange: (id) => handleChange(path, id), templateIds: templateIds, getError: getError, label: label, enabled: enabled }));
68
56
  };
69
57
  registerComponent("component", FormRendererComponentPicker, ComponentPool.FORM);
70
58
  export const fetchComponents = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -73,8 +73,6 @@ const defaultConverter = (field, stage, omitTitle, isChild) => {
73
73
  let templates = field.fieldType === "component"
74
74
  ? { "x-templateIds": field.componentOptions["x-templateIds"] }
75
75
  : {};
76
- console.log(templates);
77
76
  let title = omitTitle ? undefined : field.name;
78
- console.log("FINAL", Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (!isChild && !(Array.isArray(field.editableIn) ? field.editableIn : []).map(Number).includes(stage) && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties })));
79
77
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (!isChild && !(Array.isArray(field.editableIn) ? field.editableIn : []).map(Number).includes(stage) && { readOnly: true })), { title, type: schema.schema.type, "x-type": schema.schema["x-type"] }), templates), (schema.schema.type === "object" && { properties })), (field.fieldType === "object" && { required: requiredFields })), (enumOpts && { enum: enumOpts })), (stagedEnumOpts && { items: { enum: stagedEnumOpts, type: "string" } })), (arrayItems && { items: arrayItems })), (field.fieldType === "object" && { properties }));
80
78
  };
package/dist/test.d.ts CHANGED
@@ -1 +0,0 @@
1
- export {};
package/dist/test.js CHANGED
@@ -1,489 +1 @@
1
- import { generateJsonSchema, Stage } from "./rendering";
2
- const schema = [
3
- {
4
- "required": true,
5
- "name": "Location",
6
- "fieldType": "component",
7
- // @ts-expect-error
8
- "existsFrom": "0",
9
- "editableIn": [
10
- // @ts-expect-error
11
- "0"
12
- ],
13
- "componentOptions": {
14
- "x-templateIds": [
15
- "template_0c105b25350647b096753b4f863ab06c"
16
- ]
17
- }
18
- },
19
- {
20
- "required": false,
21
- "name": "Facilities",
22
- "fieldType": "object",
23
- // @ts-expect-error
24
- "existsFrom": "0",
25
- "editableIn": [
26
- // @ts-expect-error
27
- "0"
28
- ],
29
- "objectOptions": {
30
- "properties": [
31
- {
32
- "required": true,
33
- "name": "Bar",
34
- "fieldType": "boolean",
35
- "editableIn": [
36
- "0"
37
- ],
38
- "existsFrom": "0"
39
- },
40
- {
41
- "required": true,
42
- "name": "Elevator",
43
- "fieldType": "boolean",
44
- "editableIn": [
45
- "0"
46
- ],
47
- "existsFrom": "0"
48
- },
49
- {
50
- "required": true,
51
- "name": "Jacuzzi",
52
- "fieldType": "boolean",
53
- "existsFrom": "0",
54
- "editableIn": [
55
- "0"
56
- ]
57
- },
58
- {
59
- "required": true,
60
- "name": "Library",
61
- "fieldType": "boolean",
62
- "existsFrom": "0",
63
- "editableIn": [
64
- "0"
65
- ]
66
- },
67
- {
68
- "required": true,
69
- "name": "Pool",
70
- "existsFrom": "0",
71
- "editableIn": [
72
- "0"
73
- ],
74
- "fieldType": "boolean"
75
- },
76
- {
77
- "required": true,
78
- "name": "Spa",
79
- "fieldType": "boolean",
80
- "existsFrom": "0",
81
- "editableIn": [
82
- "0"
83
- ]
84
- },
85
- {
86
- "required": true,
87
- "name": "Steam Room",
88
- "fieldType": "boolean",
89
- "existsFrom": "0",
90
- "editableIn": [
91
- "0"
92
- ]
93
- },
94
- {
95
- "required": true,
96
- "name": "Laundry",
97
- "fieldType": "boolean",
98
- "existsFrom": "0",
99
- "editableIn": [
100
- "0"
101
- ]
102
- },
103
- {
104
- "required": true,
105
- "name": "Shop",
106
- "fieldType": "boolean",
107
- "existsFrom": "0",
108
- "editableIn": [
109
- "0"
110
- ]
111
- },
112
- {
113
- "required": true,
114
- "name": "Restaurants",
115
- "fieldType": "boolean",
116
- "existsFrom": "0",
117
- "editableIn": [
118
- "0"
119
- ]
120
- },
121
- {
122
- "required": true,
123
- "name": "Sauna",
124
- "fieldType": "boolean",
125
- "existsFrom": "0",
126
- "editableIn": [
127
- "0"
128
- ]
129
- },
130
- {
131
- "required": true,
132
- "name": "Gym",
133
- "fieldType": "boolean",
134
- "existsFrom": "0",
135
- "editableIn": [
136
- "0"
137
- ]
138
- },
139
- {
140
- "required": true,
141
- "name": "Massage",
142
- "fieldType": "boolean",
143
- "existsFrom": "0",
144
- "editableIn": [
145
- "0"
146
- ]
147
- },
148
- {
149
- "required": true,
150
- "name": "Room Service",
151
- "fieldType": "boolean",
152
- "existsFrom": "0",
153
- "editableIn": [
154
- "0"
155
- ]
156
- },
157
- {
158
- "required": true,
159
- "name": "WiFi",
160
- "fieldType": "boolean",
161
- "existsFrom": "0",
162
- "editableIn": [
163
- "0"
164
- ]
165
- },
166
- {
167
- "required": true,
168
- "name": "Phone Signal",
169
- "fieldType": "boolean",
170
- "existsFrom": "0",
171
- "editableIn": [
172
- "0"
173
- ]
174
- }
175
- ]
176
- }
177
- },
178
- {
179
- "required": false,
180
- "name": "Check-in",
181
- "fieldType": "object",
182
- "editableIn": [
183
- // @ts-expect-error
184
- "0",
185
- // @ts-expect-error
186
- "1"
187
- ],
188
- // @ts-expect-error
189
- "existsFrom": "0",
190
- "objectOptions": {
191
- "properties": [
192
- {
193
- "required": false,
194
- "name": "Start",
195
- "fieldType": "string",
196
- "stringOptions": {
197
- "format": "time"
198
- },
199
- "editableIn": [
200
- "0",
201
- "1"
202
- ],
203
- "existsFrom": "0"
204
- },
205
- {
206
- "required": false,
207
- "name": "End",
208
- "fieldType": "string",
209
- "existsFrom": "0",
210
- "editableIn": [
211
- "0",
212
- "1"
213
- ],
214
- "stringOptions": {
215
- "format": "time"
216
- }
217
- },
218
- {
219
- "required": false,
220
- "name": "Out",
221
- "fieldType": "string",
222
- "existsFrom": "0",
223
- "editableIn": [
224
- "0",
225
- "1"
226
- ],
227
- "stringOptions": {
228
- "format": "time"
229
- }
230
- }
231
- ]
232
- }
233
- },
234
- {
235
- "required": false,
236
- "name": "Info",
237
- "fieldType": "object",
238
- // @ts-expect-error
239
- "existsFrom": "0",
240
- "editableIn": [
241
- // @ts-expect-error
242
- "0"
243
- ],
244
- "objectOptions": {
245
- "properties": [
246
- {
247
- "required": false,
248
- "name": "Year Built",
249
- "fieldType": "integer",
250
- "editableIn": [
251
- "0"
252
- ],
253
- "stringOptions": {},
254
- "existsFrom": "0"
255
- },
256
- {
257
- "required": false,
258
- "name": "Capacity",
259
- "fieldType": "integer",
260
- "existsFrom": "0",
261
- "editableIn": [
262
- "0"
263
- ]
264
- }
265
- ]
266
- }
267
- },
268
- {
269
- "required": true,
270
- "name": "Rooms",
271
- "fieldType": "array",
272
- // @ts-expect-error
273
- "existsFrom": "0",
274
- "editableIn": [
275
- // @ts-expect-error
276
- "0"
277
- ],
278
- "arrayOptions": {
279
- "itemDefinition": {
280
- "fieldType": "object",
281
- "objectOptions": {
282
- "properties": [
283
- {
284
- "required": true,
285
- "name": "Size (m^2)",
286
- "fieldType": "number",
287
- "editableIn": [
288
- "0"
289
- ],
290
- "existsFrom": "0"
291
- },
292
- {
293
- "required": true,
294
- "name": "Bed Configurations",
295
- "fieldType": "array",
296
- "existsFrom": "0",
297
- "editableIn": [
298
- "0"
299
- ],
300
- "arrayOptions": {
301
- "itemDefinition": {
302
- "fieldType": "enum",
303
- "enumOptions": {
304
- "enumValues": [
305
- "Other",
306
- "Double",
307
- "Twin",
308
- "Bunk Bed",
309
- "Single",
310
- "Triple",
311
- "Quad",
312
- "Quintuple"
313
- ]
314
- }
315
- },
316
- "uniqueItems": true
317
- }
318
- },
319
- {
320
- "required": true,
321
- "name": "Bathroom configurations",
322
- "fieldType": "array",
323
- "existsFrom": "0",
324
- "editableIn": [
325
- "0"
326
- ],
327
- "arrayOptions": {
328
- "itemDefinition": {
329
- "fieldType": "enum",
330
- "enumOptions": {
331
- "enumValues": [
332
- "En-suite",
333
- "Shower",
334
- "Sink",
335
- "Shared Bathroom",
336
- "WC",
337
- "Wetroom",
338
- "Toilet",
339
- "Composting Toilet",
340
- "Combi Bath/Shower"
341
- ]
342
- }
343
- },
344
- "uniqueItems": true
345
- }
346
- },
347
- {
348
- "required": true,
349
- "name": "Energy Type",
350
- "fieldType": "array",
351
- "existsFrom": "0",
352
- "editableIn": [
353
- "0"
354
- ],
355
- "enumOptions": {
356
- "enumValues": [
357
- "Other",
358
- "Non-renewable",
359
- "Solar",
360
- "Hydro-electric",
361
- "Micro Hydro-turbines",
362
- "Mini Hydro-electric",
363
- "Wind"
364
- ]
365
- },
366
- "arrayOptions": {
367
- "itemDefinition": {
368
- "fieldType": "enum",
369
- "enumOptions": {
370
- "enumValues": [
371
- "Other",
372
- "Non-renewable",
373
- "Solar",
374
- "Hydroelectric",
375
- "Wind",
376
- "Carbon Neutral"
377
- ]
378
- }
379
- }
380
- }
381
- },
382
- {
383
- "required": true,
384
- "name": "Name",
385
- "fieldType": "string",
386
- "existsFrom": "0",
387
- "editableIn": [
388
- "0"
389
- ]
390
- },
391
- {
392
- "required": true,
393
- "name": "Type",
394
- "fieldType": "enum",
395
- "existsFrom": "0",
396
- "editableIn": [
397
- "0"
398
- ],
399
- "enumOptions": {
400
- "enumValues": [
401
- "Cabin",
402
- "Hotel"
403
- ]
404
- }
405
- }
406
- ]
407
- }
408
- }
409
- }
410
- },
411
- {
412
- "required": false,
413
- "name": "Requirements",
414
- "fieldType": "object",
415
- // @ts-expect-error
416
- "existsFrom": "0",
417
- "editableIn": [
418
- // @ts-expect-error
419
- "0"
420
- ],
421
- "objectOptions": {
422
- "properties": [
423
- {
424
- "required": false,
425
- "name": "Minimum Age",
426
- "fieldType": "integer",
427
- "existsFrom": "0",
428
- "editableIn": [
429
- "0"
430
- ],
431
- "integerOptions": {
432
- "minimum": 0
433
- }
434
- }
435
- ]
436
- }
437
- },
438
- {
439
- "required": false,
440
- "name": "Inspections",
441
- "fieldType": "array",
442
- // @ts-expect-error
443
- "existsFrom": "0",
444
- "editableIn": [
445
- // @ts-expect-error
446
- "0"
447
- ],
448
- "arrayOptions": {
449
- "itemDefinition": {
450
- "fieldType": "object",
451
- "objectOptions": {
452
- "properties": [
453
- {
454
- "required": true,
455
- "name": "Inspected By",
456
- "fieldType": "string",
457
- "editableIn": [
458
- "0"
459
- ],
460
- "existsFrom": "0"
461
- },
462
- {
463
- "required": true,
464
- "name": "Date",
465
- "fieldType": "string",
466
- "existsFrom": "0",
467
- "editableIn": [
468
- "0"
469
- ],
470
- "stringOptions": {
471
- "format": "date"
472
- }
473
- },
474
- {
475
- "required": false,
476
- "name": "Notes",
477
- "fieldType": "string",
478
- "editableIn": [
479
- "0"
480
- ],
481
- "existsFrom": "0"
482
- }
483
- ]
484
- }
485
- }
486
- }
487
- }
488
- ];
489
- console.log(JSON.stringify(generateJsonSchema(schema, Stage.Comp), null, 2));
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swoop-common",
3
- "version": "2.1.34",
3
+ "version": "2.1.36",
4
4
  "main": "dist/api/index.js",
5
5
  "types": "dist/api/index.d.ts",
6
6
  "exports": {