@bigbinary/neeto-approvals-frontend 0.3.10 → 0.4.0-beta1
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 +3 -3
- package/dist/index.cjs.js +1580 -675
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1565 -679
- package/dist/index.js.map +1 -1
- package/package.json +17 -14
package/dist/index.cjs.js
CHANGED
|
@@ -8,24 +8,41 @@ var Container = require('@bigbinary/neeto-molecules/Container');
|
|
|
8
8
|
var reactRouterDom = require('react-router-dom');
|
|
9
9
|
var i18next = require('i18next');
|
|
10
10
|
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
11
|
-
var
|
|
12
|
-
var ramda = require('ramda');
|
|
11
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
13
12
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
14
13
|
var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
|
|
14
|
+
var Table$1 = require('@bigbinary/neetoui/Table');
|
|
15
|
+
var NoData = require('@bigbinary/neetoui/NoData');
|
|
16
|
+
var ramda = require('ramda');
|
|
15
17
|
var reactI18next = require('react-i18next');
|
|
16
|
-
var
|
|
18
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
17
19
|
var axios = require('axios');
|
|
20
|
+
var Tag = require('@bigbinary/neetoui/Tag');
|
|
18
21
|
var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
|
|
19
22
|
var neetoEditor = require('@bigbinary/neeto-editor');
|
|
20
23
|
var yup = require('yup');
|
|
21
24
|
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
25
|
+
var Label = require('@bigbinary/neetoui/Label');
|
|
26
|
+
var Pane = require('@bigbinary/neetoui/Pane');
|
|
27
|
+
var Textarea = require('@bigbinary/neetoui/Textarea');
|
|
28
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
29
|
+
var dayjs = require('dayjs');
|
|
30
|
+
var timezone = require('dayjs/plugin/timezone');
|
|
31
|
+
var utc = require('dayjs/plugin/utc');
|
|
22
32
|
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
23
33
|
var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
|
|
24
|
-
var
|
|
34
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
35
|
+
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
36
|
+
var FormikForm = require('@bigbinary/neetoui/formik/Form');
|
|
25
37
|
var formik = require('formik');
|
|
26
38
|
var ToggleFeatureCard = require('@bigbinary/neeto-molecules/ToggleFeatureCard');
|
|
39
|
+
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
40
|
+
var Textarea$1 = require('@bigbinary/neetoui/formik/Textarea');
|
|
27
41
|
var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
28
42
|
var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
|
|
43
|
+
var NeetoUITab = require('@bigbinary/neetoui/Tab');
|
|
44
|
+
var Select = require('@bigbinary/neetoui/Select');
|
|
45
|
+
var Callout = require('@bigbinary/neetoui/Callout');
|
|
29
46
|
|
|
30
47
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
48
|
|
|
@@ -47,17 +64,37 @@ function _interopNamespace(e) {
|
|
|
47
64
|
return Object.freeze(n);
|
|
48
65
|
}
|
|
49
66
|
|
|
67
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
50
68
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
51
69
|
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
52
70
|
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
71
|
+
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
53
72
|
var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
|
|
73
|
+
var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table$1);
|
|
74
|
+
var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
|
|
54
75
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
76
|
+
var Tag__default = /*#__PURE__*/_interopDefaultLegacy(Tag);
|
|
55
77
|
var DateFormat__default = /*#__PURE__*/_interopDefaultLegacy(DateFormat);
|
|
56
78
|
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
79
|
+
var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
|
|
80
|
+
var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
|
|
81
|
+
var Textarea__default = /*#__PURE__*/_interopDefaultLegacy(Textarea);
|
|
82
|
+
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
83
|
+
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
84
|
+
var timezone__default = /*#__PURE__*/_interopDefaultLegacy(timezone);
|
|
85
|
+
var utc__default = /*#__PURE__*/_interopDefaultLegacy(utc);
|
|
57
86
|
var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
87
|
+
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
88
|
+
var ActionBlock__default = /*#__PURE__*/_interopDefaultLegacy(ActionBlock);
|
|
89
|
+
var FormikForm__default = /*#__PURE__*/_interopDefaultLegacy(FormikForm);
|
|
58
90
|
var ToggleFeatureCard__default = /*#__PURE__*/_interopDefaultLegacy(ToggleFeatureCard);
|
|
91
|
+
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
92
|
+
var Textarea__default$1 = /*#__PURE__*/_interopDefaultLegacy(Textarea$1);
|
|
59
93
|
var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
|
|
60
94
|
var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
|
|
95
|
+
var NeetoUITab__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUITab);
|
|
96
|
+
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
97
|
+
var Callout__default = /*#__PURE__*/_interopDefaultLegacy(Callout);
|
|
61
98
|
|
|
62
99
|
function _typeof(o) {
|
|
63
100
|
"@babel/helpers - typeof";
|
|
@@ -174,6 +211,868 @@ var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageC
|
|
|
174
211
|
}
|
|
175
212
|
};
|
|
176
213
|
|
|
214
|
+
// src/subscribable.ts
|
|
215
|
+
var Subscribable = class {
|
|
216
|
+
constructor() {
|
|
217
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
218
|
+
this.subscribe = this.subscribe.bind(this);
|
|
219
|
+
}
|
|
220
|
+
subscribe(listener) {
|
|
221
|
+
this.listeners.add(listener);
|
|
222
|
+
this.onSubscribe();
|
|
223
|
+
return () => {
|
|
224
|
+
this.listeners.delete(listener);
|
|
225
|
+
this.onUnsubscribe();
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
hasListeners() {
|
|
229
|
+
return this.listeners.size > 0;
|
|
230
|
+
}
|
|
231
|
+
onSubscribe() {
|
|
232
|
+
}
|
|
233
|
+
onUnsubscribe() {
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/utils.ts
|
|
238
|
+
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
239
|
+
function noop() {
|
|
240
|
+
return void 0;
|
|
241
|
+
}
|
|
242
|
+
function isValidTimeout(value) {
|
|
243
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
244
|
+
}
|
|
245
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
246
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
247
|
+
}
|
|
248
|
+
function replaceEqualDeep(a, b) {
|
|
249
|
+
if (a === b) {
|
|
250
|
+
return a;
|
|
251
|
+
}
|
|
252
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
253
|
+
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
254
|
+
const aItems = array ? a : Object.keys(a);
|
|
255
|
+
const aSize = aItems.length;
|
|
256
|
+
const bItems = array ? b : Object.keys(b);
|
|
257
|
+
const bSize = bItems.length;
|
|
258
|
+
const copy = array ? [] : {};
|
|
259
|
+
let equalItems = 0;
|
|
260
|
+
for (let i = 0; i < bSize; i++) {
|
|
261
|
+
const key = array ? i : bItems[i];
|
|
262
|
+
if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
|
|
263
|
+
copy[key] = void 0;
|
|
264
|
+
equalItems++;
|
|
265
|
+
} else {
|
|
266
|
+
copy[key] = replaceEqualDeep(a[key], b[key]);
|
|
267
|
+
if (copy[key] === a[key] && a[key] !== void 0) {
|
|
268
|
+
equalItems++;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
273
|
+
}
|
|
274
|
+
return b;
|
|
275
|
+
}
|
|
276
|
+
function shallowEqualObjects(a, b) {
|
|
277
|
+
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
for (const key in a) {
|
|
281
|
+
if (a[key] !== b[key]) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
function isPlainArray(value) {
|
|
288
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
289
|
+
}
|
|
290
|
+
function isPlainObject(o) {
|
|
291
|
+
if (!hasObjectPrototype(o)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
const ctor = o.constructor;
|
|
295
|
+
if (ctor === void 0) {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
const prot = ctor.prototype;
|
|
299
|
+
if (!hasObjectPrototype(prot)) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
function hasObjectPrototype(o) {
|
|
311
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
312
|
+
}
|
|
313
|
+
function replaceData(prevData, data, options) {
|
|
314
|
+
if (typeof options.structuralSharing === "function") {
|
|
315
|
+
return options.structuralSharing(prevData, data);
|
|
316
|
+
} else if (options.structuralSharing !== false) {
|
|
317
|
+
return replaceEqualDeep(prevData, data);
|
|
318
|
+
}
|
|
319
|
+
return data;
|
|
320
|
+
}
|
|
321
|
+
function keepPreviousData(previousData) {
|
|
322
|
+
return previousData;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/focusManager.ts
|
|
326
|
+
var FocusManager = class extends Subscribable {
|
|
327
|
+
#focused;
|
|
328
|
+
#cleanup;
|
|
329
|
+
#setup;
|
|
330
|
+
constructor() {
|
|
331
|
+
super();
|
|
332
|
+
this.#setup = (onFocus) => {
|
|
333
|
+
if (!isServer && window.addEventListener) {
|
|
334
|
+
const listener = () => onFocus();
|
|
335
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
336
|
+
return () => {
|
|
337
|
+
window.removeEventListener("visibilitychange", listener);
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
onSubscribe() {
|
|
344
|
+
if (!this.#cleanup) {
|
|
345
|
+
this.setEventListener(this.#setup);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
onUnsubscribe() {
|
|
349
|
+
if (!this.hasListeners()) {
|
|
350
|
+
this.#cleanup?.();
|
|
351
|
+
this.#cleanup = void 0;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
setEventListener(setup) {
|
|
355
|
+
this.#setup = setup;
|
|
356
|
+
this.#cleanup?.();
|
|
357
|
+
this.#cleanup = setup((focused) => {
|
|
358
|
+
if (typeof focused === "boolean") {
|
|
359
|
+
this.setFocused(focused);
|
|
360
|
+
} else {
|
|
361
|
+
this.onFocus();
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
setFocused(focused) {
|
|
366
|
+
const changed = this.#focused !== focused;
|
|
367
|
+
if (changed) {
|
|
368
|
+
this.#focused = focused;
|
|
369
|
+
this.onFocus();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
onFocus() {
|
|
373
|
+
const isFocused = this.isFocused();
|
|
374
|
+
this.listeners.forEach((listener) => {
|
|
375
|
+
listener(isFocused);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
isFocused() {
|
|
379
|
+
if (typeof this.#focused === "boolean") {
|
|
380
|
+
return this.#focused;
|
|
381
|
+
}
|
|
382
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var focusManager = new FocusManager();
|
|
386
|
+
|
|
387
|
+
// src/onlineManager.ts
|
|
388
|
+
var OnlineManager = class extends Subscribable {
|
|
389
|
+
#online = true;
|
|
390
|
+
#cleanup;
|
|
391
|
+
#setup;
|
|
392
|
+
constructor() {
|
|
393
|
+
super();
|
|
394
|
+
this.#setup = (onOnline) => {
|
|
395
|
+
if (!isServer && window.addEventListener) {
|
|
396
|
+
const onlineListener = () => onOnline(true);
|
|
397
|
+
const offlineListener = () => onOnline(false);
|
|
398
|
+
window.addEventListener("online", onlineListener, false);
|
|
399
|
+
window.addEventListener("offline", offlineListener, false);
|
|
400
|
+
return () => {
|
|
401
|
+
window.removeEventListener("online", onlineListener);
|
|
402
|
+
window.removeEventListener("offline", offlineListener);
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
return;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
onSubscribe() {
|
|
409
|
+
if (!this.#cleanup) {
|
|
410
|
+
this.setEventListener(this.#setup);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
onUnsubscribe() {
|
|
414
|
+
if (!this.hasListeners()) {
|
|
415
|
+
this.#cleanup?.();
|
|
416
|
+
this.#cleanup = void 0;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
setEventListener(setup) {
|
|
420
|
+
this.#setup = setup;
|
|
421
|
+
this.#cleanup?.();
|
|
422
|
+
this.#cleanup = setup(this.setOnline.bind(this));
|
|
423
|
+
}
|
|
424
|
+
setOnline(online) {
|
|
425
|
+
const changed = this.#online !== online;
|
|
426
|
+
if (changed) {
|
|
427
|
+
this.#online = online;
|
|
428
|
+
this.listeners.forEach((listener) => {
|
|
429
|
+
listener(online);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
isOnline() {
|
|
434
|
+
return this.#online;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
var onlineManager = new OnlineManager();
|
|
438
|
+
|
|
439
|
+
// src/retryer.ts
|
|
440
|
+
function canFetch(networkMode) {
|
|
441
|
+
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/notifyManager.ts
|
|
445
|
+
function createNotifyManager() {
|
|
446
|
+
let queue = [];
|
|
447
|
+
let transactions = 0;
|
|
448
|
+
let notifyFn = (callback) => {
|
|
449
|
+
callback();
|
|
450
|
+
};
|
|
451
|
+
let batchNotifyFn = (callback) => {
|
|
452
|
+
callback();
|
|
453
|
+
};
|
|
454
|
+
let scheduleFn = (cb) => setTimeout(cb, 0);
|
|
455
|
+
const setScheduler = (fn) => {
|
|
456
|
+
scheduleFn = fn;
|
|
457
|
+
};
|
|
458
|
+
const batch = (callback) => {
|
|
459
|
+
let result;
|
|
460
|
+
transactions++;
|
|
461
|
+
try {
|
|
462
|
+
result = callback();
|
|
463
|
+
} finally {
|
|
464
|
+
transactions--;
|
|
465
|
+
if (!transactions) {
|
|
466
|
+
flush();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
};
|
|
471
|
+
const schedule = (callback) => {
|
|
472
|
+
if (transactions) {
|
|
473
|
+
queue.push(callback);
|
|
474
|
+
} else {
|
|
475
|
+
scheduleFn(() => {
|
|
476
|
+
notifyFn(callback);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const batchCalls = (callback) => {
|
|
481
|
+
return (...args) => {
|
|
482
|
+
schedule(() => {
|
|
483
|
+
callback(...args);
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
const flush = () => {
|
|
488
|
+
const originalQueue = queue;
|
|
489
|
+
queue = [];
|
|
490
|
+
if (originalQueue.length) {
|
|
491
|
+
scheduleFn(() => {
|
|
492
|
+
batchNotifyFn(() => {
|
|
493
|
+
originalQueue.forEach((callback) => {
|
|
494
|
+
notifyFn(callback);
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
const setNotifyFunction = (fn) => {
|
|
501
|
+
notifyFn = fn;
|
|
502
|
+
};
|
|
503
|
+
const setBatchNotifyFunction = (fn) => {
|
|
504
|
+
batchNotifyFn = fn;
|
|
505
|
+
};
|
|
506
|
+
return {
|
|
507
|
+
batch,
|
|
508
|
+
batchCalls,
|
|
509
|
+
schedule,
|
|
510
|
+
setNotifyFunction,
|
|
511
|
+
setBatchNotifyFunction,
|
|
512
|
+
setScheduler
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
var notifyManager = createNotifyManager();
|
|
516
|
+
|
|
517
|
+
// src/query.ts
|
|
518
|
+
function fetchState(data, options) {
|
|
519
|
+
return {
|
|
520
|
+
fetchFailureCount: 0,
|
|
521
|
+
fetchFailureReason: null,
|
|
522
|
+
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
523
|
+
...data === void 0 && {
|
|
524
|
+
error: null,
|
|
525
|
+
status: "pending"
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/queryObserver.ts
|
|
531
|
+
var QueryObserver = class extends Subscribable {
|
|
532
|
+
constructor(client, options) {
|
|
533
|
+
super();
|
|
534
|
+
this.options = options;
|
|
535
|
+
this.#client = client;
|
|
536
|
+
this.#selectError = null;
|
|
537
|
+
this.bindMethods();
|
|
538
|
+
this.setOptions(options);
|
|
539
|
+
}
|
|
540
|
+
#client;
|
|
541
|
+
#currentQuery = void 0;
|
|
542
|
+
#currentQueryInitialState = void 0;
|
|
543
|
+
#currentResult = void 0;
|
|
544
|
+
#currentResultState;
|
|
545
|
+
#currentResultOptions;
|
|
546
|
+
#selectError;
|
|
547
|
+
#selectFn;
|
|
548
|
+
#selectResult;
|
|
549
|
+
// This property keeps track of the last query with defined data.
|
|
550
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
551
|
+
#lastQueryWithDefinedData;
|
|
552
|
+
#staleTimeoutId;
|
|
553
|
+
#refetchIntervalId;
|
|
554
|
+
#currentRefetchInterval;
|
|
555
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
556
|
+
bindMethods() {
|
|
557
|
+
this.refetch = this.refetch.bind(this);
|
|
558
|
+
}
|
|
559
|
+
onSubscribe() {
|
|
560
|
+
if (this.listeners.size === 1) {
|
|
561
|
+
this.#currentQuery.addObserver(this);
|
|
562
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
563
|
+
this.#executeFetch();
|
|
564
|
+
} else {
|
|
565
|
+
this.updateResult();
|
|
566
|
+
}
|
|
567
|
+
this.#updateTimers();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
onUnsubscribe() {
|
|
571
|
+
if (!this.hasListeners()) {
|
|
572
|
+
this.destroy();
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
shouldFetchOnReconnect() {
|
|
576
|
+
return shouldFetchOn(
|
|
577
|
+
this.#currentQuery,
|
|
578
|
+
this.options,
|
|
579
|
+
this.options.refetchOnReconnect
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
shouldFetchOnWindowFocus() {
|
|
583
|
+
return shouldFetchOn(
|
|
584
|
+
this.#currentQuery,
|
|
585
|
+
this.options,
|
|
586
|
+
this.options.refetchOnWindowFocus
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
destroy() {
|
|
590
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
591
|
+
this.#clearStaleTimeout();
|
|
592
|
+
this.#clearRefetchInterval();
|
|
593
|
+
this.#currentQuery.removeObserver(this);
|
|
594
|
+
}
|
|
595
|
+
setOptions(options, notifyOptions) {
|
|
596
|
+
const prevOptions = this.options;
|
|
597
|
+
const prevQuery = this.#currentQuery;
|
|
598
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
599
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean") {
|
|
600
|
+
throw new Error("Expected enabled to be a boolean");
|
|
601
|
+
}
|
|
602
|
+
this.#updateQuery();
|
|
603
|
+
this.#currentQuery.setOptions(this.options);
|
|
604
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
605
|
+
this.#client.getQueryCache().notify({
|
|
606
|
+
type: "observerOptionsUpdated",
|
|
607
|
+
query: this.#currentQuery,
|
|
608
|
+
observer: this
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
const mounted = this.hasListeners();
|
|
612
|
+
if (mounted && shouldFetchOptionally(
|
|
613
|
+
this.#currentQuery,
|
|
614
|
+
prevQuery,
|
|
615
|
+
this.options,
|
|
616
|
+
prevOptions
|
|
617
|
+
)) {
|
|
618
|
+
this.#executeFetch();
|
|
619
|
+
}
|
|
620
|
+
this.updateResult(notifyOptions);
|
|
621
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
622
|
+
this.#updateStaleTimeout();
|
|
623
|
+
}
|
|
624
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
625
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
626
|
+
this.#updateRefetchInterval(nextRefetchInterval);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
getOptimisticResult(options) {
|
|
630
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
631
|
+
const result = this.createResult(query, options);
|
|
632
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
633
|
+
this.#currentResult = result;
|
|
634
|
+
this.#currentResultOptions = this.options;
|
|
635
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
636
|
+
}
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
getCurrentResult() {
|
|
640
|
+
return this.#currentResult;
|
|
641
|
+
}
|
|
642
|
+
trackResult(result, onPropTracked) {
|
|
643
|
+
const trackedResult = {};
|
|
644
|
+
Object.keys(result).forEach((key) => {
|
|
645
|
+
Object.defineProperty(trackedResult, key, {
|
|
646
|
+
configurable: false,
|
|
647
|
+
enumerable: true,
|
|
648
|
+
get: () => {
|
|
649
|
+
this.trackProp(key);
|
|
650
|
+
onPropTracked?.(key);
|
|
651
|
+
return result[key];
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
return trackedResult;
|
|
656
|
+
}
|
|
657
|
+
trackProp(key) {
|
|
658
|
+
this.#trackedProps.add(key);
|
|
659
|
+
}
|
|
660
|
+
getCurrentQuery() {
|
|
661
|
+
return this.#currentQuery;
|
|
662
|
+
}
|
|
663
|
+
refetch({ ...options } = {}) {
|
|
664
|
+
return this.fetch({
|
|
665
|
+
...options
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
fetchOptimistic(options) {
|
|
669
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
670
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
671
|
+
query.isFetchingOptimistic = true;
|
|
672
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
673
|
+
}
|
|
674
|
+
fetch(fetchOptions) {
|
|
675
|
+
return this.#executeFetch({
|
|
676
|
+
...fetchOptions,
|
|
677
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
678
|
+
}).then(() => {
|
|
679
|
+
this.updateResult();
|
|
680
|
+
return this.#currentResult;
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
#executeFetch(fetchOptions) {
|
|
684
|
+
this.#updateQuery();
|
|
685
|
+
let promise = this.#currentQuery.fetch(
|
|
686
|
+
this.options,
|
|
687
|
+
fetchOptions
|
|
688
|
+
);
|
|
689
|
+
if (!fetchOptions?.throwOnError) {
|
|
690
|
+
promise = promise.catch(noop);
|
|
691
|
+
}
|
|
692
|
+
return promise;
|
|
693
|
+
}
|
|
694
|
+
#updateStaleTimeout() {
|
|
695
|
+
this.#clearStaleTimeout();
|
|
696
|
+
if (isServer || this.#currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const time = timeUntilStale(
|
|
700
|
+
this.#currentResult.dataUpdatedAt,
|
|
701
|
+
this.options.staleTime
|
|
702
|
+
);
|
|
703
|
+
const timeout = time + 1;
|
|
704
|
+
this.#staleTimeoutId = setTimeout(() => {
|
|
705
|
+
if (!this.#currentResult.isStale) {
|
|
706
|
+
this.updateResult();
|
|
707
|
+
}
|
|
708
|
+
}, timeout);
|
|
709
|
+
}
|
|
710
|
+
#computeRefetchInterval() {
|
|
711
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
712
|
+
}
|
|
713
|
+
#updateRefetchInterval(nextInterval) {
|
|
714
|
+
this.#clearRefetchInterval();
|
|
715
|
+
this.#currentRefetchInterval = nextInterval;
|
|
716
|
+
if (isServer || this.options.enabled === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
this.#refetchIntervalId = setInterval(() => {
|
|
720
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
721
|
+
this.#executeFetch();
|
|
722
|
+
}
|
|
723
|
+
}, this.#currentRefetchInterval);
|
|
724
|
+
}
|
|
725
|
+
#updateTimers() {
|
|
726
|
+
this.#updateStaleTimeout();
|
|
727
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
728
|
+
}
|
|
729
|
+
#clearStaleTimeout() {
|
|
730
|
+
if (this.#staleTimeoutId) {
|
|
731
|
+
clearTimeout(this.#staleTimeoutId);
|
|
732
|
+
this.#staleTimeoutId = void 0;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
#clearRefetchInterval() {
|
|
736
|
+
if (this.#refetchIntervalId) {
|
|
737
|
+
clearInterval(this.#refetchIntervalId);
|
|
738
|
+
this.#refetchIntervalId = void 0;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
createResult(query, options) {
|
|
742
|
+
const prevQuery = this.#currentQuery;
|
|
743
|
+
const prevOptions = this.options;
|
|
744
|
+
const prevResult = this.#currentResult;
|
|
745
|
+
const prevResultState = this.#currentResultState;
|
|
746
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
747
|
+
const queryChange = query !== prevQuery;
|
|
748
|
+
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
749
|
+
const { state } = query;
|
|
750
|
+
let newState = { ...state };
|
|
751
|
+
let isPlaceholderData = false;
|
|
752
|
+
let data;
|
|
753
|
+
if (options._optimisticResults) {
|
|
754
|
+
const mounted = this.hasListeners();
|
|
755
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
756
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
757
|
+
if (fetchOnMount || fetchOptionally) {
|
|
758
|
+
newState = {
|
|
759
|
+
...newState,
|
|
760
|
+
...fetchState(state.data, query.options)
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
if (options._optimisticResults === "isRestoring") {
|
|
764
|
+
newState.fetchStatus = "idle";
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
768
|
+
if (options.select && newState.data !== void 0) {
|
|
769
|
+
if (prevResult && newState.data === prevResultState?.data && options.select === this.#selectFn) {
|
|
770
|
+
data = this.#selectResult;
|
|
771
|
+
} else {
|
|
772
|
+
try {
|
|
773
|
+
this.#selectFn = options.select;
|
|
774
|
+
data = options.select(newState.data);
|
|
775
|
+
data = replaceData(prevResult?.data, data, options);
|
|
776
|
+
this.#selectResult = data;
|
|
777
|
+
this.#selectError = null;
|
|
778
|
+
} catch (selectError) {
|
|
779
|
+
this.#selectError = selectError;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
} else {
|
|
783
|
+
data = newState.data;
|
|
784
|
+
}
|
|
785
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
786
|
+
let placeholderData;
|
|
787
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
788
|
+
placeholderData = prevResult.data;
|
|
789
|
+
} else {
|
|
790
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
791
|
+
this.#lastQueryWithDefinedData?.state.data,
|
|
792
|
+
this.#lastQueryWithDefinedData
|
|
793
|
+
) : options.placeholderData;
|
|
794
|
+
if (options.select && placeholderData !== void 0) {
|
|
795
|
+
try {
|
|
796
|
+
placeholderData = options.select(placeholderData);
|
|
797
|
+
this.#selectError = null;
|
|
798
|
+
} catch (selectError) {
|
|
799
|
+
this.#selectError = selectError;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if (placeholderData !== void 0) {
|
|
804
|
+
status = "success";
|
|
805
|
+
data = replaceData(
|
|
806
|
+
prevResult?.data,
|
|
807
|
+
placeholderData,
|
|
808
|
+
options
|
|
809
|
+
);
|
|
810
|
+
isPlaceholderData = true;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (this.#selectError) {
|
|
814
|
+
error = this.#selectError;
|
|
815
|
+
data = this.#selectResult;
|
|
816
|
+
errorUpdatedAt = Date.now();
|
|
817
|
+
status = "error";
|
|
818
|
+
}
|
|
819
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
820
|
+
const isPending = status === "pending";
|
|
821
|
+
const isError = status === "error";
|
|
822
|
+
const isLoading = isPending && isFetching;
|
|
823
|
+
const hasData = data !== void 0;
|
|
824
|
+
const result = {
|
|
825
|
+
status,
|
|
826
|
+
fetchStatus: newState.fetchStatus,
|
|
827
|
+
isPending,
|
|
828
|
+
isSuccess: status === "success",
|
|
829
|
+
isError,
|
|
830
|
+
isInitialLoading: isLoading,
|
|
831
|
+
isLoading,
|
|
832
|
+
data,
|
|
833
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
834
|
+
error,
|
|
835
|
+
errorUpdatedAt,
|
|
836
|
+
failureCount: newState.fetchFailureCount,
|
|
837
|
+
failureReason: newState.fetchFailureReason,
|
|
838
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
839
|
+
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
840
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
841
|
+
isFetching,
|
|
842
|
+
isRefetching: isFetching && !isPending,
|
|
843
|
+
isLoadingError: isError && !hasData,
|
|
844
|
+
isPaused: newState.fetchStatus === "paused",
|
|
845
|
+
isPlaceholderData,
|
|
846
|
+
isRefetchError: isError && hasData,
|
|
847
|
+
isStale: isStale(query, options),
|
|
848
|
+
refetch: this.refetch
|
|
849
|
+
};
|
|
850
|
+
return result;
|
|
851
|
+
}
|
|
852
|
+
updateResult(notifyOptions) {
|
|
853
|
+
const prevResult = this.#currentResult;
|
|
854
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
855
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
856
|
+
this.#currentResultOptions = this.options;
|
|
857
|
+
if (this.#currentResultState.data !== void 0) {
|
|
858
|
+
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
859
|
+
}
|
|
860
|
+
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
this.#currentResult = nextResult;
|
|
864
|
+
const defaultNotifyOptions = {};
|
|
865
|
+
const shouldNotifyListeners = () => {
|
|
866
|
+
if (!prevResult) {
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
const { notifyOnChangeProps } = this.options;
|
|
870
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
871
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
const includedProps = new Set(
|
|
875
|
+
notifyOnChangePropsValue ?? this.#trackedProps
|
|
876
|
+
);
|
|
877
|
+
if (this.options.throwOnError) {
|
|
878
|
+
includedProps.add("error");
|
|
879
|
+
}
|
|
880
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
881
|
+
const typedKey = key;
|
|
882
|
+
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
883
|
+
return changed && includedProps.has(typedKey);
|
|
884
|
+
});
|
|
885
|
+
};
|
|
886
|
+
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
|
|
887
|
+
defaultNotifyOptions.listeners = true;
|
|
888
|
+
}
|
|
889
|
+
this.#notify({ ...defaultNotifyOptions, ...notifyOptions });
|
|
890
|
+
}
|
|
891
|
+
#updateQuery() {
|
|
892
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
893
|
+
if (query === this.#currentQuery) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
const prevQuery = this.#currentQuery;
|
|
897
|
+
this.#currentQuery = query;
|
|
898
|
+
this.#currentQueryInitialState = query.state;
|
|
899
|
+
if (this.hasListeners()) {
|
|
900
|
+
prevQuery?.removeObserver(this);
|
|
901
|
+
query.addObserver(this);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
onQueryUpdate() {
|
|
905
|
+
this.updateResult();
|
|
906
|
+
if (this.hasListeners()) {
|
|
907
|
+
this.#updateTimers();
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
#notify(notifyOptions) {
|
|
911
|
+
notifyManager.batch(() => {
|
|
912
|
+
if (notifyOptions.listeners) {
|
|
913
|
+
this.listeners.forEach((listener) => {
|
|
914
|
+
listener(this.#currentResult);
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
this.#client.getQueryCache().notify({
|
|
918
|
+
query: this.#currentQuery,
|
|
919
|
+
type: "observerResultsUpdated"
|
|
920
|
+
});
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
function shouldLoadOnMount(query, options) {
|
|
925
|
+
return options.enabled !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
926
|
+
}
|
|
927
|
+
function shouldFetchOnMount(query, options) {
|
|
928
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
929
|
+
}
|
|
930
|
+
function shouldFetchOn(query, options, field) {
|
|
931
|
+
if (options.enabled !== false) {
|
|
932
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
933
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
934
|
+
}
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
938
|
+
return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
939
|
+
}
|
|
940
|
+
function isStale(query, options) {
|
|
941
|
+
return options.enabled !== false && query.isStaleByTime(options.staleTime);
|
|
942
|
+
}
|
|
943
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
944
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
var QueryClientContext = React__namespace.createContext(
|
|
951
|
+
void 0
|
|
952
|
+
);
|
|
953
|
+
var useQueryClient = (queryClient) => {
|
|
954
|
+
const client = React__namespace.useContext(QueryClientContext);
|
|
955
|
+
if (queryClient) {
|
|
956
|
+
return queryClient;
|
|
957
|
+
}
|
|
958
|
+
if (!client) {
|
|
959
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
960
|
+
}
|
|
961
|
+
return client;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
var IsRestoringContext = React__namespace.createContext(false);
|
|
965
|
+
var useIsRestoring = () => React__namespace.useContext(IsRestoringContext);
|
|
966
|
+
IsRestoringContext.Provider;
|
|
967
|
+
|
|
968
|
+
function createValue() {
|
|
969
|
+
let isReset = false;
|
|
970
|
+
return {
|
|
971
|
+
clearReset: () => {
|
|
972
|
+
isReset = false;
|
|
973
|
+
},
|
|
974
|
+
reset: () => {
|
|
975
|
+
isReset = true;
|
|
976
|
+
},
|
|
977
|
+
isReset: () => {
|
|
978
|
+
return isReset;
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
var QueryErrorResetBoundaryContext = React__namespace.createContext(createValue());
|
|
983
|
+
var useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext);
|
|
984
|
+
|
|
985
|
+
// src/utils.ts
|
|
986
|
+
function shouldThrowError(throwError, params) {
|
|
987
|
+
if (typeof throwError === "function") {
|
|
988
|
+
return throwError(...params);
|
|
989
|
+
}
|
|
990
|
+
return !!throwError;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
994
|
+
if (options.suspense || options.throwOnError) {
|
|
995
|
+
if (!errorResetBoundary.isReset()) {
|
|
996
|
+
options.retryOnMount = false;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
1001
|
+
React__namespace.useEffect(() => {
|
|
1002
|
+
errorResetBoundary.clearReset();
|
|
1003
|
+
}, [errorResetBoundary]);
|
|
1004
|
+
};
|
|
1005
|
+
var getHasError = ({
|
|
1006
|
+
result,
|
|
1007
|
+
errorResetBoundary,
|
|
1008
|
+
throwOnError,
|
|
1009
|
+
query
|
|
1010
|
+
}) => {
|
|
1011
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
// src/suspense.ts
|
|
1015
|
+
var ensureStaleTime = (defaultedOptions) => {
|
|
1016
|
+
if (defaultedOptions.suspense) {
|
|
1017
|
+
if (typeof defaultedOptions.staleTime !== "number") {
|
|
1018
|
+
defaultedOptions.staleTime = 1e3;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
1023
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
1024
|
+
errorResetBoundary.clearReset();
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
1028
|
+
const client = useQueryClient(queryClient);
|
|
1029
|
+
const isRestoring = useIsRestoring();
|
|
1030
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
1031
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
1032
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
1033
|
+
ensureStaleTime(defaultedOptions);
|
|
1034
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
1035
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
1036
|
+
const [observer] = React__namespace.useState(
|
|
1037
|
+
() => new Observer(
|
|
1038
|
+
client,
|
|
1039
|
+
defaultedOptions
|
|
1040
|
+
)
|
|
1041
|
+
);
|
|
1042
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
1043
|
+
React__namespace.useSyncExternalStore(
|
|
1044
|
+
React__namespace.useCallback(
|
|
1045
|
+
(onStoreChange) => {
|
|
1046
|
+
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
1047
|
+
observer.updateResult();
|
|
1048
|
+
return unsubscribe;
|
|
1049
|
+
},
|
|
1050
|
+
[observer, isRestoring]
|
|
1051
|
+
),
|
|
1052
|
+
() => observer.getCurrentResult(),
|
|
1053
|
+
() => observer.getCurrentResult()
|
|
1054
|
+
);
|
|
1055
|
+
React__namespace.useEffect(() => {
|
|
1056
|
+
observer.setOptions(defaultedOptions, { listeners: false });
|
|
1057
|
+
}, [defaultedOptions, observer]);
|
|
1058
|
+
if (shouldSuspend(defaultedOptions, result)) {
|
|
1059
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
1060
|
+
}
|
|
1061
|
+
if (getHasError({
|
|
1062
|
+
result,
|
|
1063
|
+
errorResetBoundary,
|
|
1064
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
1065
|
+
query: client.getQueryCache().get(defaultedOptions.queryHash)
|
|
1066
|
+
})) {
|
|
1067
|
+
throw result.error;
|
|
1068
|
+
}
|
|
1069
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
function useQuery(options, queryClient) {
|
|
1073
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
177
1076
|
var BASE_URL = "neeto_approvals";
|
|
178
1077
|
var TEMPLATE_URL = "".concat(BASE_URL, "/templates");
|
|
179
1078
|
|
|
@@ -211,23 +1110,20 @@ var useFetchRequests = function useFetchRequests(_ref) {
|
|
|
211
1110
|
params = _ref$params === void 0 ? {} : _ref$params,
|
|
212
1111
|
_ref$options = _ref.options,
|
|
213
1112
|
options = _ref$options === void 0 ? {} : _ref$options;
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
|
|
1113
|
+
return useQuery(_objectSpread$b({
|
|
1114
|
+
queryKey: [QUERY_KEYS.REQUESTS, params],
|
|
1115
|
+
queryFn: function queryFn() {
|
|
1116
|
+
return requestsApi.fetch(params, requestUrl);
|
|
1117
|
+
},
|
|
217
1118
|
select: function select(response) {
|
|
218
1119
|
return response.data || response;
|
|
219
1120
|
},
|
|
220
|
-
|
|
221
|
-
onSuccess: function onSuccess(_ref2) {
|
|
222
|
-
var _options$onSuccess;
|
|
223
|
-
var requests = _ref2.requests;
|
|
224
|
-
return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, requests);
|
|
225
|
-
}
|
|
1121
|
+
placeholderData: keepPreviousData
|
|
226
1122
|
}, options));
|
|
227
1123
|
};
|
|
228
1124
|
var useUpdateRequest = function useUpdateRequest(options) {
|
|
229
1125
|
return reactUtils.useMutationWithInvalidation(requestsApi.update, _objectSpread$b({
|
|
230
|
-
keysToInvalidate: [QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
1126
|
+
keysToInvalidate: [[QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
231
1127
|
}, options));
|
|
232
1128
|
};
|
|
233
1129
|
|
|
@@ -308,7 +1204,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
308
1204
|
render: function render(approvalLabel, _ref) {
|
|
309
1205
|
var requestableUrl = _ref.requestableUrl;
|
|
310
1206
|
var url = new URL(requestableUrl || window.location.origin);
|
|
311
|
-
return /*#__PURE__*/
|
|
1207
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
312
1208
|
label: approvalLabel,
|
|
313
1209
|
style: "link",
|
|
314
1210
|
to: url.pathname
|
|
@@ -327,7 +1223,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
327
1223
|
width: "25%",
|
|
328
1224
|
title: i18next.t("neetoApprovals.common.status"),
|
|
329
1225
|
render: function render(status) {
|
|
330
|
-
return /*#__PURE__*/
|
|
1226
|
+
return /*#__PURE__*/jsxRuntime.jsx(Tag__default["default"], {
|
|
331
1227
|
label: neetoCist.capitalize(status),
|
|
332
1228
|
style: STATUS_TAG_STYLE[status]
|
|
333
1229
|
});
|
|
@@ -339,7 +1235,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
339
1235
|
width: "25%",
|
|
340
1236
|
title: i18next.t("neetoApprovals.common.created"),
|
|
341
1237
|
render: function render(createdAt) {
|
|
342
|
-
return /*#__PURE__*/
|
|
1238
|
+
return /*#__PURE__*/jsxRuntime.jsx(DateFormat__default["default"].FromNow, {
|
|
343
1239
|
date: createdAt,
|
|
344
1240
|
typographyProps: {
|
|
345
1241
|
style: "body2"
|
|
@@ -357,77 +1253,40 @@ var Footer = function Footer(_ref) {
|
|
|
357
1253
|
t = _useTranslation.t;
|
|
358
1254
|
if (!isCurrentUserApprover && !isCurrentUserRequester) return null;
|
|
359
1255
|
if (isCurrentUserApprover) {
|
|
360
|
-
return /*#__PURE__*/
|
|
361
|
-
className: "flex gap-x-2"
|
|
362
|
-
|
|
363
|
-
|
|
1256
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Footer, {
|
|
1257
|
+
className: "flex gap-x-2",
|
|
1258
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
1259
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
1260
|
+
loading: isLoading,
|
|
1261
|
+
type: "submit",
|
|
1262
|
+
onClick: function onClick() {
|
|
1263
|
+
return handleSubmit(STATUSES.approved);
|
|
1264
|
+
}
|
|
1265
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
1266
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
1267
|
+
loading: isLoading,
|
|
1268
|
+
style: "text",
|
|
1269
|
+
onClick: function onClick() {
|
|
1270
|
+
return handleSubmit(STATUSES.rejected);
|
|
1271
|
+
}
|
|
1272
|
+
})]
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
return /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
|
|
1276
|
+
className: "flex gap-x-2",
|
|
1277
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
1278
|
+
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
364
1279
|
loading: isLoading,
|
|
365
1280
|
type: "submit",
|
|
366
1281
|
onClick: function onClick() {
|
|
367
|
-
return handleSubmit(STATUSES.
|
|
368
|
-
}
|
|
369
|
-
}), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
370
|
-
label: t("neetoApprovals.buttons.decline"),
|
|
371
|
-
loading: isLoading,
|
|
372
|
-
style: "text",
|
|
373
|
-
onClick: function onClick() {
|
|
374
|
-
return handleSubmit(STATUSES.rejected);
|
|
1282
|
+
return handleSubmit(STATUSES.cancelled);
|
|
375
1283
|
}
|
|
376
|
-
})
|
|
377
|
-
}
|
|
378
|
-
return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
|
|
379
|
-
className: "flex gap-x-2"
|
|
380
|
-
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
381
|
-
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
382
|
-
loading: isLoading,
|
|
383
|
-
type: "submit",
|
|
384
|
-
onClick: function onClick() {
|
|
385
|
-
return handleSubmit(STATUSES.cancelled);
|
|
386
|
-
}
|
|
387
|
-
}));
|
|
1284
|
+
})
|
|
1285
|
+
});
|
|
388
1286
|
};
|
|
389
1287
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
function getDefaultExportFromCjs (x) {
|
|
393
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
var dayjs_min = {exports: {}};
|
|
397
|
-
|
|
398
|
-
dayjs_min.exports;
|
|
399
|
-
|
|
400
|
-
(function (module, exports) {
|
|
401
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
402
|
-
} (dayjs_min, dayjs_min.exports));
|
|
403
|
-
|
|
404
|
-
var dayjs_minExports = dayjs_min.exports;
|
|
405
|
-
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
406
|
-
|
|
407
|
-
var timezone$1 = {exports: {}};
|
|
408
|
-
|
|
409
|
-
timezone$1.exports;
|
|
410
|
-
|
|
411
|
-
(function (module, exports) {
|
|
412
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];return r||(r=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10));}var d=r[3],l=24===d?0:d,h=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",v=+e;return (o.utc(h).valueOf()-(v-=v%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n=this.utcOffset(),i=this.toDate(),a=i.toLocaleString("en-US",{timeZone:t}),u=Math.round((i-new Date(a))/1e3/60),f=o(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-u,!0);if(e){var s=f.utcOffset();f=f.add(n-s,"minute");}return f.$x.$timezone=t,f},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return "timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return [i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t;};}}));
|
|
413
|
-
} (timezone$1, timezone$1.exports));
|
|
414
|
-
|
|
415
|
-
var timezoneExports = timezone$1.exports;
|
|
416
|
-
var timezone = /*@__PURE__*/getDefaultExportFromCjs(timezoneExports);
|
|
417
|
-
|
|
418
|
-
var utc$1 = {exports: {}};
|
|
419
|
-
|
|
420
|
-
utc$1.exports;
|
|
421
|
-
|
|
422
|
-
(function (module, exports) {
|
|
423
|
-
!function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
|
|
424
|
-
} (utc$1, utc$1.exports));
|
|
425
|
-
|
|
426
|
-
var utcExports = utc$1.exports;
|
|
427
|
-
var utc = /*@__PURE__*/getDefaultExportFromCjs(utcExports);
|
|
428
|
-
|
|
429
|
-
dayjs.extend(utc);
|
|
430
|
-
dayjs.extend(timezone);
|
|
1288
|
+
dayjs__default["default"].extend(utc__default["default"]);
|
|
1289
|
+
dayjs__default["default"].extend(timezone__default["default"]);
|
|
431
1290
|
var updateApprovalDetails = function updateApprovalDetails(_ref) {
|
|
432
1291
|
var requestsData = _ref.requestsData,
|
|
433
1292
|
approvalDetails = _ref.approvalDetails;
|
|
@@ -441,8 +1300,8 @@ var updateApprovalDetails = function updateApprovalDetails(_ref) {
|
|
|
441
1300
|
};
|
|
442
1301
|
var timeInZone = function timeInZone(time) {
|
|
443
1302
|
var _globalProps$user, _globalProps$user2;
|
|
444
|
-
((_globalProps$user = initializers.globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.timeZone) &&
|
|
445
|
-
return
|
|
1303
|
+
((_globalProps$user = initializers.globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.timeZone) && dayjs__default["default"].tz.setDefault((_globalProps$user2 = initializers.globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.timeZone);
|
|
1304
|
+
return dayjs__default["default"](time).tz();
|
|
446
1305
|
};
|
|
447
1306
|
var getApprovalFilter = function getApprovalFilter() {
|
|
448
1307
|
return {
|
|
@@ -488,7 +1347,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
488
1347
|
setNote = _useState2[1];
|
|
489
1348
|
var _useUpdateRequest = useUpdateRequest(),
|
|
490
1349
|
updatePendingRequest = _useUpdateRequest.mutate,
|
|
491
|
-
|
|
1350
|
+
isUpdateRequestPending = _useUpdateRequest.isPending;
|
|
492
1351
|
React.useEffect(function () {
|
|
493
1352
|
setNote(initialNote);
|
|
494
1353
|
}, [initialNote]);
|
|
@@ -516,65 +1375,82 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
516
1375
|
onSuccess: handleOnClose
|
|
517
1376
|
});
|
|
518
1377
|
};
|
|
519
|
-
return /*#__PURE__*/
|
|
1378
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
520
1379
|
isOpen: isOpen,
|
|
521
1380
|
size: "large",
|
|
522
|
-
onClose: handleOnClose
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
1381
|
+
onClose: handleOnClose,
|
|
1382
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Header, {
|
|
1383
|
+
className: "space-y-2",
|
|
1384
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1385
|
+
style: "h2",
|
|
1386
|
+
children: title
|
|
1387
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Tag__default["default"], {
|
|
1388
|
+
label: neetoCist.capitalize(status),
|
|
1389
|
+
style: STATUS_TAG_STYLE[status]
|
|
1390
|
+
})]
|
|
1391
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Body, {
|
|
1392
|
+
className: "space-y-6",
|
|
1393
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1394
|
+
className: "w-full divide-y border px-3",
|
|
1395
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1396
|
+
className: "flex space-x-3 p-2",
|
|
1397
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1398
|
+
className: "font-normal",
|
|
1399
|
+
children: getStatusLabel()
|
|
1400
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1401
|
+
style: "body2",
|
|
1402
|
+
weight: "medium",
|
|
1403
|
+
children: requesterOrApproverDetails
|
|
1404
|
+
})]
|
|
1405
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1406
|
+
className: "flex space-x-3 p-2",
|
|
1407
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1408
|
+
className: "font-normal",
|
|
1409
|
+
children: t("neetoApprovals.common.created")
|
|
1410
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1411
|
+
style: "body2",
|
|
1412
|
+
weight: "medium",
|
|
1413
|
+
children: utils.dateFormat.defaultWithTime(timeInZone(createdAt))
|
|
1414
|
+
})]
|
|
1415
|
+
})]
|
|
1416
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1417
|
+
className: "w-full space-y-2",
|
|
1418
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1419
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
1420
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedEditorContent$1, {
|
|
1421
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
1422
|
+
content: message
|
|
1423
|
+
})]
|
|
1424
|
+
}), isPending && isCurrentUserApprover && /*#__PURE__*/jsxRuntime.jsx(Textarea__default["default"], {
|
|
1425
|
+
className: "w-full",
|
|
1426
|
+
disabled: !isPending,
|
|
1427
|
+
label: t("neetoApprovals.common.note"),
|
|
1428
|
+
value: note,
|
|
1429
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
1430
|
+
what: t("neetoApprovals.common.note")
|
|
1431
|
+
}),
|
|
1432
|
+
onChange: utils.withEventTargetValue(setNote)
|
|
1433
|
+
}), !isPending && note && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1434
|
+
className: "w-full space-y-2",
|
|
1435
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1436
|
+
children: t("neetoApprovals.common.note")
|
|
1437
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1438
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
1439
|
+
children: note
|
|
1440
|
+
})]
|
|
1441
|
+
})]
|
|
1442
|
+
}), isPending && /*#__PURE__*/jsxRuntime.jsx(Footer, {
|
|
1443
|
+
handleSubmit: handleSubmit,
|
|
1444
|
+
isCurrentUserApprover: isCurrentUserApprover,
|
|
1445
|
+
isCurrentUserRequester: isCurrentUserRequester,
|
|
1446
|
+
isLoading: isUpdateRequestPending
|
|
1447
|
+
})]
|
|
1448
|
+
});
|
|
572
1449
|
};
|
|
573
1450
|
|
|
574
1451
|
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
575
1452
|
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
576
1453
|
var History = function History(_ref) {
|
|
577
|
-
var _t;
|
|
578
1454
|
var requestUrl = _ref.requestUrl;
|
|
579
1455
|
var _useState = React.useState(DEFAULT_FILTER_VALUES),
|
|
580
1456
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -595,64 +1471,66 @@ var History = function History(_ref) {
|
|
|
595
1471
|
searchTerm: debouncedSearchTerm.trim(),
|
|
596
1472
|
status: [STATUSES.approved, STATUSES.rejected, STATUSES.cancelled]
|
|
597
1473
|
}),
|
|
598
|
-
options: {
|
|
599
|
-
onSuccess: function onSuccess(_ref2) {
|
|
600
|
-
var requests = _ref2.requests;
|
|
601
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
602
|
-
setApprovalDetails(function (approvalDetails) {
|
|
603
|
-
return updateApprovalDetails({
|
|
604
|
-
requestsData: requests,
|
|
605
|
-
approvalDetails: approvalDetails
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
1474
|
requestUrl: requestUrl
|
|
611
1475
|
}),
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
approvalHistories =
|
|
616
|
-
|
|
617
|
-
totalCount =
|
|
1476
|
+
data = _useFetchRequests.data;
|
|
1477
|
+
var _ref2 = data || {},
|
|
1478
|
+
_ref2$requests = _ref2.requests,
|
|
1479
|
+
approvalHistories = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
1480
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
1481
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
1482
|
+
React.useEffect(function () {
|
|
1483
|
+
if (!data) return;
|
|
1484
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
1485
|
+
setApprovalDetails(function (approvalDetails) {
|
|
1486
|
+
return updateApprovalDetails({
|
|
1487
|
+
requestsData: data === null || data === void 0 ? void 0 : data.requests,
|
|
1488
|
+
approvalDetails: approvalDetails
|
|
1489
|
+
});
|
|
1490
|
+
});
|
|
1491
|
+
}, [data]);
|
|
618
1492
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
619
1493
|
setFilters(_objectSpread$a(_objectSpread$a({}, filters), {}, {
|
|
620
1494
|
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
621
1495
|
orderBy: SORT_ORDER[sorter.order]
|
|
622
1496
|
}));
|
|
623
1497
|
};
|
|
624
|
-
return /*#__PURE__*/
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
1498
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1499
|
+
children: [!ramda.isEmpty(approvalHistories) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
1500
|
+
className: "mt-6",
|
|
1501
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
1502
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
1503
|
+
handlePageChange: handlePageChange,
|
|
1504
|
+
totalCount: totalCount,
|
|
1505
|
+
allowRowClick: true,
|
|
1506
|
+
fixedHeight: true,
|
|
1507
|
+
columnData: HISTORY_TABLE_COLUMNS,
|
|
1508
|
+
currentPageNumber: pageProperties.page,
|
|
1509
|
+
defaultPageSize: pageProperties.pageSize,
|
|
1510
|
+
rowData: approvalHistories,
|
|
1511
|
+
paginationProps: {
|
|
1512
|
+
hideOnSinglePage: (approvalHistories === null || approvalHistories === void 0 ? void 0 : approvalHistories.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
1513
|
+
},
|
|
1514
|
+
onChange: handleTableChange,
|
|
1515
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
1516
|
+
return setApprovalDetails(approvalDetails);
|
|
1517
|
+
}
|
|
1518
|
+
})
|
|
1519
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1520
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
1521
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], {
|
|
1522
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
1523
|
+
what: t("neetoApprovals.common.record", constants.PLURAL)
|
|
1524
|
+
})
|
|
1525
|
+
})
|
|
1526
|
+
}), /*#__PURE__*/jsxRuntime.jsx(RequestDetailsPane, {
|
|
1527
|
+
approvalDetails: approvalDetails,
|
|
1528
|
+
isOpen: neetoCist.isPresent(approvalDetails),
|
|
1529
|
+
onClose: function onClose() {
|
|
1530
|
+
return setApprovalDetails({});
|
|
1531
|
+
}
|
|
1532
|
+
})]
|
|
1533
|
+
});
|
|
656
1534
|
};
|
|
657
1535
|
|
|
658
1536
|
var PENDING_TABLE_COLUMNS = neetoCist.removeBy({
|
|
@@ -662,7 +1540,6 @@ var PENDING_TABLE_COLUMNS = neetoCist.removeBy({
|
|
|
662
1540
|
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
663
1541
|
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
664
1542
|
var PendingRequests = function PendingRequests(_ref) {
|
|
665
|
-
var _t;
|
|
666
1543
|
var requestUrl = _ref.requestUrl;
|
|
667
1544
|
var _useState = React.useState(DEFAULT_FILTER_VALUES),
|
|
668
1545
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -683,75 +1560,62 @@ var PendingRequests = function PendingRequests(_ref) {
|
|
|
683
1560
|
searchTerm: debouncedSearchTerm.trim(),
|
|
684
1561
|
status: [STATUSES.pending]
|
|
685
1562
|
}),
|
|
686
|
-
options: {
|
|
687
|
-
onSuccess: function onSuccess(_ref2) {
|
|
688
|
-
var requests = _ref2.requests;
|
|
689
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
690
|
-
}
|
|
691
|
-
},
|
|
692
1563
|
requestUrl: requestUrl
|
|
693
1564
|
}),
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
pendingRequests =
|
|
698
|
-
|
|
699
|
-
totalCount =
|
|
1565
|
+
data = _useFetchRequests.data;
|
|
1566
|
+
var _ref2 = data || {},
|
|
1567
|
+
_ref2$requests = _ref2.requests,
|
|
1568
|
+
pendingRequests = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
1569
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
1570
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
1571
|
+
React.useEffect(function () {
|
|
1572
|
+
if (!data) return;
|
|
1573
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
1574
|
+
}, [data]);
|
|
700
1575
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
701
1576
|
setFilters(_objectSpread$9(_objectSpread$9({}, filters), {}, {
|
|
702
1577
|
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
703
1578
|
orderBy: SORT_ORDER[sorter.order]
|
|
704
1579
|
}));
|
|
705
1580
|
};
|
|
706
|
-
return /*#__PURE__*/
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
})) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
726
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
727
|
-
}, /*#__PURE__*/React__default["default"].createElement(neetoui.NoData, {
|
|
728
|
-
title: t("neetoApprovals.common.notFound_", {
|
|
729
|
-
what: (_t = t("neetoApprovals.common.pendingApproval", constants.PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
730
|
-
})
|
|
731
|
-
})), /*#__PURE__*/React__default["default"].createElement(RequestDetailsPane, {
|
|
732
|
-
isPending: true,
|
|
733
|
-
approvalDetails: approvalDetails,
|
|
734
|
-
isOpen: neetoCist.isPresent(approvalDetails),
|
|
735
|
-
onClose: function onClose() {
|
|
736
|
-
return setApprovalDetails({});
|
|
737
|
-
}
|
|
738
|
-
}));
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
function _extends() {
|
|
742
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
743
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
744
|
-
var source = arguments[i];
|
|
745
|
-
for (var key in source) {
|
|
746
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
747
|
-
target[key] = source[key];
|
|
1581
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1582
|
+
children: [!ramda.isEmpty(pendingRequests) ? /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
1583
|
+
className: "mt-6",
|
|
1584
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
1585
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
1586
|
+
handlePageChange: handlePageChange,
|
|
1587
|
+
totalCount: totalCount,
|
|
1588
|
+
allowRowClick: true,
|
|
1589
|
+
fixedHeight: true,
|
|
1590
|
+
columnData: PENDING_TABLE_COLUMNS,
|
|
1591
|
+
currentPageNumber: pageProperties.page,
|
|
1592
|
+
defaultPageSize: pageProperties.pageSize,
|
|
1593
|
+
rowData: pendingRequests,
|
|
1594
|
+
paginationProps: {
|
|
1595
|
+
hideOnSinglePage: (pendingRequests === null || pendingRequests === void 0 ? void 0 : pendingRequests.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
1596
|
+
},
|
|
1597
|
+
onChange: handleTableChange,
|
|
1598
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
1599
|
+
return setApprovalDetails(approvalDetails);
|
|
748
1600
|
}
|
|
1601
|
+
})
|
|
1602
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1603
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
1604
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], {
|
|
1605
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
1606
|
+
what: t("neetoApprovals.common.pendingApproval", constants.PLURAL)
|
|
1607
|
+
})
|
|
1608
|
+
})
|
|
1609
|
+
}), /*#__PURE__*/jsxRuntime.jsx(RequestDetailsPane, {
|
|
1610
|
+
approvalDetails: approvalDetails,
|
|
1611
|
+
isPending: true,
|
|
1612
|
+
isOpen: neetoCist.isPresent(approvalDetails),
|
|
1613
|
+
onClose: function onClose() {
|
|
1614
|
+
return setApprovalDetails({});
|
|
749
1615
|
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
return _extends.apply(this, arguments);
|
|
754
|
-
}
|
|
1616
|
+
})]
|
|
1617
|
+
});
|
|
1618
|
+
};
|
|
755
1619
|
|
|
756
1620
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
757
1621
|
if (source == null) return {};
|
|
@@ -824,48 +1688,47 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
824
1688
|
var useFetchTemplates = function useFetchTemplates() {
|
|
825
1689
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
826
1690
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
827
|
-
return
|
|
828
|
-
|
|
829
|
-
|
|
1691
|
+
return useQuery(_objectSpread$8({
|
|
1692
|
+
queryKey: [QUERY_KEYS.TEMPLATES, params],
|
|
1693
|
+
queryFn: function queryFn() {
|
|
1694
|
+
return templatesApi.fetch(params);
|
|
1695
|
+
},
|
|
830
1696
|
select: function select(response) {
|
|
831
1697
|
return response.data || response;
|
|
832
1698
|
},
|
|
833
|
-
|
|
834
|
-
onSuccess: function onSuccess(_ref) {
|
|
835
|
-
var _params$onSuccess;
|
|
836
|
-
var templates = _ref.templates;
|
|
837
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, templates);
|
|
838
|
-
}
|
|
1699
|
+
placeholderData: keepPreviousData
|
|
839
1700
|
}, options));
|
|
840
1701
|
};
|
|
841
|
-
var useFetchTemplate = function useFetchTemplate(
|
|
842
|
-
var id =
|
|
843
|
-
params =
|
|
844
|
-
return
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1702
|
+
var useFetchTemplate = function useFetchTemplate(_ref) {
|
|
1703
|
+
var id = _ref.id,
|
|
1704
|
+
params = _ref.params;
|
|
1705
|
+
return useQuery({
|
|
1706
|
+
queryKey: [QUERY_KEYS.SHOW_TEMPLATE, id, params],
|
|
1707
|
+
queryFn: function queryFn() {
|
|
1708
|
+
return templatesApi.show({
|
|
1709
|
+
id: id,
|
|
1710
|
+
params: params
|
|
1711
|
+
});
|
|
1712
|
+
},
|
|
850
1713
|
enabled: !!id
|
|
851
1714
|
});
|
|
852
1715
|
};
|
|
853
1716
|
var useCreateTemplate = function useCreateTemplate(options) {
|
|
854
1717
|
return reactUtils.useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
|
|
855
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1718
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
856
1719
|
}, options));
|
|
857
1720
|
};
|
|
858
1721
|
var useUpdateTemplate = function useUpdateTemplate(options) {
|
|
859
1722
|
return reactUtils.useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
|
|
860
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, function (_,
|
|
861
|
-
var id =
|
|
1723
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], function (_, _ref2) {
|
|
1724
|
+
var id = _ref2.id;
|
|
862
1725
|
return [QUERY_KEYS.SHOW_TEMPLATE, id];
|
|
863
1726
|
}]
|
|
864
1727
|
}, options));
|
|
865
1728
|
};
|
|
866
1729
|
var useDeleteTemplate = function useDeleteTemplate(options) {
|
|
867
1730
|
return reactUtils.useMutationWithInvalidation(templatesApi.destroy, _objectSpread$8({
|
|
868
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1731
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
869
1732
|
}, options));
|
|
870
1733
|
};
|
|
871
1734
|
|
|
@@ -891,7 +1754,7 @@ var MessageEditor = reactUtils.withT(function (_ref) {
|
|
|
891
1754
|
placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
|
|
892
1755
|
_ref$initialValue = _ref.initialValue,
|
|
893
1756
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
894
|
-
return /*#__PURE__*/
|
|
1757
|
+
return /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, {
|
|
895
1758
|
initialValue: initialValue,
|
|
896
1759
|
required: true,
|
|
897
1760
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
@@ -919,32 +1782,34 @@ var TemplateForm = function TemplateForm(_ref) {
|
|
|
919
1782
|
setFieldValue("description", "");
|
|
920
1783
|
}
|
|
921
1784
|
};
|
|
922
|
-
return /*#__PURE__*/
|
|
923
|
-
className: "flex w-full flex-col space-y-6"
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1785
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1786
|
+
className: "flex w-full flex-col space-y-6",
|
|
1787
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
|
|
1788
|
+
autoFocus: true,
|
|
1789
|
+
required: true,
|
|
1790
|
+
label: t("neetoApprovals.common.name"),
|
|
1791
|
+
name: "name",
|
|
1792
|
+
placeholder: t("neetoApprovals.inputs.placeholders.name")
|
|
1793
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ToggleFeatureCard__default["default"], {
|
|
1794
|
+
switchName: "descriptionEnabled",
|
|
1795
|
+
title: t("neetoApprovals.inputs.labels.description"),
|
|
1796
|
+
switchProps: {
|
|
1797
|
+
onChange: handleDescriptionToggle,
|
|
1798
|
+
tooltipProps: {
|
|
1799
|
+
enabledSwitchText: t("neetoApprovals.templates.descriptionToggle.enable"),
|
|
1800
|
+
disabledSwitchText: t("neetoApprovals.templates.descriptionToggle.disable")
|
|
1801
|
+
}
|
|
1802
|
+
},
|
|
1803
|
+
children: values.descriptionEnabled && /*#__PURE__*/jsxRuntime.jsx(Textarea__default$1["default"], {
|
|
1804
|
+
className: "w-full",
|
|
1805
|
+
name: "description",
|
|
1806
|
+
placeholder: t("neetoApprovals.inputs.placeholders.description")
|
|
1807
|
+
})
|
|
1808
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MessageEditor, {
|
|
1809
|
+
placeholders: placeholders,
|
|
1810
|
+
initialValue: initialData.message
|
|
1811
|
+
})]
|
|
1812
|
+
});
|
|
948
1813
|
};
|
|
949
1814
|
|
|
950
1815
|
var Form$2 = function Form(_ref) {
|
|
@@ -965,36 +1830,42 @@ var Form$2 = function Form(_ref) {
|
|
|
965
1830
|
}) : t("neetoApprovals.common.edit_", {
|
|
966
1831
|
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
967
1832
|
});
|
|
968
|
-
return /*#__PURE__*/
|
|
1833
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
969
1834
|
isOpen: isOpen,
|
|
970
1835
|
onClose: onClose,
|
|
971
1836
|
initialFocusRef: inputReference,
|
|
972
|
-
size: "large"
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1837
|
+
size: "large",
|
|
1838
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
1839
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1840
|
+
style: "h2",
|
|
1841
|
+
children: header
|
|
1842
|
+
})
|
|
1843
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(FormikForm__default["default"], {
|
|
1844
|
+
formikProps: {
|
|
1845
|
+
enableReinitialize: true,
|
|
1846
|
+
initialValues: neetoCist.isPresent(initialData) ? initialData : TEMPLATE_FORM_INITIAL_VALUES,
|
|
1847
|
+
validationSchema: TEMPLATE_FORM_VALIDATION_SCHEMA,
|
|
1848
|
+
onSubmit: onSubmit
|
|
1849
|
+
},
|
|
1850
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
|
|
1851
|
+
children: /*#__PURE__*/jsxRuntime.jsx(TemplateForm, {
|
|
1852
|
+
initialData: initialData,
|
|
1853
|
+
placeholders: placeholders
|
|
1854
|
+
})
|
|
1855
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
|
|
1856
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
|
|
1857
|
+
isSubmitting: isLoading,
|
|
1858
|
+
cancelButtonProps: {
|
|
1859
|
+
"data-cy": "neeto-approvals-templates-close-template-form-btn",
|
|
1860
|
+
onClick: onClose
|
|
1861
|
+
},
|
|
1862
|
+
submitButtonProps: {
|
|
1863
|
+
"data-cy": "neeto-approvals-templates-save-template-btn"
|
|
1864
|
+
}
|
|
1865
|
+
})
|
|
1866
|
+
})]
|
|
1867
|
+
})]
|
|
1868
|
+
});
|
|
998
1869
|
};
|
|
999
1870
|
|
|
1000
1871
|
var Create = function Create(_ref) {
|
|
@@ -1004,7 +1875,7 @@ var Create = function Create(_ref) {
|
|
|
1004
1875
|
templatePlaceholders = _ref.templatePlaceholders;
|
|
1005
1876
|
var _useCreateTemplate = useCreateTemplate(),
|
|
1006
1877
|
createTemplate = _useCreateTemplate.mutate,
|
|
1007
|
-
|
|
1878
|
+
isPending = _useCreateTemplate.isPending;
|
|
1008
1879
|
var onSubmit = function onSubmit(template) {
|
|
1009
1880
|
var payload = {
|
|
1010
1881
|
template: template
|
|
@@ -1016,11 +1887,11 @@ var Create = function Create(_ref) {
|
|
|
1016
1887
|
onSuccess: onClose
|
|
1017
1888
|
});
|
|
1018
1889
|
};
|
|
1019
|
-
return /*#__PURE__*/
|
|
1020
|
-
isLoading: isLoading,
|
|
1890
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1021
1891
|
isOpen: isOpen,
|
|
1022
1892
|
onClose: onClose,
|
|
1023
1893
|
onSubmit: onSubmit,
|
|
1894
|
+
isLoading: isPending,
|
|
1024
1895
|
placeholders: templatePlaceholders
|
|
1025
1896
|
});
|
|
1026
1897
|
};
|
|
@@ -1040,7 +1911,7 @@ var Edit = function Edit(_ref) {
|
|
|
1040
1911
|
}
|
|
1041
1912
|
}),
|
|
1042
1913
|
updateTemplate = _useUpdateTemplate.mutate,
|
|
1043
|
-
isUpdating = _useUpdateTemplate.
|
|
1914
|
+
isUpdating = _useUpdateTemplate.isPending;
|
|
1044
1915
|
var onSubmit = function onSubmit(template) {
|
|
1045
1916
|
var payload = {
|
|
1046
1917
|
template: template
|
|
@@ -1054,7 +1925,7 @@ var Edit = function Edit(_ref) {
|
|
|
1054
1925
|
var initialData = _objectSpread$7(_objectSpread$7({}, template), {}, {
|
|
1055
1926
|
descriptionEnabled: !!template.description
|
|
1056
1927
|
});
|
|
1057
|
-
return /*#__PURE__*/
|
|
1928
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1058
1929
|
initialData: initialData,
|
|
1059
1930
|
isOpen: isOpen,
|
|
1060
1931
|
onClose: onClose,
|
|
@@ -1067,14 +1938,17 @@ var Edit = function Edit(_ref) {
|
|
|
1067
1938
|
var Field = function Field(_ref) {
|
|
1068
1939
|
var label = _ref.label,
|
|
1069
1940
|
value = _ref.value;
|
|
1070
|
-
return /*#__PURE__*/
|
|
1071
|
-
className: "flex flex-col items-start justify-center"
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1941
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1942
|
+
className: "flex flex-col items-start justify-center",
|
|
1943
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1944
|
+
className: "mb-1 font-normal",
|
|
1945
|
+
children: label
|
|
1946
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1947
|
+
style: "body1",
|
|
1948
|
+
weight: "medium",
|
|
1949
|
+
children: value
|
|
1950
|
+
})]
|
|
1951
|
+
});
|
|
1078
1952
|
};
|
|
1079
1953
|
var Field$1 = /*#__PURE__*/React__default["default"].memo(Field);
|
|
1080
1954
|
|
|
@@ -1088,41 +1962,47 @@ var TemplateDetails = function TemplateDetails(_ref) {
|
|
|
1088
1962
|
var name = template.name,
|
|
1089
1963
|
description = template.description,
|
|
1090
1964
|
message = template.message;
|
|
1091
|
-
return /*#__PURE__*/
|
|
1965
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
1092
1966
|
isOpen: isOpen,
|
|
1093
|
-
onClose: onClose
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1967
|
+
onClose: onClose,
|
|
1968
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
1969
|
+
className: "space-y-2",
|
|
1970
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
1971
|
+
style: "h2",
|
|
1972
|
+
children: t("neetoApprovals.common.templateDetails")
|
|
1973
|
+
})
|
|
1974
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"].Body, {
|
|
1975
|
+
className: "space-y-6",
|
|
1976
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Field$1, {
|
|
1977
|
+
label: t("neetoApprovals.common.name"),
|
|
1978
|
+
value: name
|
|
1979
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Field$1, {
|
|
1980
|
+
label: t("neetoApprovals.inputs.labels.description"),
|
|
1981
|
+
value: description
|
|
1982
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1983
|
+
className: "flex w-full flex-col space-y-4",
|
|
1984
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
|
|
1985
|
+
className: "mb-1 font-normal",
|
|
1986
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
1987
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedEditorContent, {
|
|
1988
|
+
className: "neeto-ui-bg-gray-100 neeto-ui-rounded-lg p-3",
|
|
1989
|
+
content: message
|
|
1990
|
+
})]
|
|
1991
|
+
})]
|
|
1992
|
+
})]
|
|
1993
|
+
});
|
|
1114
1994
|
};
|
|
1115
1995
|
|
|
1116
1996
|
var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
|
|
1117
1997
|
var entity = _ref.entity,
|
|
1118
1998
|
url = _ref.url;
|
|
1119
|
-
return /*#__PURE__*/
|
|
1999
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1120
2000
|
i18nKey: "neetoApprovals.common.noDataHelpText",
|
|
1121
2001
|
values: {
|
|
1122
2002
|
entity: entity
|
|
1123
2003
|
},
|
|
1124
2004
|
components: {
|
|
1125
|
-
a: /*#__PURE__*/
|
|
2005
|
+
a: /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Link, {
|
|
1126
2006
|
className: "neeto-ui-text-primary-600 underline",
|
|
1127
2007
|
target: "_blank",
|
|
1128
2008
|
to: {
|
|
@@ -1177,34 +2057,36 @@ var Table = function Table(_ref) {
|
|
|
1177
2057
|
})
|
|
1178
2058
|
};
|
|
1179
2059
|
if (ramda.isEmpty(rowData)) {
|
|
1180
|
-
return /*#__PURE__*/
|
|
1181
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
2060
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2061
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
2062
|
+
children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$6({
|
|
2063
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
2064
|
+
what: entity
|
|
2065
|
+
})
|
|
2066
|
+
}, !filters.searchTerm && noDataProps))
|
|
2067
|
+
});
|
|
1187
2068
|
}
|
|
1188
|
-
return /*#__PURE__*/
|
|
2069
|
+
return /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
1189
2070
|
className: "mt-6",
|
|
1190
|
-
hasPagination: totalCount > pageProperties.pageSize
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
2071
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
2072
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], _objectSpread$6({
|
|
2073
|
+
fixedHeight: true,
|
|
2074
|
+
columnData: columns,
|
|
2075
|
+
currentPageNumber: pageProperties.page,
|
|
2076
|
+
defaultPageSize: pageProperties.pageSize,
|
|
2077
|
+
scroll: {
|
|
2078
|
+
x: 0
|
|
2079
|
+
},
|
|
2080
|
+
tableLayout: "fixed",
|
|
2081
|
+
paginationProps: {
|
|
2082
|
+
hideOnSinglePage: (rowData === null || rowData === void 0 ? void 0 : rowData.length) < constants.DEFAULT_PAGE_SIZE + 1
|
|
2083
|
+
},
|
|
2084
|
+
onChange: handleTableChange
|
|
2085
|
+
}, _objectSpread$6({
|
|
2086
|
+
rowData: rowData,
|
|
2087
|
+
totalCount: totalCount
|
|
2088
|
+
}, otherProps)))
|
|
2089
|
+
});
|
|
1208
2090
|
};
|
|
1209
2091
|
|
|
1210
2092
|
var columnData = function columnData(_ref) {
|
|
@@ -1217,32 +2099,34 @@ var columnData = function columnData(_ref) {
|
|
|
1217
2099
|
title: i18next__default["default"].t("neetoApprovals.common.name"),
|
|
1218
2100
|
ellipsis: true,
|
|
1219
2101
|
render: function render(_, template) {
|
|
1220
|
-
return /*#__PURE__*/
|
|
1221
|
-
className: "flex items-center justify-between gap-x-3"
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
2102
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2103
|
+
className: "flex items-center justify-between gap-x-3",
|
|
2104
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
2105
|
+
className: "truncate",
|
|
2106
|
+
style: "body2",
|
|
2107
|
+
children: template.name
|
|
2108
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
|
|
2109
|
+
dropdownProps: {
|
|
2110
|
+
strategy: "fixed",
|
|
2111
|
+
onClick: function onClick(e) {
|
|
2112
|
+
return e.stopPropagation();
|
|
2113
|
+
}
|
|
2114
|
+
},
|
|
2115
|
+
menuItems: [_defineProperty({
|
|
2116
|
+
key: "edit",
|
|
2117
|
+
label: i18next__default["default"].t("neetoApprovals.common.edit"),
|
|
2118
|
+
onClick: function onClick(event) {
|
|
2119
|
+
return onEditClick(event, template);
|
|
2120
|
+
}
|
|
2121
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-edit-template-btn"), _defineProperty({
|
|
2122
|
+
key: "delete",
|
|
2123
|
+
label: i18next__default["default"].t("neetoApprovals.common.delete"),
|
|
2124
|
+
onClick: function onClick(event) {
|
|
2125
|
+
return onDeleteClick(event, template);
|
|
2126
|
+
}
|
|
2127
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-delete-template-btn")]
|
|
2128
|
+
})]
|
|
2129
|
+
});
|
|
1246
2130
|
}
|
|
1247
2131
|
}, {
|
|
1248
2132
|
dataIndex: "description",
|
|
@@ -1255,7 +2139,6 @@ var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpe
|
|
|
1255
2139
|
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1256
2140
|
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1257
2141
|
var Templates = function Templates(_ref) {
|
|
1258
|
-
var _t, _t2, _t3;
|
|
1259
2142
|
var searchTerm = _ref.searchTerm,
|
|
1260
2143
|
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
1261
2144
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
|
|
@@ -1293,28 +2176,27 @@ var Templates = function Templates(_ref) {
|
|
|
1293
2176
|
}, [searchTerm]);
|
|
1294
2177
|
var _useFetchTemplates = useFetchTemplates(_objectSpread$5(_objectSpread$5(_objectSpread$5({}, pageProperties), filters), {}, {
|
|
1295
2178
|
searchTerm: debouncedSearchTerm.trim()
|
|
1296
|
-
}),
|
|
1297
|
-
|
|
1298
|
-
var templates = _ref2.templates;
|
|
1299
|
-
handleEmptyPage(templates, pageProperties, handlePageChange);
|
|
1300
|
-
}
|
|
1301
|
-
}),
|
|
1302
|
-
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1303
|
-
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1304
|
-
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1305
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
1306
|
-
_useFetchTemplates$da4 = _useFetchTemplates$da2.totalCount,
|
|
1307
|
-
totalCount = _useFetchTemplates$da4 === void 0 ? 0 : _useFetchTemplates$da4,
|
|
2179
|
+
})),
|
|
2180
|
+
data = _useFetchTemplates.data,
|
|
1308
2181
|
isTemplateLoading = _useFetchTemplates.isLoading;
|
|
2182
|
+
var _ref2 = data || {},
|
|
2183
|
+
_ref2$templates = _ref2.templates,
|
|
2184
|
+
templates = _ref2$templates === void 0 ? [] : _ref2$templates,
|
|
2185
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
2186
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
2187
|
+
React.useEffect(function () {
|
|
2188
|
+
if (data) {
|
|
2189
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.templates, pageProperties, handlePageChange);
|
|
2190
|
+
}
|
|
2191
|
+
}, [data]);
|
|
1309
2192
|
var _useDeleteTemplate = useDeleteTemplate(),
|
|
1310
2193
|
deleteTemplate = _useDeleteTemplate.mutate,
|
|
1311
|
-
isDeleting = _useDeleteTemplate.
|
|
2194
|
+
isDeleting = _useDeleteTemplate.isPending;
|
|
1312
2195
|
React.useEffect(function () {
|
|
1313
|
-
if (ramda.isEmpty(selectedTemplate))
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
}
|
|
2196
|
+
if (!ramda.isEmpty(selectedTemplate)) return;
|
|
2197
|
+
setIsDeleteAlertOpen(false);
|
|
2198
|
+
setIsEditPaneOpen(false);
|
|
2199
|
+
setIsShowPaneOpen(false);
|
|
1318
2200
|
}, [selectedTemplate]);
|
|
1319
2201
|
var onEditClick = function onEditClick(event, template) {
|
|
1320
2202
|
event.stopPropagation();
|
|
@@ -1336,62 +2218,64 @@ var Templates = function Templates(_ref) {
|
|
|
1336
2218
|
});
|
|
1337
2219
|
setSelectedTemplate({});
|
|
1338
2220
|
};
|
|
1339
|
-
var entity =
|
|
1340
|
-
return /*#__PURE__*/
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}, otherProps)), /*#__PURE__*/React__default["default"].createElement(Edit, _extends({
|
|
1361
|
-
isOpen: isEditPaneOpen,
|
|
1362
|
-
setTemplate: setSelectedTemplate,
|
|
1363
|
-
template: selectedTemplate
|
|
1364
|
-
}, otherProps, {
|
|
1365
|
-
onClose: function onClose() {
|
|
1366
|
-
return setIsEditPaneOpen(false);
|
|
1367
|
-
}
|
|
1368
|
-
})), /*#__PURE__*/React__default["default"].createElement(neetoui.Alert, {
|
|
1369
|
-
isOpen: isDeleteAlertOpen,
|
|
1370
|
-
isSubmitting: isDeleting,
|
|
1371
|
-
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
1372
|
-
message: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
|
|
1373
|
-
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
1374
|
-
values: {
|
|
1375
|
-
what: (_t2 = t("neetoApprovals.common.template", constants.SINGULAR)) === null || _t2 === void 0 ? void 0 : _t2.toLocaleLowerCase(),
|
|
1376
|
-
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
2221
|
+
var entity = t("neetoApprovals.common.template", constants.PLURAL);
|
|
2222
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2223
|
+
children: [isTemplateLoading ? /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {}) : /*#__PURE__*/jsxRuntime.jsx(Table, {
|
|
2224
|
+
columnData: columnData,
|
|
2225
|
+
entity: entity,
|
|
2226
|
+
filters: filters,
|
|
2227
|
+
handlePageChange: handlePageChange,
|
|
2228
|
+
helpDocUrl: helpDocUrl,
|
|
2229
|
+
onDeleteClick: onDeleteClick,
|
|
2230
|
+
onEditClick: onEditClick,
|
|
2231
|
+
onRowClick: onRowClick,
|
|
2232
|
+
pageProperties: pageProperties,
|
|
2233
|
+
searchTerm: searchTerm,
|
|
2234
|
+
setFilters: setFilters,
|
|
2235
|
+
totalCount: totalCount,
|
|
2236
|
+
rowData: templates,
|
|
2237
|
+
setIsPaneOpen: setIsNewTemplatePaneOpen
|
|
2238
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Create, _objectSpread$5({
|
|
2239
|
+
isOpen: isNewTemplatePaneOpen,
|
|
2240
|
+
onClose: function onClose() {
|
|
2241
|
+
return setIsNewTemplatePaneOpen(false);
|
|
1377
2242
|
}
|
|
1378
|
-
}),
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
2243
|
+
}, otherProps)), /*#__PURE__*/jsxRuntime.jsx(Edit, _objectSpread$5(_objectSpread$5({
|
|
2244
|
+
isOpen: isEditPaneOpen,
|
|
2245
|
+
setTemplate: setSelectedTemplate,
|
|
2246
|
+
template: selectedTemplate
|
|
2247
|
+
}, otherProps), {}, {
|
|
2248
|
+
onClose: function onClose() {
|
|
2249
|
+
return setIsEditPaneOpen(false);
|
|
2250
|
+
}
|
|
2251
|
+
})), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
|
|
2252
|
+
isOpen: isDeleteAlertOpen,
|
|
2253
|
+
isSubmitting: isDeleting,
|
|
2254
|
+
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
2255
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
2256
|
+
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
2257
|
+
values: {
|
|
2258
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR),
|
|
2259
|
+
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
2260
|
+
}
|
|
2261
|
+
}),
|
|
2262
|
+
title: t("neetoApprovals.common.delete_", {
|
|
2263
|
+
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
2264
|
+
}),
|
|
2265
|
+
onClose: function onClose() {
|
|
2266
|
+
return setSelectedTemplate({});
|
|
2267
|
+
},
|
|
2268
|
+
onSubmit: function onSubmit() {
|
|
2269
|
+
return handleDelete(selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.id);
|
|
2270
|
+
}
|
|
2271
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TemplateDetails, {
|
|
2272
|
+
isOpen: isShowPaneOpen,
|
|
2273
|
+
template: selectedTemplate,
|
|
2274
|
+
onClose: function onClose() {
|
|
2275
|
+
return setSelectedTemplate({});
|
|
2276
|
+
}
|
|
2277
|
+
})]
|
|
2278
|
+
});
|
|
1395
2279
|
};
|
|
1396
2280
|
|
|
1397
2281
|
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -1403,16 +2287,16 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1403
2287
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
|
|
1404
2288
|
return [{
|
|
1405
2289
|
component: function component() {
|
|
1406
|
-
return /*#__PURE__*/
|
|
2290
|
+
return /*#__PURE__*/jsxRuntime.jsx(Templates, _objectSpread$4({}, _objectSpread$4({
|
|
1407
2291
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1408
2292
|
searchTerm: searchTerm,
|
|
1409
2293
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1410
|
-
}, config));
|
|
2294
|
+
}, config)));
|
|
1411
2295
|
},
|
|
1412
2296
|
path: "".concat(config.approvalsPath).concat(routes.templates.index),
|
|
1413
2297
|
actionBlock: function actionBlock() {
|
|
1414
2298
|
var _t;
|
|
1415
|
-
return /*#__PURE__*/
|
|
2299
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
1416
2300
|
"data-cy": "neeto-approvals-templates-add-new-button",
|
|
1417
2301
|
label: i18next.t("neetoApprovals.common.addNew_", {
|
|
1418
2302
|
what: (_t = i18next.t("neetoApprovals.common.template", constants.SINGULAR)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
@@ -1427,12 +2311,12 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1427
2311
|
})
|
|
1428
2312
|
}, {
|
|
1429
2313
|
component: function component() {
|
|
1430
|
-
return /*#__PURE__*/
|
|
2314
|
+
return /*#__PURE__*/jsxRuntime.jsx(PendingRequests, _objectSpread$4({}, config));
|
|
1431
2315
|
},
|
|
1432
2316
|
path: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1433
2317
|
}, {
|
|
1434
2318
|
component: function component() {
|
|
1435
|
-
return /*#__PURE__*/
|
|
2319
|
+
return /*#__PURE__*/jsxRuntime.jsx(History, _objectSpread$4({}, config));
|
|
1436
2320
|
},
|
|
1437
2321
|
path: "".concat(config.approvalsPath).concat(routes.history)
|
|
1438
2322
|
}];
|
|
@@ -1449,7 +2333,7 @@ var Header = function Header(_ref) {
|
|
|
1449
2333
|
var currentTab = neetoCist.findBy({
|
|
1450
2334
|
path: pathname
|
|
1451
2335
|
}, appRoutes);
|
|
1452
|
-
return /*#__PURE__*/
|
|
2336
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
|
|
1453
2337
|
actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
|
|
1454
2338
|
title: t("neetoApprovals.common.approval", constants.PLURAL),
|
|
1455
2339
|
searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
|
|
@@ -1470,9 +2354,9 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
|
|
|
1470
2354
|
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1471
2355
|
var useFetchViews = function useFetchViews() {
|
|
1472
2356
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1473
|
-
return
|
|
1474
|
-
|
|
1475
|
-
|
|
2357
|
+
return useQuery(_objectSpread$3({
|
|
2358
|
+
queryKey: [QUERY_KEYS.VIEWS],
|
|
2359
|
+
queryFn: viewsApi.fetch,
|
|
1476
2360
|
select: function select(response) {
|
|
1477
2361
|
return response.data || response;
|
|
1478
2362
|
}
|
|
@@ -1499,17 +2383,19 @@ var Tab = function Tab(_ref) {
|
|
|
1499
2383
|
_useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
|
|
1500
2384
|
_useFetchViews$data2$ = _useFetchViews$data2.views,
|
|
1501
2385
|
views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
|
|
1502
|
-
return /*#__PURE__*/
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
2386
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoUITab__default["default"], {
|
|
2387
|
+
children: approvalFilterKeys.map(function (filter) {
|
|
2388
|
+
return /*#__PURE__*/jsxRuntime.jsxs(NeetoUITab__default["default"].Item, {
|
|
2389
|
+
active: isActive(filter),
|
|
2390
|
+
count: views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()],
|
|
2391
|
+
label: approvalFilter[filter].label,
|
|
2392
|
+
onClick: function onClick() {
|
|
2393
|
+
return history.push(getRoute(filter));
|
|
2394
|
+
},
|
|
2395
|
+
children: [approvalFilter[filter].label, " (", views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()] || 0, ")"]
|
|
2396
|
+
}, filter);
|
|
2397
|
+
})
|
|
2398
|
+
});
|
|
1513
2399
|
};
|
|
1514
2400
|
|
|
1515
2401
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -1529,28 +2415,33 @@ var Approvals = function Approvals(_ref) {
|
|
|
1529
2415
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1530
2416
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1531
2417
|
});
|
|
1532
|
-
return /*#__PURE__*/
|
|
1533
|
-
className: "w-full overflow-y-auto"
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
2418
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2419
|
+
className: "w-full overflow-y-auto",
|
|
2420
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
|
|
2421
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, _objectSpread$2({}, _objectSpread$2({
|
|
2422
|
+
appRoutes: appRoutes
|
|
2423
|
+
}, config))), /*#__PURE__*/jsxRuntime.jsx(Tab, {
|
|
2424
|
+
approvalsPath: config.approvalsPath
|
|
2425
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(reactRouterDom.Switch, {
|
|
2426
|
+
children: [appRoutes.map(function (_ref2) {
|
|
2427
|
+
var path = _ref2.path,
|
|
2428
|
+
component = _ref2.component;
|
|
2429
|
+
return /*#__PURE__*/React.createElement(reactRouterDom.Route, {
|
|
2430
|
+
exact: true,
|
|
2431
|
+
component: component,
|
|
2432
|
+
path: path,
|
|
2433
|
+
key: path
|
|
2434
|
+
});
|
|
2435
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Redirect, {
|
|
2436
|
+
exact: true,
|
|
2437
|
+
from: config.approvalsPath
|
|
2438
|
+
// eslint-disable-next-line @bigbinary/neeto/use-common-routes
|
|
2439
|
+
,
|
|
2440
|
+
to: "".concat(config.approvalsPath).concat(routes.pending)
|
|
2441
|
+
})]
|
|
2442
|
+
})]
|
|
2443
|
+
})
|
|
2444
|
+
});
|
|
1554
2445
|
};
|
|
1555
2446
|
|
|
1556
2447
|
var fetch = function fetch(params) {
|
|
@@ -1567,17 +2458,13 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
1567
2458
|
var useFetchApprovers = function useFetchApprovers() {
|
|
1568
2459
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1569
2460
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1570
|
-
return
|
|
1571
|
-
|
|
1572
|
-
|
|
2461
|
+
return useQuery(_objectSpread$1({
|
|
2462
|
+
queryKey: [QUERY_KEYS.APPROVERS, params],
|
|
2463
|
+
queryFn: function queryFn() {
|
|
2464
|
+
return approversApi.fetch(params);
|
|
2465
|
+
},
|
|
1573
2466
|
select: function select(response) {
|
|
1574
2467
|
return response.data || response;
|
|
1575
|
-
},
|
|
1576
|
-
keepPreviousData: true,
|
|
1577
|
-
onSuccess: function onSuccess(_ref) {
|
|
1578
|
-
var _params$onSuccess;
|
|
1579
|
-
var approvers = _ref.approvers;
|
|
1580
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, approvers);
|
|
1581
2468
|
}
|
|
1582
2469
|
}, options));
|
|
1583
2470
|
};
|
|
@@ -1656,37 +2543,42 @@ var Form$1 = function Form(_ref) {
|
|
|
1656
2543
|
setSelectedTemplateData(template);
|
|
1657
2544
|
updateMessage();
|
|
1658
2545
|
}, [template]);
|
|
1659
|
-
return /*#__PURE__*/
|
|
1660
|
-
className: "w-full space-y-6"
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
2546
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2547
|
+
className: "w-full space-y-6",
|
|
2548
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
|
|
2549
|
+
label: t("neetoApprovals.select.approval"),
|
|
2550
|
+
options: templateOptions,
|
|
2551
|
+
onChange: function onChange(selectedTemplate) {
|
|
2552
|
+
return handleTemplateChange(selectedTemplate);
|
|
2553
|
+
}
|
|
2554
|
+
}), (selectedTemplateData === null || selectedTemplateData === void 0 ? void 0 : selectedTemplateData.message) && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2555
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2556
|
+
className: "flex space-x-6",
|
|
2557
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
|
|
2558
|
+
required: true,
|
|
2559
|
+
label: t("neetoApprovals.inputs.labels.approver"),
|
|
2560
|
+
name: "approver",
|
|
2561
|
+
options: approverOptions,
|
|
2562
|
+
placeholder: t("neetoApprovals.inputs.placeholders.select_", {
|
|
2563
|
+
what: t("neetoApprovals.common.approver", constants.SINGULAR)
|
|
2564
|
+
}),
|
|
2565
|
+
onChange: handleApproverChange
|
|
2566
|
+
})
|
|
2567
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2568
|
+
className: "space-y-2",
|
|
2569
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, {
|
|
2570
|
+
required: true,
|
|
2571
|
+
label: t("neetoApprovals.inputs.labels.message"),
|
|
2572
|
+
name: "message",
|
|
2573
|
+
ref: inputRef,
|
|
2574
|
+
rows: 3,
|
|
2575
|
+
placeholder: t("neetoApprovals.inputs.placeholders.enter_", {
|
|
2576
|
+
what: t("neetoApprovals.inputs.labels.message")
|
|
2577
|
+
})
|
|
2578
|
+
})
|
|
2579
|
+
})]
|
|
2580
|
+
})]
|
|
2581
|
+
});
|
|
1690
2582
|
};
|
|
1691
2583
|
|
|
1692
2584
|
var Form = function Form(_ref) {
|
|
@@ -1712,38 +2604,38 @@ var Form = function Form(_ref) {
|
|
|
1712
2604
|
approverId: values.approver.value
|
|
1713
2605
|
}, selectedTemplateData, onClose);
|
|
1714
2606
|
};
|
|
1715
|
-
return /*#__PURE__*/
|
|
2607
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
1716
2608
|
isOpen: isOpen,
|
|
1717
|
-
onClose: onClose
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
})
|
|
1746
|
-
})
|
|
2609
|
+
onClose: onClose,
|
|
2610
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
2611
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
2612
|
+
style: "h2",
|
|
2613
|
+
children: t("neetoApprovals.common.add_", {
|
|
2614
|
+
what: t("neetoApprovals.common.approval", constants.SINGULAR)
|
|
2615
|
+
})
|
|
2616
|
+
})
|
|
2617
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(FormikForm__default["default"], {
|
|
2618
|
+
formikProps: {
|
|
2619
|
+
onSubmit: handleSubmit,
|
|
2620
|
+
initialValues: APPROVAL_REQUEST_FORM_INITIAL_VALUES,
|
|
2621
|
+
validationSchema: REQUEST_FORM_VALIDATION_SCHEMA
|
|
2622
|
+
},
|
|
2623
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
|
|
2624
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Form$1, {
|
|
2625
|
+
requestableId: requestableId,
|
|
2626
|
+
selectedTemplateData: selectedTemplateData,
|
|
2627
|
+
setSelectedTemplateData: setSelectedTemplateData
|
|
2628
|
+
})
|
|
2629
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Footer, {
|
|
2630
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
|
|
2631
|
+
cancelButtonProps: {
|
|
2632
|
+
onClick: onClose
|
|
2633
|
+
},
|
|
2634
|
+
isSubmitting: isLoading
|
|
2635
|
+
})
|
|
2636
|
+
})]
|
|
2637
|
+
})]
|
|
2638
|
+
});
|
|
1747
2639
|
};
|
|
1748
2640
|
|
|
1749
2641
|
var show = function show(id) {
|
|
@@ -1773,20 +2665,21 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
1773
2665
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1774
2666
|
var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
|
|
1775
2667
|
var requestId = _ref.requestId;
|
|
1776
|
-
return
|
|
1777
|
-
|
|
1778
|
-
|
|
2668
|
+
return useQuery(_objectSpread({
|
|
2669
|
+
queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
|
|
2670
|
+
queryFn: function queryFn() {
|
|
2671
|
+
return publicRequestsApi.show(requestId);
|
|
2672
|
+
}
|
|
2673
|
+
}, options));
|
|
1779
2674
|
};
|
|
1780
2675
|
var useAcceptPendingRequest = function useAcceptPendingRequest(options) {
|
|
1781
|
-
reactQuery.useQueryClient();
|
|
1782
2676
|
return reactUtils.useMutationWithInvalidation(publicRequestsApi.accept, _objectSpread({
|
|
1783
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
2677
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1784
2678
|
}, options));
|
|
1785
2679
|
};
|
|
1786
2680
|
var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
|
|
1787
|
-
reactQuery.useQueryClient();
|
|
1788
2681
|
return reactUtils.useMutationWithInvalidation(publicRequestsApi.decline, _objectSpread({
|
|
1789
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
2682
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1790
2683
|
}, options));
|
|
1791
2684
|
};
|
|
1792
2685
|
|
|
@@ -1802,84 +2695,96 @@ var Public = function Public() {
|
|
|
1802
2695
|
t = _useTranslation.t;
|
|
1803
2696
|
var _useFetchPublicReques = useFetchPublicRequest({
|
|
1804
2697
|
requestId: id
|
|
1805
|
-
}, {
|
|
1806
|
-
onSuccess: function onSuccess(_ref) {
|
|
1807
|
-
var note = _ref.approvalRequest.note;
|
|
1808
|
-
note && setNote(note);
|
|
1809
|
-
}
|
|
1810
2698
|
}),
|
|
1811
|
-
|
|
1812
|
-
_useFetchPublicReques3 = _useFetchPublicReques2 === void 0 ? {} : _useFetchPublicReques2,
|
|
1813
|
-
_useFetchPublicReques4 = _useFetchPublicReques3.approvalRequest,
|
|
1814
|
-
approvalRequest = _useFetchPublicReques4 === void 0 ? {} : _useFetchPublicReques4,
|
|
2699
|
+
data = _useFetchPublicReques.data,
|
|
1815
2700
|
isLoading = _useFetchPublicReques.isLoading;
|
|
2701
|
+
var _ref = data || {},
|
|
2702
|
+
_ref$approvalRequest = _ref.approvalRequest,
|
|
2703
|
+
approvalRequest = _ref$approvalRequest === void 0 ? {} : _ref$approvalRequest;
|
|
2704
|
+
React.useEffect(function () {
|
|
2705
|
+
var _data$approvalRequest;
|
|
2706
|
+
if (data !== null && data !== void 0 && (_data$approvalRequest = data.approvalRequest) !== null && _data$approvalRequest !== void 0 && _data$approvalRequest.note) {
|
|
2707
|
+
setNote(data.approvalRequest.note);
|
|
2708
|
+
}
|
|
2709
|
+
}, [data]);
|
|
1816
2710
|
var _useAcceptPendingRequ = useAcceptPendingRequest(),
|
|
1817
2711
|
acceptPendingRequest = _useAcceptPendingRequ.mutate,
|
|
1818
|
-
isAccepting = _useAcceptPendingRequ.
|
|
2712
|
+
isAccepting = _useAcceptPendingRequ.isPending;
|
|
1819
2713
|
var _useDeclinePendingReq = useDeclinePendingRequest(),
|
|
1820
2714
|
declinePendingRequest = _useDeclinePendingReq.mutate,
|
|
1821
|
-
isDeclining = _useDeclinePendingReq.
|
|
2715
|
+
isDeclining = _useDeclinePendingReq.isPending;
|
|
1822
2716
|
var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
|
|
1823
2717
|
var hideTextArea = approvalRequest.status !== STATUSES.pending && ramda.isEmpty(note);
|
|
1824
2718
|
if (isLoading) {
|
|
1825
|
-
return /*#__PURE__*/
|
|
1826
|
-
className: "h-screen items-center justify-center"
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
2719
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2720
|
+
className: "h-screen items-center justify-center",
|
|
2721
|
+
children: /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {})
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
|
|
2725
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
|
|
2726
|
+
title: t("neetoApprovals.common.approval", constants.PLURAL)
|
|
2727
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2728
|
+
className: "flex h-screen w-full flex-col items-center",
|
|
2729
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2730
|
+
className: "neeto-ui-shadow-s w-2/5 rounded border p-6",
|
|
2731
|
+
children: approvalRequest ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2732
|
+
className: "flex w-full flex-col space-y-6",
|
|
2733
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
2734
|
+
style: "h2",
|
|
2735
|
+
children: approvalRequest.title
|
|
2736
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoEditor.EditorContent, {
|
|
2737
|
+
content: approvalRequest.message
|
|
2738
|
+
}), !hideTextArea && /*#__PURE__*/jsxRuntime.jsx(Textarea__default["default"], {
|
|
2739
|
+
label: t("neetoApprovals.common.note"),
|
|
2740
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
2741
|
+
what: (_t = t("neetoApprovals.common.note")) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
2742
|
+
}),
|
|
2743
|
+
value: note,
|
|
2744
|
+
disabled: approvalRequest.status !== STATUSES.pending,
|
|
2745
|
+
onChange: utils.withEventTargetValue(setNote)
|
|
2746
|
+
}), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2747
|
+
className: "mx-auto mt-8 flex space-x-6",
|
|
2748
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
2749
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
2750
|
+
onClick: function onClick() {
|
|
2751
|
+
return acceptPendingRequest({
|
|
2752
|
+
id: approvalRequest.id,
|
|
2753
|
+
note: note
|
|
2754
|
+
});
|
|
2755
|
+
},
|
|
2756
|
+
loading: isAccepting
|
|
2757
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
2758
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
2759
|
+
onClick: function onClick() {
|
|
2760
|
+
return declinePendingRequest({
|
|
2761
|
+
id: approvalRequest.id,
|
|
2762
|
+
note: note
|
|
2763
|
+
});
|
|
2764
|
+
},
|
|
2765
|
+
style: "secondary",
|
|
2766
|
+
loading: isDeclining
|
|
2767
|
+
})]
|
|
2768
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(Callout__default["default"], {
|
|
2769
|
+
style: calloutStyle,
|
|
2770
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
2771
|
+
style: "body1",
|
|
2772
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
2773
|
+
i18nKey: "neetoApprovals.typography.approvalRequest",
|
|
2774
|
+
values: {
|
|
2775
|
+
status: approvalRequest.status
|
|
2776
|
+
}
|
|
2777
|
+
})
|
|
2778
|
+
})
|
|
2779
|
+
})]
|
|
2780
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
2781
|
+
style: "h4",
|
|
2782
|
+
className: "text-center",
|
|
2783
|
+
children: t("neetoApprovals.common.notFound")
|
|
2784
|
+
})
|
|
2785
|
+
})
|
|
2786
|
+
})]
|
|
2787
|
+
});
|
|
1883
2788
|
};
|
|
1884
2789
|
|
|
1885
2790
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|