@star-insure/sdk 1.1.10 → 1.1.13
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/components/common/Button.d.ts +14 -0
- package/dist/components/common/Card.d.ts +7 -0
- package/dist/components/common/Modal.d.ts +9 -0
- package/dist/components/common/Pagination.d.ts +9 -0
- package/dist/components/common/ToastItem.d.ts +3 -0
- package/dist/components/common/Toasts.d.ts +2 -0
- package/dist/components/common/index.d.ts +7 -0
- package/dist/components/forms/DateOfBirthField.d.ts +7 -0
- package/dist/components/forms/ErrorList.d.ts +10 -0
- package/dist/components/forms/FormTester.d.ts +6 -0
- package/dist/components/forms/MoneyField.d.ts +11 -0
- package/dist/components/forms/RegistrationSearchField.d.ts +23 -0
- package/dist/components/forms/index.d.ts +6 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/tables/Table.d.ts +6 -0
- package/dist/components/tables/TableActions.d.ts +7 -0
- package/dist/components/tables/TableBody.d.ts +7 -0
- package/dist/components/tables/TableCell.d.ts +7 -0
- package/dist/components/tables/TableHead.d.ts +7 -0
- package/dist/components/tables/TableHeader.d.ts +9 -0
- package/dist/components/tables/TableRow.d.ts +8 -0
- package/dist/components/tables/index.d.ts +8 -0
- package/{index.js → dist/index.d.ts} +3 -4
- package/dist/index.js +8 -0
- package/dist/lib/addressFinder.d.ts +54 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/calculateAge.d.ts +5 -0
- package/dist/lib/clickOutside.d.ts +1 -0
- package/dist/lib/dates.d.ts +8 -0
- package/dist/lib/index.d.ts +12 -0
- package/dist/lib/inertiaOptions.d.ts +6 -0
- package/dist/lib/localStorage.d.ts +1 -0
- package/dist/lib/money.d.ts +32 -0
- package/dist/lib/quoteRequestForm.d.ts +19 -0
- package/dist/lib/quoteRequestOptions.d.ts +11 -0
- package/dist/lib/toast.d.ts +10 -0
- package/dist/lib/vehicles.d.ts +2 -0
- package/dist/sdk.cjs.development.js +2005 -0
- package/dist/sdk.cjs.development.js.map +1 -0
- package/dist/sdk.cjs.production.min.js +2 -0
- package/dist/sdk.cjs.production.min.js.map +1 -0
- package/dist/sdk.esm.js +1955 -0
- package/dist/sdk.esm.js.map +1 -0
- package/dist/types/api/auth.d.ts +9 -0
- package/dist/types/api/enums.d.ts +4 -0
- package/dist/types/api/index.d.ts +31 -0
- package/dist/types/api/responses/claimRequestActions.d.ts +12 -0
- package/dist/types/api/responses/index.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/misc/index.d.ts +8 -0
- package/dist/types/misc/inertia.d.ts +8 -0
- package/dist/types/models/auth/Group.d.ts +10 -0
- package/dist/types/models/auth/Permission.d.ts +4 -0
- package/dist/types/models/auth/Role.d.ts +6 -0
- package/dist/types/models/auth/User.d.ts +12 -0
- package/dist/types/models/auth/index.d.ts +4 -0
- package/dist/types/models/claims/ClaimRequest.d.ts +287 -0
- package/dist/types/models/claims/index.d.ts +1 -0
- package/dist/types/models/index.d.ts +6 -0
- package/dist/types/models/oracle/Risk.d.ts +8 -0
- package/dist/types/models/oracle/TableData.d.ts +9 -0
- package/dist/types/models/oracle/index.d.ts +2 -0
- package/dist/types/models/payments/Gateways.d.ts +1 -0
- package/dist/types/models/payments/Payment.d.ts +35 -0
- package/dist/types/models/payments/index.d.ts +2 -0
- package/dist/types/models/quotes/Club.d.ts +4 -0
- package/dist/types/models/quotes/EmailContentOption.d.ts +7 -0
- package/dist/types/models/quotes/InformationRequest.d.ts +34 -0
- package/dist/types/models/quotes/Lead.d.ts +17 -0
- package/dist/types/models/quotes/MotorwebVehicle.d.ts +120 -0
- package/dist/types/models/quotes/PolicyBenefit.d.ts +16 -0
- package/dist/types/models/quotes/PolicyEnhancement.d.ts +11 -0
- package/dist/types/models/quotes/PostalAddress.d.ts +7 -0
- package/dist/types/models/quotes/PromoCode.d.ts +18 -0
- package/dist/types/models/quotes/QuoteRequest.d.ts +88 -0
- package/dist/types/models/quotes/QuoteRequestDeclaration.d.ts +22 -0
- package/dist/types/models/quotes/QuoteRequestForm.d.ts +112 -0
- package/dist/types/models/quotes/QuoteRequestIncident.d.ts +5 -0
- package/dist/types/models/quotes/QuoteRequestLog.d.ts +10 -0
- package/dist/types/models/quotes/QuoteRequestOptions.d.ts +59 -0
- package/dist/types/models/quotes/QuoteRequestPurchaseOption.d.ts +35 -0
- package/dist/types/models/quotes/QuoteRequestReferrer.d.ts +7 -0
- package/dist/types/models/quotes/QuoteRequestReferrerCategory.d.ts +4 -0
- package/dist/types/models/quotes/QuoteRequestVehicle.d.ts +20 -0
- package/dist/types/models/quotes/QuoteRequestVehicleDriver.d.ts +10 -0
- package/dist/types/models/quotes/RedbookVehicle.d.ts +55 -0
- package/dist/types/models/quotes/StreetAddress.d.ts +8 -0
- package/dist/types/models/quotes/index.d.ts +22 -0
- package/dist/types/models/sms-messages/SmsContentOption.d.ts +7 -0
- package/dist/types/models/sms-messages/SmsMessage.d.ts +18 -0
- package/dist/types/models/sms-messages/SmsMessageReply.d.ts +10 -0
- package/dist/types/models/sms-messages/index.d.ts +3 -0
- package/package.json +9 -3
- package/src/components/forms/{Errors.tsx → ErrorList.tsx} +1 -1
- package/src/components/forms/index.ts +2 -2
|
@@ -0,0 +1,2005 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var dateFns = require('date-fns');
|
|
8
|
+
var inertiaReact = require('@inertiajs/inertia-react');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var React__default = _interopDefault(React);
|
|
11
|
+
var uuid = require('uuid');
|
|
12
|
+
var react = require('@headlessui/react');
|
|
13
|
+
var lodashEs = require('lodash-es');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function formatDateNice(date, includeTime) {
|
|
20
|
+
if (includeTime === void 0) {
|
|
21
|
+
includeTime = true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var formatString = includeTime ? "MMM d, yyyy 'at' h:mma" : 'MMM d, yyyy';
|
|
25
|
+
return dateFns.format(new Date(date), formatString);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Formats a date like "01/01/2022 9:50AM"
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function formatDateForTable(date, includeTime) {
|
|
32
|
+
if (includeTime === void 0) {
|
|
33
|
+
includeTime = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var formatString = includeTime ? 'dd/MM/yyyy h:mma' : 'dd/MM/yyyy';
|
|
37
|
+
return dateFns.format(new Date(date), formatString);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Safely rounds a number
|
|
42
|
+
*/
|
|
43
|
+
function round(value) {
|
|
44
|
+
return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets the GST value from a number
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
function getGst(value) {
|
|
51
|
+
return round(value * 3 / 23);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Adds GST to a number
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
function addGst(value) {
|
|
58
|
+
return round(value * 1.15);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Subtracts GST from a number
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
function subtractGst(value) {
|
|
65
|
+
return round(value - getGst(value));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Calculates the various GST values on a figure
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
function gstCalc(input) {
|
|
72
|
+
var value = input;
|
|
73
|
+
|
|
74
|
+
if (typeof value === 'string') {
|
|
75
|
+
value = parseFloat(value.replace(/[^0-9.]/g, ''));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
value = round(value);
|
|
79
|
+
return {
|
|
80
|
+
gst: getGst(value),
|
|
81
|
+
amountInclusive: addGst(value),
|
|
82
|
+
amountExclusive: subtractGst(value)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Formats a value nicely
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
function formatMoney(value, decimals) {
|
|
90
|
+
if (decimals === void 0) {
|
|
91
|
+
decimals = 2;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var toFormat = value;
|
|
95
|
+
|
|
96
|
+
if (typeof value === 'string') {
|
|
97
|
+
toFormat = value.replace(/[^\d.-]/g, '');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return Number(toFormat).toLocaleString('en', {
|
|
101
|
+
minimumFractionDigits: decimals,
|
|
102
|
+
maximumFractionDigits: decimals
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Turns a formatted value in to a float
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
function formatNumber(value) {
|
|
110
|
+
return parseFloat(value.replace(/[^0-9.]/g, ''));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function sanitiseVehicleType(inputType) {
|
|
114
|
+
var type;
|
|
115
|
+
|
|
116
|
+
switch (inputType) {
|
|
117
|
+
case 'Camper':
|
|
118
|
+
case 'Goods Van/Truck/Utility':
|
|
119
|
+
case 'Bus':
|
|
120
|
+
case 'Motor Caravan':
|
|
121
|
+
case 'Trailer/Caravan':
|
|
122
|
+
case 'TRAILER_CARAVAN':
|
|
123
|
+
case 'TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE':
|
|
124
|
+
case 'MOBILE_MACHINE':
|
|
125
|
+
case 'GOODS_VAN_TRUCK_UTILITY':
|
|
126
|
+
case 'BUS':
|
|
127
|
+
case 'MOTOR_CARAVAN':
|
|
128
|
+
{
|
|
129
|
+
type = 'motorhome';
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case 'Motorcycle':
|
|
134
|
+
case 'Moped':
|
|
135
|
+
case 'ATV':
|
|
136
|
+
case 'Agricultural Machine':
|
|
137
|
+
case 'MOTORCYCLE':
|
|
138
|
+
case 'ATV':
|
|
139
|
+
case 'MOPED':
|
|
140
|
+
case 'TRACTOR':
|
|
141
|
+
case 'AGRICULTURAL_MACHINE':
|
|
142
|
+
case 'HIGH_SPEED_AGRICULTURAL_VEHICLE':
|
|
143
|
+
{
|
|
144
|
+
type = 'motorcycle';
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
case 'Passenger Car/Van':
|
|
149
|
+
case 'PASSENGER_CAR_VAN':
|
|
150
|
+
case 'SPECIAL_PURPOSE_VEHICLE':
|
|
151
|
+
case 'UNKNOWN':
|
|
152
|
+
default:
|
|
153
|
+
type = 'car';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return type;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function useAuth() {
|
|
160
|
+
var _usePage = inertiaReact.usePage(),
|
|
161
|
+
props = _usePage.props;
|
|
162
|
+
|
|
163
|
+
return props.auth;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function useClickOutside(ref, handler) {
|
|
167
|
+
React.useEffect(function () {
|
|
168
|
+
var listener = function listener(event) {
|
|
169
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
170
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
handler(event);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
document.addEventListener('mousedown', listener);
|
|
178
|
+
document.addEventListener('touchstart', listener);
|
|
179
|
+
return function () {
|
|
180
|
+
document.removeEventListener('mousedown', listener);
|
|
181
|
+
document.removeEventListener('touchstart', listener);
|
|
182
|
+
};
|
|
183
|
+
}, [ref, handler]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
var ToastContext = /*#__PURE__*/React.createContext({
|
|
187
|
+
toasts: [],
|
|
188
|
+
addToast: function addToast(t) {
|
|
189
|
+
},
|
|
190
|
+
removeToast: function removeToast(t) {
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
function ToastProvider(_ref) {
|
|
194
|
+
var children = _ref.children;
|
|
195
|
+
|
|
196
|
+
var _React$useState = React.useState([]),
|
|
197
|
+
toasts = _React$useState[0],
|
|
198
|
+
setToasts = _React$useState[1];
|
|
199
|
+
/**
|
|
200
|
+
* Add a new toast popup message
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
function addToast(_ref2) {
|
|
205
|
+
var message = _ref2.message,
|
|
206
|
+
status = _ref2.status,
|
|
207
|
+
_ref2$timeout = _ref2.timeout,
|
|
208
|
+
timeout = _ref2$timeout === void 0 ? 4000 : _ref2$timeout;
|
|
209
|
+
var newToast = {
|
|
210
|
+
message: message,
|
|
211
|
+
status: status,
|
|
212
|
+
timeout: timeout
|
|
213
|
+
};
|
|
214
|
+
newToast._id = uuid.v4();
|
|
215
|
+
setToasts(function (curr) {
|
|
216
|
+
return [].concat(curr, [newToast]);
|
|
217
|
+
});
|
|
218
|
+
setTimeout(function () {
|
|
219
|
+
removeToast(newToast._id);
|
|
220
|
+
}, timeout);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Remove a toast message
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
function removeToast(id) {
|
|
228
|
+
setToasts(function (curr) {
|
|
229
|
+
return curr.filter(function (toast) {
|
|
230
|
+
return toast._id !== id;
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
var context = {
|
|
236
|
+
toasts: toasts,
|
|
237
|
+
addToast: addToast,
|
|
238
|
+
removeToast: removeToast
|
|
239
|
+
};
|
|
240
|
+
return React.createElement(ToastContext.Provider, {
|
|
241
|
+
value: context
|
|
242
|
+
}, children);
|
|
243
|
+
}
|
|
244
|
+
var useToast = function useToast() {
|
|
245
|
+
return React.useContext(ToastContext);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
function useInertiaOptions(_ref) {
|
|
249
|
+
var _ref$successMessage = _ref.successMessage,
|
|
250
|
+
successMessage = _ref$successMessage === void 0 ? '' : _ref$successMessage;
|
|
251
|
+
|
|
252
|
+
var _useToast = useToast(),
|
|
253
|
+
addToast = _useToast.addToast;
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
onSuccess: function onSuccess() {
|
|
257
|
+
addToast({
|
|
258
|
+
message: successMessage != null ? successMessage : 'Your request was successful.',
|
|
259
|
+
status: 'success'
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
onError: function onError(errors) {
|
|
263
|
+
Object.values(errors).forEach(function (err) {
|
|
264
|
+
addToast({
|
|
265
|
+
message: err,
|
|
266
|
+
status: 'error'
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function useLocalStorage(key, initialValue) {
|
|
274
|
+
// State to store our value
|
|
275
|
+
// Pass initial state function to useState so logic is only executed once
|
|
276
|
+
var _useState = React.useState(function () {
|
|
277
|
+
if (typeof window === "undefined") {
|
|
278
|
+
return initialValue;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
try {
|
|
282
|
+
// Get from local storage by key
|
|
283
|
+
var item = window.localStorage.getItem(key); // Parse stored json or if none return initialValue
|
|
284
|
+
|
|
285
|
+
return item ? JSON.parse(item) : initialValue;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
// If error also return initialValue
|
|
288
|
+
console.log(error);
|
|
289
|
+
return initialValue;
|
|
290
|
+
}
|
|
291
|
+
}),
|
|
292
|
+
storedValue = _useState[0],
|
|
293
|
+
setStoredValue = _useState[1]; // Return a wrapped version of useState's setter function that ...
|
|
294
|
+
// ... persists the new value to localStorage.
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
var setValue = function setValue(value) {
|
|
298
|
+
try {
|
|
299
|
+
// Allow value to be a function so we have same API as useState
|
|
300
|
+
var valueToStore = value instanceof Function ? value(storedValue) : value; // Save state
|
|
301
|
+
|
|
302
|
+
setStoredValue(valueToStore); // Save to local storage
|
|
303
|
+
|
|
304
|
+
if (typeof window !== "undefined") {
|
|
305
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
306
|
+
}
|
|
307
|
+
} catch (error) {
|
|
308
|
+
// A more advanced implementation would handle the error case
|
|
309
|
+
console.log(error);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
return [storedValue, setValue];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function _regeneratorRuntime() {
|
|
317
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
318
|
+
|
|
319
|
+
_regeneratorRuntime = function () {
|
|
320
|
+
return exports;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
var exports = {},
|
|
324
|
+
Op = Object.prototype,
|
|
325
|
+
hasOwn = Op.hasOwnProperty,
|
|
326
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
327
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
328
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
329
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
330
|
+
|
|
331
|
+
function define(obj, key, value) {
|
|
332
|
+
return Object.defineProperty(obj, key, {
|
|
333
|
+
value: value,
|
|
334
|
+
enumerable: !0,
|
|
335
|
+
configurable: !0,
|
|
336
|
+
writable: !0
|
|
337
|
+
}), obj[key];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
try {
|
|
341
|
+
define({}, "");
|
|
342
|
+
} catch (err) {
|
|
343
|
+
define = function (obj, key, value) {
|
|
344
|
+
return obj[key] = value;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
349
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
350
|
+
generator = Object.create(protoGenerator.prototype),
|
|
351
|
+
context = new Context(tryLocsList || []);
|
|
352
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
353
|
+
var state = "suspendedStart";
|
|
354
|
+
return function (method, arg) {
|
|
355
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
356
|
+
|
|
357
|
+
if ("completed" === state) {
|
|
358
|
+
if ("throw" === method) throw arg;
|
|
359
|
+
return doneResult();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
for (context.method = method, context.arg = arg;;) {
|
|
363
|
+
var delegate = context.delegate;
|
|
364
|
+
|
|
365
|
+
if (delegate) {
|
|
366
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
367
|
+
|
|
368
|
+
if (delegateResult) {
|
|
369
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
370
|
+
return delegateResult;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
375
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
376
|
+
context.dispatchException(context.arg);
|
|
377
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
378
|
+
state = "executing";
|
|
379
|
+
var record = tryCatch(innerFn, self, context);
|
|
380
|
+
|
|
381
|
+
if ("normal" === record.type) {
|
|
382
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
383
|
+
return {
|
|
384
|
+
value: record.arg,
|
|
385
|
+
done: context.done
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}(innerFn, self, context), generator;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function tryCatch(fn, obj, arg) {
|
|
396
|
+
try {
|
|
397
|
+
return {
|
|
398
|
+
type: "normal",
|
|
399
|
+
arg: fn.call(obj, arg)
|
|
400
|
+
};
|
|
401
|
+
} catch (err) {
|
|
402
|
+
return {
|
|
403
|
+
type: "throw",
|
|
404
|
+
arg: err
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
exports.wrap = wrap;
|
|
410
|
+
var ContinueSentinel = {};
|
|
411
|
+
|
|
412
|
+
function Generator() {}
|
|
413
|
+
|
|
414
|
+
function GeneratorFunction() {}
|
|
415
|
+
|
|
416
|
+
function GeneratorFunctionPrototype() {}
|
|
417
|
+
|
|
418
|
+
var IteratorPrototype = {};
|
|
419
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
420
|
+
return this;
|
|
421
|
+
});
|
|
422
|
+
var getProto = Object.getPrototypeOf,
|
|
423
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
424
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
425
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
426
|
+
|
|
427
|
+
function defineIteratorMethods(prototype) {
|
|
428
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
429
|
+
define(prototype, method, function (arg) {
|
|
430
|
+
return this._invoke(method, arg);
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
436
|
+
function invoke(method, arg, resolve, reject) {
|
|
437
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
438
|
+
|
|
439
|
+
if ("throw" !== record.type) {
|
|
440
|
+
var result = record.arg,
|
|
441
|
+
value = result.value;
|
|
442
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
443
|
+
invoke("next", value, resolve, reject);
|
|
444
|
+
}, function (err) {
|
|
445
|
+
invoke("throw", err, resolve, reject);
|
|
446
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
447
|
+
result.value = unwrapped, resolve(result);
|
|
448
|
+
}, function (error) {
|
|
449
|
+
return invoke("throw", error, resolve, reject);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
reject(record.arg);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var previousPromise;
|
|
457
|
+
|
|
458
|
+
this._invoke = function (method, arg) {
|
|
459
|
+
function callInvokeWithMethodAndArg() {
|
|
460
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
461
|
+
invoke(method, arg, resolve, reject);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
470
|
+
var method = delegate.iterator[context.method];
|
|
471
|
+
|
|
472
|
+
if (undefined === method) {
|
|
473
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
474
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
475
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return ContinueSentinel;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
482
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
483
|
+
var info = record.arg;
|
|
484
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function pushTryEntry(locs) {
|
|
488
|
+
var entry = {
|
|
489
|
+
tryLoc: locs[0]
|
|
490
|
+
};
|
|
491
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function resetTryEntry(entry) {
|
|
495
|
+
var record = entry.completion || {};
|
|
496
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function Context(tryLocsList) {
|
|
500
|
+
this.tryEntries = [{
|
|
501
|
+
tryLoc: "root"
|
|
502
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function values(iterable) {
|
|
506
|
+
if (iterable) {
|
|
507
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
508
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
509
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
510
|
+
|
|
511
|
+
if (!isNaN(iterable.length)) {
|
|
512
|
+
var i = -1,
|
|
513
|
+
next = function next() {
|
|
514
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
515
|
+
|
|
516
|
+
return next.value = undefined, next.done = !0, next;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
return next.next = next;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return {
|
|
524
|
+
next: doneResult
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function doneResult() {
|
|
529
|
+
return {
|
|
530
|
+
value: undefined,
|
|
531
|
+
done: !0
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
536
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
537
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
538
|
+
}, exports.mark = function (genFun) {
|
|
539
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
540
|
+
}, exports.awrap = function (arg) {
|
|
541
|
+
return {
|
|
542
|
+
__await: arg
|
|
543
|
+
};
|
|
544
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
545
|
+
return this;
|
|
546
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
547
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
548
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
549
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
550
|
+
return result.done ? result.value : iter.next();
|
|
551
|
+
});
|
|
552
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
553
|
+
return this;
|
|
554
|
+
}), define(Gp, "toString", function () {
|
|
555
|
+
return "[object Generator]";
|
|
556
|
+
}), exports.keys = function (object) {
|
|
557
|
+
var keys = [];
|
|
558
|
+
|
|
559
|
+
for (var key in object) keys.push(key);
|
|
560
|
+
|
|
561
|
+
return keys.reverse(), function next() {
|
|
562
|
+
for (; keys.length;) {
|
|
563
|
+
var key = keys.pop();
|
|
564
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
return next.done = !0, next;
|
|
568
|
+
};
|
|
569
|
+
}, exports.values = values, Context.prototype = {
|
|
570
|
+
constructor: Context,
|
|
571
|
+
reset: function (skipTempReset) {
|
|
572
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
573
|
+
},
|
|
574
|
+
stop: function () {
|
|
575
|
+
this.done = !0;
|
|
576
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
577
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
578
|
+
return this.rval;
|
|
579
|
+
},
|
|
580
|
+
dispatchException: function (exception) {
|
|
581
|
+
if (this.done) throw exception;
|
|
582
|
+
var context = this;
|
|
583
|
+
|
|
584
|
+
function handle(loc, caught) {
|
|
585
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
589
|
+
var entry = this.tryEntries[i],
|
|
590
|
+
record = entry.completion;
|
|
591
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
592
|
+
|
|
593
|
+
if (entry.tryLoc <= this.prev) {
|
|
594
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
595
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
596
|
+
|
|
597
|
+
if (hasCatch && hasFinally) {
|
|
598
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
599
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
600
|
+
} else if (hasCatch) {
|
|
601
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
602
|
+
} else {
|
|
603
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
604
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
abrupt: function (type, arg) {
|
|
610
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
611
|
+
var entry = this.tryEntries[i];
|
|
612
|
+
|
|
613
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
614
|
+
var finallyEntry = entry;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
620
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
621
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
622
|
+
},
|
|
623
|
+
complete: function (record, afterLoc) {
|
|
624
|
+
if ("throw" === record.type) throw record.arg;
|
|
625
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
626
|
+
},
|
|
627
|
+
finish: function (finallyLoc) {
|
|
628
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
629
|
+
var entry = this.tryEntries[i];
|
|
630
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
catch: function (tryLoc) {
|
|
634
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
635
|
+
var entry = this.tryEntries[i];
|
|
636
|
+
|
|
637
|
+
if (entry.tryLoc === tryLoc) {
|
|
638
|
+
var record = entry.completion;
|
|
639
|
+
|
|
640
|
+
if ("throw" === record.type) {
|
|
641
|
+
var thrown = record.arg;
|
|
642
|
+
resetTryEntry(entry);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
return thrown;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
throw new Error("illegal catch attempt");
|
|
650
|
+
},
|
|
651
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
652
|
+
return this.delegate = {
|
|
653
|
+
iterator: values(iterable),
|
|
654
|
+
resultName: resultName,
|
|
655
|
+
nextLoc: nextLoc
|
|
656
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
657
|
+
}
|
|
658
|
+
}, exports;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
662
|
+
try {
|
|
663
|
+
var info = gen[key](arg);
|
|
664
|
+
var value = info.value;
|
|
665
|
+
} catch (error) {
|
|
666
|
+
reject(error);
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (info.done) {
|
|
671
|
+
resolve(value);
|
|
672
|
+
} else {
|
|
673
|
+
Promise.resolve(value).then(_next, _throw);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function _asyncToGenerator(fn) {
|
|
678
|
+
return function () {
|
|
679
|
+
var self = this,
|
|
680
|
+
args = arguments;
|
|
681
|
+
return new Promise(function (resolve, reject) {
|
|
682
|
+
var gen = fn.apply(self, args);
|
|
683
|
+
|
|
684
|
+
function _next(value) {
|
|
685
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function _throw(err) {
|
|
689
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
_next(undefined);
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function _extends() {
|
|
698
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
699
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
700
|
+
var source = arguments[i];
|
|
701
|
+
|
|
702
|
+
for (var key in source) {
|
|
703
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
704
|
+
target[key] = source[key];
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return target;
|
|
710
|
+
};
|
|
711
|
+
return _extends.apply(this, arguments);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
var initialData = {
|
|
715
|
+
id: undefined,
|
|
716
|
+
status: 'new',
|
|
717
|
+
source: 'web',
|
|
718
|
+
reference: '',
|
|
719
|
+
client_number: '',
|
|
720
|
+
first_name: '',
|
|
721
|
+
last_name: '',
|
|
722
|
+
phone: '',
|
|
723
|
+
mobile: '',
|
|
724
|
+
email: '',
|
|
725
|
+
licence: '',
|
|
726
|
+
licence_other: '',
|
|
727
|
+
promo_code: '',
|
|
728
|
+
club_membership_number: '',
|
|
729
|
+
length_of_insurance: '',
|
|
730
|
+
dob: '',
|
|
731
|
+
club_id: undefined,
|
|
732
|
+
street_address: {
|
|
733
|
+
address: '',
|
|
734
|
+
unit: '',
|
|
735
|
+
suburb: '',
|
|
736
|
+
city: '',
|
|
737
|
+
post_code: ''
|
|
738
|
+
},
|
|
739
|
+
declaration: {
|
|
740
|
+
had_incident: undefined,
|
|
741
|
+
incidents: [],
|
|
742
|
+
has_demerit_points: undefined,
|
|
743
|
+
demerit_points: '',
|
|
744
|
+
has_lost_licence: undefined,
|
|
745
|
+
lost_licence_details: '',
|
|
746
|
+
was_refused_insurance: undefined,
|
|
747
|
+
refused_insurance_details: '',
|
|
748
|
+
has_criminal_conviction: undefined,
|
|
749
|
+
criminal_conviction_details: '',
|
|
750
|
+
has_vehicle_modifications: undefined,
|
|
751
|
+
vehicle_modifications_details: '',
|
|
752
|
+
has_previous_insurer: undefined,
|
|
753
|
+
previous_insurer_details: '',
|
|
754
|
+
previous_insurer_expires_at: '',
|
|
755
|
+
additional_details: ''
|
|
756
|
+
},
|
|
757
|
+
vehicles: [],
|
|
758
|
+
// Portal specific fields:
|
|
759
|
+
purchase_options: [],
|
|
760
|
+
theme: '',
|
|
761
|
+
broker_fee: undefined,
|
|
762
|
+
broker_id: undefined,
|
|
763
|
+
broker_firm_id: undefined,
|
|
764
|
+
agent_id: undefined,
|
|
765
|
+
agent_firm_id: undefined,
|
|
766
|
+
staff_member_id: undefined,
|
|
767
|
+
sent_at: undefined,
|
|
768
|
+
sold_at: undefined,
|
|
769
|
+
referrer_id: undefined,
|
|
770
|
+
referrer_category_id: undefined,
|
|
771
|
+
pricing_expires_at: undefined,
|
|
772
|
+
follow_up_at: undefined
|
|
773
|
+
};
|
|
774
|
+
var QuoteRequestFormContext = /*#__PURE__*/React__default.createContext({});
|
|
775
|
+
function QuoteRequestFormProvider(_ref) {
|
|
776
|
+
var children = _ref.children;
|
|
777
|
+
var form = inertiaReact.useForm(initialData);
|
|
778
|
+
/**
|
|
779
|
+
* Handle the change event for all form inputs
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
function handleChange(e) {
|
|
783
|
+
var name = e.currentTarget.name;
|
|
784
|
+
var value = e.currentTarget.value;
|
|
785
|
+
|
|
786
|
+
if (e.currentTarget.type === 'checkbox' || e.currentTarget.type === 'radio') {
|
|
787
|
+
var target = e.currentTarget;
|
|
788
|
+
value = target.value === '1' ? true : false;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (name.includes('.')) {
|
|
792
|
+
var parts = name.split('.');
|
|
793
|
+
|
|
794
|
+
if (parts.length === 2) {
|
|
795
|
+
return form.setData(function (prevData) {
|
|
796
|
+
var _extends2, _extends3;
|
|
797
|
+
|
|
798
|
+
return _extends({}, prevData, (_extends3 = {}, _extends3[parts[0]] = _extends({}, prevData[parts[0]], (_extends2 = {}, _extends2[parts[1]] = value, _extends2)), _extends3));
|
|
799
|
+
});
|
|
800
|
+
} else {
|
|
801
|
+
// We don't want to handle anything double-nested. These should be handled by their own local state.
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
return form.setData(function (prevData) {
|
|
807
|
+
var _extends4;
|
|
808
|
+
|
|
809
|
+
return _extends({}, prevData, (_extends4 = {}, _extends4[name] = value, _extends4));
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
return React__default.createElement(QuoteRequestFormContext.Provider, {
|
|
814
|
+
value: {
|
|
815
|
+
form: form,
|
|
816
|
+
handleChange: handleChange
|
|
817
|
+
}
|
|
818
|
+
}, children);
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Takes in a quote request and returns data suitable to populate a form
|
|
822
|
+
* by recursively calling this function, converting null to undefined.
|
|
823
|
+
*/
|
|
824
|
+
|
|
825
|
+
function sanitiseQuoteRequestFormData(value) {
|
|
826
|
+
if (Array.isArray(value)) {
|
|
827
|
+
return value.map(function (item) {
|
|
828
|
+
return sanitiseQuoteRequestFormData(item);
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (value === null) {
|
|
833
|
+
return "";
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (typeof value === 'object') {
|
|
837
|
+
// Map over each property and convert null to undefined
|
|
838
|
+
return Object.keys(value).reduce(function (acc, key) {
|
|
839
|
+
// @ts-ignore
|
|
840
|
+
acc[key] = sanitiseQuoteRequestFormData(value[key]);
|
|
841
|
+
return acc;
|
|
842
|
+
}, {});
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
return value;
|
|
846
|
+
}
|
|
847
|
+
var useQuoteRequestForm = function useQuoteRequestForm() {
|
|
848
|
+
return React__default.useContext(QuoteRequestFormContext);
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
var QuoteRequestOptionsContext = /*#__PURE__*/React__default.createContext({
|
|
852
|
+
setOptions: function setOptions() {}
|
|
853
|
+
});
|
|
854
|
+
function QuoteRequestOptionsProvider(_ref) {
|
|
855
|
+
var children = _ref.children;
|
|
856
|
+
|
|
857
|
+
var _React$useState = React__default.useState(),
|
|
858
|
+
options = _React$useState[0],
|
|
859
|
+
setOptions = _React$useState[1];
|
|
860
|
+
|
|
861
|
+
return React__default.createElement(QuoteRequestOptionsContext.Provider, {
|
|
862
|
+
value: {
|
|
863
|
+
options: options,
|
|
864
|
+
setOptions: setOptions
|
|
865
|
+
}
|
|
866
|
+
}, children);
|
|
867
|
+
}
|
|
868
|
+
var useQuoteRequestOptions = function useQuoteRequestOptions() {
|
|
869
|
+
return React__default.useContext(QuoteRequestOptionsContext);
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
var prodConfig = {
|
|
873
|
+
key: 'XVAKN4Q9PREJD8CUTFBW',
|
|
874
|
+
baseUrl: 'https://api.addressfinder.io/api/nz/address'
|
|
875
|
+
};
|
|
876
|
+
var config = prodConfig;
|
|
877
|
+
function autocomplete(_x) {
|
|
878
|
+
return _autocomplete.apply(this, arguments);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function _autocomplete() {
|
|
882
|
+
_autocomplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
|
|
883
|
+
var key, baseUrl, q, res, data;
|
|
884
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
885
|
+
while (1) {
|
|
886
|
+
switch (_context.prev = _context.next) {
|
|
887
|
+
case 0:
|
|
888
|
+
key = config.key, baseUrl = config.baseUrl;
|
|
889
|
+
q = encodeURIComponent(search);
|
|
890
|
+
_context.next = 4;
|
|
891
|
+
return fetch(baseUrl + "/autocomplete/?key=" + key + "&q=" + q + "&format=json&strict=2");
|
|
892
|
+
|
|
893
|
+
case 4:
|
|
894
|
+
res = _context.sent;
|
|
895
|
+
|
|
896
|
+
if (res.ok) {
|
|
897
|
+
_context.next = 7;
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return _context.abrupt("return", []);
|
|
902
|
+
|
|
903
|
+
case 7:
|
|
904
|
+
_context.next = 9;
|
|
905
|
+
return res.json();
|
|
906
|
+
|
|
907
|
+
case 9:
|
|
908
|
+
data = _context.sent;
|
|
909
|
+
|
|
910
|
+
if (!data.completions) {
|
|
911
|
+
_context.next = 12;
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
return _context.abrupt("return", data.completions);
|
|
916
|
+
|
|
917
|
+
case 12:
|
|
918
|
+
return _context.abrupt("return", []);
|
|
919
|
+
|
|
920
|
+
case 13:
|
|
921
|
+
case "end":
|
|
922
|
+
return _context.stop();
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}, _callee);
|
|
926
|
+
}));
|
|
927
|
+
return _autocomplete.apply(this, arguments);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function getAddressData(_x2) {
|
|
931
|
+
return _getAddressData.apply(this, arguments);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function _getAddressData() {
|
|
935
|
+
_getAddressData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(completion) {
|
|
936
|
+
var key, baseUrl, res, data;
|
|
937
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
938
|
+
while (1) {
|
|
939
|
+
switch (_context2.prev = _context2.next) {
|
|
940
|
+
case 0:
|
|
941
|
+
key = config.key, baseUrl = config.baseUrl;
|
|
942
|
+
_context2.next = 3;
|
|
943
|
+
return fetch(baseUrl + "/metadata/?key=" + key + "&pxid=" + completion.pxid + "&format=json");
|
|
944
|
+
|
|
945
|
+
case 3:
|
|
946
|
+
res = _context2.sent;
|
|
947
|
+
|
|
948
|
+
if (res.ok) {
|
|
949
|
+
_context2.next = 6;
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return _context2.abrupt("return", null);
|
|
954
|
+
|
|
955
|
+
case 6:
|
|
956
|
+
_context2.next = 8;
|
|
957
|
+
return res.json();
|
|
958
|
+
|
|
959
|
+
case 8:
|
|
960
|
+
data = _context2.sent;
|
|
961
|
+
return _context2.abrupt("return", data);
|
|
962
|
+
|
|
963
|
+
case 10:
|
|
964
|
+
case "end":
|
|
965
|
+
return _context2.stop();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}, _callee2);
|
|
969
|
+
}));
|
|
970
|
+
return _getAddressData.apply(this, arguments);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Calculate someone's age from a date of birth.
|
|
975
|
+
* @param date YYYY-MM-DD
|
|
976
|
+
*/
|
|
977
|
+
function calculateAge(date) {
|
|
978
|
+
var today = new Date();
|
|
979
|
+
var birthDate = new Date(date);
|
|
980
|
+
var age = today.getFullYear() - birthDate.getFullYear();
|
|
981
|
+
var m = today.getMonth() - birthDate.getMonth();
|
|
982
|
+
|
|
983
|
+
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
984
|
+
return age - 1;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
return age;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
function Button(_ref) {
|
|
991
|
+
var className = _ref.className,
|
|
992
|
+
href = _ref.href,
|
|
993
|
+
target = _ref.target,
|
|
994
|
+
_onClick = _ref.onClick,
|
|
995
|
+
type = _ref.type,
|
|
996
|
+
children = _ref.children,
|
|
997
|
+
_ref$status = _ref.status,
|
|
998
|
+
status = _ref$status === void 0 ? 'default' : _ref$status,
|
|
999
|
+
_ref$disabled = _ref.disabled,
|
|
1000
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
1001
|
+
as = _ref.as;
|
|
1002
|
+
var baseClasses = 'font-black inline-flex items-center gap-3 justify-center text-white text-center px-5 py-2 rounded-md min-w-[120px] transition-all hover:opacity-75';
|
|
1003
|
+
var statusClass = status === 'primary' && 'bg-teal' || status === 'danger' && 'bg-red-500' || status === 'warning' && 'bg-yellow-400' || status === 'info' && 'bg-blue-400' || 'bg-gray-600';
|
|
1004
|
+
var classes = (className != null ? className : '') + " " + baseClasses + " " + statusClass;
|
|
1005
|
+
|
|
1006
|
+
if (_onClick) {
|
|
1007
|
+
return React__default.createElement("button", {
|
|
1008
|
+
className: classes,
|
|
1009
|
+
type: type != null ? type : 'button',
|
|
1010
|
+
onClick: function onClick(e) {
|
|
1011
|
+
return _onClick(e);
|
|
1012
|
+
},
|
|
1013
|
+
disabled: disabled
|
|
1014
|
+
}, children);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (type) {
|
|
1018
|
+
return React__default.createElement("button", {
|
|
1019
|
+
className: classes,
|
|
1020
|
+
type: type != null ? type : 'button',
|
|
1021
|
+
disabled: disabled
|
|
1022
|
+
}, children);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
if (href) {
|
|
1026
|
+
if (href.includes('http') || target === '_blank' || as === 'a') {
|
|
1027
|
+
return React__default.createElement("a", {
|
|
1028
|
+
href: href,
|
|
1029
|
+
target: target != null ? target : '_self',
|
|
1030
|
+
className: classes
|
|
1031
|
+
}, children);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
return React__default.createElement(inertiaReact.Link, {
|
|
1035
|
+
href: href,
|
|
1036
|
+
className: classes
|
|
1037
|
+
}, children);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
return React__default.createElement("p", {
|
|
1041
|
+
className: "text-red-500 text-sm"
|
|
1042
|
+
}, "[Invalid button]");
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function Card(_ref) {
|
|
1046
|
+
var className = _ref.className,
|
|
1047
|
+
children = _ref.children;
|
|
1048
|
+
return React__default.createElement("div", {
|
|
1049
|
+
className: (className != null ? className : '') + " flex flex-col items-start bg-white rounded-md shadow border border-gray-200 p-4 md:p-6"
|
|
1050
|
+
}, children);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function Pagination(_ref) {
|
|
1054
|
+
var meta = _ref.meta,
|
|
1055
|
+
className = _ref.className,
|
|
1056
|
+
_ref$showPerPageSelec = _ref.showPerPageSelector,
|
|
1057
|
+
showPerPageSelector = _ref$showPerPageSelec === void 0 ? false : _ref$showPerPageSelec;
|
|
1058
|
+
var current_page = meta.current_page,
|
|
1059
|
+
total = meta.total,
|
|
1060
|
+
per_page = meta.per_page;
|
|
1061
|
+
var page_count = Math.ceil(total / per_page);
|
|
1062
|
+
|
|
1063
|
+
function getNextPageLink() {
|
|
1064
|
+
if (typeof window !== 'undefined') {
|
|
1065
|
+
var search = new URLSearchParams(window.location.search);
|
|
1066
|
+
search.set('page', String(current_page + 1));
|
|
1067
|
+
return "?" + search.toString();
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
return '';
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function getPrevPageLink() {
|
|
1074
|
+
if (typeof window !== 'undefined') {
|
|
1075
|
+
var search = new URLSearchParams(window.location.search);
|
|
1076
|
+
search.set('page', String(current_page - 1));
|
|
1077
|
+
return "?" + search.toString();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
return '';
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
var nextPageLink = getNextPageLink();
|
|
1084
|
+
var prevPageLink = getPrevPageLink();
|
|
1085
|
+
|
|
1086
|
+
function handlePerPageChange(e) {
|
|
1087
|
+
var _window;
|
|
1088
|
+
|
|
1089
|
+
var search = new URLSearchParams((_window = window) == null ? void 0 : _window.location.search);
|
|
1090
|
+
search.set('limit', e.currentTarget.value);
|
|
1091
|
+
search.set('page', '1');
|
|
1092
|
+
window.location.href = "?" + search.toString();
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
return React__default.createElement("div", {
|
|
1096
|
+
className: "" + (className != null ? className : '')
|
|
1097
|
+
}, React__default.createElement("nav", {
|
|
1098
|
+
className: "font-bold flex justify-between items-center gap-6"
|
|
1099
|
+
}, React__default.createElement(inertiaReact.Link, {
|
|
1100
|
+
href: prevPageLink,
|
|
1101
|
+
className: "flex items-center gap-2",
|
|
1102
|
+
disabled: current_page === 1
|
|
1103
|
+
}, React__default.createElement("svg", {
|
|
1104
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1105
|
+
className: "h-4 w-4",
|
|
1106
|
+
fill: "none",
|
|
1107
|
+
viewBox: "0 0 24 24",
|
|
1108
|
+
stroke: "currentColor",
|
|
1109
|
+
strokeWidth: "2"
|
|
1110
|
+
}, React__default.createElement("path", {
|
|
1111
|
+
strokeLinecap: "round",
|
|
1112
|
+
strokeLinejoin: "round",
|
|
1113
|
+
d: "M10 19l-7-7m0 0l7-7m-7 7h18"
|
|
1114
|
+
})), "Prev"), React__default.createElement("div", {
|
|
1115
|
+
className: "flex gap-6 items-center"
|
|
1116
|
+
}, React__default.createElement("p", null, "Page ", current_page, " of ", page_count), showPerPageSelector ? React__default.createElement("select", {
|
|
1117
|
+
value: per_page,
|
|
1118
|
+
onChange: handlePerPageChange
|
|
1119
|
+
}, React__default.createElement("option", {
|
|
1120
|
+
value: "10"
|
|
1121
|
+
}, "10 per page"), React__default.createElement("option", {
|
|
1122
|
+
value: "25"
|
|
1123
|
+
}, "25 per page"), React__default.createElement("option", {
|
|
1124
|
+
value: "50"
|
|
1125
|
+
}, "50 per page"), React__default.createElement("option", {
|
|
1126
|
+
value: "100"
|
|
1127
|
+
}, "100 per page")) : ''), React__default.createElement(inertiaReact.Link, {
|
|
1128
|
+
href: nextPageLink,
|
|
1129
|
+
className: "flex items-center gap-2",
|
|
1130
|
+
disabled: current_page === page_count
|
|
1131
|
+
}, "Next", React__default.createElement("svg", {
|
|
1132
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1133
|
+
className: "h-4 w-4",
|
|
1134
|
+
fill: "none",
|
|
1135
|
+
viewBox: "0 0 24 24",
|
|
1136
|
+
stroke: "currentColor",
|
|
1137
|
+
strokeWidth: "2"
|
|
1138
|
+
}, React__default.createElement("path", {
|
|
1139
|
+
strokeLinecap: "round",
|
|
1140
|
+
strokeLinejoin: "round",
|
|
1141
|
+
d: "M14 5l7 7m0 0l-7 7m7-7H3"
|
|
1142
|
+
})))));
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
function ToastItem(_ref) {
|
|
1146
|
+
var _ref$_id = _ref._id,
|
|
1147
|
+
_id = _ref$_id === void 0 ? '' : _ref$_id,
|
|
1148
|
+
message = _ref.message,
|
|
1149
|
+
_ref$status = _ref.status,
|
|
1150
|
+
status = _ref$status === void 0 ? 'default' : _ref$status;
|
|
1151
|
+
|
|
1152
|
+
var _useToast = useToast(),
|
|
1153
|
+
removeToast = _useToast.removeToast;
|
|
1154
|
+
|
|
1155
|
+
var defaultClasses = 'w-full min-w-[250px] p-4 shadow flex justify-between items-center font-black rounded-md not:';
|
|
1156
|
+
var statusClasses = status === 'success' && 'bg-teal text-white' || status === 'error' && 'bg-red-500 text-white' || status === 'warning' && 'bg-yellow-400 text-white' || 'bg-white text-asphalt';
|
|
1157
|
+
var classes = defaultClasses + " " + statusClasses;
|
|
1158
|
+
|
|
1159
|
+
function handleClick() {
|
|
1160
|
+
removeToast(_id);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
return React__default.createElement(react.Transition, {
|
|
1164
|
+
show: true,
|
|
1165
|
+
appear: true,
|
|
1166
|
+
enter: "transition-all duration-300",
|
|
1167
|
+
enterFrom: "opacity-0 translate-y-4",
|
|
1168
|
+
enterTo: "opacity-100 translate-y-0",
|
|
1169
|
+
leave: "transition-all duration-300",
|
|
1170
|
+
leaveFrom: "opacity-100 translate-y-0",
|
|
1171
|
+
leaveTo: "opacity-0 translate-y-2"
|
|
1172
|
+
}, React__default.createElement("div", {
|
|
1173
|
+
className: classes
|
|
1174
|
+
}, React__default.createElement("p", null, message), React__default.createElement("button", {
|
|
1175
|
+
className: "",
|
|
1176
|
+
onClick: handleClick,
|
|
1177
|
+
title: "Close message"
|
|
1178
|
+
}, React__default.createElement("svg", {
|
|
1179
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1180
|
+
fill: "none",
|
|
1181
|
+
viewBox: "0 0 24 24",
|
|
1182
|
+
stroke: "currentColor",
|
|
1183
|
+
className: "h-6 w-6"
|
|
1184
|
+
}, React__default.createElement("path", {
|
|
1185
|
+
strokeLinecap: "round",
|
|
1186
|
+
strokeLinejoin: "round",
|
|
1187
|
+
strokeWidth: "2",
|
|
1188
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
1189
|
+
})))));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
function Toasts() {
|
|
1193
|
+
var _useToast = useToast(),
|
|
1194
|
+
toasts = _useToast.toasts;
|
|
1195
|
+
|
|
1196
|
+
return React__default.createElement("div", {
|
|
1197
|
+
className: "fixed bottom-4 right-4 z-[110] flex flex-col gap-6"
|
|
1198
|
+
}, toasts.map(function (toast) {
|
|
1199
|
+
return React__default.createElement(ToastItem, Object.assign({}, toast, {
|
|
1200
|
+
key: toast._id
|
|
1201
|
+
}));
|
|
1202
|
+
}));
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
function Modal(_ref) {
|
|
1206
|
+
var children = _ref.children,
|
|
1207
|
+
_ref$isActive = _ref.isActive,
|
|
1208
|
+
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
1209
|
+
onClose = _ref.onClose,
|
|
1210
|
+
title = _ref.title;
|
|
1211
|
+
return React__default.createElement(react.Transition.Root, {
|
|
1212
|
+
show: isActive,
|
|
1213
|
+
as: React.Fragment
|
|
1214
|
+
}, React__default.createElement(react.Dialog, {
|
|
1215
|
+
as: "div",
|
|
1216
|
+
className: "fixed z-[110] inset-0 overflow-y-auto",
|
|
1217
|
+
onClose: onClose
|
|
1218
|
+
}, React__default.createElement("div", {
|
|
1219
|
+
className: "flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"
|
|
1220
|
+
}, React__default.createElement(react.Transition.Child, {
|
|
1221
|
+
as: React.Fragment,
|
|
1222
|
+
enter: "ease-out duration-300",
|
|
1223
|
+
enterFrom: "opacity-0",
|
|
1224
|
+
enterTo: "opacity-100",
|
|
1225
|
+
leave: "ease-in duration-200",
|
|
1226
|
+
leaveFrom: "opacity-100",
|
|
1227
|
+
leaveTo: "opacity-0"
|
|
1228
|
+
}, React__default.createElement(react.Dialog.Overlay, {
|
|
1229
|
+
className: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
|
|
1230
|
+
})), React__default.createElement(react.Transition.Child, {
|
|
1231
|
+
as: React.Fragment,
|
|
1232
|
+
enter: "ease-out duration-300",
|
|
1233
|
+
enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
1234
|
+
enterTo: "opacity-100 translate-y-0 sm:scale-100",
|
|
1235
|
+
leave: "ease-in duration-200",
|
|
1236
|
+
leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
|
|
1237
|
+
leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
1238
|
+
}, React__default.createElement("div", {
|
|
1239
|
+
className: "w-full align-start inline-block bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-3xl sm:p-6"
|
|
1240
|
+
}, React__default.createElement("div", {
|
|
1241
|
+
className: "flex gap-4 mb-4 text-asphalt " + (title ? 'border-b-2 border-asphalt pb-4' : '')
|
|
1242
|
+
}, title && React__default.createElement("h3", {
|
|
1243
|
+
className: "font-black text-lg"
|
|
1244
|
+
}, title), React__default.createElement("button", {
|
|
1245
|
+
type: "button",
|
|
1246
|
+
onClick: onClose,
|
|
1247
|
+
className: "ml-auto transition-all hover:opacity-50"
|
|
1248
|
+
}, React__default.createElement("svg", {
|
|
1249
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1250
|
+
className: "h-6 w-6",
|
|
1251
|
+
fill: "none",
|
|
1252
|
+
viewBox: "0 0 24 24",
|
|
1253
|
+
stroke: "currentColor",
|
|
1254
|
+
strokeWidth: 2
|
|
1255
|
+
}, React__default.createElement("path", {
|
|
1256
|
+
strokeLinecap: "round",
|
|
1257
|
+
strokeLinejoin: "round",
|
|
1258
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
1259
|
+
})))), React__default.createElement("div", null, children))))));
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
function Table(_ref) {
|
|
1263
|
+
var children = _ref.children;
|
|
1264
|
+
return React__default.createElement("div", {
|
|
1265
|
+
className: "-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8 text-sm"
|
|
1266
|
+
}, React__default.createElement("div", {
|
|
1267
|
+
className: "inline-block min-w-full py-2 align-middle md:px-6 lg:px-8"
|
|
1268
|
+
}, React__default.createElement("div", {
|
|
1269
|
+
className: "overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg"
|
|
1270
|
+
}, React__default.createElement("table", {
|
|
1271
|
+
className: "min-w-full divide-y divide-gray-300"
|
|
1272
|
+
}, children))));
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function TableActions(_ref) {
|
|
1276
|
+
var children = _ref.children,
|
|
1277
|
+
_ref$className = _ref.className,
|
|
1278
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1279
|
+
return React__default.createElement("div", {
|
|
1280
|
+
className: className + " flex gap-4 justify-end items-center"
|
|
1281
|
+
}, children);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function TableBody(_ref) {
|
|
1285
|
+
var children = _ref.children,
|
|
1286
|
+
_ref$className = _ref.className,
|
|
1287
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1288
|
+
return React__default.createElement("tbody", {
|
|
1289
|
+
className: (className != null ? className : '') + " divide-y divide-gray-200 bg-white"
|
|
1290
|
+
}, children);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
function TableCell(_ref) {
|
|
1294
|
+
var children = _ref.children,
|
|
1295
|
+
_ref$className = _ref.className,
|
|
1296
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1297
|
+
return React__default.createElement("td", {
|
|
1298
|
+
className: className + " px-3 py-3 text-sm text-gray-500"
|
|
1299
|
+
}, children);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
function TableHead(_ref) {
|
|
1303
|
+
var children = _ref.children,
|
|
1304
|
+
_ref$className = _ref.className,
|
|
1305
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1306
|
+
return React__default.createElement("thead", {
|
|
1307
|
+
className: className + " px-3 py-4 text-sm text-white bg-gray-600"
|
|
1308
|
+
}, children);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function TableHeader(_ref) {
|
|
1312
|
+
var children = _ref.children,
|
|
1313
|
+
_ref$className = _ref.className,
|
|
1314
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1315
|
+
sort = _ref.sort,
|
|
1316
|
+
_ref$textAlign = _ref.textAlign,
|
|
1317
|
+
textAlign = _ref$textAlign === void 0 ? 'left' : _ref$textAlign;
|
|
1318
|
+
|
|
1319
|
+
var _React$useState = React__default.useState(''),
|
|
1320
|
+
sortLink = _React$useState[0],
|
|
1321
|
+
setSortLink = _React$useState[1];
|
|
1322
|
+
|
|
1323
|
+
React__default.useEffect(function () {
|
|
1324
|
+
if (typeof window !== 'undefined' && sort) {
|
|
1325
|
+
var query = new URLSearchParams(window.location.search);
|
|
1326
|
+
var direction = 'asc';
|
|
1327
|
+
|
|
1328
|
+
if (query.get('sort')) {
|
|
1329
|
+
var _query$get;
|
|
1330
|
+
|
|
1331
|
+
// Choose the opposite direction for sorting
|
|
1332
|
+
direction = (_query$get = query.get('sort')) != null && _query$get.includes('asc') ? 'desc' : 'asc';
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
query.set('sort', sort + " " + direction);
|
|
1336
|
+
setSortLink("?" + query.toString());
|
|
1337
|
+
}
|
|
1338
|
+
}, []);
|
|
1339
|
+
var textAlignClass = textAlign === 'center' && 'text-center justify-center' || textAlign === 'right' && 'text-right justify-end' || 'text-left justify-between';
|
|
1340
|
+
return React__default.createElement("th", {
|
|
1341
|
+
className: className + " py-3.5 px-3 text-sm font-semibold text-left"
|
|
1342
|
+
}, React__default.createElement("div", {
|
|
1343
|
+
className: "flex items-center gap-3 " + textAlignClass
|
|
1344
|
+
}, children, sort && React__default.createElement(inertiaReact.Link, {
|
|
1345
|
+
href: sortLink
|
|
1346
|
+
}, React__default.createElement("svg", {
|
|
1347
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1348
|
+
className: "h-5 w-5",
|
|
1349
|
+
fill: "none",
|
|
1350
|
+
viewBox: "0 0 24 24",
|
|
1351
|
+
stroke: "currentColor",
|
|
1352
|
+
strokeWidth: "2"
|
|
1353
|
+
}, React__default.createElement("path", {
|
|
1354
|
+
strokeLinecap: "round",
|
|
1355
|
+
strokeLinejoin: "round",
|
|
1356
|
+
d: "M8 9l4-4 4 4m0 6l-4 4-4-4"
|
|
1357
|
+
})))));
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
function TableRow(_ref) {
|
|
1361
|
+
var children = _ref.children,
|
|
1362
|
+
_ref$className = _ref.className,
|
|
1363
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1364
|
+
_ref$onClick = _ref.onClick,
|
|
1365
|
+
onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick;
|
|
1366
|
+
var bgClass = className.includes('bg') ? '' : 'bg-white even:bg-gray-50';
|
|
1367
|
+
return React__default.createElement("tr", {
|
|
1368
|
+
className: className + " " + bgClass + " hover:bg-gray-100",
|
|
1369
|
+
onClick: onClick
|
|
1370
|
+
}, children);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
function DateOfBirthField(_ref) {
|
|
1374
|
+
var value = _ref.value,
|
|
1375
|
+
onChange = _ref.onChange;
|
|
1376
|
+
|
|
1377
|
+
var _React$useState = React__default.useState({
|
|
1378
|
+
day: (value == null ? void 0 : value.split("-")[2]) || '',
|
|
1379
|
+
month: (value == null ? void 0 : value.split("-")[1]) || '',
|
|
1380
|
+
year: (value == null ? void 0 : value.split("-")[0]) || ''
|
|
1381
|
+
}),
|
|
1382
|
+
dateOfBirth = _React$useState[0],
|
|
1383
|
+
setDateOfBirth = _React$useState[1];
|
|
1384
|
+
|
|
1385
|
+
var dayOptions = [].concat(Array.from(Array(31).keys())).map(function (value) {
|
|
1386
|
+
return lodashEs.padStart("" + (value + 1), 2, '0');
|
|
1387
|
+
});
|
|
1388
|
+
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
1389
|
+
var monthOptions = [].concat(Array.from(Array(12).keys())).map(function (value) {
|
|
1390
|
+
return {
|
|
1391
|
+
title: months[value],
|
|
1392
|
+
value: lodashEs.padStart("" + (value + 1), 2, '0')
|
|
1393
|
+
};
|
|
1394
|
+
});
|
|
1395
|
+
var thisYear = new Date().getFullYear();
|
|
1396
|
+
var yearOptions = [].concat(Array.from(Array(100).keys())).map(function (value) {
|
|
1397
|
+
return (thisYear - value - 16).toString();
|
|
1398
|
+
});
|
|
1399
|
+
|
|
1400
|
+
function handleSelectChange(e) {
|
|
1401
|
+
var _extends2;
|
|
1402
|
+
|
|
1403
|
+
var _e$currentTarget = e.currentTarget,
|
|
1404
|
+
name = _e$currentTarget.name,
|
|
1405
|
+
value = _e$currentTarget.value;
|
|
1406
|
+
|
|
1407
|
+
var newDob = _extends({}, dateOfBirth, (_extends2 = {}, _extends2[name] = value, _extends2)); // Set local state
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
setDateOfBirth(newDob); // Format the date for the API
|
|
1411
|
+
|
|
1412
|
+
var formattedDate = newDob.year + "-" + newDob.month + "-" + newDob.day; // Call the upstream prop if we have all of the date parts
|
|
1413
|
+
|
|
1414
|
+
if (Object.values(newDob).every(function (value) {
|
|
1415
|
+
return value !== '';
|
|
1416
|
+
})) {
|
|
1417
|
+
onChange(formattedDate);
|
|
1418
|
+
} else {
|
|
1419
|
+
// Otherwise, clear the value
|
|
1420
|
+
onChange('');
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
return React__default.createElement("label", {
|
|
1425
|
+
className: "w-full"
|
|
1426
|
+
}, React__default.createElement("span", {
|
|
1427
|
+
className: "relative mr-auto"
|
|
1428
|
+
}, React__default.createElement("span", null, "Date of birth")), React__default.createElement("span", {
|
|
1429
|
+
className: "flex space-x-4 border border-gray-300 rounded-lg mt-1 bg-white"
|
|
1430
|
+
}, React__default.createElement("select", {
|
|
1431
|
+
name: "day",
|
|
1432
|
+
value: dateOfBirth.day,
|
|
1433
|
+
className: "flex-grow focus:outline-none border-0",
|
|
1434
|
+
onChange: handleSelectChange,
|
|
1435
|
+
required: true
|
|
1436
|
+
}, React__default.createElement("option", {
|
|
1437
|
+
value: ""
|
|
1438
|
+
}, "Day"), dayOptions.map(function (option) {
|
|
1439
|
+
return React__default.createElement("option", {
|
|
1440
|
+
key: option,
|
|
1441
|
+
value: option
|
|
1442
|
+
}, option);
|
|
1443
|
+
})), React__default.createElement("select", {
|
|
1444
|
+
name: "month",
|
|
1445
|
+
value: dateOfBirth.month,
|
|
1446
|
+
className: "flex-grow focus:outline-none border-0",
|
|
1447
|
+
onChange: handleSelectChange,
|
|
1448
|
+
required: true
|
|
1449
|
+
}, React__default.createElement("option", {
|
|
1450
|
+
value: ""
|
|
1451
|
+
}, "Month"), monthOptions.map(function (option) {
|
|
1452
|
+
return React__default.createElement("option", {
|
|
1453
|
+
key: option.value,
|
|
1454
|
+
value: option.value
|
|
1455
|
+
}, option.title);
|
|
1456
|
+
})), React__default.createElement("select", {
|
|
1457
|
+
name: "year",
|
|
1458
|
+
value: dateOfBirth.year,
|
|
1459
|
+
className: "flex-grow focus:outline-none border-0",
|
|
1460
|
+
onChange: handleSelectChange,
|
|
1461
|
+
required: true
|
|
1462
|
+
}, React__default.createElement("option", {
|
|
1463
|
+
value: ""
|
|
1464
|
+
}, "Year"), yearOptions.map(function (option) {
|
|
1465
|
+
return React__default.createElement("option", {
|
|
1466
|
+
key: option,
|
|
1467
|
+
value: option
|
|
1468
|
+
}, option);
|
|
1469
|
+
}))));
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function MoneyField(_ref) {
|
|
1473
|
+
var _ref$value = _ref.value,
|
|
1474
|
+
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
1475
|
+
onChange = _ref.onChange,
|
|
1476
|
+
_ref$name = _ref.name,
|
|
1477
|
+
name = _ref$name === void 0 ? 'value' : _ref$name,
|
|
1478
|
+
_ref$id = _ref.id,
|
|
1479
|
+
id = _ref$id === void 0 ? 'value' : _ref$id,
|
|
1480
|
+
_ref$className = _ref.className,
|
|
1481
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1482
|
+
_ref$required = _ref.required,
|
|
1483
|
+
required = _ref$required === void 0 ? false : _ref$required;
|
|
1484
|
+
|
|
1485
|
+
function handleChange(e) {
|
|
1486
|
+
var newValue = 0;
|
|
1487
|
+
|
|
1488
|
+
if (e.currentTarget.value) {
|
|
1489
|
+
newValue = formatNumber(e.currentTarget.value);
|
|
1490
|
+
|
|
1491
|
+
if (isNaN(newValue)) {
|
|
1492
|
+
newValue = 0;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
onChange(newValue);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
var displayValue = formatMoney(value, 0);
|
|
1500
|
+
return React__default.createElement("div", {
|
|
1501
|
+
className: className + " flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-teal focus-within:outline-none focus-within:ring focus-within:ring-teal focus-within:ring-opacity-50"
|
|
1502
|
+
}, React__default.createElement("span", {
|
|
1503
|
+
className: "font-bold"
|
|
1504
|
+
}, "$"), React__default.createElement("input", {
|
|
1505
|
+
type: "text",
|
|
1506
|
+
name: name,
|
|
1507
|
+
id: id,
|
|
1508
|
+
value: displayValue,
|
|
1509
|
+
onChange: handleChange,
|
|
1510
|
+
className: "w-full !focus:outline-none !focus:ring-0 !focus:ring-transparent !focus:ring-opacity-0 !ring-0 !border-0 !transition-none",
|
|
1511
|
+
required: required
|
|
1512
|
+
}));
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
var conditionOptions = ['POOR', 'FAIR', 'AVERAGE', 'GOOD', 'VERY_GOOD', 'AS_NEW', 'NEW'];
|
|
1516
|
+
function RegistrationSearchField(_ref) {
|
|
1517
|
+
var _ref$initialRegistrat = _ref.initialRegistrationValue,
|
|
1518
|
+
initialRegistrationValue = _ref$initialRegistrat === void 0 ? '' : _ref$initialRegistrat,
|
|
1519
|
+
onVehicleDataFound = _ref.onVehicleDataFound,
|
|
1520
|
+
_ref$apiUrl = _ref.apiUrl,
|
|
1521
|
+
apiUrl = _ref$apiUrl === void 0 ? "/api/rego-search" : _ref$apiUrl,
|
|
1522
|
+
_ref$showOdometerRead = _ref.showOdometerReadingField,
|
|
1523
|
+
showOdometerReadingField = _ref$showOdometerRead === void 0 ? false : _ref$showOdometerRead,
|
|
1524
|
+
_ref$showConditionFie = _ref.showConditionField,
|
|
1525
|
+
showConditionField = _ref$showConditionFie === void 0 ? false : _ref$showConditionFie,
|
|
1526
|
+
onChange = _ref.onChange;
|
|
1527
|
+
|
|
1528
|
+
var _React$useState = React__default.useState(initialRegistrationValue),
|
|
1529
|
+
rego = _React$useState[0],
|
|
1530
|
+
setRego = _React$useState[1];
|
|
1531
|
+
|
|
1532
|
+
var _React$useState2 = React__default.useState(''),
|
|
1533
|
+
odo = _React$useState2[0],
|
|
1534
|
+
setOdo = _React$useState2[1];
|
|
1535
|
+
|
|
1536
|
+
var _React$useState3 = React__default.useState('GOOD'),
|
|
1537
|
+
condition = _React$useState3[0],
|
|
1538
|
+
setCondition = _React$useState3[1];
|
|
1539
|
+
|
|
1540
|
+
var _React$useState4 = React__default.useState('idle'),
|
|
1541
|
+
status = _React$useState4[0],
|
|
1542
|
+
setStatus = _React$useState4[1];
|
|
1543
|
+
|
|
1544
|
+
var _useToast = useToast(),
|
|
1545
|
+
addToast = _useToast.addToast;
|
|
1546
|
+
|
|
1547
|
+
function handleChange(e) {
|
|
1548
|
+
if (e.currentTarget.name === 'registration_search') {
|
|
1549
|
+
var _e$currentTarget$valu;
|
|
1550
|
+
|
|
1551
|
+
setRego(((_e$currentTarget$valu = e.currentTarget.value) == null ? void 0 : _e$currentTarget$valu.toUpperCase()) || '');
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
if (e.currentTarget.name === 'odo_search') {
|
|
1555
|
+
setOdo(e.currentTarget.value);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
if (e.currentTarget.name === 'condition_search') {
|
|
1559
|
+
setCondition(e.currentTarget.value);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
if (onChange) {
|
|
1563
|
+
onChange({
|
|
1564
|
+
registration: e.currentTarget.value.toUpperCase()
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
function handleKeydown(e) {
|
|
1570
|
+
if (e.key === 'Enter') {
|
|
1571
|
+
handleSearch();
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function handleSearch() {
|
|
1576
|
+
return _handleSearch.apply(this, arguments);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
function _handleSearch() {
|
|
1580
|
+
_handleSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1581
|
+
var payload, query, res, _yield$res$json, data, ok, vehicleData, make, model, year, weight, vehicleType;
|
|
1582
|
+
|
|
1583
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1584
|
+
while (1) {
|
|
1585
|
+
switch (_context.prev = _context.next) {
|
|
1586
|
+
case 0:
|
|
1587
|
+
setStatus('processing');
|
|
1588
|
+
payload = {
|
|
1589
|
+
registration: rego,
|
|
1590
|
+
odometerReading: odo,
|
|
1591
|
+
condition: condition
|
|
1592
|
+
}; // Turn the payload in to a query string
|
|
1593
|
+
// @ts-ignore
|
|
1594
|
+
|
|
1595
|
+
query = new URLSearchParams(payload).toString();
|
|
1596
|
+
_context.next = 5;
|
|
1597
|
+
return fetch(apiUrl + "?" + query, {
|
|
1598
|
+
headers: {
|
|
1599
|
+
'Content-Type': 'application/json'
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
case 5:
|
|
1604
|
+
res = _context.sent;
|
|
1605
|
+
|
|
1606
|
+
if (res.ok) {
|
|
1607
|
+
_context.next = 10;
|
|
1608
|
+
break;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
addToast({
|
|
1612
|
+
message: "There was an error with the provided registration.",
|
|
1613
|
+
status: 'error',
|
|
1614
|
+
timeout: 3000
|
|
1615
|
+
});
|
|
1616
|
+
setStatus('error');
|
|
1617
|
+
return _context.abrupt("return");
|
|
1618
|
+
|
|
1619
|
+
case 10:
|
|
1620
|
+
_context.next = 12;
|
|
1621
|
+
return res.json();
|
|
1622
|
+
|
|
1623
|
+
case 12:
|
|
1624
|
+
_yield$res$json = _context.sent;
|
|
1625
|
+
data = _yield$res$json.data;
|
|
1626
|
+
ok = _yield$res$json.ok;
|
|
1627
|
+
|
|
1628
|
+
if (!(!ok || !data)) {
|
|
1629
|
+
_context.next = 19;
|
|
1630
|
+
break;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
addToast({
|
|
1634
|
+
message: "Failed to find vehicle, please complete manually.",
|
|
1635
|
+
status: 'error',
|
|
1636
|
+
timeout: 3000
|
|
1637
|
+
});
|
|
1638
|
+
setStatus('error');
|
|
1639
|
+
return _context.abrupt("return");
|
|
1640
|
+
|
|
1641
|
+
case 19:
|
|
1642
|
+
vehicleData = data.data.vehicle;
|
|
1643
|
+
make = vehicleData.make;
|
|
1644
|
+
model = vehicleData.model;
|
|
1645
|
+
year = vehicleData['year-of-manufacture'];
|
|
1646
|
+
weight = vehicleData['gross-vehicle-mass'] ? parseInt(vehicleData['gross-vehicle-mass'].replaceAll(',', '')) : 0;
|
|
1647
|
+
vehicleType = vehicleData['vehicle-type'];
|
|
1648
|
+
|
|
1649
|
+
if (!make || !model || !year || !vehicleType) {
|
|
1650
|
+
addToast({
|
|
1651
|
+
message: "We couldn't find all of your data, please complete manually.",
|
|
1652
|
+
status: 'error',
|
|
1653
|
+
timeout: 3000
|
|
1654
|
+
});
|
|
1655
|
+
setStatus('error');
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
onVehicleDataFound(_extends({}, data, {
|
|
1659
|
+
make: make || '',
|
|
1660
|
+
model: model || '',
|
|
1661
|
+
year: year || '',
|
|
1662
|
+
vehicle_type: vehicleType ? sanitiseVehicleType(vehicleType) : 'car',
|
|
1663
|
+
is_heavy: weight && weight > 3500 || false
|
|
1664
|
+
}));
|
|
1665
|
+
setStatus('success');
|
|
1666
|
+
|
|
1667
|
+
case 28:
|
|
1668
|
+
case "end":
|
|
1669
|
+
return _context.stop();
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}, _callee);
|
|
1673
|
+
}));
|
|
1674
|
+
return _handleSearch.apply(this, arguments);
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
return React__default.createElement("div", {
|
|
1678
|
+
className: "w-full flex flex-col"
|
|
1679
|
+
}, React__default.createElement("div", {
|
|
1680
|
+
className: "w-full flex flex-wrap gap-3 bg-gray-100 rounded-md p-3"
|
|
1681
|
+
}, showOdometerReadingField || showConditionField && React__default.createElement("div", {
|
|
1682
|
+
className: "w-full grid grid-cols-2 gap-3"
|
|
1683
|
+
}, showOdometerReadingField && React__default.createElement("label", null, "Approx. km travelled", React__default.createElement("input", {
|
|
1684
|
+
onKeyDown: handleKeydown,
|
|
1685
|
+
type: "number",
|
|
1686
|
+
name: "odo_search",
|
|
1687
|
+
id: "odo_search",
|
|
1688
|
+
value: odo,
|
|
1689
|
+
onChange: handleChange,
|
|
1690
|
+
className: "transition-all " + (status === 'processing' ? 'pointer-events-none opacity-50' : ''),
|
|
1691
|
+
disabled: status === 'processing'
|
|
1692
|
+
})), showConditionField && React__default.createElement("label", null, "Vehicle condition", React__default.createElement("select", {
|
|
1693
|
+
name: "condition_search",
|
|
1694
|
+
id: "condition_search",
|
|
1695
|
+
value: condition,
|
|
1696
|
+
onChange: handleChange,
|
|
1697
|
+
className: "transition-all " + (status === 'processing' ? 'pointer-events-none opacity-50' : ''),
|
|
1698
|
+
disabled: status === 'processing'
|
|
1699
|
+
}, conditionOptions.map(function (conditionOption) {
|
|
1700
|
+
return React__default.createElement("option", {
|
|
1701
|
+
key: conditionOption
|
|
1702
|
+
}, conditionOption);
|
|
1703
|
+
})))), React__default.createElement("input", {
|
|
1704
|
+
onKeyDown: handleKeydown,
|
|
1705
|
+
placeholder: "Search for your rego",
|
|
1706
|
+
type: "text",
|
|
1707
|
+
name: "registration_search",
|
|
1708
|
+
id: "registration_search",
|
|
1709
|
+
value: rego,
|
|
1710
|
+
onChange: handleChange,
|
|
1711
|
+
className: "flex-grow transition-all " + (status === 'processing' ? 'pointer-events-none opacity-50' : ''),
|
|
1712
|
+
disabled: status === 'processing'
|
|
1713
|
+
}), React__default.createElement("button", {
|
|
1714
|
+
title: "Search",
|
|
1715
|
+
type: "button",
|
|
1716
|
+
onClick: handleSearch,
|
|
1717
|
+
disabled: status === 'processing',
|
|
1718
|
+
className: "bg-teal px-4 py-3 rounded-md transition-all"
|
|
1719
|
+
}, React__default.createElement("span", {
|
|
1720
|
+
className: "sr-only"
|
|
1721
|
+
}, "Search"), React__default.createElement("svg", {
|
|
1722
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1723
|
+
className: "h-5 w-5 text-white",
|
|
1724
|
+
fill: "none",
|
|
1725
|
+
viewBox: "0 0 24 24",
|
|
1726
|
+
stroke: "currentColor",
|
|
1727
|
+
strokeWidth: "2"
|
|
1728
|
+
}, React__default.createElement("path", {
|
|
1729
|
+
strokeLinecap: "round",
|
|
1730
|
+
strokeLinejoin: "round",
|
|
1731
|
+
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
1732
|
+
})))));
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
function FormTester(_ref) {
|
|
1736
|
+
var _ref$populatePurchase = _ref.populatePurchaseOptions,
|
|
1737
|
+
populatePurchaseOptions = _ref$populatePurchase === void 0 ? false : _ref$populatePurchase;
|
|
1738
|
+
|
|
1739
|
+
var _useQuoteRequestForm = useQuoteRequestForm(),
|
|
1740
|
+
form = _useQuoteRequestForm.form;
|
|
1741
|
+
|
|
1742
|
+
var _React$useState = React__default.useState([]),
|
|
1743
|
+
keys = _React$useState[0],
|
|
1744
|
+
setKeys = _React$useState[1];
|
|
1745
|
+
|
|
1746
|
+
var _React$useState2 = React__default.useState(false),
|
|
1747
|
+
isDev = _React$useState2[0],
|
|
1748
|
+
setDev = _React$useState2[1];
|
|
1749
|
+
|
|
1750
|
+
function handlePopulate() {
|
|
1751
|
+
form == null ? void 0 : form.setData(function (prevData) {
|
|
1752
|
+
return _extends({}, prevData, {
|
|
1753
|
+
first_name: 'TEST',
|
|
1754
|
+
last_name: 'TEST',
|
|
1755
|
+
email: 'dev@sual.co.nz',
|
|
1756
|
+
phone: '021 234 5678',
|
|
1757
|
+
mobile: '021 234 5678',
|
|
1758
|
+
dob: '1990-01-01',
|
|
1759
|
+
licence: 'Other',
|
|
1760
|
+
licence_other: 'Test',
|
|
1761
|
+
club_id: 50,
|
|
1762
|
+
club_membership_number: '12345',
|
|
1763
|
+
street_address: {
|
|
1764
|
+
address: '123 Street Name',
|
|
1765
|
+
unit: 'Level 1',
|
|
1766
|
+
suburb: 'Suburb',
|
|
1767
|
+
city: 'Auckland',
|
|
1768
|
+
post_code: '1234'
|
|
1769
|
+
},
|
|
1770
|
+
promo_code: 'TEST',
|
|
1771
|
+
declaration: {
|
|
1772
|
+
had_incident: true,
|
|
1773
|
+
incidents: [{
|
|
1774
|
+
description: 'Lorem ipsum dolor sit amet.',
|
|
1775
|
+
month: 'January',
|
|
1776
|
+
year: '2020'
|
|
1777
|
+
}],
|
|
1778
|
+
has_demerit_points: true,
|
|
1779
|
+
demerit_points: '1-24',
|
|
1780
|
+
has_lost_licence: true,
|
|
1781
|
+
lost_licence_details: 'Lorem ipsum dolor sit amet.',
|
|
1782
|
+
was_refused_insurance: true,
|
|
1783
|
+
refused_insurance_details: 'Lorem ipsum dolor sit amet.',
|
|
1784
|
+
has_criminal_conviction: true,
|
|
1785
|
+
criminal_conviction_details: 'Lorem ipsum dolor sit amet.',
|
|
1786
|
+
has_vehicle_modifications: true,
|
|
1787
|
+
vehicle_modifications_details: 'Lorem ipsum dolor sit amet.',
|
|
1788
|
+
has_previous_insurer: true,
|
|
1789
|
+
previous_insurer_details: 'AA',
|
|
1790
|
+
previous_insurer_expires_at: '2020-01-01',
|
|
1791
|
+
additional_details: 'I am a robot, beep boop. Please ignore this submission.'
|
|
1792
|
+
},
|
|
1793
|
+
vehicles: [{
|
|
1794
|
+
make: 'Tesla',
|
|
1795
|
+
model: 'Cybertruck',
|
|
1796
|
+
year: '2023',
|
|
1797
|
+
registration: 'ELMUSK',
|
|
1798
|
+
vehicle_type: 'car',
|
|
1799
|
+
product: 'star-enthusiast-prestige-everyday-plus',
|
|
1800
|
+
value: 100000,
|
|
1801
|
+
is_heavy: false,
|
|
1802
|
+
usage: 'Childrens car',
|
|
1803
|
+
storage_location: 'Carport',
|
|
1804
|
+
has_financially_interested_party: true,
|
|
1805
|
+
financially_interested_party_detail: 'MTA',
|
|
1806
|
+
owned_duration: 'Less than 12 months',
|
|
1807
|
+
drivers: [{
|
|
1808
|
+
first_name: 'X Æ',
|
|
1809
|
+
last_name: 'A-12',
|
|
1810
|
+
dob: '2020-05-04',
|
|
1811
|
+
licence: 'Other',
|
|
1812
|
+
licence_other: 'None',
|
|
1813
|
+
relationship: 'Child'
|
|
1814
|
+
}]
|
|
1815
|
+
}],
|
|
1816
|
+
purchase_options: populatePurchaseOptions ? [{
|
|
1817
|
+
premium_type: 'annual',
|
|
1818
|
+
level_of_insurance_id: 12,
|
|
1819
|
+
authorised_drivers: 'TEST',
|
|
1820
|
+
excess_details: 'TEST',
|
|
1821
|
+
terms: 'TEST',
|
|
1822
|
+
description: 'This is a test purchase option',
|
|
1823
|
+
premium: 100000,
|
|
1824
|
+
monthly_premium: 8500,
|
|
1825
|
+
show_monthly: true,
|
|
1826
|
+
fsl: 100,
|
|
1827
|
+
benefits: [{
|
|
1828
|
+
id: 2
|
|
1829
|
+
}, {
|
|
1830
|
+
id: 8
|
|
1831
|
+
}],
|
|
1832
|
+
benefit_template_id: 3,
|
|
1833
|
+
sort_order: 1,
|
|
1834
|
+
enhancements: [{
|
|
1835
|
+
name: 'Test enhancement',
|
|
1836
|
+
premium: 2500,
|
|
1837
|
+
disable_rounding: false,
|
|
1838
|
+
description: 'Test enhancement',
|
|
1839
|
+
auto_select: true
|
|
1840
|
+
}, {
|
|
1841
|
+
name: 'Test enhancement',
|
|
1842
|
+
premium: 5000,
|
|
1843
|
+
disable_rounding: false,
|
|
1844
|
+
description: 'Test enhancement',
|
|
1845
|
+
auto_select: false
|
|
1846
|
+
}]
|
|
1847
|
+
}, {
|
|
1848
|
+
premium_type: 'total-due',
|
|
1849
|
+
level_of_insurance_id: 13,
|
|
1850
|
+
authorised_drivers: 'TEST',
|
|
1851
|
+
excess_details: 'TEST',
|
|
1852
|
+
terms: 'TEST',
|
|
1853
|
+
description: 'This is a test purchase option',
|
|
1854
|
+
premium: 100000,
|
|
1855
|
+
show_monthly: false,
|
|
1856
|
+
fsl: 100,
|
|
1857
|
+
benefits: [{
|
|
1858
|
+
id: 2
|
|
1859
|
+
}, {
|
|
1860
|
+
id: 8
|
|
1861
|
+
}],
|
|
1862
|
+
benefit_template_id: 3,
|
|
1863
|
+
sort_order: 2,
|
|
1864
|
+
enhancements: [{
|
|
1865
|
+
name: 'Test enhancement',
|
|
1866
|
+
premium: 2500,
|
|
1867
|
+
disable_rounding: false,
|
|
1868
|
+
description: 'Test enhancement',
|
|
1869
|
+
auto_select: true
|
|
1870
|
+
}, {
|
|
1871
|
+
name: 'Test enhancement',
|
|
1872
|
+
premium: 5000,
|
|
1873
|
+
disable_rounding: false,
|
|
1874
|
+
description: 'Test enhancement',
|
|
1875
|
+
auto_select: false
|
|
1876
|
+
}]
|
|
1877
|
+
}] : []
|
|
1878
|
+
});
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
function handleKeydown(e) {
|
|
1883
|
+
if (e.key === 'Escape') {
|
|
1884
|
+
return setKeys([]);
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
setKeys(function (prevKeys) {
|
|
1888
|
+
return [].concat(prevKeys, [e.key]);
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
React__default.useEffect(function () {
|
|
1893
|
+
// Detect when the user has typed the word "debug"
|
|
1894
|
+
if (keys.join('') === 'debug') {
|
|
1895
|
+
handlePopulate();
|
|
1896
|
+
}
|
|
1897
|
+
}, [keys]);
|
|
1898
|
+
React__default.useEffect(function () {
|
|
1899
|
+
if (typeof window !== 'undefined') {
|
|
1900
|
+
if (window.location.href.includes('dev') || window.location.href.includes('localhost') || window.location.href.includes('test') || window.location.href.includes('local')) {
|
|
1901
|
+
setDev(true);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
window.addEventListener('keydown', function (e) {
|
|
1905
|
+
return handleKeydown(e);
|
|
1906
|
+
});
|
|
1907
|
+
return function () {
|
|
1908
|
+
window.removeEventListener('keydown', function (e) {
|
|
1909
|
+
return handleKeydown(e);
|
|
1910
|
+
});
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
return;
|
|
1915
|
+
}, []);
|
|
1916
|
+
|
|
1917
|
+
if (isDev) {
|
|
1918
|
+
return React__default.createElement(Button, {
|
|
1919
|
+
onClick: handlePopulate,
|
|
1920
|
+
type: "button",
|
|
1921
|
+
status: "primary",
|
|
1922
|
+
className: "fixed bottom-4 right-4"
|
|
1923
|
+
}, "Populate data");
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
function ErrorList(_ref) {
|
|
1930
|
+
var _ref$heading = _ref.heading,
|
|
1931
|
+
heading = _ref$heading === void 0 ? 'There was an error with your submission.' : _ref$heading,
|
|
1932
|
+
_ref$errors = _ref.errors,
|
|
1933
|
+
errors = _ref$errors === void 0 ? {} : _ref$errors,
|
|
1934
|
+
_ref$renderKeys = _ref.renderKeys,
|
|
1935
|
+
renderKeys = _ref$renderKeys === void 0 ? false : _ref$renderKeys,
|
|
1936
|
+
_ref$className = _ref.className,
|
|
1937
|
+
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1938
|
+
|
|
1939
|
+
if (Object.values(errors).length === 0) {
|
|
1940
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
return React__default.createElement("aside", {
|
|
1944
|
+
className: className + " col-span-full"
|
|
1945
|
+
}, React__default.createElement(Card, {
|
|
1946
|
+
className: "border border-red-500 !bg-red-50"
|
|
1947
|
+
}, React__default.createElement("h2", {
|
|
1948
|
+
className: "font-black text-red-500 mb-2"
|
|
1949
|
+
}, heading), React__default.createElement("ul", {
|
|
1950
|
+
className: "space-y-2 list-disc ml-4"
|
|
1951
|
+
}, Object.entries(errors).map(function (_ref2) {
|
|
1952
|
+
var field = _ref2[0],
|
|
1953
|
+
message = _ref2[1];
|
|
1954
|
+
return React__default.createElement("li", {
|
|
1955
|
+
className: "font-bold text-red-500",
|
|
1956
|
+
key: field
|
|
1957
|
+
}, renderKeys && React__default.createElement("strong", null, field, ": "), message);
|
|
1958
|
+
}))));
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
exports.Button = Button;
|
|
1962
|
+
exports.Card = Card;
|
|
1963
|
+
exports.DateOfBirthField = DateOfBirthField;
|
|
1964
|
+
exports.ErrorList = ErrorList;
|
|
1965
|
+
exports.FormTester = FormTester;
|
|
1966
|
+
exports.Modal = Modal;
|
|
1967
|
+
exports.MoneyField = MoneyField;
|
|
1968
|
+
exports.Pagination = Pagination;
|
|
1969
|
+
exports.QuoteRequestFormContext = QuoteRequestFormContext;
|
|
1970
|
+
exports.QuoteRequestFormProvider = QuoteRequestFormProvider;
|
|
1971
|
+
exports.QuoteRequestOptionsProvider = QuoteRequestOptionsProvider;
|
|
1972
|
+
exports.RegistrationSearchField = RegistrationSearchField;
|
|
1973
|
+
exports.Table = Table;
|
|
1974
|
+
exports.TableActions = TableActions;
|
|
1975
|
+
exports.TableBody = TableBody;
|
|
1976
|
+
exports.TableCell = TableCell;
|
|
1977
|
+
exports.TableHead = TableHead;
|
|
1978
|
+
exports.TableHeader = TableHeader;
|
|
1979
|
+
exports.TableRow = TableRow;
|
|
1980
|
+
exports.ToastItem = ToastItem;
|
|
1981
|
+
exports.ToastProvider = ToastProvider;
|
|
1982
|
+
exports.Toasts = Toasts;
|
|
1983
|
+
exports.addGst = addGst;
|
|
1984
|
+
exports.autocomplete = autocomplete;
|
|
1985
|
+
exports.calculateAge = calculateAge;
|
|
1986
|
+
exports.formatDateForTable = formatDateForTable;
|
|
1987
|
+
exports.formatDateNice = formatDateNice;
|
|
1988
|
+
exports.formatMoney = formatMoney;
|
|
1989
|
+
exports.formatNumber = formatNumber;
|
|
1990
|
+
exports.getAddressData = getAddressData;
|
|
1991
|
+
exports.getGst = getGst;
|
|
1992
|
+
exports.gstCalc = gstCalc;
|
|
1993
|
+
exports.initialData = initialData;
|
|
1994
|
+
exports.round = round;
|
|
1995
|
+
exports.sanitiseQuoteRequestFormData = sanitiseQuoteRequestFormData;
|
|
1996
|
+
exports.sanitiseVehicleType = sanitiseVehicleType;
|
|
1997
|
+
exports.subtractGst = subtractGst;
|
|
1998
|
+
exports.useAuth = useAuth;
|
|
1999
|
+
exports.useClickOutside = useClickOutside;
|
|
2000
|
+
exports.useInertiaOptions = useInertiaOptions;
|
|
2001
|
+
exports.useLocalStorage = useLocalStorage;
|
|
2002
|
+
exports.useQuoteRequestForm = useQuoteRequestForm;
|
|
2003
|
+
exports.useQuoteRequestOptions = useQuoteRequestOptions;
|
|
2004
|
+
exports.useToast = useToast;
|
|
2005
|
+
//# sourceMappingURL=sdk.cjs.development.js.map
|