@star-insure/sdk 5.0.13 → 6.0.0
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/README.md +30 -1
- package/dist/index.d.ts +1810 -3
- package/dist/sdk.es.js +9436 -0
- package/dist/sdk.es.js.map +1 -0
- package/package.json +22 -45
- package/src/{tailwind-preset.js → tailwind-preset.cjs} +1 -0
- package/dist/components/common/Button.d.ts +0 -15
- package/dist/components/common/Card.d.ts +0 -7
- package/dist/components/common/Modal.d.ts +0 -11
- package/dist/components/common/Pagination.d.ts +0 -10
- package/dist/components/common/SimplePagination.d.ts +0 -10
- package/dist/components/common/ToastItem.d.ts +0 -3
- package/dist/components/common/Toasts.d.ts +0 -2
- package/dist/components/common/index.d.ts +0 -8
- package/dist/components/filter/Action.d.ts +0 -3
- package/dist/components/filter/Back.d.ts +0 -5
- package/dist/components/filter/Dropdown.d.ts +0 -9
- package/dist/components/filter/FilterItem.d.ts +0 -6
- package/dist/components/filter/FilterOptions.d.ts +0 -5
- package/dist/components/filter/PageHeader.d.ts +0 -21
- package/dist/components/filter/SearchBar.d.ts +0 -10
- package/dist/components/filter/index.d.ts +0 -1
- package/dist/components/forms/DateOfBirthField.d.ts +0 -12
- package/dist/components/forms/ErrorList.d.ts +0 -10
- package/dist/components/forms/FormTester.d.ts +0 -6
- package/dist/components/forms/MoneyField.d.ts +0 -11
- package/dist/components/forms/RegistrationSearchField.d.ts +0 -29
- package/dist/components/forms/index.d.ts +0 -6
- package/dist/components/index.d.ts +0 -4
- package/dist/components/tables/Table.d.ts +0 -6
- package/dist/components/tables/TableActions.d.ts +0 -7
- package/dist/components/tables/TableBody.d.ts +0 -7
- package/dist/components/tables/TableCell.d.ts +0 -8
- package/dist/components/tables/TableHead.d.ts +0 -7
- package/dist/components/tables/TableHeader.d.ts +0 -10
- package/dist/components/tables/TableRow.d.ts +0 -8
- package/dist/components/tables/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/lib/addressFinder.d.ts +0 -54
- package/dist/lib/auth.d.ts +0 -2
- package/dist/lib/calculateAge.d.ts +0 -4
- package/dist/lib/calculatePricing.d.ts +0 -19
- package/dist/lib/clickOutside.d.ts +0 -1
- package/dist/lib/dates.d.ts +0 -20
- package/dist/lib/fetch.d.ts +0 -20
- package/dist/lib/index.d.ts +0 -14
- package/dist/lib/inertiaOptions.d.ts +0 -6
- package/dist/lib/localStorage.d.ts +0 -1
- package/dist/lib/money.d.ts +0 -32
- package/dist/lib/page.d.ts +0 -19
- package/dist/lib/quoteRequestForm.d.ts +0 -21
- package/dist/lib/quoteRequestOptions.d.ts +0 -11
- package/dist/lib/toast.d.ts +0 -10
- package/dist/lib/vehicles.d.ts +0 -2
- package/dist/sdk.cjs.development.js +0 -3398
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -3339
- package/dist/sdk.esm.js.map +0 -1
- package/dist/types/api/auth.d.ts +0 -35
- package/dist/types/api/enums.d.ts +0 -4
- package/dist/types/api/index.d.ts +0 -31
- package/dist/types/api/responses/claimRequestActions.d.ts +0 -12
- package/dist/types/api/responses/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/misc/index.d.ts +0 -47
- package/dist/types/models/auth/Group.d.ts +0 -10
- package/dist/types/models/auth/Permission.d.ts +0 -4
- package/dist/types/models/auth/Role.d.ts +0 -8
- package/dist/types/models/auth/User.d.ts +0 -17
- package/dist/types/models/auth/index.d.ts +0 -4
- package/dist/types/models/claims/ClaimRequest.d.ts +0 -328
- package/dist/types/models/claims/index.d.ts +0 -1
- package/dist/types/models/index.d.ts +0 -6
- package/dist/types/models/oracle/Risk.d.ts +0 -8
- package/dist/types/models/oracle/TableData.d.ts +0 -9
- package/dist/types/models/oracle/index.d.ts +0 -2
- package/dist/types/models/payments/Gateways.d.ts +0 -1
- package/dist/types/models/payments/Payment.d.ts +0 -36
- package/dist/types/models/payments/index.d.ts +0 -2
- package/dist/types/models/quotes/Blacklist.d.ts +0 -20
- package/dist/types/models/quotes/Club.d.ts +0 -4
- package/dist/types/models/quotes/EmailContentOption.d.ts +0 -7
- package/dist/types/models/quotes/InformationRequest.d.ts +0 -34
- package/dist/types/models/quotes/Lead.d.ts +0 -17
- package/dist/types/models/quotes/MotorwebVehicle.d.ts +0 -120
- package/dist/types/models/quotes/PolicyBenefit.d.ts +0 -16
- package/dist/types/models/quotes/PolicyEnhancement.d.ts +0 -13
- package/dist/types/models/quotes/PostalAddress.d.ts +0 -7
- package/dist/types/models/quotes/PromoCode.d.ts +0 -18
- package/dist/types/models/quotes/QuoteRequest.d.ts +0 -110
- package/dist/types/models/quotes/QuoteRequestDeclaration.d.ts +0 -22
- package/dist/types/models/quotes/QuoteRequestForm.d.ts +0 -113
- package/dist/types/models/quotes/QuoteRequestIncident.d.ts +0 -6
- package/dist/types/models/quotes/QuoteRequestLog.d.ts +0 -11
- package/dist/types/models/quotes/QuoteRequestOptions.d.ts +0 -62
- package/dist/types/models/quotes/QuoteRequestPurchaseOption.d.ts +0 -38
- package/dist/types/models/quotes/QuoteRequestReferrer.d.ts +0 -9
- package/dist/types/models/quotes/QuoteRequestReferrerCategory.d.ts +0 -6
- package/dist/types/models/quotes/QuoteRequestVehicle.d.ts +0 -23
- package/dist/types/models/quotes/QuoteRequestVehicleDriver.d.ts +0 -11
- package/dist/types/models/quotes/RedbookVehicle.d.ts +0 -55
- package/dist/types/models/quotes/StreetAddress.d.ts +0 -8
- package/dist/types/models/quotes/index.d.ts +0 -23
- package/dist/types/models/sms-messages/SmsContentOption.d.ts +0 -7
- package/dist/types/models/sms-messages/SmsMessage.d.ts +0 -18
- package/dist/types/models/sms-messages/SmsMessageReply.d.ts +0 -10
- package/dist/types/models/sms-messages/index.d.ts +0 -3
|
@@ -1,3398 +0,0 @@
|
|
|
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 react = require('@inertiajs/react');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var React__default = _interopDefault(React);
|
|
11
|
-
var uuid = require('uuid');
|
|
12
|
-
var react$1 = require('@headlessui/react');
|
|
13
|
-
var cn = _interopDefault(require('classnames'));
|
|
14
|
-
var lodash = require('lodash');
|
|
15
|
-
var hi2 = require('react-icons/hi2');
|
|
16
|
-
var reactTooltip = require('react-tooltip');
|
|
17
|
-
var Select = _interopDefault(require('react-select'));
|
|
18
|
-
var core = require('@inertiajs/core');
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Formats a date like "Jan 1, 2022 at 9:50am"
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function formatDateNice(date, includeTime) {
|
|
25
|
-
if (includeTime === void 0) {
|
|
26
|
-
includeTime = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var formatString = includeTime ? "MMM d, yyyy 'at' h:mma" : 'MMM d, yyyy';
|
|
30
|
-
var formatFunc = includeTime ? formatDateTime : formatDate;
|
|
31
|
-
return formatFunc(date, formatString);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Formats a date like "01/01/2022 09:50"
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
function formatDateForTable(date, includeTime) {
|
|
38
|
-
if (includeTime === void 0) {
|
|
39
|
-
includeTime = true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return includeTime ? formatDateTime(date) : formatDate(date);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Formats a date to Star Insure standard format - dd/mm/yyyy
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
function formatDate(date, overrideFormatString) {
|
|
49
|
-
// If date is undefined or null
|
|
50
|
-
if (!date) {
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var formatString = overrideFormatString || 'dd/MM/yyyy'; // If date is a date object
|
|
55
|
-
|
|
56
|
-
if (date instanceof Date) {
|
|
57
|
-
return dateFns.format(date, formatString);
|
|
58
|
-
}
|
|
59
|
-
/*
|
|
60
|
-
* If date is a string, first attempt to parse it in non-standard formats
|
|
61
|
-
* Only parse the first 10 characters of the string
|
|
62
|
-
* dd/MM/yyyy, dd-MM-yyyy, dd.MM.yyyy
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var nonStandardDate = date.substring(0, 10).split('-').join('/').split('.').join('/');
|
|
67
|
-
var parsedDate = dateFns.parse(nonStandardDate, 'dd/MM/yyyy', new Date());
|
|
68
|
-
|
|
69
|
-
if (parsedDate.toString() !== 'Invalid Date') {
|
|
70
|
-
return dateFns.format(parsedDate, formatString);
|
|
71
|
-
} // Then attempt to parse it natively
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var nativelyParsedDate = new Date(date);
|
|
75
|
-
|
|
76
|
-
if (nativelyParsedDate.toString() !== 'Invalid Date') {
|
|
77
|
-
return dateFns.format(nativelyParsedDate, formatString);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return '';
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Formats a dateTime to Star Insure standard format - dd/mm/yyyy hh:mm
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
function formatDateTime(dateTime, overrideFormatString) {
|
|
87
|
-
// If date is undefined or null
|
|
88
|
-
if (!dateTime) {
|
|
89
|
-
return '';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var formatString = overrideFormatString || 'dd/MM/yyyy HH:mm'; // If date is a date object
|
|
93
|
-
|
|
94
|
-
if (dateTime instanceof Date) {
|
|
95
|
-
return dateFns.format(dateTime, formatString);
|
|
96
|
-
}
|
|
97
|
-
/*
|
|
98
|
-
* If date is a string, first attempt to parse it in non-standard formats
|
|
99
|
-
* dd/MM/yyyy HH:mm, dd-MM-yyyy HH:mm, dd.MM.yyyy HH:mm,
|
|
100
|
-
* dd/MM/yyyy hh:mm a, dd-MM-yyyy hh:mm a, dd.MM.yyyy hh:mm a,
|
|
101
|
-
* dd/MM/yyyy HH:mm:ss, dd-MM-yyyy HH:mm:ss, dd.MM.yyyy HH:mm:ss,
|
|
102
|
-
* dd/MM/yyyy hh:mm:ss a, dd-MM-yyyy hh:mm:ss a, dd.MM.yyyy hh:mm:ss a
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var nonStandardDateTime = dateTime // Remove commas between date and time
|
|
107
|
-
.split(',').join('') // Only parse the first 22 characters of the string
|
|
108
|
-
.substring(0, 22) // Replace dashes and dots with slashes
|
|
109
|
-
.split('-').join('/').split('.').join('/');
|
|
110
|
-
var is12Hour = ['AM', 'PM'].includes(nonStandardDateTime.slice(-2).toUpperCase());
|
|
111
|
-
var hasSeconds = nonStandardDateTime.split(':').length === 3;
|
|
112
|
-
var nonStandardFormat = ("dd/MM/yyyy " + (is12Hour ? 'hh' : 'HH') + ":mm" + (hasSeconds ? ':ss' : '') + " " + (is12Hour ? 'a' : '')).trim();
|
|
113
|
-
var parsedDateTime = dateFns.parse(nonStandardDateTime, nonStandardFormat, new Date());
|
|
114
|
-
|
|
115
|
-
if (parsedDateTime.toString() !== 'Invalid Date') {
|
|
116
|
-
return dateFns.format(parsedDateTime, formatString);
|
|
117
|
-
} // Then attempt to parse it natively
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var nativelyParsedDateTime = new Date(dateTime);
|
|
121
|
-
|
|
122
|
-
if (nativelyParsedDateTime.toString() !== 'Invalid Date') {
|
|
123
|
-
return dateFns.format(nativelyParsedDateTime, formatString);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return '';
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Attempts to create a date object from a date string
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
function createDate(dateString) {
|
|
133
|
-
// Re-use our logic from formatDateTime
|
|
134
|
-
var formattedDateTime = formatDateTime(dateString);
|
|
135
|
-
|
|
136
|
-
if (!formattedDateTime) {
|
|
137
|
-
return null;
|
|
138
|
-
} // Attempt to parse the formatted date to a date object
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
return dateFns.parse(formattedDateTime, 'dd/MM/yyyy HH:mm', new Date());
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("Error parsing date: " + (dateString == null ? void 0 : dateString.toString()));
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Safely rounds a number
|
|
151
|
-
*/
|
|
152
|
-
function round(value) {
|
|
153
|
-
return Number(Math.round(parseFloat(value + 'e' + 2)) + 'e-' + 2);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Gets the GST value from a number
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
function getGst(value) {
|
|
160
|
-
return round(value * 3 / 23);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Adds GST to a number
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
function addGst(value) {
|
|
167
|
-
return round(value * 1.15);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Subtracts GST from a number
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
function subtractGst(value) {
|
|
174
|
-
return round(value - getGst(value));
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Calculates the various GST values on a figure
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
function gstCalc(input) {
|
|
181
|
-
var value = input;
|
|
182
|
-
|
|
183
|
-
if (typeof value === 'string') {
|
|
184
|
-
value = parseFloat(value.replace(/[^0-9.]/g, ''));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
value = round(value);
|
|
188
|
-
return {
|
|
189
|
-
gst: getGst(value),
|
|
190
|
-
amountInclusive: addGst(value),
|
|
191
|
-
amountExclusive: subtractGst(value)
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Formats a value nicely
|
|
196
|
-
*/
|
|
197
|
-
|
|
198
|
-
function formatMoney(value, decimals) {
|
|
199
|
-
if (decimals === void 0) {
|
|
200
|
-
decimals = 2;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (value === null || value === undefined) {
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var toFormat = value;
|
|
208
|
-
|
|
209
|
-
if (typeof value === 'string') {
|
|
210
|
-
toFormat = value.replace(/[^\d.-]/g, '');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return Number(toFormat).toLocaleString('en', {
|
|
214
|
-
minimumFractionDigits: decimals,
|
|
215
|
-
maximumFractionDigits: decimals
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Turns a formatted value in to a float
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
function formatNumber(value) {
|
|
223
|
-
return parseFloat(value.replace(/[^0-9.]/g, ''));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function sanitiseVehicleType(inputType) {
|
|
227
|
-
var type;
|
|
228
|
-
|
|
229
|
-
switch (inputType) {
|
|
230
|
-
case 'Camper':
|
|
231
|
-
case 'Goods Van/Truck/Utility':
|
|
232
|
-
case 'Bus':
|
|
233
|
-
case 'Motor Caravan':
|
|
234
|
-
case 'Trailer/Caravan':
|
|
235
|
-
case 'TRAILER_CARAVAN':
|
|
236
|
-
case 'TRAILER_NOT_DESIGNED_FOR_HIGHWAY_USE':
|
|
237
|
-
case 'MOBILE_MACHINE':
|
|
238
|
-
case 'GOODS_VAN_TRUCK_UTILITY':
|
|
239
|
-
case 'BUS':
|
|
240
|
-
case 'MOTOR_CARAVAN':
|
|
241
|
-
{
|
|
242
|
-
type = 'motorhome';
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
case 'Motorcycle':
|
|
247
|
-
case 'Moped':
|
|
248
|
-
case 'ATV':
|
|
249
|
-
case 'Agricultural Machine':
|
|
250
|
-
case 'MOTORCYCLE':
|
|
251
|
-
case 'MOPED':
|
|
252
|
-
case 'TRACTOR':
|
|
253
|
-
case 'AGRICULTURAL_MACHINE':
|
|
254
|
-
case 'HIGH_SPEED_AGRICULTURAL_VEHICLE':
|
|
255
|
-
{
|
|
256
|
-
type = 'motorcycle';
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
case 'Passenger Car/Van':
|
|
261
|
-
case 'PASSENGER_CAR_VAN':
|
|
262
|
-
case 'SPECIAL_PURPOSE_VEHICLE':
|
|
263
|
-
case 'UNKNOWN':
|
|
264
|
-
default:
|
|
265
|
-
type = 'car';
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return type;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function _regeneratorRuntime() {
|
|
272
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
273
|
-
|
|
274
|
-
_regeneratorRuntime = function () {
|
|
275
|
-
return exports;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
var exports = {},
|
|
279
|
-
Op = Object.prototype,
|
|
280
|
-
hasOwn = Op.hasOwnProperty,
|
|
281
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
282
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
283
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
284
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
285
|
-
|
|
286
|
-
function define(obj, key, value) {
|
|
287
|
-
return Object.defineProperty(obj, key, {
|
|
288
|
-
value: value,
|
|
289
|
-
enumerable: !0,
|
|
290
|
-
configurable: !0,
|
|
291
|
-
writable: !0
|
|
292
|
-
}), obj[key];
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
try {
|
|
296
|
-
define({}, "");
|
|
297
|
-
} catch (err) {
|
|
298
|
-
define = function (obj, key, value) {
|
|
299
|
-
return obj[key] = value;
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
304
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
305
|
-
generator = Object.create(protoGenerator.prototype),
|
|
306
|
-
context = new Context(tryLocsList || []);
|
|
307
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
308
|
-
var state = "suspendedStart";
|
|
309
|
-
return function (method, arg) {
|
|
310
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
311
|
-
|
|
312
|
-
if ("completed" === state) {
|
|
313
|
-
if ("throw" === method) throw arg;
|
|
314
|
-
return doneResult();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
for (context.method = method, context.arg = arg;;) {
|
|
318
|
-
var delegate = context.delegate;
|
|
319
|
-
|
|
320
|
-
if (delegate) {
|
|
321
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
322
|
-
|
|
323
|
-
if (delegateResult) {
|
|
324
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
325
|
-
return delegateResult;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
330
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
331
|
-
context.dispatchException(context.arg);
|
|
332
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
333
|
-
state = "executing";
|
|
334
|
-
var record = tryCatch(innerFn, self, context);
|
|
335
|
-
|
|
336
|
-
if ("normal" === record.type) {
|
|
337
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
338
|
-
return {
|
|
339
|
-
value: record.arg,
|
|
340
|
-
done: context.done
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
}(innerFn, self, context), generator;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function tryCatch(fn, obj, arg) {
|
|
351
|
-
try {
|
|
352
|
-
return {
|
|
353
|
-
type: "normal",
|
|
354
|
-
arg: fn.call(obj, arg)
|
|
355
|
-
};
|
|
356
|
-
} catch (err) {
|
|
357
|
-
return {
|
|
358
|
-
type: "throw",
|
|
359
|
-
arg: err
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
exports.wrap = wrap;
|
|
365
|
-
var ContinueSentinel = {};
|
|
366
|
-
|
|
367
|
-
function Generator() {}
|
|
368
|
-
|
|
369
|
-
function GeneratorFunction() {}
|
|
370
|
-
|
|
371
|
-
function GeneratorFunctionPrototype() {}
|
|
372
|
-
|
|
373
|
-
var IteratorPrototype = {};
|
|
374
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
375
|
-
return this;
|
|
376
|
-
});
|
|
377
|
-
var getProto = Object.getPrototypeOf,
|
|
378
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
379
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
380
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
381
|
-
|
|
382
|
-
function defineIteratorMethods(prototype) {
|
|
383
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
384
|
-
define(prototype, method, function (arg) {
|
|
385
|
-
return this._invoke(method, arg);
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
391
|
-
function invoke(method, arg, resolve, reject) {
|
|
392
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
393
|
-
|
|
394
|
-
if ("throw" !== record.type) {
|
|
395
|
-
var result = record.arg,
|
|
396
|
-
value = result.value;
|
|
397
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
398
|
-
invoke("next", value, resolve, reject);
|
|
399
|
-
}, function (err) {
|
|
400
|
-
invoke("throw", err, resolve, reject);
|
|
401
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
402
|
-
result.value = unwrapped, resolve(result);
|
|
403
|
-
}, function (error) {
|
|
404
|
-
return invoke("throw", error, resolve, reject);
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
reject(record.arg);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
var previousPromise;
|
|
412
|
-
|
|
413
|
-
this._invoke = function (method, arg) {
|
|
414
|
-
function callInvokeWithMethodAndArg() {
|
|
415
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
416
|
-
invoke(method, arg, resolve, reject);
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
425
|
-
var method = delegate.iterator[context.method];
|
|
426
|
-
|
|
427
|
-
if (undefined === method) {
|
|
428
|
-
if (context.delegate = null, "throw" === context.method) {
|
|
429
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
430
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return ContinueSentinel;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
437
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
438
|
-
var info = record.arg;
|
|
439
|
-
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);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
function pushTryEntry(locs) {
|
|
443
|
-
var entry = {
|
|
444
|
-
tryLoc: locs[0]
|
|
445
|
-
};
|
|
446
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function resetTryEntry(entry) {
|
|
450
|
-
var record = entry.completion || {};
|
|
451
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function Context(tryLocsList) {
|
|
455
|
-
this.tryEntries = [{
|
|
456
|
-
tryLoc: "root"
|
|
457
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function values(iterable) {
|
|
461
|
-
if (iterable) {
|
|
462
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
463
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
464
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
465
|
-
|
|
466
|
-
if (!isNaN(iterable.length)) {
|
|
467
|
-
var i = -1,
|
|
468
|
-
next = function next() {
|
|
469
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
470
|
-
|
|
471
|
-
return next.value = undefined, next.done = !0, next;
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
return next.next = next;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
return {
|
|
479
|
-
next: doneResult
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function doneResult() {
|
|
484
|
-
return {
|
|
485
|
-
value: undefined,
|
|
486
|
-
done: !0
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
491
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
492
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
493
|
-
}, exports.mark = function (genFun) {
|
|
494
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
495
|
-
}, exports.awrap = function (arg) {
|
|
496
|
-
return {
|
|
497
|
-
__await: arg
|
|
498
|
-
};
|
|
499
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
500
|
-
return this;
|
|
501
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
502
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
503
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
504
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
505
|
-
return result.done ? result.value : iter.next();
|
|
506
|
-
});
|
|
507
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
508
|
-
return this;
|
|
509
|
-
}), define(Gp, "toString", function () {
|
|
510
|
-
return "[object Generator]";
|
|
511
|
-
}), exports.keys = function (object) {
|
|
512
|
-
var keys = [];
|
|
513
|
-
|
|
514
|
-
for (var key in object) keys.push(key);
|
|
515
|
-
|
|
516
|
-
return keys.reverse(), function next() {
|
|
517
|
-
for (; keys.length;) {
|
|
518
|
-
var key = keys.pop();
|
|
519
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
return next.done = !0, next;
|
|
523
|
-
};
|
|
524
|
-
}, exports.values = values, Context.prototype = {
|
|
525
|
-
constructor: Context,
|
|
526
|
-
reset: function (skipTempReset) {
|
|
527
|
-
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);
|
|
528
|
-
},
|
|
529
|
-
stop: function () {
|
|
530
|
-
this.done = !0;
|
|
531
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
532
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
533
|
-
return this.rval;
|
|
534
|
-
},
|
|
535
|
-
dispatchException: function (exception) {
|
|
536
|
-
if (this.done) throw exception;
|
|
537
|
-
var context = this;
|
|
538
|
-
|
|
539
|
-
function handle(loc, caught) {
|
|
540
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
544
|
-
var entry = this.tryEntries[i],
|
|
545
|
-
record = entry.completion;
|
|
546
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
547
|
-
|
|
548
|
-
if (entry.tryLoc <= this.prev) {
|
|
549
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
550
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
551
|
-
|
|
552
|
-
if (hasCatch && hasFinally) {
|
|
553
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
554
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
555
|
-
} else if (hasCatch) {
|
|
556
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
557
|
-
} else {
|
|
558
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
559
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
abrupt: function (type, arg) {
|
|
565
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
566
|
-
var entry = this.tryEntries[i];
|
|
567
|
-
|
|
568
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
569
|
-
var finallyEntry = entry;
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
575
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
576
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
577
|
-
},
|
|
578
|
-
complete: function (record, afterLoc) {
|
|
579
|
-
if ("throw" === record.type) throw record.arg;
|
|
580
|
-
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;
|
|
581
|
-
},
|
|
582
|
-
finish: function (finallyLoc) {
|
|
583
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
584
|
-
var entry = this.tryEntries[i];
|
|
585
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
catch: function (tryLoc) {
|
|
589
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
590
|
-
var entry = this.tryEntries[i];
|
|
591
|
-
|
|
592
|
-
if (entry.tryLoc === tryLoc) {
|
|
593
|
-
var record = entry.completion;
|
|
594
|
-
|
|
595
|
-
if ("throw" === record.type) {
|
|
596
|
-
var thrown = record.arg;
|
|
597
|
-
resetTryEntry(entry);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
return thrown;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
throw new Error("illegal catch attempt");
|
|
605
|
-
},
|
|
606
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
|
607
|
-
return this.delegate = {
|
|
608
|
-
iterator: values(iterable),
|
|
609
|
-
resultName: resultName,
|
|
610
|
-
nextLoc: nextLoc
|
|
611
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
612
|
-
}
|
|
613
|
-
}, exports;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
617
|
-
try {
|
|
618
|
-
var info = gen[key](arg);
|
|
619
|
-
var value = info.value;
|
|
620
|
-
} catch (error) {
|
|
621
|
-
reject(error);
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
if (info.done) {
|
|
626
|
-
resolve(value);
|
|
627
|
-
} else {
|
|
628
|
-
Promise.resolve(value).then(_next, _throw);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
function _asyncToGenerator(fn) {
|
|
633
|
-
return function () {
|
|
634
|
-
var self = this,
|
|
635
|
-
args = arguments;
|
|
636
|
-
return new Promise(function (resolve, reject) {
|
|
637
|
-
var gen = fn.apply(self, args);
|
|
638
|
-
|
|
639
|
-
function _next(value) {
|
|
640
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
function _throw(err) {
|
|
644
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
_next(undefined);
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
function _extends() {
|
|
653
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
654
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
655
|
-
var source = arguments[i];
|
|
656
|
-
|
|
657
|
-
for (var key in source) {
|
|
658
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
659
|
-
target[key] = source[key];
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return target;
|
|
665
|
-
};
|
|
666
|
-
return _extends.apply(this, arguments);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
670
|
-
if (source == null) return {};
|
|
671
|
-
var target = {};
|
|
672
|
-
var sourceKeys = Object.keys(source);
|
|
673
|
-
var key, i;
|
|
674
|
-
|
|
675
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
676
|
-
key = sourceKeys[i];
|
|
677
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
678
|
-
target[key] = source[key];
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
return target;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function useAuth() {
|
|
685
|
-
var _usePage = react.usePage(),
|
|
686
|
-
props = _usePage.props;
|
|
687
|
-
/**
|
|
688
|
-
* Check if the user has permission to perform the given ability.
|
|
689
|
-
*/
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
function can(ability) {
|
|
693
|
-
return props.auth.permissions.includes(ability);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
return _extends({}, props.auth, {
|
|
697
|
-
can: can
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
function useClickOutside(ref, handler) {
|
|
702
|
-
React.useEffect(function () {
|
|
703
|
-
var listener = function listener(event) {
|
|
704
|
-
// Do nothing if clicking ref's element or descendent elements
|
|
705
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
handler(event);
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
document.addEventListener('mousedown', listener);
|
|
713
|
-
document.addEventListener('touchstart', listener);
|
|
714
|
-
return function () {
|
|
715
|
-
document.removeEventListener('mousedown', listener);
|
|
716
|
-
document.removeEventListener('touchstart', listener);
|
|
717
|
-
};
|
|
718
|
-
}, [ref, handler]);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
var ToastContext = /*#__PURE__*/React.createContext({
|
|
722
|
-
toasts: [],
|
|
723
|
-
addToast: function addToast(t) {
|
|
724
|
-
},
|
|
725
|
-
removeToast: function removeToast(t) {
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
function ToastProvider(_ref) {
|
|
729
|
-
var children = _ref.children;
|
|
730
|
-
|
|
731
|
-
var _React$useState = React.useState([]),
|
|
732
|
-
toasts = _React$useState[0],
|
|
733
|
-
setToasts = _React$useState[1];
|
|
734
|
-
/**
|
|
735
|
-
* Add a new toast popup message
|
|
736
|
-
*/
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
function addToast(_ref2) {
|
|
740
|
-
var message = _ref2.message,
|
|
741
|
-
status = _ref2.status,
|
|
742
|
-
_ref2$timeout = _ref2.timeout,
|
|
743
|
-
timeout = _ref2$timeout === void 0 ? 4000 : _ref2$timeout;
|
|
744
|
-
var newToast = {
|
|
745
|
-
message: message,
|
|
746
|
-
status: status,
|
|
747
|
-
timeout: timeout
|
|
748
|
-
};
|
|
749
|
-
newToast._id = uuid.v4();
|
|
750
|
-
setToasts(function (curr) {
|
|
751
|
-
return [].concat(curr, [newToast]);
|
|
752
|
-
});
|
|
753
|
-
setTimeout(function () {
|
|
754
|
-
removeToast(newToast._id);
|
|
755
|
-
}, timeout);
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* Remove a toast message
|
|
759
|
-
*/
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
function removeToast(id) {
|
|
763
|
-
setToasts(function (curr) {
|
|
764
|
-
return curr.filter(function (toast) {
|
|
765
|
-
return toast._id !== id;
|
|
766
|
-
});
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
var context = {
|
|
771
|
-
toasts: toasts,
|
|
772
|
-
addToast: addToast,
|
|
773
|
-
removeToast: removeToast
|
|
774
|
-
};
|
|
775
|
-
return React.createElement(ToastContext.Provider, {
|
|
776
|
-
value: context
|
|
777
|
-
}, children);
|
|
778
|
-
}
|
|
779
|
-
var useToast = function useToast() {
|
|
780
|
-
return React.useContext(ToastContext);
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
function useInertiaOptions(_temp) {
|
|
784
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
785
|
-
_ref$successMessage = _ref.successMessage,
|
|
786
|
-
successMessage = _ref$successMessage === void 0 ? '' : _ref$successMessage;
|
|
787
|
-
|
|
788
|
-
var _useToast = useToast(),
|
|
789
|
-
addToast = _useToast.addToast;
|
|
790
|
-
|
|
791
|
-
return {
|
|
792
|
-
onSuccess: function onSuccess() {
|
|
793
|
-
addToast({
|
|
794
|
-
message: successMessage != null ? successMessage : 'Your request was successful.',
|
|
795
|
-
status: 'success'
|
|
796
|
-
});
|
|
797
|
-
},
|
|
798
|
-
onError: function onError(errors) {
|
|
799
|
-
Object.values(errors).forEach(function (err) {
|
|
800
|
-
addToast({
|
|
801
|
-
message: err,
|
|
802
|
-
status: 'error'
|
|
803
|
-
});
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
function useLocalStorage(key, initialValue) {
|
|
810
|
-
// State to store our value
|
|
811
|
-
// Pass initial state function to useState so logic is only executed once
|
|
812
|
-
var _useState = React.useState(function () {
|
|
813
|
-
if (typeof window === "undefined") {
|
|
814
|
-
return initialValue;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
try {
|
|
818
|
-
// Get from local storage by key
|
|
819
|
-
var item = window.localStorage.getItem(key); // Parse stored json or if none return initialValue
|
|
820
|
-
|
|
821
|
-
return item ? JSON.parse(item) : initialValue;
|
|
822
|
-
} catch (error) {
|
|
823
|
-
// If error also return initialValue
|
|
824
|
-
console.log(error);
|
|
825
|
-
return initialValue;
|
|
826
|
-
}
|
|
827
|
-
}),
|
|
828
|
-
storedValue = _useState[0],
|
|
829
|
-
setStoredValue = _useState[1]; // Return a wrapped version of useState's setter function that ...
|
|
830
|
-
// ... persists the new value to localStorage.
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
var setValue = function setValue(value) {
|
|
834
|
-
try {
|
|
835
|
-
// Allow value to be a function so we have same API as useState
|
|
836
|
-
var valueToStore = value instanceof Function ? value(storedValue) : value; // Save state
|
|
837
|
-
|
|
838
|
-
setStoredValue(valueToStore); // Save to local storage
|
|
839
|
-
|
|
840
|
-
if (typeof window !== "undefined") {
|
|
841
|
-
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
842
|
-
}
|
|
843
|
-
} catch (error) {
|
|
844
|
-
// A more advanced implementation would handle the error case
|
|
845
|
-
console.log(error);
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
|
|
849
|
-
return [storedValue, setValue];
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
var initialData = {
|
|
853
|
-
id: undefined,
|
|
854
|
-
status: 'new',
|
|
855
|
-
source: 'phone',
|
|
856
|
-
reference: '',
|
|
857
|
-
client_number: '',
|
|
858
|
-
first_name: '',
|
|
859
|
-
last_name: '',
|
|
860
|
-
phone: '',
|
|
861
|
-
mobile: '',
|
|
862
|
-
email: '',
|
|
863
|
-
licence: '',
|
|
864
|
-
licence_other: '',
|
|
865
|
-
promo_code: '',
|
|
866
|
-
club_membership_number: '',
|
|
867
|
-
length_of_insurance: '',
|
|
868
|
-
dob: '',
|
|
869
|
-
secondary_first_name: '',
|
|
870
|
-
secondary_last_name: '',
|
|
871
|
-
secondary_licence: '',
|
|
872
|
-
secondary_licence_other: '',
|
|
873
|
-
secondary_dob: '',
|
|
874
|
-
club_id: undefined,
|
|
875
|
-
street_address: {
|
|
876
|
-
address: '',
|
|
877
|
-
unit: '',
|
|
878
|
-
suburb: '',
|
|
879
|
-
city: '',
|
|
880
|
-
post_code: ''
|
|
881
|
-
},
|
|
882
|
-
declaration: {
|
|
883
|
-
had_incident: undefined,
|
|
884
|
-
incidents: [],
|
|
885
|
-
has_demerit_points: undefined,
|
|
886
|
-
demerit_points: '',
|
|
887
|
-
has_lost_licence: undefined,
|
|
888
|
-
lost_licence_details: '',
|
|
889
|
-
was_refused_insurance: undefined,
|
|
890
|
-
refused_insurance_details: '',
|
|
891
|
-
has_criminal_conviction: undefined,
|
|
892
|
-
criminal_conviction_details: '',
|
|
893
|
-
has_vehicle_modifications: undefined,
|
|
894
|
-
vehicle_modifications_details: '',
|
|
895
|
-
has_previous_insurer: undefined,
|
|
896
|
-
previous_insurer_details: '',
|
|
897
|
-
previous_insurer_expires_at: '',
|
|
898
|
-
additional_details: ''
|
|
899
|
-
},
|
|
900
|
-
vehicles: [],
|
|
901
|
-
// Portal specific fields:
|
|
902
|
-
purchase_options: [],
|
|
903
|
-
theme: '',
|
|
904
|
-
broker_fee: undefined,
|
|
905
|
-
broker_id: undefined,
|
|
906
|
-
broker_firm_id: undefined,
|
|
907
|
-
agent_id: undefined,
|
|
908
|
-
agent_firm_id: undefined,
|
|
909
|
-
staff_member_id: undefined,
|
|
910
|
-
sent_at: undefined,
|
|
911
|
-
sold_at: undefined,
|
|
912
|
-
referrer_id: undefined,
|
|
913
|
-
referrer_category_id: undefined,
|
|
914
|
-
pricing_expires_at: undefined,
|
|
915
|
-
follow_up_at: undefined,
|
|
916
|
-
is_follow_up_required: true
|
|
917
|
-
};
|
|
918
|
-
var QuoteRequestFormContext = /*#__PURE__*/React__default.createContext({
|
|
919
|
-
clear: function clear() {
|
|
920
|
-
return null;
|
|
921
|
-
}
|
|
922
|
-
});
|
|
923
|
-
function QuoteRequestFormProvider(_ref) {
|
|
924
|
-
var children = _ref.children;
|
|
925
|
-
var form = react.useForm(_extends({}, initialData));
|
|
926
|
-
/**
|
|
927
|
-
* Handle the change event for all form inputs
|
|
928
|
-
*/
|
|
929
|
-
|
|
930
|
-
function handleChange(e) {
|
|
931
|
-
var name = e.currentTarget.name;
|
|
932
|
-
var value = e.currentTarget.value;
|
|
933
|
-
|
|
934
|
-
if (e.currentTarget.type === 'checkbox' || e.currentTarget.type === 'radio') {
|
|
935
|
-
var target = e.currentTarget;
|
|
936
|
-
value = target.value === '1' ? true : false;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
if (name.includes('.')) {
|
|
940
|
-
var parts = name.split('.');
|
|
941
|
-
|
|
942
|
-
if (parts.length === 2) {
|
|
943
|
-
return form.setData(function (prevData) {
|
|
944
|
-
var _extends2, _extends3;
|
|
945
|
-
|
|
946
|
-
return _extends({}, prevData, (_extends3 = {}, _extends3[parts[0]] = _extends({}, prevData[parts[0]], (_extends2 = {}, _extends2[parts[1]] = value, _extends2)), _extends3));
|
|
947
|
-
});
|
|
948
|
-
} else {
|
|
949
|
-
// We don't want to handle anything double-nested. These should be handled by their own local state.
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
return form.setData(function (prevData) {
|
|
955
|
-
var _extends4;
|
|
956
|
-
|
|
957
|
-
return _extends({}, prevData, (_extends4 = {}, _extends4[name] = value, _extends4));
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
function clear() {
|
|
962
|
-
form.setData(_extends({}, initialData));
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
return React__default.createElement(QuoteRequestFormContext.Provider, {
|
|
966
|
-
value: {
|
|
967
|
-
form: form,
|
|
968
|
-
handleChange: handleChange,
|
|
969
|
-
clear: clear
|
|
970
|
-
}
|
|
971
|
-
}, children);
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Takes in a quote request and returns data suitable to populate a form
|
|
975
|
-
* by recursively calling this function, converting null to undefined.
|
|
976
|
-
*/
|
|
977
|
-
|
|
978
|
-
function sanitiseQuoteRequestFormData(value) {
|
|
979
|
-
if (Array.isArray(value)) {
|
|
980
|
-
return value.map(function (item) {
|
|
981
|
-
return sanitiseQuoteRequestFormData(item);
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
if (value === null) {
|
|
986
|
-
return "";
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
if (typeof value === 'object') {
|
|
990
|
-
// Map over each property and convert null to undefined
|
|
991
|
-
return Object.keys(value).reduce(function (acc, key) {
|
|
992
|
-
// @ts-ignore
|
|
993
|
-
acc[key] = sanitiseQuoteRequestFormData(value[key]);
|
|
994
|
-
return acc;
|
|
995
|
-
}, {});
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
return value;
|
|
999
|
-
}
|
|
1000
|
-
var useQuoteRequestForm = function useQuoteRequestForm() {
|
|
1001
|
-
return React__default.useContext(QuoteRequestFormContext);
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
|
-
var QuoteRequestOptionsContext = /*#__PURE__*/React__default.createContext({
|
|
1005
|
-
setOptions: function setOptions() {}
|
|
1006
|
-
});
|
|
1007
|
-
function QuoteRequestOptionsProvider(_ref) {
|
|
1008
|
-
var children = _ref.children;
|
|
1009
|
-
|
|
1010
|
-
var _React$useState = React__default.useState(),
|
|
1011
|
-
options = _React$useState[0],
|
|
1012
|
-
setOptions = _React$useState[1];
|
|
1013
|
-
|
|
1014
|
-
return React__default.createElement(QuoteRequestOptionsContext.Provider, {
|
|
1015
|
-
value: {
|
|
1016
|
-
options: options,
|
|
1017
|
-
setOptions: setOptions
|
|
1018
|
-
}
|
|
1019
|
-
}, children);
|
|
1020
|
-
}
|
|
1021
|
-
var useQuoteRequestOptions = function useQuoteRequestOptions() {
|
|
1022
|
-
return React__default.useContext(QuoteRequestOptionsContext);
|
|
1023
|
-
};
|
|
1024
|
-
|
|
1025
|
-
var prodConfig = {
|
|
1026
|
-
key: 'XVAKN4Q9PREJD8CUTFBW',
|
|
1027
|
-
baseUrl: 'https://api.addressfinder.io/api/nz/address'
|
|
1028
|
-
};
|
|
1029
|
-
var config = prodConfig;
|
|
1030
|
-
function autocomplete(_x) {
|
|
1031
|
-
return _autocomplete.apply(this, arguments);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
function _autocomplete() {
|
|
1035
|
-
_autocomplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
|
|
1036
|
-
var key, baseUrl, q, res, data;
|
|
1037
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1038
|
-
while (1) {
|
|
1039
|
-
switch (_context.prev = _context.next) {
|
|
1040
|
-
case 0:
|
|
1041
|
-
key = config.key, baseUrl = config.baseUrl;
|
|
1042
|
-
q = encodeURIComponent(search);
|
|
1043
|
-
_context.next = 4;
|
|
1044
|
-
return fetch(baseUrl + "/autocomplete/?key=" + key + "&q=" + q + "&format=json&strict=2");
|
|
1045
|
-
|
|
1046
|
-
case 4:
|
|
1047
|
-
res = _context.sent;
|
|
1048
|
-
|
|
1049
|
-
if (res.ok) {
|
|
1050
|
-
_context.next = 7;
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
return _context.abrupt("return", []);
|
|
1055
|
-
|
|
1056
|
-
case 7:
|
|
1057
|
-
_context.next = 9;
|
|
1058
|
-
return res.json();
|
|
1059
|
-
|
|
1060
|
-
case 9:
|
|
1061
|
-
data = _context.sent;
|
|
1062
|
-
|
|
1063
|
-
if (!data.completions) {
|
|
1064
|
-
_context.next = 12;
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
return _context.abrupt("return", data.completions);
|
|
1069
|
-
|
|
1070
|
-
case 12:
|
|
1071
|
-
return _context.abrupt("return", []);
|
|
1072
|
-
|
|
1073
|
-
case 13:
|
|
1074
|
-
case "end":
|
|
1075
|
-
return _context.stop();
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}, _callee);
|
|
1079
|
-
}));
|
|
1080
|
-
return _autocomplete.apply(this, arguments);
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function getAddressData(_x2) {
|
|
1084
|
-
return _getAddressData.apply(this, arguments);
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
function _getAddressData() {
|
|
1088
|
-
_getAddressData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(completion) {
|
|
1089
|
-
var key, baseUrl, res, data;
|
|
1090
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1091
|
-
while (1) {
|
|
1092
|
-
switch (_context2.prev = _context2.next) {
|
|
1093
|
-
case 0:
|
|
1094
|
-
key = config.key, baseUrl = config.baseUrl;
|
|
1095
|
-
_context2.next = 3;
|
|
1096
|
-
return fetch(baseUrl + "/metadata/?key=" + key + "&pxid=" + completion.pxid + "&format=json");
|
|
1097
|
-
|
|
1098
|
-
case 3:
|
|
1099
|
-
res = _context2.sent;
|
|
1100
|
-
|
|
1101
|
-
if (res.ok) {
|
|
1102
|
-
_context2.next = 6;
|
|
1103
|
-
break;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
return _context2.abrupt("return", null);
|
|
1107
|
-
|
|
1108
|
-
case 6:
|
|
1109
|
-
_context2.next = 8;
|
|
1110
|
-
return res.json();
|
|
1111
|
-
|
|
1112
|
-
case 8:
|
|
1113
|
-
data = _context2.sent;
|
|
1114
|
-
return _context2.abrupt("return", data);
|
|
1115
|
-
|
|
1116
|
-
case 10:
|
|
1117
|
-
case "end":
|
|
1118
|
-
return _context2.stop();
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}, _callee2);
|
|
1122
|
-
}));
|
|
1123
|
-
return _getAddressData.apply(this, arguments);
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* Calculate someone's age from a date of birth.
|
|
1128
|
-
*/
|
|
1129
|
-
function calculateAge(date) {
|
|
1130
|
-
if (!date) {
|
|
1131
|
-
return 0;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
try {
|
|
1135
|
-
var today = new Date();
|
|
1136
|
-
var birthDate = new Date(date);
|
|
1137
|
-
var age = today.getFullYear() - birthDate.getFullYear();
|
|
1138
|
-
var m = today.getMonth() - birthDate.getMonth();
|
|
1139
|
-
|
|
1140
|
-
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
1141
|
-
return age - 1;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
return age;
|
|
1145
|
-
} catch (error) {
|
|
1146
|
-
console.error(error);
|
|
1147
|
-
return 0;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
function calculateMonthly(_ref) {
|
|
1152
|
-
var option = _ref.option,
|
|
1153
|
-
selectedEnhancements = _ref.selectedEnhancements;
|
|
1154
|
-
var premium = option.monthly_premium || 0;
|
|
1155
|
-
var enhancementsCost = selectedEnhancements.reduce(function (acc, id) {
|
|
1156
|
-
var _option$enhancements;
|
|
1157
|
-
|
|
1158
|
-
var enhancement = (_option$enhancements = option.enhancements) == null ? void 0 : _option$enhancements.find(function (e) {
|
|
1159
|
-
return e.id === id;
|
|
1160
|
-
});
|
|
1161
|
-
if (!enhancement) return acc;
|
|
1162
|
-
var enhancementPremium = calcMonthlyEnhancementPrice(enhancement);
|
|
1163
|
-
|
|
1164
|
-
if (!acc) {
|
|
1165
|
-
return enhancementPremium;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
return acc + enhancementPremium;
|
|
1169
|
-
}, 0) || 0;
|
|
1170
|
-
return premium + enhancementsCost;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
function calculateAnnually(_ref2) {
|
|
1174
|
-
var option = _ref2.option,
|
|
1175
|
-
selectedEnhancements = _ref2.selectedEnhancements,
|
|
1176
|
-
_ref2$brokerFee = _ref2.brokerFee,
|
|
1177
|
-
brokerFee = _ref2$brokerFee === void 0 ? 0 : _ref2$brokerFee;
|
|
1178
|
-
var premium = option.premium || 0;
|
|
1179
|
-
var fsl = option.fsl || 0;
|
|
1180
|
-
var enhancementsCost = selectedEnhancements.reduce(function (acc, id) {
|
|
1181
|
-
var _option$enhancements2;
|
|
1182
|
-
|
|
1183
|
-
var enhancement = (_option$enhancements2 = option.enhancements) == null ? void 0 : _option$enhancements2.find(function (e) {
|
|
1184
|
-
return e.id === id;
|
|
1185
|
-
});
|
|
1186
|
-
if (!enhancement) return acc;
|
|
1187
|
-
return (acc || 0) + (enhancement.premium || 0);
|
|
1188
|
-
}, 0) || 0;
|
|
1189
|
-
return premium + fsl + enhancementsCost + brokerFee;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
function calcMonthlyEnhancementPrice(enhancement) {
|
|
1193
|
-
if (!enhancement.premium) return 0;
|
|
1194
|
-
var monthlyPremium = enhancement.premium / 100 / 12;
|
|
1195
|
-
|
|
1196
|
-
if (enhancement.disable_rounding) {
|
|
1197
|
-
return Math.round(monthlyPremium * 100);
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
return Math.round(Math.ceil(monthlyPremium) * 100);
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* Fix rounding errors we get from subtracting, and then adding GST back on
|
|
1204
|
-
* (Issues with 2 decimal place rounding)
|
|
1205
|
-
*/
|
|
1206
|
-
|
|
1207
|
-
function fixRoundingError(premium) {
|
|
1208
|
-
// If the premium ends in "01" then we need to round it down
|
|
1209
|
-
if (premium % 100 === 1) {
|
|
1210
|
-
return premium - 1;
|
|
1211
|
-
} // If the premium ends in "99" then we need to round it up
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
if (premium % 100 === 99) {
|
|
1215
|
-
return premium + 1;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
return premium;
|
|
1219
|
-
}
|
|
1220
|
-
function calcPurchaseOptionPricing(_ref3) {
|
|
1221
|
-
var option = _ref3.option,
|
|
1222
|
-
selectedEnhancements = _ref3.selectedEnhancements,
|
|
1223
|
-
_ref3$brokerFee = _ref3.brokerFee,
|
|
1224
|
-
brokerFee = _ref3$brokerFee === void 0 ? 0 : _ref3$brokerFee;
|
|
1225
|
-
var monthly = calculateMonthly({
|
|
1226
|
-
option: option,
|
|
1227
|
-
selectedEnhancements: selectedEnhancements
|
|
1228
|
-
});
|
|
1229
|
-
var annually = calculateAnnually({
|
|
1230
|
-
option: option,
|
|
1231
|
-
selectedEnhancements: selectedEnhancements,
|
|
1232
|
-
brokerFee: brokerFee
|
|
1233
|
-
});
|
|
1234
|
-
var monthlyWithGst = fixRoundingError(Math.round(addGst(monthly)));
|
|
1235
|
-
var annuallyWithGst = fixRoundingError(Math.round(addGst(annually)));
|
|
1236
|
-
return {
|
|
1237
|
-
monthly: monthly,
|
|
1238
|
-
annually: annually,
|
|
1239
|
-
monthlyWithGst: monthlyWithGst,
|
|
1240
|
-
annuallyWithGst: annuallyWithGst
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
/**
|
|
1245
|
-
* A wrapper around Inertia's usePage function that gives better type-safety
|
|
1246
|
-
*/
|
|
1247
|
-
|
|
1248
|
-
function usePage() {
|
|
1249
|
-
// @ts-ignore
|
|
1250
|
-
return react.usePage();
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
/**
|
|
1254
|
-
* A helper to return a fetch function including default headers and authorization.
|
|
1255
|
-
*/
|
|
1256
|
-
|
|
1257
|
-
function useFetch(_ref) {
|
|
1258
|
-
var baseUrl = _ref.url,
|
|
1259
|
-
_ref$method = _ref.method,
|
|
1260
|
-
method = _ref$method === void 0 ? 'GET' : _ref$method,
|
|
1261
|
-
_ref$params = _ref.params,
|
|
1262
|
-
params = _ref$params === void 0 ? {} : _ref$params,
|
|
1263
|
-
_ref$headers = _ref.headers,
|
|
1264
|
-
headers = _ref$headers === void 0 ? {} : _ref$headers;
|
|
1265
|
-
var access_token = usePage().props.access_token;
|
|
1266
|
-
var url = baseUrl;
|
|
1267
|
-
|
|
1268
|
-
if (method === 'GET') {
|
|
1269
|
-
var queryParams = new URLSearchParams(params);
|
|
1270
|
-
url = url + "?" + queryParams.toString();
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
return React__default.useMemo(function () {
|
|
1274
|
-
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1275
|
-
var res, ok, body, parsedBody, message, data;
|
|
1276
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1277
|
-
while (1) {
|
|
1278
|
-
switch (_context.prev = _context.next) {
|
|
1279
|
-
case 0:
|
|
1280
|
-
_context.next = 2;
|
|
1281
|
-
return fetch(url, {
|
|
1282
|
-
method: method,
|
|
1283
|
-
headers: _extends({
|
|
1284
|
-
'Content-Type': 'application/json',
|
|
1285
|
-
Accept: 'application/json',
|
|
1286
|
-
Authorization: access_token ? "Bearer " + access_token : ''
|
|
1287
|
-
}, headers),
|
|
1288
|
-
body: Object.keys(params).length > 0 && method !== 'GET' ? JSON.stringify(params) : null
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
case 2:
|
|
1292
|
-
res = _context.sent;
|
|
1293
|
-
ok = res.ok;
|
|
1294
|
-
_context.next = 6;
|
|
1295
|
-
return res.text();
|
|
1296
|
-
|
|
1297
|
-
case 6:
|
|
1298
|
-
body = _context.sent;
|
|
1299
|
-
parsedBody = body;
|
|
1300
|
-
|
|
1301
|
-
try {
|
|
1302
|
-
parsedBody = JSON.parse(body);
|
|
1303
|
-
} catch (error) {// Response wasn't JSON, just use the text version.
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
message = typeof parsedBody === 'string' ? parsedBody : undefined;
|
|
1307
|
-
|
|
1308
|
-
if (ok) {
|
|
1309
|
-
_context.next = 12;
|
|
1310
|
-
break;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
return _context.abrupt("return", {
|
|
1314
|
-
ok: ok,
|
|
1315
|
-
message: message
|
|
1316
|
-
});
|
|
1317
|
-
|
|
1318
|
-
case 12:
|
|
1319
|
-
data = typeof parsedBody !== 'string' ? parsedBody : undefined;
|
|
1320
|
-
return _context.abrupt("return", {
|
|
1321
|
-
ok: ok,
|
|
1322
|
-
data: data,
|
|
1323
|
-
message: message
|
|
1324
|
-
});
|
|
1325
|
-
|
|
1326
|
-
case 14:
|
|
1327
|
-
case "end":
|
|
1328
|
-
return _context.stop();
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
}, _callee);
|
|
1332
|
-
}));
|
|
1333
|
-
}, [access_token, url, params, headers, method]);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
function Button(_ref) {
|
|
1337
|
-
var className = _ref.className,
|
|
1338
|
-
href = _ref.href,
|
|
1339
|
-
target = _ref.target,
|
|
1340
|
-
_onClick = _ref.onClick,
|
|
1341
|
-
type = _ref.type,
|
|
1342
|
-
children = _ref.children,
|
|
1343
|
-
_ref$status = _ref.status,
|
|
1344
|
-
status = _ref$status === void 0 ? 'default' : _ref$status,
|
|
1345
|
-
_ref$disabled = _ref.disabled,
|
|
1346
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
1347
|
-
as = _ref.as,
|
|
1348
|
-
_ref$small = _ref.small,
|
|
1349
|
-
small = _ref$small === void 0 ? false : _ref$small;
|
|
1350
|
-
var baseClasses = small ? 'font-bold text-sm inline-flex items-center gap-3 justify-center text-white text-center px-3 py-1 rounded min-w-[80px] transition-all hover:brightness-110' : '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:brightness-110';
|
|
1351
|
-
var statusClass = status === 'primary' && 'bg-accent' || status === 'danger' && 'bg-red-500' || status === 'warning' && 'bg-yellow-400' || status === 'info' && 'bg-blue-400' || 'bg-gray-600';
|
|
1352
|
-
var classes = (className != null ? className : '') + " " + baseClasses + " " + statusClass;
|
|
1353
|
-
|
|
1354
|
-
if (_onClick) {
|
|
1355
|
-
return React__default.createElement("button", {
|
|
1356
|
-
className: classes,
|
|
1357
|
-
type: type != null ? type : 'button',
|
|
1358
|
-
onClick: function onClick(e) {
|
|
1359
|
-
return _onClick(e);
|
|
1360
|
-
},
|
|
1361
|
-
disabled: disabled
|
|
1362
|
-
}, children);
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
if (type) {
|
|
1366
|
-
return React__default.createElement("button", {
|
|
1367
|
-
className: classes,
|
|
1368
|
-
type: type != null ? type : 'button',
|
|
1369
|
-
disabled: disabled
|
|
1370
|
-
}, children);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
if (href) {
|
|
1374
|
-
if (href.includes('http') || target === '_blank' || as === 'a') {
|
|
1375
|
-
return React__default.createElement("a", {
|
|
1376
|
-
href: href,
|
|
1377
|
-
target: target != null ? target : '_self',
|
|
1378
|
-
className: classes
|
|
1379
|
-
}, children);
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
return React__default.createElement(react.Link, {
|
|
1383
|
-
href: href,
|
|
1384
|
-
className: classes
|
|
1385
|
-
}, children);
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
return React__default.createElement("p", {
|
|
1389
|
-
className: "text-red-500 text-sm"
|
|
1390
|
-
}, "[Invalid button]");
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
function Card(_ref) {
|
|
1394
|
-
var className = _ref.className,
|
|
1395
|
-
children = _ref.children;
|
|
1396
|
-
return React__default.createElement("div", {
|
|
1397
|
-
className: (className != null ? className : '') + " flex flex-col items-start bg-white rounded-md shadow-sm border border-gray-300 p-4 md:p-6"
|
|
1398
|
-
}, children);
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
function Pagination(_ref) {
|
|
1402
|
-
var meta = _ref.meta,
|
|
1403
|
-
className = _ref.className,
|
|
1404
|
-
_ref$showPerPageSelec = _ref.showPerPageSelector,
|
|
1405
|
-
showPerPageSelector = _ref$showPerPageSelec === void 0 ? false : _ref$showPerPageSelec,
|
|
1406
|
-
defaultValue = _ref.defaultValue;
|
|
1407
|
-
var current_page = meta.current_page,
|
|
1408
|
-
total = meta.total,
|
|
1409
|
-
per_page = meta.per_page;
|
|
1410
|
-
var perPageValue = defaultValue != null ? defaultValue : per_page;
|
|
1411
|
-
var page_count = Math.ceil(total / per_page);
|
|
1412
|
-
|
|
1413
|
-
function getNextPageLink() {
|
|
1414
|
-
if (typeof window !== 'undefined') {
|
|
1415
|
-
var search = new URLSearchParams(window.location.search);
|
|
1416
|
-
search.set('page', String(current_page + 1));
|
|
1417
|
-
return "?" + search.toString();
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
return '';
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
function getPrevPageLink() {
|
|
1424
|
-
if (typeof window !== 'undefined') {
|
|
1425
|
-
var search = new URLSearchParams(window.location.search);
|
|
1426
|
-
search.set('page', String(current_page - 1));
|
|
1427
|
-
return "?" + search.toString();
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
return '';
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
var nextPageLink = getNextPageLink();
|
|
1434
|
-
var prevPageLink = getPrevPageLink();
|
|
1435
|
-
|
|
1436
|
-
function handlePerPageChange(e) {
|
|
1437
|
-
var _window;
|
|
1438
|
-
|
|
1439
|
-
var search = new URLSearchParams((_window = window) == null ? void 0 : _window.location.search);
|
|
1440
|
-
search.set('limit', e.currentTarget.value);
|
|
1441
|
-
search.set('page', '1');
|
|
1442
|
-
window.location.href = "?" + search.toString();
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
return React__default.createElement("div", {
|
|
1446
|
-
className: "" + (className != null ? className : '')
|
|
1447
|
-
}, React__default.createElement("nav", {
|
|
1448
|
-
className: "font-bold flex justify-between items-center gap-6"
|
|
1449
|
-
}, React__default.createElement(react.Link, {
|
|
1450
|
-
href: prevPageLink,
|
|
1451
|
-
className: "flex items-center gap-2",
|
|
1452
|
-
disabled: current_page === 1
|
|
1453
|
-
}, React__default.createElement("svg", {
|
|
1454
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1455
|
-
className: "h-4 w-4",
|
|
1456
|
-
fill: "none",
|
|
1457
|
-
viewBox: "0 0 24 24",
|
|
1458
|
-
stroke: "currentColor",
|
|
1459
|
-
strokeWidth: "2"
|
|
1460
|
-
}, React__default.createElement("path", {
|
|
1461
|
-
strokeLinecap: "round",
|
|
1462
|
-
strokeLinejoin: "round",
|
|
1463
|
-
d: "M10 19l-7-7m0 0l7-7m-7 7h18"
|
|
1464
|
-
})), "Prev"), React__default.createElement("div", {
|
|
1465
|
-
className: "flex gap-6 items-center"
|
|
1466
|
-
}, React__default.createElement("p", null, "Page ", current_page, " of ", page_count), showPerPageSelector ? React__default.createElement("select", {
|
|
1467
|
-
value: perPageValue,
|
|
1468
|
-
onChange: handlePerPageChange
|
|
1469
|
-
}, React__default.createElement("option", {
|
|
1470
|
-
value: "10"
|
|
1471
|
-
}, "10 per page"), React__default.createElement("option", {
|
|
1472
|
-
value: "25"
|
|
1473
|
-
}, "25 per page"), React__default.createElement("option", {
|
|
1474
|
-
value: "50"
|
|
1475
|
-
}, "50 per page"), React__default.createElement("option", {
|
|
1476
|
-
value: "100"
|
|
1477
|
-
}, "100 per page"), React__default.createElement("option", {
|
|
1478
|
-
value: "250"
|
|
1479
|
-
}, "250 per page"), React__default.createElement("option", {
|
|
1480
|
-
value: "500"
|
|
1481
|
-
}, "500 per page")) : ''), React__default.createElement(react.Link, {
|
|
1482
|
-
href: nextPageLink,
|
|
1483
|
-
className: "flex items-center gap-2",
|
|
1484
|
-
disabled: current_page === page_count
|
|
1485
|
-
}, "Next", React__default.createElement("svg", {
|
|
1486
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1487
|
-
className: "h-4 w-4",
|
|
1488
|
-
fill: "none",
|
|
1489
|
-
viewBox: "0 0 24 24",
|
|
1490
|
-
stroke: "currentColor",
|
|
1491
|
-
strokeWidth: "2"
|
|
1492
|
-
}, React__default.createElement("path", {
|
|
1493
|
-
strokeLinecap: "round",
|
|
1494
|
-
strokeLinejoin: "round",
|
|
1495
|
-
d: "M14 5l7 7m0 0l-7 7m7-7H3"
|
|
1496
|
-
})))));
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
function SimplePagination(_ref) {
|
|
1500
|
-
var meta = _ref.meta,
|
|
1501
|
-
className = _ref.className,
|
|
1502
|
-
_ref$showPerPageSelec = _ref.showPerPageSelector,
|
|
1503
|
-
showPerPageSelector = _ref$showPerPageSelec === void 0 ? false : _ref$showPerPageSelec,
|
|
1504
|
-
defaultValue = _ref.defaultValue;
|
|
1505
|
-
var current_page = meta.current_page,
|
|
1506
|
-
per_page = meta.per_page,
|
|
1507
|
-
to = meta.to,
|
|
1508
|
-
from = meta.from;
|
|
1509
|
-
var perPageValue = defaultValue != null ? defaultValue : per_page;
|
|
1510
|
-
var results_on_page = to - from + 1;
|
|
1511
|
-
var has_more_pages = results_on_page === per_page;
|
|
1512
|
-
|
|
1513
|
-
function getNextPageLink() {
|
|
1514
|
-
if (typeof window !== 'undefined') {
|
|
1515
|
-
var search = new URLSearchParams(window.location.search);
|
|
1516
|
-
search.set('page', String(current_page + 1));
|
|
1517
|
-
return "?" + search.toString();
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
return '';
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
function getPrevPageLink() {
|
|
1524
|
-
if (typeof window !== 'undefined') {
|
|
1525
|
-
var search = new URLSearchParams(window.location.search);
|
|
1526
|
-
search.set('page', String(current_page - 1));
|
|
1527
|
-
return "?" + search.toString();
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
return '';
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
var nextPageLink = getNextPageLink();
|
|
1534
|
-
var prevPageLink = getPrevPageLink();
|
|
1535
|
-
|
|
1536
|
-
function handlePerPageChange(e) {
|
|
1537
|
-
var _window;
|
|
1538
|
-
|
|
1539
|
-
var search = new URLSearchParams((_window = window) == null ? void 0 : _window.location.search);
|
|
1540
|
-
search.set('limit', e.currentTarget.value);
|
|
1541
|
-
search.set('page', '1');
|
|
1542
|
-
window.location.href = "?" + search.toString();
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
return React__default.createElement("div", {
|
|
1546
|
-
className: "" + (className != null ? className : '')
|
|
1547
|
-
}, React__default.createElement("nav", {
|
|
1548
|
-
className: "font-bold flex justify-between items-center gap-6"
|
|
1549
|
-
}, React__default.createElement(react.Link, {
|
|
1550
|
-
href: prevPageLink,
|
|
1551
|
-
className: "flex items-center gap-2",
|
|
1552
|
-
disabled: current_page === 1
|
|
1553
|
-
}, React__default.createElement("svg", {
|
|
1554
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1555
|
-
className: "h-4 w-4",
|
|
1556
|
-
fill: "none",
|
|
1557
|
-
viewBox: "0 0 24 24",
|
|
1558
|
-
stroke: "currentColor",
|
|
1559
|
-
strokeWidth: "2"
|
|
1560
|
-
}, React__default.createElement("path", {
|
|
1561
|
-
strokeLinecap: "round",
|
|
1562
|
-
strokeLinejoin: "round",
|
|
1563
|
-
d: "M10 19l-7-7m0 0l7-7m-7 7h18"
|
|
1564
|
-
})), "Prev"), React__default.createElement("div", {
|
|
1565
|
-
className: "flex gap-6 items-center"
|
|
1566
|
-
}, React__default.createElement("p", null, "Page ", current_page), showPerPageSelector ? React__default.createElement("select", {
|
|
1567
|
-
value: perPageValue,
|
|
1568
|
-
onChange: handlePerPageChange
|
|
1569
|
-
}, React__default.createElement("option", {
|
|
1570
|
-
value: "10"
|
|
1571
|
-
}, "10 per page"), React__default.createElement("option", {
|
|
1572
|
-
value: "25"
|
|
1573
|
-
}, "25 per page"), React__default.createElement("option", {
|
|
1574
|
-
value: "50"
|
|
1575
|
-
}, "50 per page"), React__default.createElement("option", {
|
|
1576
|
-
value: "100"
|
|
1577
|
-
}, "100 per page"), React__default.createElement("option", {
|
|
1578
|
-
value: "250"
|
|
1579
|
-
}, "250 per page"), React__default.createElement("option", {
|
|
1580
|
-
value: "500"
|
|
1581
|
-
}, "500 per page")) : ''), React__default.createElement(react.Link, {
|
|
1582
|
-
href: nextPageLink,
|
|
1583
|
-
className: "flex items-center gap-2",
|
|
1584
|
-
disabled: !has_more_pages
|
|
1585
|
-
}, "Next", React__default.createElement("svg", {
|
|
1586
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1587
|
-
className: "h-4 w-4",
|
|
1588
|
-
fill: "none",
|
|
1589
|
-
viewBox: "0 0 24 24",
|
|
1590
|
-
stroke: "currentColor",
|
|
1591
|
-
strokeWidth: "2"
|
|
1592
|
-
}, React__default.createElement("path", {
|
|
1593
|
-
strokeLinecap: "round",
|
|
1594
|
-
strokeLinejoin: "round",
|
|
1595
|
-
d: "M14 5l7 7m0 0l-7 7m7-7H3"
|
|
1596
|
-
})))));
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
function ToastItem(_ref) {
|
|
1600
|
-
var _ref$_id = _ref._id,
|
|
1601
|
-
_id = _ref$_id === void 0 ? '' : _ref$_id,
|
|
1602
|
-
message = _ref.message,
|
|
1603
|
-
_ref$status = _ref.status,
|
|
1604
|
-
status = _ref$status === void 0 ? 'default' : _ref$status;
|
|
1605
|
-
|
|
1606
|
-
var _useToast = useToast(),
|
|
1607
|
-
removeToast = _useToast.removeToast;
|
|
1608
|
-
|
|
1609
|
-
var defaultClasses = 'w-full min-w-[250px] p-4 shadow flex justify-between items-center font-black rounded-md not:';
|
|
1610
|
-
var statusClasses = status === 'success' && 'bg-accent text-white' || status === 'error' && 'bg-red-500 text-white' || status === 'warning' && 'bg-yellow-400 text-white' || 'bg-white text-primary';
|
|
1611
|
-
var classes = defaultClasses + " " + statusClasses;
|
|
1612
|
-
|
|
1613
|
-
function handleClick() {
|
|
1614
|
-
removeToast(_id);
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
return React__default.createElement(react$1.Transition, {
|
|
1618
|
-
show: true,
|
|
1619
|
-
appear: true,
|
|
1620
|
-
enter: "transition-all duration-300",
|
|
1621
|
-
enterFrom: "opacity-0 translate-y-4",
|
|
1622
|
-
enterTo: "opacity-100 translate-y-0",
|
|
1623
|
-
leave: "transition-all duration-300",
|
|
1624
|
-
leaveFrom: "opacity-100 translate-y-0",
|
|
1625
|
-
leaveTo: "opacity-0 translate-y-2"
|
|
1626
|
-
}, React__default.createElement("div", {
|
|
1627
|
-
className: classes
|
|
1628
|
-
}, React__default.createElement("p", null, message), React__default.createElement("button", {
|
|
1629
|
-
className: "",
|
|
1630
|
-
onClick: handleClick,
|
|
1631
|
-
title: "Close message"
|
|
1632
|
-
}, React__default.createElement("svg", {
|
|
1633
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1634
|
-
fill: "none",
|
|
1635
|
-
viewBox: "0 0 24 24",
|
|
1636
|
-
stroke: "currentColor",
|
|
1637
|
-
className: "h-6 w-6"
|
|
1638
|
-
}, React__default.createElement("path", {
|
|
1639
|
-
strokeLinecap: "round",
|
|
1640
|
-
strokeLinejoin: "round",
|
|
1641
|
-
strokeWidth: "2",
|
|
1642
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
1643
|
-
})))));
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
function Toasts() {
|
|
1647
|
-
var _useToast = useToast(),
|
|
1648
|
-
toasts = _useToast.toasts;
|
|
1649
|
-
|
|
1650
|
-
return React__default.createElement("div", {
|
|
1651
|
-
className: "fixed bottom-4 right-4 z-[120] flex flex-col gap-6"
|
|
1652
|
-
}, toasts.map(function (toast) {
|
|
1653
|
-
return React__default.createElement(ToastItem, Object.assign({}, toast, {
|
|
1654
|
-
key: toast._id
|
|
1655
|
-
}));
|
|
1656
|
-
}));
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
function Modal(_ref) {
|
|
1660
|
-
var children = _ref.children,
|
|
1661
|
-
_ref$isActive = _ref.isActive,
|
|
1662
|
-
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
1663
|
-
onClose = _ref.onClose,
|
|
1664
|
-
title = _ref.title,
|
|
1665
|
-
_ref$width = _ref.width,
|
|
1666
|
-
width = _ref$width === void 0 ? '' : _ref$width,
|
|
1667
|
-
_ref$className = _ref.className,
|
|
1668
|
-
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1669
|
-
return React__default.createElement(react$1.Transition.Root, {
|
|
1670
|
-
show: isActive,
|
|
1671
|
-
as: React.Fragment
|
|
1672
|
-
}, React__default.createElement(react$1.Dialog, {
|
|
1673
|
-
as: "div",
|
|
1674
|
-
className: "fixed z-[110] inset-0 overflow-y-auto",
|
|
1675
|
-
onClose: onClose
|
|
1676
|
-
}, React__default.createElement("div", {
|
|
1677
|
-
className: "flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"
|
|
1678
|
-
}, React__default.createElement(react$1.Transition.Child, {
|
|
1679
|
-
as: React.Fragment,
|
|
1680
|
-
enter: "ease-out duration-300",
|
|
1681
|
-
enterFrom: "opacity-0",
|
|
1682
|
-
enterTo: "opacity-100",
|
|
1683
|
-
leave: "ease-in duration-200",
|
|
1684
|
-
leaveFrom: "opacity-100",
|
|
1685
|
-
leaveTo: "opacity-0"
|
|
1686
|
-
}, React__default.createElement(react$1.Dialog.Overlay, {
|
|
1687
|
-
className: "fixed inset-0 bg-gray-500/75 transition-opacity"
|
|
1688
|
-
})), React__default.createElement(react$1.Transition.Child, {
|
|
1689
|
-
as: React.Fragment,
|
|
1690
|
-
enter: "ease-out duration-300",
|
|
1691
|
-
enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
1692
|
-
enterTo: "opacity-100 translate-y-0 sm:scale-100",
|
|
1693
|
-
leave: "ease-in duration-200",
|
|
1694
|
-
leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
|
|
1695
|
-
leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
1696
|
-
}, React__default.createElement("div", {
|
|
1697
|
-
className: 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-7xl sm:p-6 " + width
|
|
1698
|
-
}, React__default.createElement("div", {
|
|
1699
|
-
className: "flex gap-4 mb-4 text-primary " + (title ? 'border-b-2 border-primary pb-4' : '')
|
|
1700
|
-
}, title && React__default.createElement("h3", {
|
|
1701
|
-
className: "font-black text-lg"
|
|
1702
|
-
}, title), React__default.createElement("button", {
|
|
1703
|
-
type: "button",
|
|
1704
|
-
onClick: onClose,
|
|
1705
|
-
className: "ml-auto transition-all hover:opacity-50"
|
|
1706
|
-
}, React__default.createElement("svg", {
|
|
1707
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1708
|
-
className: "h-6 w-6",
|
|
1709
|
-
fill: "none",
|
|
1710
|
-
viewBox: "0 0 24 24",
|
|
1711
|
-
stroke: "currentColor",
|
|
1712
|
-
strokeWidth: 2
|
|
1713
|
-
}, React__default.createElement("path", {
|
|
1714
|
-
strokeLinecap: "round",
|
|
1715
|
-
strokeLinejoin: "round",
|
|
1716
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
1717
|
-
})))), React__default.createElement("div", null, children))))));
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
var _excluded = ["children"];
|
|
1721
|
-
function Table(_ref) {
|
|
1722
|
-
var children = _ref.children,
|
|
1723
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1724
|
-
|
|
1725
|
-
return React__default.createElement("div", {
|
|
1726
|
-
className: "-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8 text-sm"
|
|
1727
|
-
}, React__default.createElement("div", {
|
|
1728
|
-
className: "inline-block min-w-full py-2 align-middle md:px-6 lg:px-8"
|
|
1729
|
-
}, React__default.createElement("div", {
|
|
1730
|
-
className: "overflow-hidden shadow ring-1 ring-gray-300 ring-opacity-5 md:rounded-lg"
|
|
1731
|
-
}, React__default.createElement("table", Object.assign({}, props, {
|
|
1732
|
-
className: "min-w-full divide-y divide-gray-300"
|
|
1733
|
-
}), children))));
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
function TableActions(_ref) {
|
|
1737
|
-
var children = _ref.children,
|
|
1738
|
-
_ref$className = _ref.className,
|
|
1739
|
-
className = _ref$className === void 0 ? '' : _ref$className;
|
|
1740
|
-
return React__default.createElement("div", {
|
|
1741
|
-
className: className + " flex gap-4 justify-end items-center"
|
|
1742
|
-
}, children);
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
var _excluded$1 = ["children", "className"];
|
|
1746
|
-
function TableBody(_ref) {
|
|
1747
|
-
var children = _ref.children,
|
|
1748
|
-
className = _ref.className,
|
|
1749
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1750
|
-
|
|
1751
|
-
return React__default.createElement("tbody", Object.assign({}, props, {
|
|
1752
|
-
className: cn(className, 'divide-y divide-gray-200 bg-white')
|
|
1753
|
-
}), children);
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
var _excluded$2 = ["children", "className", "condensed"];
|
|
1757
|
-
function TableCell(_ref) {
|
|
1758
|
-
var children = _ref.children,
|
|
1759
|
-
className = _ref.className,
|
|
1760
|
-
condensed = _ref.condensed,
|
|
1761
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1762
|
-
|
|
1763
|
-
return React__default.createElement("td", Object.assign({}, props, {
|
|
1764
|
-
className: cn(className, 'px-3 py-3 text-sm text-gray-500', {
|
|
1765
|
-
'w-0 whitespace-nowrap': condensed
|
|
1766
|
-
})
|
|
1767
|
-
}), children);
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
var _excluded$3 = ["children", "className"];
|
|
1771
|
-
function TableHead(_ref) {
|
|
1772
|
-
var children = _ref.children,
|
|
1773
|
-
className = _ref.className,
|
|
1774
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
1775
|
-
|
|
1776
|
-
return React__default.createElement("thead", Object.assign({}, props, {
|
|
1777
|
-
className: cn(className, 'px-3 py-4 text-sm text-white bg-primary')
|
|
1778
|
-
}), children);
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
var _excluded$4 = ["children", "className", "sort", "textAlign", "condensed"];
|
|
1782
|
-
function TableHeader(_ref) {
|
|
1783
|
-
var children = _ref.children,
|
|
1784
|
-
_ref$className = _ref.className,
|
|
1785
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1786
|
-
sort = _ref.sort,
|
|
1787
|
-
_ref$textAlign = _ref.textAlign,
|
|
1788
|
-
textAlign = _ref$textAlign === void 0 ? 'left' : _ref$textAlign,
|
|
1789
|
-
condensed = _ref.condensed,
|
|
1790
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
1791
|
-
|
|
1792
|
-
var _React$useState = React__default.useState(''),
|
|
1793
|
-
sortLink = _React$useState[0],
|
|
1794
|
-
setSortLink = _React$useState[1];
|
|
1795
|
-
|
|
1796
|
-
React__default.useEffect(function () {
|
|
1797
|
-
if (typeof window !== 'undefined' && sort) {
|
|
1798
|
-
var query = new URLSearchParams(window.location.search);
|
|
1799
|
-
var direction = 'asc';
|
|
1800
|
-
|
|
1801
|
-
if (query.get('sort')) {
|
|
1802
|
-
var _query$get;
|
|
1803
|
-
|
|
1804
|
-
// Choose the opposite direction for sorting
|
|
1805
|
-
direction = (_query$get = query.get('sort')) != null && _query$get.includes('asc') ? 'desc' : 'asc';
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
query.set('sort', sort + " " + direction);
|
|
1809
|
-
setSortLink("?" + query.toString());
|
|
1810
|
-
}
|
|
1811
|
-
}, []);
|
|
1812
|
-
var textAlignClass = textAlign === 'center' && 'text-center justify-center' || textAlign === 'right' && 'text-right justify-end' || 'text-left justify-between';
|
|
1813
|
-
return React__default.createElement("th", Object.assign({}, props, {
|
|
1814
|
-
className: cn(className, 'py-3.5 px-3 text-sm font-semibold text-left', {
|
|
1815
|
-
'w-0 whitespace-nowrap': condensed
|
|
1816
|
-
})
|
|
1817
|
-
}), React__default.createElement("div", {
|
|
1818
|
-
className: "flex items-center gap-3 " + textAlignClass
|
|
1819
|
-
}, children, sort && React__default.createElement(react.Link, {
|
|
1820
|
-
href: sortLink
|
|
1821
|
-
}, React__default.createElement("svg", {
|
|
1822
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1823
|
-
className: "h-5 w-5",
|
|
1824
|
-
fill: "none",
|
|
1825
|
-
viewBox: "0 0 24 24",
|
|
1826
|
-
stroke: "currentColor",
|
|
1827
|
-
strokeWidth: "2"
|
|
1828
|
-
}, React__default.createElement("path", {
|
|
1829
|
-
strokeLinecap: "round",
|
|
1830
|
-
strokeLinejoin: "round",
|
|
1831
|
-
d: "M8 9l4-4 4 4m0 6l-4 4-4-4"
|
|
1832
|
-
})))));
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
var _excluded$5 = ["children", "className", "onClick"];
|
|
1836
|
-
function TableRow(_ref) {
|
|
1837
|
-
var children = _ref.children,
|
|
1838
|
-
_ref$className = _ref.className,
|
|
1839
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1840
|
-
_ref$onClick = _ref.onClick,
|
|
1841
|
-
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
1842
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
1843
|
-
|
|
1844
|
-
var bgClass = className.includes('bg') ? '' : 'bg-white even:bg-gray-50';
|
|
1845
|
-
return React__default.createElement("tr", Object.assign({}, props, {
|
|
1846
|
-
className: cn(className, bgClass, 'hover:bg-gray-100'),
|
|
1847
|
-
onClick: function onClick(e) {
|
|
1848
|
-
return _onClick(e);
|
|
1849
|
-
}
|
|
1850
|
-
}), children);
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
function DateOfBirthField(_ref) {
|
|
1854
|
-
var _ref$name = _ref.name,
|
|
1855
|
-
name = _ref$name === void 0 ? 'dob' : _ref$name,
|
|
1856
|
-
_ref$id = _ref.id,
|
|
1857
|
-
id = _ref$id === void 0 ? 'dob' : _ref$id,
|
|
1858
|
-
onChange = _ref.onChange,
|
|
1859
|
-
value = _ref.value,
|
|
1860
|
-
_ref$maxYear = _ref.maxYear,
|
|
1861
|
-
maxYear = _ref$maxYear === void 0 ? 0 : _ref$maxYear,
|
|
1862
|
-
_ref$showAge = _ref.showAge,
|
|
1863
|
-
showAge = _ref$showAge === void 0 ? false : _ref$showAge,
|
|
1864
|
-
_ref$isRequired = _ref.isRequired,
|
|
1865
|
-
isRequired = _ref$isRequired === void 0 ? true : _ref$isRequired;
|
|
1866
|
-
var dayOptions = [].concat(Array.from(Array(31).keys())).map(function (value) {
|
|
1867
|
-
return lodash.padStart("" + (value + 1), 2, '0');
|
|
1868
|
-
});
|
|
1869
|
-
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
1870
|
-
var monthOptions = [].concat(Array.from(Array(12).keys())).map(function (value) {
|
|
1871
|
-
return {
|
|
1872
|
-
title: months[value],
|
|
1873
|
-
value: lodash.padStart("" + (value + 1), 2, '0')
|
|
1874
|
-
};
|
|
1875
|
-
}); // Create 100 years of options, subtracting the maximum year if provided
|
|
1876
|
-
|
|
1877
|
-
var yearOptions = [].concat(Array.from(Array(100).keys())).map(function (value) {
|
|
1878
|
-
return maxYear ? maxYear - value : new Date().getFullYear() - value;
|
|
1879
|
-
});
|
|
1880
|
-
|
|
1881
|
-
function handleChange(e) {
|
|
1882
|
-
var _e$currentTarget = e.currentTarget,
|
|
1883
|
-
name = _e$currentTarget.name,
|
|
1884
|
-
value = _e$currentTarget.value;
|
|
1885
|
-
var y = name.includes('year') ? value : year;
|
|
1886
|
-
var m = name.includes('month') ? value : month;
|
|
1887
|
-
var d = name.includes('day') ? value : day;
|
|
1888
|
-
onChange(y + "-" + m + "-" + d);
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
var _ref2 = value ? value.split('-') : ['', '', ''],
|
|
1892
|
-
year = _ref2[0],
|
|
1893
|
-
month = _ref2[1],
|
|
1894
|
-
day = _ref2[2];
|
|
1895
|
-
|
|
1896
|
-
var isValidDate = year && month && day && !isNaN(Date.parse(year + "-" + month + "-" + day));
|
|
1897
|
-
var styleReq = {
|
|
1898
|
-
backgroundPosition: 'top 10px right 3px, center right 10px'
|
|
1899
|
-
};
|
|
1900
|
-
var style = {
|
|
1901
|
-
backgroundPosition: 'right 0.5rem center',
|
|
1902
|
-
paddingRight: '1.5rem'
|
|
1903
|
-
};
|
|
1904
|
-
return React__default.createElement("span", {
|
|
1905
|
-
className: "flex flex-col gap-2"
|
|
1906
|
-
}, React__default.createElement("span", {
|
|
1907
|
-
className: "flex w-full border border-gray-300 rounded-lg bg-white"
|
|
1908
|
-
}, React__default.createElement("select", {
|
|
1909
|
-
name: name + "_day",
|
|
1910
|
-
id: id + "_day",
|
|
1911
|
-
value: day,
|
|
1912
|
-
className: "flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",
|
|
1913
|
-
onChange: handleChange,
|
|
1914
|
-
required: isRequired,
|
|
1915
|
-
style: isRequired ? styleReq : style
|
|
1916
|
-
}, React__default.createElement("option", {
|
|
1917
|
-
value: ""
|
|
1918
|
-
}, "Day"), dayOptions.map(function (option) {
|
|
1919
|
-
return React__default.createElement("option", {
|
|
1920
|
-
key: option,
|
|
1921
|
-
value: option
|
|
1922
|
-
}, option);
|
|
1923
|
-
})), React__default.createElement("select", {
|
|
1924
|
-
name: name + "_month",
|
|
1925
|
-
id: id + "_month",
|
|
1926
|
-
value: month,
|
|
1927
|
-
className: "flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",
|
|
1928
|
-
onChange: handleChange,
|
|
1929
|
-
required: isRequired,
|
|
1930
|
-
style: isRequired ? styleReq : style
|
|
1931
|
-
}, React__default.createElement("option", {
|
|
1932
|
-
value: ""
|
|
1933
|
-
}, "Month"), monthOptions.map(function (option) {
|
|
1934
|
-
return React__default.createElement("option", {
|
|
1935
|
-
key: option.value,
|
|
1936
|
-
value: option.value
|
|
1937
|
-
}, option.title);
|
|
1938
|
-
})), React__default.createElement("select", {
|
|
1939
|
-
name: name + "_year",
|
|
1940
|
-
id: id + "_year",
|
|
1941
|
-
value: year,
|
|
1942
|
-
className: "flex-grow focus:outline-none border-0 !mr-[3px] lg:pl-4 xl:pl-2",
|
|
1943
|
-
onChange: handleChange,
|
|
1944
|
-
required: isRequired,
|
|
1945
|
-
style: isRequired ? styleReq : style
|
|
1946
|
-
}, React__default.createElement("option", {
|
|
1947
|
-
value: ""
|
|
1948
|
-
}, "Year"), yearOptions.map(function (option) {
|
|
1949
|
-
return React__default.createElement("option", {
|
|
1950
|
-
key: option,
|
|
1951
|
-
value: option
|
|
1952
|
-
}, option);
|
|
1953
|
-
}))), showAge && value && isValidDate && React__default.createElement("span", {
|
|
1954
|
-
className: "font-bold"
|
|
1955
|
-
}, "Age: ", calculateAge(value), " years"));
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
function MoneyField(_ref) {
|
|
1959
|
-
var _ref$value = _ref.value,
|
|
1960
|
-
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
1961
|
-
onChange = _ref.onChange,
|
|
1962
|
-
_ref$name = _ref.name,
|
|
1963
|
-
name = _ref$name === void 0 ? 'value' : _ref$name,
|
|
1964
|
-
_ref$id = _ref.id,
|
|
1965
|
-
id = _ref$id === void 0 ? 'value' : _ref$id,
|
|
1966
|
-
_ref$className = _ref.className,
|
|
1967
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1968
|
-
_ref$required = _ref.required,
|
|
1969
|
-
required = _ref$required === void 0 ? false : _ref$required;
|
|
1970
|
-
|
|
1971
|
-
function handleChange(e) {
|
|
1972
|
-
var newValue = 0;
|
|
1973
|
-
|
|
1974
|
-
if (e.currentTarget.value) {
|
|
1975
|
-
newValue = formatNumber(e.currentTarget.value);
|
|
1976
|
-
|
|
1977
|
-
if (isNaN(newValue)) {
|
|
1978
|
-
newValue = 0;
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
onChange(newValue);
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
var displayValue = formatMoney(value, 0);
|
|
1986
|
-
return React__default.createElement("div", {
|
|
1987
|
-
className: className + " flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-accent focus-within:outline-none focus-within:ring focus-within:ring-accent focus-within:ring-opacity-50"
|
|
1988
|
-
}, React__default.createElement("span", {
|
|
1989
|
-
className: "font-bold pr-2"
|
|
1990
|
-
}, "$"), React__default.createElement("input", {
|
|
1991
|
-
type: "text",
|
|
1992
|
-
name: name,
|
|
1993
|
-
id: id,
|
|
1994
|
-
value: displayValue,
|
|
1995
|
-
onChange: handleChange,
|
|
1996
|
-
className: "w-full !focus:outline-none !focus:ring-0 !focus:ring-transparent !focus:ring-opacity-0 !ring-0 !border-0 !transition-none !rounded-l-none",
|
|
1997
|
-
required: required
|
|
1998
|
-
}));
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
var conditionOptions = ['POOR', 'FAIR', 'AVERAGE', 'GOOD', 'VERY_GOOD', 'AS_NEW', 'NEW'];
|
|
2002
|
-
function RegistrationSearchField(_ref) {
|
|
2003
|
-
var _ref$name = _ref.name,
|
|
2004
|
-
name = _ref$name === void 0 ? 'registration_search' : _ref$name,
|
|
2005
|
-
_ref$initialRegistrat = _ref.initialRegistrationValue,
|
|
2006
|
-
initialRegistrationValue = _ref$initialRegistrat === void 0 ? '' : _ref$initialRegistrat,
|
|
2007
|
-
onVehicleDataFound = _ref.onVehicleDataFound,
|
|
2008
|
-
_ref$apiUrl = _ref.apiUrl,
|
|
2009
|
-
apiUrl = _ref$apiUrl === void 0 ? '/api/rego-search' : _ref$apiUrl,
|
|
2010
|
-
_ref$showOdometerRead = _ref.showOdometerReadingField,
|
|
2011
|
-
showOdometerReadingField = _ref$showOdometerRead === void 0 ? false : _ref$showOdometerRead,
|
|
2012
|
-
_ref$showConditionFie = _ref.showConditionField,
|
|
2013
|
-
showConditionField = _ref$showConditionFie === void 0 ? false : _ref$showConditionFie,
|
|
2014
|
-
onChange = _ref.onChange,
|
|
2015
|
-
outerClassName = _ref.outerClassName,
|
|
2016
|
-
odoInputClassName = _ref.odoInputClassName,
|
|
2017
|
-
conditionSelectClassName = _ref.conditionSelectClassName,
|
|
2018
|
-
regoInputClassName = _ref.regoInputClassName,
|
|
2019
|
-
searchBtnClassName = _ref.searchBtnClassName;
|
|
2020
|
-
|
|
2021
|
-
var _React$useState = React__default.useState(initialRegistrationValue),
|
|
2022
|
-
rego = _React$useState[0],
|
|
2023
|
-
setRego = _React$useState[1];
|
|
2024
|
-
|
|
2025
|
-
var _React$useState2 = React__default.useState(''),
|
|
2026
|
-
odo = _React$useState2[0],
|
|
2027
|
-
setOdo = _React$useState2[1];
|
|
2028
|
-
|
|
2029
|
-
var _React$useState3 = React__default.useState('GOOD'),
|
|
2030
|
-
condition = _React$useState3[0],
|
|
2031
|
-
setCondition = _React$useState3[1];
|
|
2032
|
-
|
|
2033
|
-
var _React$useState4 = React__default.useState('idle'),
|
|
2034
|
-
status = _React$useState4[0],
|
|
2035
|
-
setStatus = _React$useState4[1];
|
|
2036
|
-
|
|
2037
|
-
var _useToast = useToast(),
|
|
2038
|
-
addToast = _useToast.addToast;
|
|
2039
|
-
|
|
2040
|
-
function handleChange(e) {
|
|
2041
|
-
if (e.currentTarget.name === name) {
|
|
2042
|
-
var _e$currentTarget$valu;
|
|
2043
|
-
|
|
2044
|
-
setRego(((_e$currentTarget$valu = e.currentTarget.value) == null ? void 0 : _e$currentTarget$valu.toUpperCase()) || '');
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
if (e.currentTarget.name === 'odo_search') {
|
|
2048
|
-
setOdo(e.currentTarget.value);
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
if (e.currentTarget.name === 'condition_search') {
|
|
2052
|
-
setCondition(e.currentTarget.value);
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
if (onChange) {
|
|
2056
|
-
onChange({
|
|
2057
|
-
registration: e.currentTarget.value.toUpperCase()
|
|
2058
|
-
});
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
function handleKeydown(e) {
|
|
2063
|
-
if (e.key === 'Enter') {
|
|
2064
|
-
handleSearch();
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
function handleSearch() {
|
|
2069
|
-
return _handleSearch.apply(this, arguments);
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
function _handleSearch() {
|
|
2073
|
-
_handleSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2074
|
-
var payload, query, res, _yield$res$json, data, ok, vehicleData, make, model, year, weight, vehicleType;
|
|
2075
|
-
|
|
2076
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2077
|
-
while (1) {
|
|
2078
|
-
switch (_context.prev = _context.next) {
|
|
2079
|
-
case 0:
|
|
2080
|
-
setStatus('processing');
|
|
2081
|
-
payload = {
|
|
2082
|
-
registration: rego,
|
|
2083
|
-
odometerReading: odo,
|
|
2084
|
-
condition: condition
|
|
2085
|
-
}; // Turn the payload in to a query string
|
|
2086
|
-
// @ts-ignore
|
|
2087
|
-
|
|
2088
|
-
query = new URLSearchParams(payload).toString();
|
|
2089
|
-
_context.next = 5;
|
|
2090
|
-
return fetch(apiUrl + "?" + query, {
|
|
2091
|
-
headers: {
|
|
2092
|
-
'Content-Type': 'application/json'
|
|
2093
|
-
}
|
|
2094
|
-
});
|
|
2095
|
-
|
|
2096
|
-
case 5:
|
|
2097
|
-
res = _context.sent;
|
|
2098
|
-
|
|
2099
|
-
if (res.ok) {
|
|
2100
|
-
_context.next = 10;
|
|
2101
|
-
break;
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
addToast({
|
|
2105
|
-
message: "There was an error with the provided registration.",
|
|
2106
|
-
status: 'error',
|
|
2107
|
-
timeout: 3000
|
|
2108
|
-
});
|
|
2109
|
-
setStatus('error');
|
|
2110
|
-
return _context.abrupt("return");
|
|
2111
|
-
|
|
2112
|
-
case 10:
|
|
2113
|
-
_context.next = 12;
|
|
2114
|
-
return res.json();
|
|
2115
|
-
|
|
2116
|
-
case 12:
|
|
2117
|
-
_yield$res$json = _context.sent;
|
|
2118
|
-
data = _yield$res$json.data;
|
|
2119
|
-
ok = _yield$res$json.ok;
|
|
2120
|
-
|
|
2121
|
-
if (!(!ok || !data)) {
|
|
2122
|
-
_context.next = 19;
|
|
2123
|
-
break;
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
addToast({
|
|
2127
|
-
message: "Failed to find vehicle, please complete manually.",
|
|
2128
|
-
status: 'error',
|
|
2129
|
-
timeout: 3000
|
|
2130
|
-
});
|
|
2131
|
-
setStatus('error');
|
|
2132
|
-
return _context.abrupt("return");
|
|
2133
|
-
|
|
2134
|
-
case 19:
|
|
2135
|
-
vehicleData = data.data.vehicle;
|
|
2136
|
-
make = vehicleData.make;
|
|
2137
|
-
model = vehicleData.model;
|
|
2138
|
-
year = vehicleData['year-of-manufacture'];
|
|
2139
|
-
weight = vehicleData['gross-vehicle-mass'] ? parseInt(vehicleData['gross-vehicle-mass'].replaceAll(',', '')) : 0;
|
|
2140
|
-
vehicleType = vehicleData['vehicle-type'];
|
|
2141
|
-
|
|
2142
|
-
if (!make || !model || !year || !vehicleType) {
|
|
2143
|
-
addToast({
|
|
2144
|
-
message: "We couldn't find all of your data, please complete manually.",
|
|
2145
|
-
status: 'error',
|
|
2146
|
-
timeout: 3000
|
|
2147
|
-
});
|
|
2148
|
-
setStatus('error');
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
onVehicleDataFound(_extends({}, data, {
|
|
2152
|
-
make: make || '',
|
|
2153
|
-
model: model || '',
|
|
2154
|
-
year: year || '',
|
|
2155
|
-
vehicle_type: vehicleType ? sanitiseVehicleType(vehicleType) : 'car',
|
|
2156
|
-
is_heavy: weight && weight > 3500 || false
|
|
2157
|
-
}));
|
|
2158
|
-
setStatus('success');
|
|
2159
|
-
|
|
2160
|
-
case 28:
|
|
2161
|
-
case "end":
|
|
2162
|
-
return _context.stop();
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
}, _callee);
|
|
2166
|
-
}));
|
|
2167
|
-
return _handleSearch.apply(this, arguments);
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
return React__default.createElement("div", {
|
|
2171
|
-
className: "w-full flex flex-col"
|
|
2172
|
-
}, React__default.createElement("div", {
|
|
2173
|
-
className: cn(outerClassName, "w-full flex flex-wrap gap-3 bg-gray-100 rounded-md p-3")
|
|
2174
|
-
}, showOdometerReadingField || showConditionField && React__default.createElement("div", {
|
|
2175
|
-
className: "w-full grid grid-cols-2 gap-3"
|
|
2176
|
-
}, showOdometerReadingField && React__default.createElement("label", null, "Approx. km travelled", React__default.createElement("input", {
|
|
2177
|
-
onKeyDown: handleKeydown,
|
|
2178
|
-
type: "number",
|
|
2179
|
-
name: "odo_search",
|
|
2180
|
-
id: "odo_search",
|
|
2181
|
-
value: odo,
|
|
2182
|
-
onChange: handleChange,
|
|
2183
|
-
className: cn(odoInputClassName, "transition-all", {
|
|
2184
|
-
'pointer-events-none opacity-50': status === 'processing'
|
|
2185
|
-
}),
|
|
2186
|
-
disabled: status === 'processing'
|
|
2187
|
-
})), showConditionField && React__default.createElement("label", null, "Vehicle condition", React__default.createElement("select", {
|
|
2188
|
-
name: "condition_search",
|
|
2189
|
-
id: "condition_search",
|
|
2190
|
-
value: condition,
|
|
2191
|
-
onChange: handleChange,
|
|
2192
|
-
className: cn(conditionSelectClassName, "transition-all", {
|
|
2193
|
-
'pointer-events-none opacity-50': status === 'processing'
|
|
2194
|
-
}),
|
|
2195
|
-
disabled: status === 'processing'
|
|
2196
|
-
}, conditionOptions.map(function (conditionOption) {
|
|
2197
|
-
return React__default.createElement("option", {
|
|
2198
|
-
key: conditionOption
|
|
2199
|
-
}, conditionOption);
|
|
2200
|
-
})))), React__default.createElement("input", {
|
|
2201
|
-
onKeyDown: handleKeydown,
|
|
2202
|
-
placeholder: "Search for your rego",
|
|
2203
|
-
type: "text",
|
|
2204
|
-
name: name,
|
|
2205
|
-
id: name,
|
|
2206
|
-
value: rego,
|
|
2207
|
-
onChange: handleChange,
|
|
2208
|
-
className: cn(regoInputClassName, "flex-grow transition-all", {
|
|
2209
|
-
'pointer-events-none opacity-50': status === 'processing'
|
|
2210
|
-
}),
|
|
2211
|
-
disabled: status === 'processing'
|
|
2212
|
-
}), React__default.createElement("button", {
|
|
2213
|
-
title: "Search",
|
|
2214
|
-
type: "button",
|
|
2215
|
-
onClick: handleSearch,
|
|
2216
|
-
disabled: status === 'processing',
|
|
2217
|
-
className: cn(searchBtnClassName, "bg-accent px-4 py-3 rounded-md transition-all")
|
|
2218
|
-
}, React__default.createElement("span", {
|
|
2219
|
-
className: "sr-only"
|
|
2220
|
-
}, "Search"), React__default.createElement("svg", {
|
|
2221
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2222
|
-
className: "h-5 w-5 text-white",
|
|
2223
|
-
fill: "none",
|
|
2224
|
-
viewBox: "0 0 24 24",
|
|
2225
|
-
stroke: "currentColor",
|
|
2226
|
-
strokeWidth: "2"
|
|
2227
|
-
}, React__default.createElement("path", {
|
|
2228
|
-
strokeLinecap: "round",
|
|
2229
|
-
strokeLinejoin: "round",
|
|
2230
|
-
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
2231
|
-
})))));
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
|
-
function FormTester(_ref) {
|
|
2235
|
-
var _ref$populatePurchase = _ref.populatePurchaseOptions,
|
|
2236
|
-
populatePurchaseOptions = _ref$populatePurchase === void 0 ? false : _ref$populatePurchase;
|
|
2237
|
-
|
|
2238
|
-
var _useQuoteRequestForm = useQuoteRequestForm(),
|
|
2239
|
-
form = _useQuoteRequestForm.form;
|
|
2240
|
-
|
|
2241
|
-
var _React$useState = React__default.useState([]),
|
|
2242
|
-
keys = _React$useState[0],
|
|
2243
|
-
setKeys = _React$useState[1];
|
|
2244
|
-
|
|
2245
|
-
var _React$useState2 = React__default.useState(false),
|
|
2246
|
-
isDev = _React$useState2[0],
|
|
2247
|
-
setDev = _React$useState2[1];
|
|
2248
|
-
|
|
2249
|
-
function handlePopulate() {
|
|
2250
|
-
form == null ? void 0 : form.setData(function (prevData) {
|
|
2251
|
-
return _extends({}, prevData, {
|
|
2252
|
-
first_name: 'TEST',
|
|
2253
|
-
last_name: 'TEST',
|
|
2254
|
-
email: 'dev@sual.co.nz',
|
|
2255
|
-
phone: '021 234 5678',
|
|
2256
|
-
mobile: '021 234 5678',
|
|
2257
|
-
dob: '1990-01-01',
|
|
2258
|
-
licence: 'Other',
|
|
2259
|
-
licence_other: 'Test',
|
|
2260
|
-
club_id: 50,
|
|
2261
|
-
club_membership_number: '12345',
|
|
2262
|
-
street_address: {
|
|
2263
|
-
address: '123 Street Name',
|
|
2264
|
-
unit: 'Level 1',
|
|
2265
|
-
suburb: 'Suburb',
|
|
2266
|
-
city: 'Auckland',
|
|
2267
|
-
post_code: '1234'
|
|
2268
|
-
},
|
|
2269
|
-
promo_code: 'TEST',
|
|
2270
|
-
declaration: {
|
|
2271
|
-
had_incident: true,
|
|
2272
|
-
incidents: [{
|
|
2273
|
-
description: 'Lorem ipsum dolor sit amet.',
|
|
2274
|
-
month: 'January',
|
|
2275
|
-
year: '2020'
|
|
2276
|
-
}],
|
|
2277
|
-
has_demerit_points: true,
|
|
2278
|
-
demerit_points: '1-24',
|
|
2279
|
-
has_lost_licence: true,
|
|
2280
|
-
lost_licence_details: 'Lorem ipsum dolor sit amet.',
|
|
2281
|
-
was_refused_insurance: true,
|
|
2282
|
-
refused_insurance_details: 'Lorem ipsum dolor sit amet.',
|
|
2283
|
-
has_criminal_conviction: true,
|
|
2284
|
-
criminal_conviction_details: 'Lorem ipsum dolor sit amet.',
|
|
2285
|
-
has_vehicle_modifications: true,
|
|
2286
|
-
vehicle_modifications_details: 'Lorem ipsum dolor sit amet.',
|
|
2287
|
-
has_previous_insurer: true,
|
|
2288
|
-
previous_insurer_details: 'AA',
|
|
2289
|
-
previous_insurer_expires_at: '2020-01-01',
|
|
2290
|
-
additional_details: 'I am a robot, beep boop. Please ignore this submission.'
|
|
2291
|
-
},
|
|
2292
|
-
vehicles: [{
|
|
2293
|
-
make: 'Tesla',
|
|
2294
|
-
model: 'Cybertruck',
|
|
2295
|
-
year: '2023',
|
|
2296
|
-
registration: 'ELMUSK',
|
|
2297
|
-
vehicle_type: 'car',
|
|
2298
|
-
product: 'star-enthusiast-prestige-everyday-plus',
|
|
2299
|
-
value: 100000,
|
|
2300
|
-
is_heavy: false,
|
|
2301
|
-
usage: 'Childrens car',
|
|
2302
|
-
storage_location: 'Carport',
|
|
2303
|
-
has_financially_interested_party: true,
|
|
2304
|
-
financially_interested_party_detail: 'MTA',
|
|
2305
|
-
owned_duration: 'Less than 12 months',
|
|
2306
|
-
main_driver: 'TEST TEST',
|
|
2307
|
-
drivers: [{
|
|
2308
|
-
first_name: 'X Æ',
|
|
2309
|
-
last_name: 'A-12',
|
|
2310
|
-
dob: '2000-05-04',
|
|
2311
|
-
licence: 'Other',
|
|
2312
|
-
licence_other: 'None',
|
|
2313
|
-
relationship: 'Child',
|
|
2314
|
-
key: 'driver-test-key'
|
|
2315
|
-
}],
|
|
2316
|
-
key: 'vehicle-test-key'
|
|
2317
|
-
}],
|
|
2318
|
-
purchase_options: populatePurchaseOptions ? [{
|
|
2319
|
-
premium_type: 'annual',
|
|
2320
|
-
level_of_insurance_id: 12,
|
|
2321
|
-
authorised_drivers: 'TEST',
|
|
2322
|
-
excess_details: 'TEST',
|
|
2323
|
-
terms: 'TEST',
|
|
2324
|
-
description: 'This is a test purchase option',
|
|
2325
|
-
premium: 100000,
|
|
2326
|
-
monthly_premium: 8500,
|
|
2327
|
-
show_monthly: true,
|
|
2328
|
-
fsl: 100,
|
|
2329
|
-
sort_order: 1,
|
|
2330
|
-
enhancements: [{
|
|
2331
|
-
name: 'Test enhancement',
|
|
2332
|
-
premium: 2500,
|
|
2333
|
-
disable_rounding: false,
|
|
2334
|
-
description: 'Test enhancement',
|
|
2335
|
-
auto_select: true,
|
|
2336
|
-
key: 'enhancement-test-key-1'
|
|
2337
|
-
}, {
|
|
2338
|
-
name: 'Test enhancement',
|
|
2339
|
-
premium: 5000,
|
|
2340
|
-
disable_rounding: false,
|
|
2341
|
-
description: 'Test enhancement',
|
|
2342
|
-
auto_select: false,
|
|
2343
|
-
key: 'enhancement-test-key-2'
|
|
2344
|
-
}],
|
|
2345
|
-
key: 'purchase-option-test-key-annual'
|
|
2346
|
-
}, {
|
|
2347
|
-
premium_type: 'total-due',
|
|
2348
|
-
level_of_insurance_id: 13,
|
|
2349
|
-
authorised_drivers: 'TEST',
|
|
2350
|
-
excess_details: 'TEST',
|
|
2351
|
-
terms: 'TEST',
|
|
2352
|
-
description: 'This is a test purchase option',
|
|
2353
|
-
premium: 100000,
|
|
2354
|
-
show_monthly: false,
|
|
2355
|
-
fsl: 100,
|
|
2356
|
-
sort_order: 2,
|
|
2357
|
-
enhancements: [{
|
|
2358
|
-
name: 'Test enhancement',
|
|
2359
|
-
premium: 2500,
|
|
2360
|
-
disable_rounding: false,
|
|
2361
|
-
description: 'Test enhancement',
|
|
2362
|
-
auto_select: true,
|
|
2363
|
-
key: 'enhancement-test-key-3'
|
|
2364
|
-
}, {
|
|
2365
|
-
name: 'Test enhancement',
|
|
2366
|
-
premium: 5000,
|
|
2367
|
-
disable_rounding: false,
|
|
2368
|
-
description: 'Test enhancement',
|
|
2369
|
-
auto_select: false,
|
|
2370
|
-
key: 'enhancement-test-key-4'
|
|
2371
|
-
}],
|
|
2372
|
-
key: 'purchase-option-test-key-total-due'
|
|
2373
|
-
}] : []
|
|
2374
|
-
});
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
function handleKeydown(e) {
|
|
2379
|
-
if (e.key === 'Escape') {
|
|
2380
|
-
return setKeys([]);
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
|
-
setKeys(function (prevKeys) {
|
|
2384
|
-
return [].concat(prevKeys, [e.key]);
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
React__default.useEffect(function () {
|
|
2389
|
-
// Detect when the user has typed the word "debug"
|
|
2390
|
-
if (keys.join('') === 'debug') {
|
|
2391
|
-
handlePopulate();
|
|
2392
|
-
}
|
|
2393
|
-
}, [keys]);
|
|
2394
|
-
React__default.useEffect(function () {
|
|
2395
|
-
if (typeof window !== 'undefined') {
|
|
2396
|
-
if (window.location.href.includes('dev') || window.location.href.includes('localhost') || window.location.href.includes('test') || window.location.href.includes('local')) {
|
|
2397
|
-
setDev(true);
|
|
2398
|
-
}
|
|
2399
|
-
|
|
2400
|
-
window.addEventListener('keydown', function (e) {
|
|
2401
|
-
return handleKeydown(e);
|
|
2402
|
-
});
|
|
2403
|
-
return function () {
|
|
2404
|
-
window.removeEventListener('keydown', function (e) {
|
|
2405
|
-
return handleKeydown(e);
|
|
2406
|
-
});
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
|
-
return;
|
|
2411
|
-
}, []);
|
|
2412
|
-
|
|
2413
|
-
if (isDev) {
|
|
2414
|
-
return React__default.createElement(Button, {
|
|
2415
|
-
onClick: handlePopulate,
|
|
2416
|
-
type: "button",
|
|
2417
|
-
status: "primary",
|
|
2418
|
-
className: "fixed bottom-4 right-4"
|
|
2419
|
-
}, "Populate data");
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
return React__default.createElement(React__default.Fragment, null);
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
function ErrorList(_ref) {
|
|
2426
|
-
var _ref$heading = _ref.heading,
|
|
2427
|
-
heading = _ref$heading === void 0 ? 'There was an error with your submission.' : _ref$heading,
|
|
2428
|
-
_ref$errors = _ref.errors,
|
|
2429
|
-
errors = _ref$errors === void 0 ? {} : _ref$errors,
|
|
2430
|
-
_ref$renderKeys = _ref.renderKeys,
|
|
2431
|
-
renderKeys = _ref$renderKeys === void 0 ? false : _ref$renderKeys,
|
|
2432
|
-
_ref$className = _ref.className,
|
|
2433
|
-
className = _ref$className === void 0 ? '' : _ref$className;
|
|
2434
|
-
|
|
2435
|
-
if (Object.values(errors).length === 0) {
|
|
2436
|
-
return React__default.createElement(React__default.Fragment, null);
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
return React__default.createElement("aside", {
|
|
2440
|
-
className: className + " col-span-full"
|
|
2441
|
-
}, React__default.createElement(Card, {
|
|
2442
|
-
className: "border border-red-500 !bg-red-50"
|
|
2443
|
-
}, React__default.createElement("h2", {
|
|
2444
|
-
className: "font-black text-red-500 mb-2"
|
|
2445
|
-
}, heading), React__default.createElement("ul", {
|
|
2446
|
-
className: "space-y-2 list-disc ml-4"
|
|
2447
|
-
}, Object.entries(errors).map(function (_ref2) {
|
|
2448
|
-
var field = _ref2[0],
|
|
2449
|
-
message = _ref2[1];
|
|
2450
|
-
return React__default.createElement("li", {
|
|
2451
|
-
className: "font-bold text-red-500",
|
|
2452
|
-
key: field
|
|
2453
|
-
}, renderKeys && React__default.createElement("strong", null, field, ": "), message);
|
|
2454
|
-
}))));
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
function BackButton(_ref) {
|
|
2458
|
-
var back = _ref.back,
|
|
2459
|
-
className = _ref.className;
|
|
2460
|
-
|
|
2461
|
-
var _React$useState = React__default.useState(typeof back === 'string' ? back : undefined),
|
|
2462
|
-
backUrl = _React$useState[0],
|
|
2463
|
-
setBackUrl = _React$useState[1];
|
|
2464
|
-
|
|
2465
|
-
var breadcrumbs = usePage().props.breadcrumbs;
|
|
2466
|
-
/**
|
|
2467
|
-
* Set the back URL on mount
|
|
2468
|
-
*/
|
|
2469
|
-
|
|
2470
|
-
React__default.useEffect(function () {
|
|
2471
|
-
if (typeof window !== 'undefined') {
|
|
2472
|
-
if (!breadcrumbs) return; // Set back button URL
|
|
2473
|
-
|
|
2474
|
-
if (back && typeof back === 'boolean') {
|
|
2475
|
-
// If we haven't provided a path as a prop, use the last breadcrumb that's not the current one
|
|
2476
|
-
var crumb = breadcrumbs.slice(breadcrumbs.length - 2, breadcrumbs.length - 1);
|
|
2477
|
-
|
|
2478
|
-
if (crumb && crumb.length === 1) {
|
|
2479
|
-
// Strip off everything but the path so the <Link> component works
|
|
2480
|
-
var url = crumb[0].url;
|
|
2481
|
-
|
|
2482
|
-
if (url) {
|
|
2483
|
-
setBackUrl(new URL(url).pathname);
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
}, [breadcrumbs]);
|
|
2489
|
-
return React__default.createElement(react.Link, {
|
|
2490
|
-
href: backUrl || '/',
|
|
2491
|
-
className: cn(className, 'flex items-center justify-center text-primary hover:text-accent transition-all')
|
|
2492
|
-
}, React__default.createElement(hi2.HiArrowLeft, {
|
|
2493
|
-
className: "h-5 w-5 stroke-[1.25]"
|
|
2494
|
-
}));
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
function SearchBar(_ref) {
|
|
2498
|
-
var search = _ref.search,
|
|
2499
|
-
active = _ref.active,
|
|
2500
|
-
onActive = _ref.onActive,
|
|
2501
|
-
placeholder = _ref.placeholder,
|
|
2502
|
-
_ref$focusSearchShort = _ref.focusSearchShortcut,
|
|
2503
|
-
focusSearchShortcut = _ref$focusSearchShort === void 0 ? false : _ref$focusSearchShort;
|
|
2504
|
-
|
|
2505
|
-
var _React$useState = React__default.useState(''),
|
|
2506
|
-
query = _React$useState[0],
|
|
2507
|
-
setQuery = _React$useState[1];
|
|
2508
|
-
|
|
2509
|
-
var searchRef = React__default.useRef(null);
|
|
2510
|
-
/**
|
|
2511
|
-
* Populate search input on load
|
|
2512
|
-
*/
|
|
2513
|
-
|
|
2514
|
-
React__default.useEffect(function () {
|
|
2515
|
-
if (typeof window !== 'undefined') {
|
|
2516
|
-
// Populate search
|
|
2517
|
-
var _search = new URLSearchParams(window.location.search);
|
|
2518
|
-
|
|
2519
|
-
var q = _search.get('search');
|
|
2520
|
-
|
|
2521
|
-
if (q) {
|
|
2522
|
-
setQuery(q);
|
|
2523
|
-
onActive(true);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
var listener = function listener(e) {
|
|
2528
|
-
if (focusSearchShortcut && e.key === '/') {
|
|
2529
|
-
e.preventDefault();
|
|
2530
|
-
onActive(true);
|
|
2531
|
-
}
|
|
2532
|
-
|
|
2533
|
-
if (e.key === 'Escape') {
|
|
2534
|
-
onActive(false);
|
|
2535
|
-
}
|
|
2536
|
-
};
|
|
2537
|
-
|
|
2538
|
-
window.addEventListener('keydown', listener);
|
|
2539
|
-
return function () {
|
|
2540
|
-
window.removeEventListener('keydown', listener);
|
|
2541
|
-
};
|
|
2542
|
-
}, [focusSearchShortcut]);
|
|
2543
|
-
/**
|
|
2544
|
-
* Minimise the search bar on click outside if there's no search query
|
|
2545
|
-
*/
|
|
2546
|
-
|
|
2547
|
-
useClickOutside(searchRef, function () {
|
|
2548
|
-
if (!query) {
|
|
2549
|
-
onActive(false);
|
|
2550
|
-
}
|
|
2551
|
-
});
|
|
2552
|
-
/**
|
|
2553
|
-
* Handle the search function
|
|
2554
|
-
*/
|
|
2555
|
-
|
|
2556
|
-
function handleSearch(e, queryOverride) {
|
|
2557
|
-
var _window;
|
|
2558
|
-
|
|
2559
|
-
e == null ? void 0 : e.preventDefault();
|
|
2560
|
-
if (typeof search !== 'string') return;
|
|
2561
|
-
var path = search;
|
|
2562
|
-
|
|
2563
|
-
if (path[0] !== '/') {
|
|
2564
|
-
path = "/" + path;
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
var params = new URLSearchParams((_window = window) == null ? void 0 : _window.location.search);
|
|
2568
|
-
params.set('search', queryOverride != null ? queryOverride : query);
|
|
2569
|
-
params.set('page', '1');
|
|
2570
|
-
react.router.get(path + "?" + params.toString());
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
return React__default.createElement("div", {
|
|
2574
|
-
ref: searchRef,
|
|
2575
|
-
className: ""
|
|
2576
|
-
}, !active && React__default.createElement("button", {
|
|
2577
|
-
title: "Open Search Bar",
|
|
2578
|
-
type: "button",
|
|
2579
|
-
onClick: function onClick() {
|
|
2580
|
-
return onActive(true);
|
|
2581
|
-
},
|
|
2582
|
-
className: "flex items-center justify-center rounded-full hover:text-accent p-1 hover:bg-gray-100"
|
|
2583
|
-
}, React__default.createElement(hi2.HiMagnifyingGlass, {
|
|
2584
|
-
className: "h-5 w-5 stroke-[1.25]"
|
|
2585
|
-
})), active && React__default.createElement("form", {
|
|
2586
|
-
onSubmit: handleSearch,
|
|
2587
|
-
className: "group flex items-center gap-2 rounded-full bg-white pr-4 pl-1 shadow transition-all focus-within:outline-none focus-within:ring-1 focus-within:ring-accent"
|
|
2588
|
-
}, React__default.createElement("input", {
|
|
2589
|
-
type: "text",
|
|
2590
|
-
name: "search",
|
|
2591
|
-
id: "search",
|
|
2592
|
-
value: query,
|
|
2593
|
-
onChange: function onChange(e) {
|
|
2594
|
-
return setQuery(e.currentTarget.value || '');
|
|
2595
|
-
},
|
|
2596
|
-
className: "no-focus-shadow !focus:border-0 !border-0 !bg-transparent !shadow-none !ring-opacity-0 !transition-none placeholder:text-gray-400 !py-1.5 text-sm",
|
|
2597
|
-
autoFocus: true,
|
|
2598
|
-
placeholder: placeholder
|
|
2599
|
-
}), query && React__default.createElement("button", {
|
|
2600
|
-
type: "button",
|
|
2601
|
-
title: "Clear Search",
|
|
2602
|
-
onClick: function onClick() {
|
|
2603
|
-
setQuery('');
|
|
2604
|
-
handleSearch(undefined, '');
|
|
2605
|
-
}
|
|
2606
|
-
}, React__default.createElement(hi2.HiXMark, {
|
|
2607
|
-
className: "h-5 w-5"
|
|
2608
|
-
})), React__default.createElement("button", {
|
|
2609
|
-
type: "submit"
|
|
2610
|
-
}, React__default.createElement(hi2.HiMagnifyingGlass, {
|
|
2611
|
-
className: "h-5 w-5"
|
|
2612
|
-
}))));
|
|
2613
|
-
}
|
|
2614
|
-
|
|
2615
|
-
function Action(_ref) {
|
|
2616
|
-
var title = _ref.title,
|
|
2617
|
-
href = _ref.href,
|
|
2618
|
-
_ref$as = _ref.as,
|
|
2619
|
-
as = _ref$as === void 0 ? 'Link' : _ref$as,
|
|
2620
|
-
_ref$target = _ref.target,
|
|
2621
|
-
target = _ref$target === void 0 ? '_self' : _ref$target,
|
|
2622
|
-
type = _ref.type,
|
|
2623
|
-
_ref$onClick = _ref.onClick,
|
|
2624
|
-
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
2625
|
-
shortcutKey = _ref.shortcutKey,
|
|
2626
|
-
backgroundColor = _ref.backgroundColor,
|
|
2627
|
-
textColor = _ref.textColor,
|
|
2628
|
-
actions = _ref.actions;
|
|
2629
|
-
|
|
2630
|
-
var backgroundColorClass = backgroundColor ? "bg-" + backgroundColor : 'bg-white';
|
|
2631
|
-
var textColorClass = textColor ? "text-" + textColor : '';
|
|
2632
|
-
var colorClass = (backgroundColorClass + " " + textColorClass).trim();
|
|
2633
|
-
var className = colorClass + ' rounded-full font-bold px-4 py-1.5 text-sm whitespace-nowrap hover:bg-gray-100 hover:border-gray-400 transition-colors border border-gray-300';
|
|
2634
|
-
var tooltipId = "action-" + title;
|
|
2635
|
-
var tooltipContent = shortcutKey ? "Ctrl + " + shortcutKey : undefined;
|
|
2636
|
-
var actionButtonRef = React__default.useRef(null);
|
|
2637
|
-
var isActionsButton = actions && actions.length > 0;
|
|
2638
|
-
var actionsButtonClassName = 'relative cursor-pointer ' + className;
|
|
2639
|
-
|
|
2640
|
-
var _React$useState = React__default.useState(false),
|
|
2641
|
-
isInnerActionVisible = _React$useState[0],
|
|
2642
|
-
setIsInnerActionVisible = _React$useState[1];
|
|
2643
|
-
|
|
2644
|
-
var toggleActionsMenu = function toggleActionsMenu() {
|
|
2645
|
-
setIsInnerActionVisible(!isInnerActionVisible);
|
|
2646
|
-
};
|
|
2647
|
-
|
|
2648
|
-
useClickOutside(actionButtonRef, function () {
|
|
2649
|
-
return setIsInnerActionVisible(false);
|
|
2650
|
-
});
|
|
2651
|
-
|
|
2652
|
-
function runAction() {
|
|
2653
|
-
if (as === 'Link' && href) {
|
|
2654
|
-
return react.router.get(href);
|
|
2655
|
-
}
|
|
2656
|
-
|
|
2657
|
-
if (as === 'a' && href) {
|
|
2658
|
-
return window.location.href = href;
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
_onClick();
|
|
2662
|
-
}
|
|
2663
|
-
React__default.useEffect(function () {
|
|
2664
|
-
if (typeof window === 'undefined') return;
|
|
2665
|
-
if (!shortcutKey) return;
|
|
2666
|
-
|
|
2667
|
-
var listener = function listener(e) {
|
|
2668
|
-
// Check if Ctrl (Windows) or Cmd (Mac) key is pressed
|
|
2669
|
-
var isCtrlOrCmdPressed = e.ctrlKey || e.metaKey; // Check if the focus is on an input element or inside a form
|
|
2670
|
-
|
|
2671
|
-
var isInInput = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement;
|
|
2672
|
-
var isInForm = e.target instanceof Element && e.target.closest('form');
|
|
2673
|
-
|
|
2674
|
-
if (isCtrlOrCmdPressed && !isInInput && !isInForm && e.key === shortcutKey) {
|
|
2675
|
-
e.preventDefault();
|
|
2676
|
-
runAction();
|
|
2677
|
-
}
|
|
2678
|
-
};
|
|
2679
|
-
|
|
2680
|
-
window.addEventListener('keydown', listener);
|
|
2681
|
-
return function () {
|
|
2682
|
-
window.removeEventListener('keydown', listener);
|
|
2683
|
-
};
|
|
2684
|
-
}, [shortcutKey]);
|
|
2685
|
-
|
|
2686
|
-
if (isActionsButton) {
|
|
2687
|
-
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2688
|
-
id: tooltipId,
|
|
2689
|
-
className: "z-10"
|
|
2690
|
-
}), React__default.createElement("div", {
|
|
2691
|
-
ref: actionButtonRef,
|
|
2692
|
-
"data-tooltip-id": tooltipId,
|
|
2693
|
-
"data-tooltip-content": tooltipContent,
|
|
2694
|
-
className: actionsButtonClassName,
|
|
2695
|
-
onClick: toggleActionsMenu
|
|
2696
|
-
}, title, isInnerActionVisible && React__default.createElement("div", {
|
|
2697
|
-
className: "absolute top-[120%] right-[-20%] z-10"
|
|
2698
|
-
}, React__default.createElement("div", {
|
|
2699
|
-
className: "flex flex-col gap-2 bg-white rounded-lg shadow-xl p-3"
|
|
2700
|
-
}, actions && actions.map(function (action, index) {
|
|
2701
|
-
if (action.hidden) return null;
|
|
2702
|
-
return React__default.createElement(Action, {
|
|
2703
|
-
key: index,
|
|
2704
|
-
title: action.title,
|
|
2705
|
-
as: action.as,
|
|
2706
|
-
href: action.href,
|
|
2707
|
-
target: action.target,
|
|
2708
|
-
onClick: action.onClick,
|
|
2709
|
-
type: 'button'
|
|
2710
|
-
});
|
|
2711
|
-
})))));
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
if (as === 'Link' && href) {
|
|
2715
|
-
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2716
|
-
id: tooltipId,
|
|
2717
|
-
className: "z-10"
|
|
2718
|
-
}), React__default.createElement(react.Link, {
|
|
2719
|
-
"data-tooltip-id": tooltipId,
|
|
2720
|
-
"data-tooltip-content": tooltipContent,
|
|
2721
|
-
className: className,
|
|
2722
|
-
href: href,
|
|
2723
|
-
onClick: function onClick() {
|
|
2724
|
-
return _onClick();
|
|
2725
|
-
}
|
|
2726
|
-
}, title));
|
|
2727
|
-
}
|
|
2728
|
-
|
|
2729
|
-
if (as === 'a' && href) {
|
|
2730
|
-
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2731
|
-
id: tooltipId,
|
|
2732
|
-
className: "z-10"
|
|
2733
|
-
}), React__default.createElement("a", {
|
|
2734
|
-
"data-tooltip-id": tooltipId,
|
|
2735
|
-
"data-tooltip-content": tooltipContent,
|
|
2736
|
-
className: className,
|
|
2737
|
-
target: target,
|
|
2738
|
-
href: href,
|
|
2739
|
-
onClick: function onClick() {
|
|
2740
|
-
return _onClick();
|
|
2741
|
-
}
|
|
2742
|
-
}, title));
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
return React__default.createElement(React__default.Fragment, null, tooltipContent && React__default.createElement(reactTooltip.Tooltip, {
|
|
2746
|
-
id: tooltipId,
|
|
2747
|
-
className: "z-10"
|
|
2748
|
-
}), React__default.createElement("button", {
|
|
2749
|
-
"data-tooltip-id": tooltipId,
|
|
2750
|
-
"data-tooltip-content": tooltipContent,
|
|
2751
|
-
className: className,
|
|
2752
|
-
type: type,
|
|
2753
|
-
onClick: function onClick() {
|
|
2754
|
-
return _onClick();
|
|
2755
|
-
}
|
|
2756
|
-
}, title));
|
|
2757
|
-
}
|
|
2758
|
-
|
|
2759
|
-
function Dropdown(_ref) {
|
|
2760
|
-
var onClose = _ref.onClose,
|
|
2761
|
-
active = _ref.active,
|
|
2762
|
-
title = _ref.title,
|
|
2763
|
-
children = _ref.children;
|
|
2764
|
-
var ref = React__default.useRef(null);
|
|
2765
|
-
var innerRef = React__default.useRef(null);
|
|
2766
|
-
useClickOutside(ref, function () {
|
|
2767
|
-
return onClose(false);
|
|
2768
|
-
});
|
|
2769
|
-
React__default.useEffect(function () {
|
|
2770
|
-
var current = ref == null ? void 0 : ref.current;
|
|
2771
|
-
var innerCurrent = innerRef.current;
|
|
2772
|
-
current == null ? void 0 : current.classList.toggle('active', active);
|
|
2773
|
-
if (!current || !innerCurrent) return;
|
|
2774
|
-
var pos = current == null ? void 0 : current.getBoundingClientRect();
|
|
2775
|
-
innerCurrent.style.setProperty('left', (pos == null ? void 0 : pos.left) + "px");
|
|
2776
|
-
}, [active, ref.current, innerRef.current]);
|
|
2777
|
-
return React__default.createElement("div", {
|
|
2778
|
-
ref: ref,
|
|
2779
|
-
className: "static inline-block"
|
|
2780
|
-
}, title, active && React__default.createElement("div", {
|
|
2781
|
-
ref: innerRef,
|
|
2782
|
-
className: "absolute children z-10 flex flex-col"
|
|
2783
|
-
}, children));
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
function FilterItem(_ref) {
|
|
2787
|
-
var _filter$options, _filter$options2, _filter$options3, _selected$, _selected$2, _selected$3;
|
|
2788
|
-
|
|
2789
|
-
var filter = _ref.filter;
|
|
2790
|
-
|
|
2791
|
-
var _React$useState = React__default.useState(false),
|
|
2792
|
-
isOpen = _React$useState[0],
|
|
2793
|
-
setOpen = _React$useState[1];
|
|
2794
|
-
|
|
2795
|
-
var _React$useState2 = React__default.useState([]),
|
|
2796
|
-
selected = _React$useState2[0],
|
|
2797
|
-
setSelected = _React$useState2[1];
|
|
2798
|
-
|
|
2799
|
-
var _React$useState3 = React__default.useState([]),
|
|
2800
|
-
selectedOptions = _React$useState3[0],
|
|
2801
|
-
setSelectedOptions = _React$useState3[1]; // Filter type: select
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
var hasFilters = selected.length > 0; // Populate values on load
|
|
2805
|
-
|
|
2806
|
-
React__default.useEffect(function () {
|
|
2807
|
-
if (typeof window !== 'undefined') {
|
|
2808
|
-
var search = new URLSearchParams(window.location.search);
|
|
2809
|
-
|
|
2810
|
-
if (filter.type === 'date') {
|
|
2811
|
-
var fromDate = search.get(filter.name + "[from]");
|
|
2812
|
-
var toDate = search.get(filter.name + "[to]");
|
|
2813
|
-
|
|
2814
|
-
if (fromDate && toDate) {
|
|
2815
|
-
setSelected([fromDate, toDate]);
|
|
2816
|
-
}
|
|
2817
|
-
} else if (filter.type === 'greaterThan') {
|
|
2818
|
-
var selectedFromUrl = search.getAll(filter.name + "-GTE");
|
|
2819
|
-
|
|
2820
|
-
if (selectedFromUrl) {
|
|
2821
|
-
setSelected(selectedFromUrl);
|
|
2822
|
-
}
|
|
2823
|
-
} else if (filter.type === 'scope') {
|
|
2824
|
-
var _selectedFromUrl = search.getAll("scope" + filter.name);
|
|
2825
|
-
|
|
2826
|
-
if (_selectedFromUrl) {
|
|
2827
|
-
setSelected(_selectedFromUrl);
|
|
2828
|
-
}
|
|
2829
|
-
} else if (filter.type === 'select') {
|
|
2830
|
-
var _selectedFromUrl2 = search.getAll(filter.name + "[]");
|
|
2831
|
-
|
|
2832
|
-
if (_selectedFromUrl2) {
|
|
2833
|
-
setSelected(_selectedFromUrl2);
|
|
2834
|
-
|
|
2835
|
-
var _selectedOptions = filter.options && filter.options.filter(function (item) {
|
|
2836
|
-
return _selectedFromUrl2.includes(item.value.toString());
|
|
2837
|
-
});
|
|
2838
|
-
|
|
2839
|
-
_selectedOptions && setSelectedOptions(_selectedOptions);
|
|
2840
|
-
}
|
|
2841
|
-
} else {
|
|
2842
|
-
var _selectedFromUrl3 = search.getAll(filter.name + "[]");
|
|
2843
|
-
|
|
2844
|
-
if (_selectedFromUrl3) {
|
|
2845
|
-
setSelected(_selectedFromUrl3);
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
}, []);
|
|
2850
|
-
|
|
2851
|
-
function handleInput(e) {
|
|
2852
|
-
var _e$currentTarget = e.currentTarget,
|
|
2853
|
-
value = _e$currentTarget.value,
|
|
2854
|
-
checked = _e$currentTarget.checked;
|
|
2855
|
-
|
|
2856
|
-
if (checked) {
|
|
2857
|
-
setSelected(function (curr) {
|
|
2858
|
-
return [].concat(curr, [value]);
|
|
2859
|
-
});
|
|
2860
|
-
} else {
|
|
2861
|
-
setSelected(selected.filter(function (f) {
|
|
2862
|
-
return f !== value;
|
|
2863
|
-
}));
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
|
|
2867
|
-
function handleDateSelect(e) {
|
|
2868
|
-
var _e$currentTarget2 = e.currentTarget,
|
|
2869
|
-
name = _e$currentTarget2.name,
|
|
2870
|
-
value = _e$currentTarget2.value; // First value in "selected" will be the "from", second will be the "to"
|
|
2871
|
-
|
|
2872
|
-
if (name.includes('from')) {
|
|
2873
|
-
return setSelected([value]);
|
|
2874
|
-
}
|
|
2875
|
-
|
|
2876
|
-
if (name.includes('to')) {
|
|
2877
|
-
// Make sure we have a "from" value first
|
|
2878
|
-
if (selected.length === 0) {
|
|
2879
|
-
// We'll default to a year ago if nothing entered
|
|
2880
|
-
return setSelected([dateFns.format(dateFns.subYears(new Date(), 1), 'yyyy-MM-dd'), value]);
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
return setSelected([selected[0], value]);
|
|
2884
|
-
}
|
|
2885
|
-
|
|
2886
|
-
return setSelected([]);
|
|
2887
|
-
}
|
|
2888
|
-
/**
|
|
2889
|
-
* Handle Select for FilterType: Select
|
|
2890
|
-
*/
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
var handleSelectedOptions = function handleSelectedOptions(options) {
|
|
2894
|
-
setSelectedOptions(options);
|
|
2895
|
-
var selectedValues = options.map(function (option) {
|
|
2896
|
-
return option.value.toString();
|
|
2897
|
-
});
|
|
2898
|
-
|
|
2899
|
-
if (selectedValues.length > 0) {
|
|
2900
|
-
setSelected(selectedValues);
|
|
2901
|
-
} else {
|
|
2902
|
-
setSelected([]);
|
|
2903
|
-
}
|
|
2904
|
-
};
|
|
2905
|
-
/**
|
|
2906
|
-
* For Filter Select
|
|
2907
|
-
* Removes the Clear Button
|
|
2908
|
-
*/
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
function NullComponent() {
|
|
2912
|
-
return null;
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
|
-
function handleSelect(e) {
|
|
2916
|
-
var value = e.currentTarget.value;
|
|
2917
|
-
|
|
2918
|
-
if (value) {
|
|
2919
|
-
setSelected([value]);
|
|
2920
|
-
} else {
|
|
2921
|
-
setSelected([]);
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
|
|
2925
|
-
function handleText(e) {
|
|
2926
|
-
var value = e.currentTarget.value;
|
|
2927
|
-
|
|
2928
|
-
if (value) {
|
|
2929
|
-
setSelected([value]);
|
|
2930
|
-
} else {
|
|
2931
|
-
setSelected([]);
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2935
|
-
function handleApply(e) {
|
|
2936
|
-
e.preventDefault();
|
|
2937
|
-
var search = new URLSearchParams(window.location.search); // Reset the page in the query
|
|
2938
|
-
|
|
2939
|
-
search.set('page', '1');
|
|
2940
|
-
|
|
2941
|
-
if (filter.type === 'date') {
|
|
2942
|
-
var from = selected[0],
|
|
2943
|
-
to = selected[1];
|
|
2944
|
-
search.set(filter.name + "[from]", from != null ? from : dateFns.format(new Date(), 'yyyy-MM-dd'));
|
|
2945
|
-
search.set(filter.name + "[to]", to != null ? to : dateFns.format(new Date(), 'yyyy-MM-dd'));
|
|
2946
|
-
} else if (filter.type === 'greaterThan') {
|
|
2947
|
-
search["delete"](filter.name + "-GTE");
|
|
2948
|
-
|
|
2949
|
-
if (selected.length > 0) {
|
|
2950
|
-
search.set(filter.name + "-GTE", selected[0]);
|
|
2951
|
-
}
|
|
2952
|
-
} else if (filter.type === 'scope') {
|
|
2953
|
-
search["delete"]("" + filter.name);
|
|
2954
|
-
|
|
2955
|
-
if (selected.length > 0) {
|
|
2956
|
-
search.set("scope" + filter.name, selected[0]);
|
|
2957
|
-
}
|
|
2958
|
-
} else {
|
|
2959
|
-
// Clear this filter first
|
|
2960
|
-
search["delete"](filter.name + "[]"); // Apply the filters to the query string
|
|
2961
|
-
|
|
2962
|
-
selected.forEach(function (selectedValue) {
|
|
2963
|
-
// Fall back to option equality filters
|
|
2964
|
-
search.append(filter.name + "[]", selectedValue);
|
|
2965
|
-
});
|
|
2966
|
-
} // Fetch new data
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
react.router.get(window.location.pathname + "?" + search.toString());
|
|
2970
|
-
}
|
|
2971
|
-
|
|
2972
|
-
function handleClear() {
|
|
2973
|
-
var search = new URLSearchParams(window.location.search); // Reset the page in the query
|
|
2974
|
-
|
|
2975
|
-
search.set('page', '1'); // Clear this filter
|
|
2976
|
-
|
|
2977
|
-
if (filter.type === 'date') {
|
|
2978
|
-
search["delete"](filter.name + "[from]");
|
|
2979
|
-
search["delete"](filter.name + "[to]");
|
|
2980
|
-
} else if (filter.type === 'greaterThan') {
|
|
2981
|
-
search["delete"](filter.name + "-GTE");
|
|
2982
|
-
} else if (filter.type === 'scope') {
|
|
2983
|
-
search["delete"]("scope" + filter.name);
|
|
2984
|
-
} else {
|
|
2985
|
-
search["delete"](filter.name + "[]");
|
|
2986
|
-
} // Fetch new data
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
react.router.get(window.location.pathname + "?" + search.toString());
|
|
2990
|
-
}
|
|
2991
|
-
|
|
2992
|
-
function handleClick(force) {
|
|
2993
|
-
if (typeof force === 'boolean') {
|
|
2994
|
-
return setOpen(force);
|
|
2995
|
-
}
|
|
2996
|
-
|
|
2997
|
-
setOpen(!isOpen);
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
|
-
return React__default.createElement(Dropdown, {
|
|
3001
|
-
onClose: function onClose() {
|
|
3002
|
-
return setOpen(!open);
|
|
3003
|
-
},
|
|
3004
|
-
active: isOpen,
|
|
3005
|
-
title: React__default.createElement("div", {
|
|
3006
|
-
onClick: function onClick() {
|
|
3007
|
-
return handleClick();
|
|
3008
|
-
},
|
|
3009
|
-
className: cn('flex rounded-2xl border hover:cursor-pointer hover:border-accent bg-gray-600 px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-accent transition-colors', {
|
|
3010
|
-
'!bg-accent border-accent': hasFilters
|
|
3011
|
-
})
|
|
3012
|
-
}, React__default.createElement("p", {
|
|
3013
|
-
className: "whitespace-nowrap"
|
|
3014
|
-
}, filter.label), React__default.createElement(hi2.HiChevronDown, null))
|
|
3015
|
-
}, React__default.createElement("form", {
|
|
3016
|
-
className: "mt-2 flex max-h-[350px] min-w-[200px] max-w-[260px] flex-col gap-2 rounded-md border border-gray-300 bg-white shadow-lg " + (filter.type && filter.type === 'select' ? '' : 'overflow-y-scroll'),
|
|
3017
|
-
onSubmit: handleApply
|
|
3018
|
-
}, React__default.createElement("div", {
|
|
3019
|
-
className: "flex flex-col items-start gap-1 p-4"
|
|
3020
|
-
}, (!filter.type || filter.type === 'options') && ((_filter$options = filter.options) == null ? void 0 : _filter$options.map(function (option, i) {
|
|
3021
|
-
return React__default.createElement("div", {
|
|
3022
|
-
className: "checkbox text-sm ",
|
|
3023
|
-
key: option.label + "-" + i
|
|
3024
|
-
}, React__default.createElement("input", {
|
|
3025
|
-
type: "checkbox",
|
|
3026
|
-
name: filter.name,
|
|
3027
|
-
id: option.label,
|
|
3028
|
-
value: option.value.toString(),
|
|
3029
|
-
checked: selected.includes(option.value.toString()),
|
|
3030
|
-
onChange: handleInput
|
|
3031
|
-
}), React__default.createElement("label", {
|
|
3032
|
-
className: "leading-tight",
|
|
3033
|
-
htmlFor: option.label
|
|
3034
|
-
}, option.label));
|
|
3035
|
-
})), filter.type === 'greaterThan' && filter.options && React__default.createElement("label", {
|
|
3036
|
-
className: "mb-2 w-full"
|
|
3037
|
-
}, React__default.createElement("div", {
|
|
3038
|
-
className: "text-sm"
|
|
3039
|
-
}, "Greater than or equal to"), React__default.createElement("select", {
|
|
3040
|
-
name: filter.name,
|
|
3041
|
-
id: filter.label,
|
|
3042
|
-
value: selected[0],
|
|
3043
|
-
onChange: handleSelect,
|
|
3044
|
-
className: "!p-2 text-sm w-full"
|
|
3045
|
-
}, React__default.createElement("option", {
|
|
3046
|
-
value: ""
|
|
3047
|
-
}, "Select option"), (_filter$options2 = filter.options) == null ? void 0 : _filter$options2.map(function (option) {
|
|
3048
|
-
return React__default.createElement("option", {
|
|
3049
|
-
key: option.value,
|
|
3050
|
-
value: option.value
|
|
3051
|
-
}, option.label);
|
|
3052
|
-
}))), filter.type === 'scope' && filter.options && React__default.createElement("label", {
|
|
3053
|
-
className: "mb-2 w-full"
|
|
3054
|
-
}, React__default.createElement("select", {
|
|
3055
|
-
name: filter.name,
|
|
3056
|
-
id: filter.label,
|
|
3057
|
-
value: selected[0],
|
|
3058
|
-
onChange: handleSelect,
|
|
3059
|
-
className: "!p-2 text-sm w-full"
|
|
3060
|
-
}, React__default.createElement("option", {
|
|
3061
|
-
value: ""
|
|
3062
|
-
}, "Select option"), (_filter$options3 = filter.options) == null ? void 0 : _filter$options3.map(function (option) {
|
|
3063
|
-
return React__default.createElement("option", {
|
|
3064
|
-
key: option.value,
|
|
3065
|
-
value: option.value
|
|
3066
|
-
}, option.label);
|
|
3067
|
-
}))), filter.type === 'date' && React__default.createElement("div", {
|
|
3068
|
-
className: "mb-2 flex flex-col gap-4 w-full"
|
|
3069
|
-
}, React__default.createElement("label", {
|
|
3070
|
-
className: "text-xs w-full"
|
|
3071
|
-
}, "From", React__default.createElement("input", {
|
|
3072
|
-
type: "date",
|
|
3073
|
-
name: filter.name + "[from]",
|
|
3074
|
-
id: filter.name + "[from]",
|
|
3075
|
-
onChange: handleDateSelect,
|
|
3076
|
-
value: (_selected$ = selected[0]) != null ? _selected$ : '',
|
|
3077
|
-
className: "!p-2 text-sm w-full"
|
|
3078
|
-
})), React__default.createElement("label", {
|
|
3079
|
-
className: "text-xs w-full"
|
|
3080
|
-
}, "To", React__default.createElement("input", {
|
|
3081
|
-
type: "date",
|
|
3082
|
-
name: filter.name + "[to]",
|
|
3083
|
-
id: filter.name + "[to]",
|
|
3084
|
-
onChange: handleDateSelect,
|
|
3085
|
-
value: (_selected$2 = selected[1]) != null ? _selected$2 : '',
|
|
3086
|
-
className: "!p-2 text-sm w-full"
|
|
3087
|
-
}))), filter.type === 'select' && filter.options && React__default.createElement("div", {
|
|
3088
|
-
className: "w-full"
|
|
3089
|
-
}, React__default.createElement(Select, {
|
|
3090
|
-
isMulti: true,
|
|
3091
|
-
options: filter.options,
|
|
3092
|
-
className: "basic-multi-select text-xs w-52 !transition-none",
|
|
3093
|
-
classNamePrefix: "select",
|
|
3094
|
-
onChange: handleSelectedOptions,
|
|
3095
|
-
components: {
|
|
3096
|
-
ClearIndicator: NullComponent
|
|
3097
|
-
},
|
|
3098
|
-
value: selectedOptions,
|
|
3099
|
-
theme: function theme(_theme) {
|
|
3100
|
-
return _extends({}, _theme, {
|
|
3101
|
-
colors: _extends({}, _theme.colors, {
|
|
3102
|
-
primary25: 'rgb(111, 199, 182)',
|
|
3103
|
-
primary: 'rgb(111, 199, 182)'
|
|
3104
|
-
})
|
|
3105
|
-
});
|
|
3106
|
-
}
|
|
3107
|
-
})), filter.type === 'text' && React__default.createElement("div", {
|
|
3108
|
-
className: 'w-full'
|
|
3109
|
-
}, React__default.createElement("input", {
|
|
3110
|
-
type: "text",
|
|
3111
|
-
name: filter.name,
|
|
3112
|
-
placeholder: filter.label,
|
|
3113
|
-
value: (_selected$3 = selected[0]) != null ? _selected$3 : '',
|
|
3114
|
-
onChange: handleText,
|
|
3115
|
-
className: "!p-2 text-sm w-full"
|
|
3116
|
-
}))), React__default.createElement("div", {
|
|
3117
|
-
className: "bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky"
|
|
3118
|
-
}, React__default.createElement(Button, {
|
|
3119
|
-
type: "button",
|
|
3120
|
-
className: "!min-w-[0px] flex-grow !px-2 text-sm !transition-none",
|
|
3121
|
-
onClick: handleClear,
|
|
3122
|
-
small: true
|
|
3123
|
-
}, "Clear"), React__default.createElement(Button, {
|
|
3124
|
-
type: "submit",
|
|
3125
|
-
status: "primary",
|
|
3126
|
-
className: "!min-w-[0px] flex-grow !px-2 text-sm !transition-none",
|
|
3127
|
-
small: true
|
|
3128
|
-
}, "Apply"))));
|
|
3129
|
-
}
|
|
3130
|
-
|
|
3131
|
-
function PageHeader(_ref) {
|
|
3132
|
-
var title = _ref.title,
|
|
3133
|
-
search = _ref.search,
|
|
3134
|
-
_ref$className = _ref.className,
|
|
3135
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
3136
|
-
_ref$innerClassName = _ref.innerClassName,
|
|
3137
|
-
innerClassName = _ref$innerClassName === void 0 ? '' : _ref$innerClassName,
|
|
3138
|
-
_ref$back = _ref.back,
|
|
3139
|
-
back = _ref$back === void 0 ? true : _ref$back,
|
|
3140
|
-
_ref$actions = _ref.actions,
|
|
3141
|
-
actions = _ref$actions === void 0 ? [] : _ref$actions,
|
|
3142
|
-
_ref$filterOptions = _ref.filterOptions,
|
|
3143
|
-
filterOptions = _ref$filterOptions === void 0 ? [] : _ref$filterOptions,
|
|
3144
|
-
_ref$focusSearchShort = _ref.focusSearchShortcut,
|
|
3145
|
-
focusSearchShortcut = _ref$focusSearchShort === void 0 ? false : _ref$focusSearchShort,
|
|
3146
|
-
children = _ref.children;
|
|
3147
|
-
|
|
3148
|
-
var _React$useState = React__default.useState(false),
|
|
3149
|
-
isSearchActive = _React$useState[0],
|
|
3150
|
-
setSearchActive = _React$useState[1];
|
|
3151
|
-
|
|
3152
|
-
var scrollContainerRef = React__default.useRef(null);
|
|
3153
|
-
|
|
3154
|
-
var _React$useState2 = React__default.useState(false),
|
|
3155
|
-
overScroll = _React$useState2[0],
|
|
3156
|
-
setOverScroll = _React$useState2[1];
|
|
3157
|
-
|
|
3158
|
-
var actionChildren = []; // Categorize children based on their type
|
|
3159
|
-
|
|
3160
|
-
React__default.Children.forEach(children, function (child) {
|
|
3161
|
-
if (React__default.isValidElement(child)) {
|
|
3162
|
-
if (child.type === PageHeader.Action) {
|
|
3163
|
-
actionChildren.push(child);
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3166
|
-
});
|
|
3167
|
-
React__default.useEffect(function () {
|
|
3168
|
-
var current = scrollContainerRef.current;
|
|
3169
|
-
if (!current) return;
|
|
3170
|
-
|
|
3171
|
-
var listener = function listener() {
|
|
3172
|
-
var activeDropdown = current.querySelector('.active');
|
|
3173
|
-
if (!activeDropdown) return;
|
|
3174
|
-
var childrenContainer = activeDropdown.querySelector('.children');
|
|
3175
|
-
if (!childrenContainer) return;
|
|
3176
|
-
var pos = activeDropdown.getBoundingClientRect();
|
|
3177
|
-
var posChild = childrenContainer.getBoundingClientRect();
|
|
3178
|
-
var posContainer = current.getBoundingClientRect(); // if the dropdown content moves outside the scroll container to the left, make it disappear
|
|
3179
|
-
|
|
3180
|
-
if (posChild.left <= posContainer.left - 50) {
|
|
3181
|
-
// @ts-ignore
|
|
3182
|
-
childrenContainer.style.visibility = 'hidden';
|
|
3183
|
-
} else if (posChild.left >= posContainer.right - 50) {
|
|
3184
|
-
// @ts-ignore
|
|
3185
|
-
childrenContainer.style.visibility = 'hidden';
|
|
3186
|
-
} else {
|
|
3187
|
-
// @ts-ignore
|
|
3188
|
-
childrenContainer.style.visibility = 'visible';
|
|
3189
|
-
} // @ts-ignore
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
childrenContainer.style.left = pos.left + "px";
|
|
3193
|
-
};
|
|
3194
|
-
|
|
3195
|
-
var mouseListener = function mouseListener(e) {
|
|
3196
|
-
var pos = current.getBoundingClientRect();
|
|
3197
|
-
|
|
3198
|
-
if (e.clientX > pos.left && e.clientX < pos.right && e.clientY > pos.top && e.clientY < pos.bottom) {
|
|
3199
|
-
setOverScroll(true);
|
|
3200
|
-
} else {
|
|
3201
|
-
setOverScroll(false);
|
|
3202
|
-
}
|
|
3203
|
-
};
|
|
3204
|
-
|
|
3205
|
-
current.addEventListener('scroll', listener);
|
|
3206
|
-
document.addEventListener('mousemove', mouseListener);
|
|
3207
|
-
return function () {
|
|
3208
|
-
current.removeEventListener('scroll', listener);
|
|
3209
|
-
document.removeEventListener('mousemove', mouseListener);
|
|
3210
|
-
};
|
|
3211
|
-
}, []);
|
|
3212
|
-
React__default.useEffect(function () {
|
|
3213
|
-
var scrollListener = function scrollListener(e) {
|
|
3214
|
-
if (overScroll) {
|
|
3215
|
-
var _scrollContainerRef$c;
|
|
3216
|
-
|
|
3217
|
-
e.preventDefault();
|
|
3218
|
-
(_scrollContainerRef$c = scrollContainerRef.current) == null ? void 0 : _scrollContainerRef$c.scrollBy({
|
|
3219
|
-
left: e.deltaY,
|
|
3220
|
-
behavior: 'auto'
|
|
3221
|
-
});
|
|
3222
|
-
}
|
|
3223
|
-
};
|
|
3224
|
-
|
|
3225
|
-
document.addEventListener('wheel', scrollListener, {
|
|
3226
|
-
passive: false
|
|
3227
|
-
});
|
|
3228
|
-
return function () {
|
|
3229
|
-
document.removeEventListener('wheel', scrollListener);
|
|
3230
|
-
};
|
|
3231
|
-
}, [overScroll]);
|
|
3232
|
-
|
|
3233
|
-
function handleClear() {
|
|
3234
|
-
core.router.get("" + window.location.pathname);
|
|
3235
|
-
}
|
|
3236
|
-
|
|
3237
|
-
var _React$useState3 = React__default.useState(false),
|
|
3238
|
-
hasScroll = _React$useState3[0],
|
|
3239
|
-
setHasScroll = _React$useState3[1];
|
|
3240
|
-
|
|
3241
|
-
var checkScroll = React__default.useCallback(function () {
|
|
3242
|
-
var current = scrollContainerRef.current;
|
|
3243
|
-
if (!current) return;
|
|
3244
|
-
var pos = current.getBoundingClientRect();
|
|
3245
|
-
setHasScroll(current.scrollWidth > pos.width + 11);
|
|
3246
|
-
}, [scrollContainerRef.current]);
|
|
3247
|
-
React__default.useEffect(function () {
|
|
3248
|
-
checkScroll();
|
|
3249
|
-
window.addEventListener('resize', checkScroll);
|
|
3250
|
-
return function () {
|
|
3251
|
-
window.removeEventListener('resize', checkScroll);
|
|
3252
|
-
};
|
|
3253
|
-
}, [checkScroll]);
|
|
3254
|
-
|
|
3255
|
-
function clickRight() {
|
|
3256
|
-
var _scrollContainerRef$c2;
|
|
3257
|
-
|
|
3258
|
-
(_scrollContainerRef$c2 = scrollContainerRef.current) == null ? void 0 : _scrollContainerRef$c2.scrollBy({
|
|
3259
|
-
left: 100,
|
|
3260
|
-
behavior: 'auto'
|
|
3261
|
-
});
|
|
3262
|
-
checkScroll();
|
|
3263
|
-
}
|
|
3264
|
-
|
|
3265
|
-
function clickLeft() {
|
|
3266
|
-
var _scrollContainerRef$c3;
|
|
3267
|
-
|
|
3268
|
-
(_scrollContainerRef$c3 = scrollContainerRef.current) == null ? void 0 : _scrollContainerRef$c3.scrollBy({
|
|
3269
|
-
left: -100,
|
|
3270
|
-
behavior: 'auto'
|
|
3271
|
-
});
|
|
3272
|
-
checkScroll();
|
|
3273
|
-
}
|
|
3274
|
-
|
|
3275
|
-
var filteredActions = React__default.useMemo(function () {
|
|
3276
|
-
return actions.filter(function (action) {
|
|
3277
|
-
return !action.hidden;
|
|
3278
|
-
});
|
|
3279
|
-
}, [actions]);
|
|
3280
|
-
return React__default.createElement("section", {
|
|
3281
|
-
className: cn('col-span-full flex items-center gap-2 max-w-full rounded-lg bg-white p-2 shadow', className)
|
|
3282
|
-
}, back && React__default.createElement(BackButton, {
|
|
3283
|
-
back: back,
|
|
3284
|
-
className: "bg-primary-100 h-[60px] w-[60px] rounded"
|
|
3285
|
-
}), React__default.createElement("div", {
|
|
3286
|
-
className: cn('w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-primary-100 p-3 gap-4', innerClassName)
|
|
3287
|
-
}, React__default.createElement("button", {
|
|
3288
|
-
type: "button",
|
|
3289
|
-
disabled: !search,
|
|
3290
|
-
onClick: function onClick() {
|
|
3291
|
-
return setSearchActive(true);
|
|
3292
|
-
},
|
|
3293
|
-
className: cn('mr-auto flex items-center gap-4 transition-colors pr-6 pl-1 disabled:opacity-100 text-primary', {
|
|
3294
|
-
'hover:text-accent': search && !isSearchActive
|
|
3295
|
-
})
|
|
3296
|
-
}, search && React__default.createElement(SearchBar, {
|
|
3297
|
-
search: search,
|
|
3298
|
-
active: isSearchActive,
|
|
3299
|
-
onActive: setSearchActive,
|
|
3300
|
-
placeholder: "Search " + title + "...",
|
|
3301
|
-
focusSearchShortcut: focusSearchShortcut
|
|
3302
|
-
}), !isSearchActive && React__default.createElement("h1", {
|
|
3303
|
-
className: "text-base text-primary font-black"
|
|
3304
|
-
}, title)), React__default.createElement("div", {
|
|
3305
|
-
className: "flex items-center ml-auto gap-2 h-full min-w-0 max-w-full"
|
|
3306
|
-
}, filterOptions.length > 0 && React__default.createElement(React__default.Fragment, null, React__default.createElement("button", {
|
|
3307
|
-
onClick: handleClear,
|
|
3308
|
-
className: "p-1.5 hover:text-red-500"
|
|
3309
|
-
}, React__default.createElement(hi2.HiXMark, {
|
|
3310
|
-
className: "w-5 h-5 stroke-[1.25]"
|
|
3311
|
-
})), hasScroll && React__default.createElement(hi2.HiChevronLeft, {
|
|
3312
|
-
onClick: clickLeft,
|
|
3313
|
-
className: "w-5 h-5 text-gray-400 stroke-[1.25]"
|
|
3314
|
-
}), React__default.createElement("div", {
|
|
3315
|
-
ref: scrollContainerRef,
|
|
3316
|
-
className: "flex items-center h-full w-full gap-3 overflow-x-scroll hide-scroll"
|
|
3317
|
-
}, filterOptions.map(function (filter) {
|
|
3318
|
-
return React__default.createElement(FilterItem, {
|
|
3319
|
-
key: filter.name,
|
|
3320
|
-
filter: filter
|
|
3321
|
-
});
|
|
3322
|
-
})), hasScroll && React__default.createElement(hi2.HiChevronRight, {
|
|
3323
|
-
onClick: clickRight,
|
|
3324
|
-
className: "w-5 h-5 text-gray-400 stroke-[1.25]"
|
|
3325
|
-
}))), filteredActions.length > 0 && React__default.createElement("div", {
|
|
3326
|
-
className: "flex items-center gap-3 bg-primary-100"
|
|
3327
|
-
}, filterOptions.length > 0 && React__default.createElement("div", {
|
|
3328
|
-
className: "w-[1px] h-full bg-gray-300"
|
|
3329
|
-
}), React__default.createElement("nav", {
|
|
3330
|
-
className: "flex items-center gap-2"
|
|
3331
|
-
}, filteredActions.map(function (action) {
|
|
3332
|
-
return React__default.createElement(Action, Object.assign({
|
|
3333
|
-
key: action.title + "-" + action.as + "-" + action.href
|
|
3334
|
-
}, action));
|
|
3335
|
-
}))), actionChildren && React__default.createElement("div", {
|
|
3336
|
-
className: "flex items-center gap-3 bg-gray-100"
|
|
3337
|
-
}, actionChildren)));
|
|
3338
|
-
} // Subcomponents
|
|
3339
|
-
|
|
3340
|
-
PageHeader.Action = function (_ref2) {
|
|
3341
|
-
var children = _ref2.children;
|
|
3342
|
-
return React__default.createElement("div", null, children);
|
|
3343
|
-
};
|
|
3344
|
-
|
|
3345
|
-
exports.Button = Button;
|
|
3346
|
-
exports.Card = Card;
|
|
3347
|
-
exports.DateOfBirthField = DateOfBirthField;
|
|
3348
|
-
exports.ErrorList = ErrorList;
|
|
3349
|
-
exports.FormTester = FormTester;
|
|
3350
|
-
exports.Modal = Modal;
|
|
3351
|
-
exports.MoneyField = MoneyField;
|
|
3352
|
-
exports.PageHeader = PageHeader;
|
|
3353
|
-
exports.Pagination = Pagination;
|
|
3354
|
-
exports.QuoteRequestFormContext = QuoteRequestFormContext;
|
|
3355
|
-
exports.QuoteRequestFormProvider = QuoteRequestFormProvider;
|
|
3356
|
-
exports.QuoteRequestOptionsProvider = QuoteRequestOptionsProvider;
|
|
3357
|
-
exports.RegistrationSearchField = RegistrationSearchField;
|
|
3358
|
-
exports.SimplePagination = SimplePagination;
|
|
3359
|
-
exports.Table = Table;
|
|
3360
|
-
exports.TableActions = TableActions;
|
|
3361
|
-
exports.TableBody = TableBody;
|
|
3362
|
-
exports.TableCell = TableCell;
|
|
3363
|
-
exports.TableHead = TableHead;
|
|
3364
|
-
exports.TableHeader = TableHeader;
|
|
3365
|
-
exports.TableRow = TableRow;
|
|
3366
|
-
exports.ToastItem = ToastItem;
|
|
3367
|
-
exports.ToastProvider = ToastProvider;
|
|
3368
|
-
exports.Toasts = Toasts;
|
|
3369
|
-
exports.addGst = addGst;
|
|
3370
|
-
exports.autocomplete = autocomplete;
|
|
3371
|
-
exports.calcMonthlyEnhancementPrice = calcMonthlyEnhancementPrice;
|
|
3372
|
-
exports.calcPurchaseOptionPricing = calcPurchaseOptionPricing;
|
|
3373
|
-
exports.calculateAge = calculateAge;
|
|
3374
|
-
exports.createDate = createDate;
|
|
3375
|
-
exports.fixRoundingError = fixRoundingError;
|
|
3376
|
-
exports.formatDate = formatDate;
|
|
3377
|
-
exports.formatDateForTable = formatDateForTable;
|
|
3378
|
-
exports.formatDateNice = formatDateNice;
|
|
3379
|
-
exports.formatDateTime = formatDateTime;
|
|
3380
|
-
exports.formatMoney = formatMoney;
|
|
3381
|
-
exports.formatNumber = formatNumber;
|
|
3382
|
-
exports.getAddressData = getAddressData;
|
|
3383
|
-
exports.getGst = getGst;
|
|
3384
|
-
exports.gstCalc = gstCalc;
|
|
3385
|
-
exports.initialData = initialData;
|
|
3386
|
-
exports.round = round;
|
|
3387
|
-
exports.sanitiseQuoteRequestFormData = sanitiseQuoteRequestFormData;
|
|
3388
|
-
exports.sanitiseVehicleType = sanitiseVehicleType;
|
|
3389
|
-
exports.subtractGst = subtractGst;
|
|
3390
|
-
exports.useAuth = useAuth;
|
|
3391
|
-
exports.useClickOutside = useClickOutside;
|
|
3392
|
-
exports.useFetch = useFetch;
|
|
3393
|
-
exports.useInertiaOptions = useInertiaOptions;
|
|
3394
|
-
exports.useLocalStorage = useLocalStorage;
|
|
3395
|
-
exports.useQuoteRequestForm = useQuoteRequestForm;
|
|
3396
|
-
exports.useQuoteRequestOptions = useQuoteRequestOptions;
|
|
3397
|
-
exports.useToast = useToast;
|
|
3398
|
-
//# sourceMappingURL=sdk.cjs.development.js.map
|