@bigbinary/neeto-approvals-frontend 0.3.11 → 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 +1538 -618
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1546 -626
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs.js
CHANGED
|
@@ -9,13 +9,13 @@ var reactRouterDom = require('react-router-dom');
|
|
|
9
9
|
var i18next = require('i18next');
|
|
10
10
|
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
11
11
|
var Button = require('@bigbinary/neetoui/Button');
|
|
12
|
-
var ramda = require('ramda');
|
|
13
12
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
14
13
|
var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
|
|
15
14
|
var Table$1 = require('@bigbinary/neetoui/Table');
|
|
16
15
|
var NoData = require('@bigbinary/neetoui/NoData');
|
|
16
|
+
var ramda = require('ramda');
|
|
17
17
|
var reactI18next = require('react-i18next');
|
|
18
|
-
var
|
|
18
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
19
19
|
var axios = require('axios');
|
|
20
20
|
var Tag = require('@bigbinary/neetoui/Tag');
|
|
21
21
|
var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
|
|
@@ -64,6 +64,7 @@ function _interopNamespace(e) {
|
|
|
64
64
|
return Object.freeze(n);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
67
68
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
68
69
|
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
|
|
69
70
|
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
@@ -210,6 +211,868 @@ var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageC
|
|
|
210
211
|
}
|
|
211
212
|
};
|
|
212
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
|
+
|
|
213
1076
|
var BASE_URL = "neeto_approvals";
|
|
214
1077
|
var TEMPLATE_URL = "".concat(BASE_URL, "/templates");
|
|
215
1078
|
|
|
@@ -247,23 +1110,20 @@ var useFetchRequests = function useFetchRequests(_ref) {
|
|
|
247
1110
|
params = _ref$params === void 0 ? {} : _ref$params,
|
|
248
1111
|
_ref$options = _ref.options,
|
|
249
1112
|
options = _ref$options === void 0 ? {} : _ref$options;
|
|
250
|
-
return
|
|
251
|
-
|
|
252
|
-
|
|
1113
|
+
return useQuery(_objectSpread$b({
|
|
1114
|
+
queryKey: [QUERY_KEYS.REQUESTS, params],
|
|
1115
|
+
queryFn: function queryFn() {
|
|
1116
|
+
return requestsApi.fetch(params, requestUrl);
|
|
1117
|
+
},
|
|
253
1118
|
select: function select(response) {
|
|
254
1119
|
return response.data || response;
|
|
255
1120
|
},
|
|
256
|
-
|
|
257
|
-
onSuccess: function onSuccess(_ref2) {
|
|
258
|
-
var _options$onSuccess;
|
|
259
|
-
var requests = _ref2.requests;
|
|
260
|
-
return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, requests);
|
|
261
|
-
}
|
|
1121
|
+
placeholderData: keepPreviousData
|
|
262
1122
|
}, options));
|
|
263
1123
|
};
|
|
264
1124
|
var useUpdateRequest = function useUpdateRequest(options) {
|
|
265
1125
|
return reactUtils.useMutationWithInvalidation(requestsApi.update, _objectSpread$b({
|
|
266
|
-
keysToInvalidate: [QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
1126
|
+
keysToInvalidate: [[QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
267
1127
|
}, options));
|
|
268
1128
|
};
|
|
269
1129
|
|
|
@@ -344,7 +1204,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
344
1204
|
render: function render(approvalLabel, _ref) {
|
|
345
1205
|
var requestableUrl = _ref.requestableUrl;
|
|
346
1206
|
var url = new URL(requestableUrl || window.location.origin);
|
|
347
|
-
return /*#__PURE__*/
|
|
1207
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
348
1208
|
label: approvalLabel,
|
|
349
1209
|
style: "link",
|
|
350
1210
|
to: url.pathname
|
|
@@ -363,7 +1223,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
363
1223
|
width: "25%",
|
|
364
1224
|
title: i18next.t("neetoApprovals.common.status"),
|
|
365
1225
|
render: function render(status) {
|
|
366
|
-
return /*#__PURE__*/
|
|
1226
|
+
return /*#__PURE__*/jsxRuntime.jsx(Tag__default["default"], {
|
|
367
1227
|
label: neetoCist.capitalize(status),
|
|
368
1228
|
style: STATUS_TAG_STYLE[status]
|
|
369
1229
|
});
|
|
@@ -375,7 +1235,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
375
1235
|
width: "25%",
|
|
376
1236
|
title: i18next.t("neetoApprovals.common.created"),
|
|
377
1237
|
render: function render(createdAt) {
|
|
378
|
-
return /*#__PURE__*/
|
|
1238
|
+
return /*#__PURE__*/jsxRuntime.jsx(DateFormat__default["default"].FromNow, {
|
|
379
1239
|
date: createdAt,
|
|
380
1240
|
typographyProps: {
|
|
381
1241
|
style: "body2"
|
|
@@ -393,34 +1253,36 @@ var Footer = function Footer(_ref) {
|
|
|
393
1253
|
t = _useTranslation.t;
|
|
394
1254
|
if (!isCurrentUserApprover && !isCurrentUserRequester) return null;
|
|
395
1255
|
if (isCurrentUserApprover) {
|
|
396
|
-
return /*#__PURE__*/
|
|
397
|
-
className: "flex gap-x-2"
|
|
398
|
-
|
|
399
|
-
|
|
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"),
|
|
400
1279
|
loading: isLoading,
|
|
401
1280
|
type: "submit",
|
|
402
1281
|
onClick: function onClick() {
|
|
403
|
-
return handleSubmit(STATUSES.
|
|
404
|
-
}
|
|
405
|
-
}), /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
406
|
-
label: t("neetoApprovals.buttons.decline"),
|
|
407
|
-
loading: isLoading,
|
|
408
|
-
style: "text",
|
|
409
|
-
onClick: function onClick() {
|
|
410
|
-
return handleSubmit(STATUSES.rejected);
|
|
1282
|
+
return handleSubmit(STATUSES.cancelled);
|
|
411
1283
|
}
|
|
412
|
-
})
|
|
413
|
-
}
|
|
414
|
-
return /*#__PURE__*/React__default["default"].createElement(Pane__default["default"].Footer, {
|
|
415
|
-
className: "flex gap-x-2"
|
|
416
|
-
}, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
417
|
-
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
418
|
-
loading: isLoading,
|
|
419
|
-
type: "submit",
|
|
420
|
-
onClick: function onClick() {
|
|
421
|
-
return handleSubmit(STATUSES.cancelled);
|
|
422
|
-
}
|
|
423
|
-
}));
|
|
1284
|
+
})
|
|
1285
|
+
});
|
|
424
1286
|
};
|
|
425
1287
|
|
|
426
1288
|
dayjs__default["default"].extend(utc__default["default"]);
|
|
@@ -485,7 +1347,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
485
1347
|
setNote = _useState2[1];
|
|
486
1348
|
var _useUpdateRequest = useUpdateRequest(),
|
|
487
1349
|
updatePendingRequest = _useUpdateRequest.mutate,
|
|
488
|
-
|
|
1350
|
+
isUpdateRequestPending = _useUpdateRequest.isPending;
|
|
489
1351
|
React.useEffect(function () {
|
|
490
1352
|
setNote(initialNote);
|
|
491
1353
|
}, [initialNote]);
|
|
@@ -513,65 +1375,82 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
513
1375
|
onSuccess: handleOnClose
|
|
514
1376
|
});
|
|
515
1377
|
};
|
|
516
|
-
return /*#__PURE__*/
|
|
1378
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
517
1379
|
isOpen: isOpen,
|
|
518
1380
|
size: "large",
|
|
519
|
-
onClose: handleOnClose
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
569
1449
|
};
|
|
570
1450
|
|
|
571
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; }
|
|
572
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; }
|
|
573
1453
|
var History = function History(_ref) {
|
|
574
|
-
var _t;
|
|
575
1454
|
var requestUrl = _ref.requestUrl;
|
|
576
1455
|
var _useState = React.useState(DEFAULT_FILTER_VALUES),
|
|
577
1456
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -592,64 +1471,66 @@ var History = function History(_ref) {
|
|
|
592
1471
|
searchTerm: debouncedSearchTerm.trim(),
|
|
593
1472
|
status: [STATUSES.approved, STATUSES.rejected, STATUSES.cancelled]
|
|
594
1473
|
}),
|
|
595
|
-
options: {
|
|
596
|
-
onSuccess: function onSuccess(_ref2) {
|
|
597
|
-
var requests = _ref2.requests;
|
|
598
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
599
|
-
setApprovalDetails(function (approvalDetails) {
|
|
600
|
-
return updateApprovalDetails({
|
|
601
|
-
requestsData: requests,
|
|
602
|
-
approvalDetails: approvalDetails
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
1474
|
requestUrl: requestUrl
|
|
608
1475
|
}),
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
approvalHistories =
|
|
613
|
-
|
|
614
|
-
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]);
|
|
615
1492
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
616
1493
|
setFilters(_objectSpread$a(_objectSpread$a({}, filters), {}, {
|
|
617
1494
|
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
618
1495
|
orderBy: SORT_ORDER[sorter.order]
|
|
619
1496
|
}));
|
|
620
1497
|
};
|
|
621
|
-
return /*#__PURE__*/
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
653
1534
|
};
|
|
654
1535
|
|
|
655
1536
|
var PENDING_TABLE_COLUMNS = neetoCist.removeBy({
|
|
@@ -659,7 +1540,6 @@ var PENDING_TABLE_COLUMNS = neetoCist.removeBy({
|
|
|
659
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; }
|
|
660
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; }
|
|
661
1542
|
var PendingRequests = function PendingRequests(_ref) {
|
|
662
|
-
var _t;
|
|
663
1543
|
var requestUrl = _ref.requestUrl;
|
|
664
1544
|
var _useState = React.useState(DEFAULT_FILTER_VALUES),
|
|
665
1545
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -680,75 +1560,62 @@ var PendingRequests = function PendingRequests(_ref) {
|
|
|
680
1560
|
searchTerm: debouncedSearchTerm.trim(),
|
|
681
1561
|
status: [STATUSES.pending]
|
|
682
1562
|
}),
|
|
683
|
-
options: {
|
|
684
|
-
onSuccess: function onSuccess(_ref2) {
|
|
685
|
-
var requests = _ref2.requests;
|
|
686
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
1563
|
requestUrl: requestUrl
|
|
690
1564
|
}),
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
pendingRequests =
|
|
695
|
-
|
|
696
|
-
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]);
|
|
697
1575
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
698
1576
|
setFilters(_objectSpread$9(_objectSpread$9({}, filters), {}, {
|
|
699
1577
|
sortBy: neetoCist.camelToSnakeCase(sorter.field || ""),
|
|
700
1578
|
orderBy: SORT_ORDER[sorter.order]
|
|
701
1579
|
}));
|
|
702
1580
|
};
|
|
703
|
-
return /*#__PURE__*/
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
})) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
723
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
724
|
-
}, /*#__PURE__*/React__default["default"].createElement(NoData__default["default"], {
|
|
725
|
-
title: t("neetoApprovals.common.notFound_", {
|
|
726
|
-
what: (_t = t("neetoApprovals.common.pendingApproval", constants.PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
727
|
-
})
|
|
728
|
-
})), /*#__PURE__*/React__default["default"].createElement(RequestDetailsPane, {
|
|
729
|
-
isPending: true,
|
|
730
|
-
approvalDetails: approvalDetails,
|
|
731
|
-
isOpen: neetoCist.isPresent(approvalDetails),
|
|
732
|
-
onClose: function onClose() {
|
|
733
|
-
return setApprovalDetails({});
|
|
734
|
-
}
|
|
735
|
-
}));
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
function _extends() {
|
|
739
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
740
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
741
|
-
var source = arguments[i];
|
|
742
|
-
for (var key in source) {
|
|
743
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
744
|
-
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);
|
|
745
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({});
|
|
746
1615
|
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
return _extends.apply(this, arguments);
|
|
751
|
-
}
|
|
1616
|
+
})]
|
|
1617
|
+
});
|
|
1618
|
+
};
|
|
752
1619
|
|
|
753
1620
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
754
1621
|
if (source == null) return {};
|
|
@@ -821,48 +1688,47 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
821
1688
|
var useFetchTemplates = function useFetchTemplates() {
|
|
822
1689
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
823
1690
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
824
|
-
return
|
|
825
|
-
|
|
826
|
-
|
|
1691
|
+
return useQuery(_objectSpread$8({
|
|
1692
|
+
queryKey: [QUERY_KEYS.TEMPLATES, params],
|
|
1693
|
+
queryFn: function queryFn() {
|
|
1694
|
+
return templatesApi.fetch(params);
|
|
1695
|
+
},
|
|
827
1696
|
select: function select(response) {
|
|
828
1697
|
return response.data || response;
|
|
829
1698
|
},
|
|
830
|
-
|
|
831
|
-
onSuccess: function onSuccess(_ref) {
|
|
832
|
-
var _params$onSuccess;
|
|
833
|
-
var templates = _ref.templates;
|
|
834
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, templates);
|
|
835
|
-
}
|
|
1699
|
+
placeholderData: keepPreviousData
|
|
836
1700
|
}, options));
|
|
837
1701
|
};
|
|
838
|
-
var useFetchTemplate = function useFetchTemplate(
|
|
839
|
-
var id =
|
|
840
|
-
params =
|
|
841
|
-
return
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
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
|
+
},
|
|
847
1713
|
enabled: !!id
|
|
848
1714
|
});
|
|
849
1715
|
};
|
|
850
1716
|
var useCreateTemplate = function useCreateTemplate(options) {
|
|
851
1717
|
return reactUtils.useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
|
|
852
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1718
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
853
1719
|
}, options));
|
|
854
1720
|
};
|
|
855
1721
|
var useUpdateTemplate = function useUpdateTemplate(options) {
|
|
856
1722
|
return reactUtils.useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
|
|
857
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, function (_,
|
|
858
|
-
var id =
|
|
1723
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], function (_, _ref2) {
|
|
1724
|
+
var id = _ref2.id;
|
|
859
1725
|
return [QUERY_KEYS.SHOW_TEMPLATE, id];
|
|
860
1726
|
}]
|
|
861
1727
|
}, options));
|
|
862
1728
|
};
|
|
863
1729
|
var useDeleteTemplate = function useDeleteTemplate(options) {
|
|
864
1730
|
return reactUtils.useMutationWithInvalidation(templatesApi.destroy, _objectSpread$8({
|
|
865
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1731
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
866
1732
|
}, options));
|
|
867
1733
|
};
|
|
868
1734
|
|
|
@@ -888,7 +1754,7 @@ var MessageEditor = reactUtils.withT(function (_ref) {
|
|
|
888
1754
|
placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
|
|
889
1755
|
_ref$initialValue = _ref.initialValue,
|
|
890
1756
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
891
|
-
return /*#__PURE__*/
|
|
1757
|
+
return /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, {
|
|
892
1758
|
initialValue: initialValue,
|
|
893
1759
|
required: true,
|
|
894
1760
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
@@ -916,32 +1782,34 @@ var TemplateForm = function TemplateForm(_ref) {
|
|
|
916
1782
|
setFieldValue("description", "");
|
|
917
1783
|
}
|
|
918
1784
|
};
|
|
919
|
-
return /*#__PURE__*/
|
|
920
|
-
className: "flex w-full flex-col space-y-6"
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
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
|
+
});
|
|
945
1813
|
};
|
|
946
1814
|
|
|
947
1815
|
var Form$2 = function Form(_ref) {
|
|
@@ -962,33 +1830,42 @@ var Form$2 = function Form(_ref) {
|
|
|
962
1830
|
}) : t("neetoApprovals.common.edit_", {
|
|
963
1831
|
what: t("neetoApprovals.common.template", constants.SINGULAR)
|
|
964
1832
|
});
|
|
965
|
-
return /*#__PURE__*/
|
|
1833
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
966
1834
|
isOpen: isOpen,
|
|
967
1835
|
onClose: onClose,
|
|
968
1836
|
initialFocusRef: inputReference,
|
|
969
|
-
size: "large"
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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
|
+
});
|
|
992
1869
|
};
|
|
993
1870
|
|
|
994
1871
|
var Create = function Create(_ref) {
|
|
@@ -998,7 +1875,7 @@ var Create = function Create(_ref) {
|
|
|
998
1875
|
templatePlaceholders = _ref.templatePlaceholders;
|
|
999
1876
|
var _useCreateTemplate = useCreateTemplate(),
|
|
1000
1877
|
createTemplate = _useCreateTemplate.mutate,
|
|
1001
|
-
|
|
1878
|
+
isPending = _useCreateTemplate.isPending;
|
|
1002
1879
|
var onSubmit = function onSubmit(template) {
|
|
1003
1880
|
var payload = {
|
|
1004
1881
|
template: template
|
|
@@ -1010,11 +1887,11 @@ var Create = function Create(_ref) {
|
|
|
1010
1887
|
onSuccess: onClose
|
|
1011
1888
|
});
|
|
1012
1889
|
};
|
|
1013
|
-
return /*#__PURE__*/
|
|
1014
|
-
isLoading: isLoading,
|
|
1890
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1015
1891
|
isOpen: isOpen,
|
|
1016
1892
|
onClose: onClose,
|
|
1017
1893
|
onSubmit: onSubmit,
|
|
1894
|
+
isLoading: isPending,
|
|
1018
1895
|
placeholders: templatePlaceholders
|
|
1019
1896
|
});
|
|
1020
1897
|
};
|
|
@@ -1034,7 +1911,7 @@ var Edit = function Edit(_ref) {
|
|
|
1034
1911
|
}
|
|
1035
1912
|
}),
|
|
1036
1913
|
updateTemplate = _useUpdateTemplate.mutate,
|
|
1037
|
-
isUpdating = _useUpdateTemplate.
|
|
1914
|
+
isUpdating = _useUpdateTemplate.isPending;
|
|
1038
1915
|
var onSubmit = function onSubmit(template) {
|
|
1039
1916
|
var payload = {
|
|
1040
1917
|
template: template
|
|
@@ -1048,7 +1925,7 @@ var Edit = function Edit(_ref) {
|
|
|
1048
1925
|
var initialData = _objectSpread$7(_objectSpread$7({}, template), {}, {
|
|
1049
1926
|
descriptionEnabled: !!template.description
|
|
1050
1927
|
});
|
|
1051
|
-
return /*#__PURE__*/
|
|
1928
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form$2, {
|
|
1052
1929
|
initialData: initialData,
|
|
1053
1930
|
isOpen: isOpen,
|
|
1054
1931
|
onClose: onClose,
|
|
@@ -1061,14 +1938,17 @@ var Edit = function Edit(_ref) {
|
|
|
1061
1938
|
var Field = function Field(_ref) {
|
|
1062
1939
|
var label = _ref.label,
|
|
1063
1940
|
value = _ref.value;
|
|
1064
|
-
return /*#__PURE__*/
|
|
1065
|
-
className: "flex flex-col items-start justify-center"
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
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
|
+
});
|
|
1072
1952
|
};
|
|
1073
1953
|
var Field$1 = /*#__PURE__*/React__default["default"].memo(Field);
|
|
1074
1954
|
|
|
@@ -1082,41 +1962,47 @@ var TemplateDetails = function TemplateDetails(_ref) {
|
|
|
1082
1962
|
var name = template.name,
|
|
1083
1963
|
description = template.description,
|
|
1084
1964
|
message = template.message;
|
|
1085
|
-
return /*#__PURE__*/
|
|
1965
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
1086
1966
|
isOpen: isOpen,
|
|
1087
|
-
onClose: onClose
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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
|
+
});
|
|
1108
1994
|
};
|
|
1109
1995
|
|
|
1110
1996
|
var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
|
|
1111
1997
|
var entity = _ref.entity,
|
|
1112
1998
|
url = _ref.url;
|
|
1113
|
-
return /*#__PURE__*/
|
|
1999
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1114
2000
|
i18nKey: "neetoApprovals.common.noDataHelpText",
|
|
1115
2001
|
values: {
|
|
1116
2002
|
entity: entity
|
|
1117
2003
|
},
|
|
1118
2004
|
components: {
|
|
1119
|
-
a: /*#__PURE__*/
|
|
2005
|
+
a: /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Link, {
|
|
1120
2006
|
className: "neeto-ui-text-primary-600 underline",
|
|
1121
2007
|
target: "_blank",
|
|
1122
2008
|
to: {
|
|
@@ -1171,34 +2057,36 @@ var Table = function Table(_ref) {
|
|
|
1171
2057
|
})
|
|
1172
2058
|
};
|
|
1173
2059
|
if (ramda.isEmpty(rowData)) {
|
|
1174
|
-
return /*#__PURE__*/
|
|
1175
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
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
|
+
});
|
|
1181
2068
|
}
|
|
1182
|
-
return /*#__PURE__*/
|
|
2069
|
+
return /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
1183
2070
|
className: "mt-6",
|
|
1184
|
-
hasPagination: totalCount > pageProperties.pageSize
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
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
|
+
});
|
|
1202
2090
|
};
|
|
1203
2091
|
|
|
1204
2092
|
var columnData = function columnData(_ref) {
|
|
@@ -1211,32 +2099,34 @@ var columnData = function columnData(_ref) {
|
|
|
1211
2099
|
title: i18next__default["default"].t("neetoApprovals.common.name"),
|
|
1212
2100
|
ellipsis: true,
|
|
1213
2101
|
render: function render(_, template) {
|
|
1214
|
-
return /*#__PURE__*/
|
|
1215
|
-
className: "flex items-center justify-between gap-x-3"
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
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
|
+
});
|
|
1240
2130
|
}
|
|
1241
2131
|
}, {
|
|
1242
2132
|
dataIndex: "description",
|
|
@@ -1249,7 +2139,6 @@ var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpe
|
|
|
1249
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; }
|
|
1250
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; }
|
|
1251
2141
|
var Templates = function Templates(_ref) {
|
|
1252
|
-
var _t, _t2, _t3;
|
|
1253
2142
|
var searchTerm = _ref.searchTerm,
|
|
1254
2143
|
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
1255
2144
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
|
|
@@ -1287,28 +2176,27 @@ var Templates = function Templates(_ref) {
|
|
|
1287
2176
|
}, [searchTerm]);
|
|
1288
2177
|
var _useFetchTemplates = useFetchTemplates(_objectSpread$5(_objectSpread$5(_objectSpread$5({}, pageProperties), filters), {}, {
|
|
1289
2178
|
searchTerm: debouncedSearchTerm.trim()
|
|
1290
|
-
}),
|
|
1291
|
-
|
|
1292
|
-
var templates = _ref2.templates;
|
|
1293
|
-
handleEmptyPage(templates, pageProperties, handlePageChange);
|
|
1294
|
-
}
|
|
1295
|
-
}),
|
|
1296
|
-
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1297
|
-
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1298
|
-
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1299
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
1300
|
-
_useFetchTemplates$da4 = _useFetchTemplates$da2.totalCount,
|
|
1301
|
-
totalCount = _useFetchTemplates$da4 === void 0 ? 0 : _useFetchTemplates$da4,
|
|
2179
|
+
})),
|
|
2180
|
+
data = _useFetchTemplates.data,
|
|
1302
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]);
|
|
1303
2192
|
var _useDeleteTemplate = useDeleteTemplate(),
|
|
1304
2193
|
deleteTemplate = _useDeleteTemplate.mutate,
|
|
1305
|
-
isDeleting = _useDeleteTemplate.
|
|
2194
|
+
isDeleting = _useDeleteTemplate.isPending;
|
|
1306
2195
|
React.useEffect(function () {
|
|
1307
|
-
if (ramda.isEmpty(selectedTemplate))
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
}
|
|
2196
|
+
if (!ramda.isEmpty(selectedTemplate)) return;
|
|
2197
|
+
setIsDeleteAlertOpen(false);
|
|
2198
|
+
setIsEditPaneOpen(false);
|
|
2199
|
+
setIsShowPaneOpen(false);
|
|
1312
2200
|
}, [selectedTemplate]);
|
|
1313
2201
|
var onEditClick = function onEditClick(event, template) {
|
|
1314
2202
|
event.stopPropagation();
|
|
@@ -1330,62 +2218,64 @@ var Templates = function Templates(_ref) {
|
|
|
1330
2218
|
});
|
|
1331
2219
|
setSelectedTemplate({});
|
|
1332
2220
|
};
|
|
1333
|
-
var entity =
|
|
1334
|
-
return /*#__PURE__*/
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
}, otherProps)), /*#__PURE__*/React__default["default"].createElement(Edit, _extends({
|
|
1355
|
-
isOpen: isEditPaneOpen,
|
|
1356
|
-
setTemplate: setSelectedTemplate,
|
|
1357
|
-
template: selectedTemplate
|
|
1358
|
-
}, otherProps, {
|
|
1359
|
-
onClose: function onClose() {
|
|
1360
|
-
return setIsEditPaneOpen(false);
|
|
1361
|
-
}
|
|
1362
|
-
})), /*#__PURE__*/React__default["default"].createElement(Alert__default["default"], {
|
|
1363
|
-
isOpen: isDeleteAlertOpen,
|
|
1364
|
-
isSubmitting: isDeleting,
|
|
1365
|
-
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
1366
|
-
message: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
|
|
1367
|
-
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
1368
|
-
values: {
|
|
1369
|
-
what: (_t2 = t("neetoApprovals.common.template", constants.SINGULAR)) === null || _t2 === void 0 ? void 0 : _t2.toLocaleLowerCase(),
|
|
1370
|
-
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);
|
|
1371
2242
|
}
|
|
1372
|
-
}),
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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
|
+
});
|
|
1389
2279
|
};
|
|
1390
2280
|
|
|
1391
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; }
|
|
@@ -1397,16 +2287,16 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1397
2287
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
|
|
1398
2288
|
return [{
|
|
1399
2289
|
component: function component() {
|
|
1400
|
-
return /*#__PURE__*/
|
|
2290
|
+
return /*#__PURE__*/jsxRuntime.jsx(Templates, _objectSpread$4({}, _objectSpread$4({
|
|
1401
2291
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1402
2292
|
searchTerm: searchTerm,
|
|
1403
2293
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1404
|
-
}, config));
|
|
2294
|
+
}, config)));
|
|
1405
2295
|
},
|
|
1406
2296
|
path: "".concat(config.approvalsPath).concat(routes.templates.index),
|
|
1407
2297
|
actionBlock: function actionBlock() {
|
|
1408
2298
|
var _t;
|
|
1409
|
-
return /*#__PURE__*/
|
|
2299
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
1410
2300
|
"data-cy": "neeto-approvals-templates-add-new-button",
|
|
1411
2301
|
label: i18next.t("neetoApprovals.common.addNew_", {
|
|
1412
2302
|
what: (_t = i18next.t("neetoApprovals.common.template", constants.SINGULAR)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
@@ -1421,12 +2311,12 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1421
2311
|
})
|
|
1422
2312
|
}, {
|
|
1423
2313
|
component: function component() {
|
|
1424
|
-
return /*#__PURE__*/
|
|
2314
|
+
return /*#__PURE__*/jsxRuntime.jsx(PendingRequests, _objectSpread$4({}, config));
|
|
1425
2315
|
},
|
|
1426
2316
|
path: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1427
2317
|
}, {
|
|
1428
2318
|
component: function component() {
|
|
1429
|
-
return /*#__PURE__*/
|
|
2319
|
+
return /*#__PURE__*/jsxRuntime.jsx(History, _objectSpread$4({}, config));
|
|
1430
2320
|
},
|
|
1431
2321
|
path: "".concat(config.approvalsPath).concat(routes.history)
|
|
1432
2322
|
}];
|
|
@@ -1443,7 +2333,7 @@ var Header = function Header(_ref) {
|
|
|
1443
2333
|
var currentTab = neetoCist.findBy({
|
|
1444
2334
|
path: pathname
|
|
1445
2335
|
}, appRoutes);
|
|
1446
|
-
return /*#__PURE__*/
|
|
2336
|
+
return /*#__PURE__*/jsxRuntime.jsx(NeetoHeader__default["default"], {
|
|
1447
2337
|
actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
|
|
1448
2338
|
title: t("neetoApprovals.common.approval", constants.PLURAL),
|
|
1449
2339
|
searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
|
|
@@ -1464,9 +2354,9 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
|
|
|
1464
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; }
|
|
1465
2355
|
var useFetchViews = function useFetchViews() {
|
|
1466
2356
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1467
|
-
return
|
|
1468
|
-
|
|
1469
|
-
|
|
2357
|
+
return useQuery(_objectSpread$3({
|
|
2358
|
+
queryKey: [QUERY_KEYS.VIEWS],
|
|
2359
|
+
queryFn: viewsApi.fetch,
|
|
1470
2360
|
select: function select(response) {
|
|
1471
2361
|
return response.data || response;
|
|
1472
2362
|
}
|
|
@@ -1493,17 +2383,19 @@ var Tab = function Tab(_ref) {
|
|
|
1493
2383
|
_useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
|
|
1494
2384
|
_useFetchViews$data2$ = _useFetchViews$data2.views,
|
|
1495
2385
|
views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
|
|
1496
|
-
return /*#__PURE__*/
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
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
|
+
});
|
|
1507
2399
|
};
|
|
1508
2400
|
|
|
1509
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; }
|
|
@@ -1523,28 +2415,33 @@ var Approvals = function Approvals(_ref) {
|
|
|
1523
2415
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1524
2416
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1525
2417
|
});
|
|
1526
|
-
return /*#__PURE__*/
|
|
1527
|
-
className: "w-full overflow-y-auto"
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
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
|
+
});
|
|
1548
2445
|
};
|
|
1549
2446
|
|
|
1550
2447
|
var fetch = function fetch(params) {
|
|
@@ -1561,17 +2458,13 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
1561
2458
|
var useFetchApprovers = function useFetchApprovers() {
|
|
1562
2459
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1563
2460
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1564
|
-
return
|
|
1565
|
-
|
|
1566
|
-
|
|
2461
|
+
return useQuery(_objectSpread$1({
|
|
2462
|
+
queryKey: [QUERY_KEYS.APPROVERS, params],
|
|
2463
|
+
queryFn: function queryFn() {
|
|
2464
|
+
return approversApi.fetch(params);
|
|
2465
|
+
},
|
|
1567
2466
|
select: function select(response) {
|
|
1568
2467
|
return response.data || response;
|
|
1569
|
-
},
|
|
1570
|
-
keepPreviousData: true,
|
|
1571
|
-
onSuccess: function onSuccess(_ref) {
|
|
1572
|
-
var _params$onSuccess;
|
|
1573
|
-
var approvers = _ref.approvers;
|
|
1574
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, approvers);
|
|
1575
2468
|
}
|
|
1576
2469
|
}, options));
|
|
1577
2470
|
};
|
|
@@ -1650,37 +2543,42 @@ var Form$1 = function Form(_ref) {
|
|
|
1650
2543
|
setSelectedTemplateData(template);
|
|
1651
2544
|
updateMessage();
|
|
1652
2545
|
}, [template]);
|
|
1653
|
-
return /*#__PURE__*/
|
|
1654
|
-
className: "w-full space-y-6"
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
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
|
+
});
|
|
1684
2582
|
};
|
|
1685
2583
|
|
|
1686
2584
|
var Form = function Form(_ref) {
|
|
@@ -1706,29 +2604,38 @@ var Form = function Form(_ref) {
|
|
|
1706
2604
|
approverId: values.approver.value
|
|
1707
2605
|
}, selectedTemplateData, onClose);
|
|
1708
2606
|
};
|
|
1709
|
-
return /*#__PURE__*/
|
|
2607
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
1710
2608
|
isOpen: isOpen,
|
|
1711
|
-
onClose: onClose
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
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
|
+
});
|
|
1732
2639
|
};
|
|
1733
2640
|
|
|
1734
2641
|
var show = function show(id) {
|
|
@@ -1758,20 +2665,21 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
1758
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; }
|
|
1759
2666
|
var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
|
|
1760
2667
|
var requestId = _ref.requestId;
|
|
1761
|
-
return
|
|
1762
|
-
|
|
1763
|
-
|
|
2668
|
+
return useQuery(_objectSpread({
|
|
2669
|
+
queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
|
|
2670
|
+
queryFn: function queryFn() {
|
|
2671
|
+
return publicRequestsApi.show(requestId);
|
|
2672
|
+
}
|
|
2673
|
+
}, options));
|
|
1764
2674
|
};
|
|
1765
2675
|
var useAcceptPendingRequest = function useAcceptPendingRequest(options) {
|
|
1766
|
-
reactQuery.useQueryClient();
|
|
1767
2676
|
return reactUtils.useMutationWithInvalidation(publicRequestsApi.accept, _objectSpread({
|
|
1768
|
-
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]]
|
|
1769
2678
|
}, options));
|
|
1770
2679
|
};
|
|
1771
2680
|
var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
|
|
1772
|
-
reactQuery.useQueryClient();
|
|
1773
2681
|
return reactUtils.useMutationWithInvalidation(publicRequestsApi.decline, _objectSpread({
|
|
1774
|
-
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]]
|
|
1775
2683
|
}, options));
|
|
1776
2684
|
};
|
|
1777
2685
|
|
|
@@ -1787,84 +2695,96 @@ var Public = function Public() {
|
|
|
1787
2695
|
t = _useTranslation.t;
|
|
1788
2696
|
var _useFetchPublicReques = useFetchPublicRequest({
|
|
1789
2697
|
requestId: id
|
|
1790
|
-
}, {
|
|
1791
|
-
onSuccess: function onSuccess(_ref) {
|
|
1792
|
-
var note = _ref.approvalRequest.note;
|
|
1793
|
-
note && setNote(note);
|
|
1794
|
-
}
|
|
1795
2698
|
}),
|
|
1796
|
-
|
|
1797
|
-
_useFetchPublicReques3 = _useFetchPublicReques2 === void 0 ? {} : _useFetchPublicReques2,
|
|
1798
|
-
_useFetchPublicReques4 = _useFetchPublicReques3.approvalRequest,
|
|
1799
|
-
approvalRequest = _useFetchPublicReques4 === void 0 ? {} : _useFetchPublicReques4,
|
|
2699
|
+
data = _useFetchPublicReques.data,
|
|
1800
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]);
|
|
1801
2710
|
var _useAcceptPendingRequ = useAcceptPendingRequest(),
|
|
1802
2711
|
acceptPendingRequest = _useAcceptPendingRequ.mutate,
|
|
1803
|
-
isAccepting = _useAcceptPendingRequ.
|
|
2712
|
+
isAccepting = _useAcceptPendingRequ.isPending;
|
|
1804
2713
|
var _useDeclinePendingReq = useDeclinePendingRequest(),
|
|
1805
2714
|
declinePendingRequest = _useDeclinePendingReq.mutate,
|
|
1806
|
-
isDeclining = _useDeclinePendingReq.
|
|
2715
|
+
isDeclining = _useDeclinePendingReq.isPending;
|
|
1807
2716
|
var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
|
|
1808
2717
|
var hideTextArea = approvalRequest.status !== STATUSES.pending && ramda.isEmpty(note);
|
|
1809
2718
|
if (isLoading) {
|
|
1810
|
-
return /*#__PURE__*/
|
|
1811
|
-
className: "h-screen items-center justify-center"
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
1868
2788
|
};
|
|
1869
2789
|
|
|
1870
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}}
|