@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.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { useState, useEffect, useRef, createElement, useMemo } from 'react';
|
|
2
3
|
import { useMutationWithInvalidation, useDebounce, withT, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
3
4
|
import Container from '@bigbinary/neeto-molecules/Container';
|
|
4
5
|
import { Link, useLocation, useHistory, Switch, Route, Redirect, useParams } from 'react-router-dom';
|
|
5
6
|
import i18next, { t as t$1 } from 'i18next';
|
|
6
7
|
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, PLURAL, SINGULAR } from '@bigbinary/neeto-commons-frontend/constants';
|
|
7
8
|
import Button from '@bigbinary/neetoui/Button';
|
|
8
|
-
import {
|
|
9
|
-
import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop } from '@bigbinary/neeto-cist';
|
|
9
|
+
import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop as noop$1 } from '@bigbinary/neeto-cist';
|
|
10
10
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
11
11
|
import Table$1 from '@bigbinary/neetoui/Table';
|
|
12
12
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
13
|
+
import { isEmpty, keys } from 'ramda';
|
|
13
14
|
import { useTranslation, Trans } from 'react-i18next';
|
|
14
|
-
import {
|
|
15
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
16
|
import axios from 'axios';
|
|
16
17
|
import Tag from '@bigbinary/neetoui/Tag';
|
|
17
18
|
import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
|
|
@@ -155,6 +156,868 @@ var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageC
|
|
|
155
156
|
}
|
|
156
157
|
};
|
|
157
158
|
|
|
159
|
+
// src/subscribable.ts
|
|
160
|
+
var Subscribable = class {
|
|
161
|
+
constructor() {
|
|
162
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
163
|
+
this.subscribe = this.subscribe.bind(this);
|
|
164
|
+
}
|
|
165
|
+
subscribe(listener) {
|
|
166
|
+
this.listeners.add(listener);
|
|
167
|
+
this.onSubscribe();
|
|
168
|
+
return () => {
|
|
169
|
+
this.listeners.delete(listener);
|
|
170
|
+
this.onUnsubscribe();
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
hasListeners() {
|
|
174
|
+
return this.listeners.size > 0;
|
|
175
|
+
}
|
|
176
|
+
onSubscribe() {
|
|
177
|
+
}
|
|
178
|
+
onUnsubscribe() {
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// src/utils.ts
|
|
183
|
+
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
184
|
+
function noop() {
|
|
185
|
+
return void 0;
|
|
186
|
+
}
|
|
187
|
+
function isValidTimeout(value) {
|
|
188
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
189
|
+
}
|
|
190
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
191
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
192
|
+
}
|
|
193
|
+
function replaceEqualDeep(a, b) {
|
|
194
|
+
if (a === b) {
|
|
195
|
+
return a;
|
|
196
|
+
}
|
|
197
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
198
|
+
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
199
|
+
const aItems = array ? a : Object.keys(a);
|
|
200
|
+
const aSize = aItems.length;
|
|
201
|
+
const bItems = array ? b : Object.keys(b);
|
|
202
|
+
const bSize = bItems.length;
|
|
203
|
+
const copy = array ? [] : {};
|
|
204
|
+
let equalItems = 0;
|
|
205
|
+
for (let i = 0; i < bSize; i++) {
|
|
206
|
+
const key = array ? i : bItems[i];
|
|
207
|
+
if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
|
|
208
|
+
copy[key] = void 0;
|
|
209
|
+
equalItems++;
|
|
210
|
+
} else {
|
|
211
|
+
copy[key] = replaceEqualDeep(a[key], b[key]);
|
|
212
|
+
if (copy[key] === a[key] && a[key] !== void 0) {
|
|
213
|
+
equalItems++;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
218
|
+
}
|
|
219
|
+
return b;
|
|
220
|
+
}
|
|
221
|
+
function shallowEqualObjects(a, b) {
|
|
222
|
+
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
for (const key in a) {
|
|
226
|
+
if (a[key] !== b[key]) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
function isPlainArray(value) {
|
|
233
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
234
|
+
}
|
|
235
|
+
function isPlainObject(o) {
|
|
236
|
+
if (!hasObjectPrototype(o)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
const ctor = o.constructor;
|
|
240
|
+
if (ctor === void 0) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
const prot = ctor.prototype;
|
|
244
|
+
if (!hasObjectPrototype(prot)) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
function hasObjectPrototype(o) {
|
|
256
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
257
|
+
}
|
|
258
|
+
function replaceData(prevData, data, options) {
|
|
259
|
+
if (typeof options.structuralSharing === "function") {
|
|
260
|
+
return options.structuralSharing(prevData, data);
|
|
261
|
+
} else if (options.structuralSharing !== false) {
|
|
262
|
+
return replaceEqualDeep(prevData, data);
|
|
263
|
+
}
|
|
264
|
+
return data;
|
|
265
|
+
}
|
|
266
|
+
function keepPreviousData(previousData) {
|
|
267
|
+
return previousData;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/focusManager.ts
|
|
271
|
+
var FocusManager = class extends Subscribable {
|
|
272
|
+
#focused;
|
|
273
|
+
#cleanup;
|
|
274
|
+
#setup;
|
|
275
|
+
constructor() {
|
|
276
|
+
super();
|
|
277
|
+
this.#setup = (onFocus) => {
|
|
278
|
+
if (!isServer && window.addEventListener) {
|
|
279
|
+
const listener = () => onFocus();
|
|
280
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
281
|
+
return () => {
|
|
282
|
+
window.removeEventListener("visibilitychange", listener);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
onSubscribe() {
|
|
289
|
+
if (!this.#cleanup) {
|
|
290
|
+
this.setEventListener(this.#setup);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
onUnsubscribe() {
|
|
294
|
+
if (!this.hasListeners()) {
|
|
295
|
+
this.#cleanup?.();
|
|
296
|
+
this.#cleanup = void 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
setEventListener(setup) {
|
|
300
|
+
this.#setup = setup;
|
|
301
|
+
this.#cleanup?.();
|
|
302
|
+
this.#cleanup = setup((focused) => {
|
|
303
|
+
if (typeof focused === "boolean") {
|
|
304
|
+
this.setFocused(focused);
|
|
305
|
+
} else {
|
|
306
|
+
this.onFocus();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
setFocused(focused) {
|
|
311
|
+
const changed = this.#focused !== focused;
|
|
312
|
+
if (changed) {
|
|
313
|
+
this.#focused = focused;
|
|
314
|
+
this.onFocus();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
onFocus() {
|
|
318
|
+
const isFocused = this.isFocused();
|
|
319
|
+
this.listeners.forEach((listener) => {
|
|
320
|
+
listener(isFocused);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
isFocused() {
|
|
324
|
+
if (typeof this.#focused === "boolean") {
|
|
325
|
+
return this.#focused;
|
|
326
|
+
}
|
|
327
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
var focusManager = new FocusManager();
|
|
331
|
+
|
|
332
|
+
// src/onlineManager.ts
|
|
333
|
+
var OnlineManager = class extends Subscribable {
|
|
334
|
+
#online = true;
|
|
335
|
+
#cleanup;
|
|
336
|
+
#setup;
|
|
337
|
+
constructor() {
|
|
338
|
+
super();
|
|
339
|
+
this.#setup = (onOnline) => {
|
|
340
|
+
if (!isServer && window.addEventListener) {
|
|
341
|
+
const onlineListener = () => onOnline(true);
|
|
342
|
+
const offlineListener = () => onOnline(false);
|
|
343
|
+
window.addEventListener("online", onlineListener, false);
|
|
344
|
+
window.addEventListener("offline", offlineListener, false);
|
|
345
|
+
return () => {
|
|
346
|
+
window.removeEventListener("online", onlineListener);
|
|
347
|
+
window.removeEventListener("offline", offlineListener);
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
onSubscribe() {
|
|
354
|
+
if (!this.#cleanup) {
|
|
355
|
+
this.setEventListener(this.#setup);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
onUnsubscribe() {
|
|
359
|
+
if (!this.hasListeners()) {
|
|
360
|
+
this.#cleanup?.();
|
|
361
|
+
this.#cleanup = void 0;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
setEventListener(setup) {
|
|
365
|
+
this.#setup = setup;
|
|
366
|
+
this.#cleanup?.();
|
|
367
|
+
this.#cleanup = setup(this.setOnline.bind(this));
|
|
368
|
+
}
|
|
369
|
+
setOnline(online) {
|
|
370
|
+
const changed = this.#online !== online;
|
|
371
|
+
if (changed) {
|
|
372
|
+
this.#online = online;
|
|
373
|
+
this.listeners.forEach((listener) => {
|
|
374
|
+
listener(online);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
isOnline() {
|
|
379
|
+
return this.#online;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
var onlineManager = new OnlineManager();
|
|
383
|
+
|
|
384
|
+
// src/retryer.ts
|
|
385
|
+
function canFetch(networkMode) {
|
|
386
|
+
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/notifyManager.ts
|
|
390
|
+
function createNotifyManager() {
|
|
391
|
+
let queue = [];
|
|
392
|
+
let transactions = 0;
|
|
393
|
+
let notifyFn = (callback) => {
|
|
394
|
+
callback();
|
|
395
|
+
};
|
|
396
|
+
let batchNotifyFn = (callback) => {
|
|
397
|
+
callback();
|
|
398
|
+
};
|
|
399
|
+
let scheduleFn = (cb) => setTimeout(cb, 0);
|
|
400
|
+
const setScheduler = (fn) => {
|
|
401
|
+
scheduleFn = fn;
|
|
402
|
+
};
|
|
403
|
+
const batch = (callback) => {
|
|
404
|
+
let result;
|
|
405
|
+
transactions++;
|
|
406
|
+
try {
|
|
407
|
+
result = callback();
|
|
408
|
+
} finally {
|
|
409
|
+
transactions--;
|
|
410
|
+
if (!transactions) {
|
|
411
|
+
flush();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return result;
|
|
415
|
+
};
|
|
416
|
+
const schedule = (callback) => {
|
|
417
|
+
if (transactions) {
|
|
418
|
+
queue.push(callback);
|
|
419
|
+
} else {
|
|
420
|
+
scheduleFn(() => {
|
|
421
|
+
notifyFn(callback);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const batchCalls = (callback) => {
|
|
426
|
+
return (...args) => {
|
|
427
|
+
schedule(() => {
|
|
428
|
+
callback(...args);
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
const flush = () => {
|
|
433
|
+
const originalQueue = queue;
|
|
434
|
+
queue = [];
|
|
435
|
+
if (originalQueue.length) {
|
|
436
|
+
scheduleFn(() => {
|
|
437
|
+
batchNotifyFn(() => {
|
|
438
|
+
originalQueue.forEach((callback) => {
|
|
439
|
+
notifyFn(callback);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const setNotifyFunction = (fn) => {
|
|
446
|
+
notifyFn = fn;
|
|
447
|
+
};
|
|
448
|
+
const setBatchNotifyFunction = (fn) => {
|
|
449
|
+
batchNotifyFn = fn;
|
|
450
|
+
};
|
|
451
|
+
return {
|
|
452
|
+
batch,
|
|
453
|
+
batchCalls,
|
|
454
|
+
schedule,
|
|
455
|
+
setNotifyFunction,
|
|
456
|
+
setBatchNotifyFunction,
|
|
457
|
+
setScheduler
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
var notifyManager = createNotifyManager();
|
|
461
|
+
|
|
462
|
+
// src/query.ts
|
|
463
|
+
function fetchState(data, options) {
|
|
464
|
+
return {
|
|
465
|
+
fetchFailureCount: 0,
|
|
466
|
+
fetchFailureReason: null,
|
|
467
|
+
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
468
|
+
...data === void 0 && {
|
|
469
|
+
error: null,
|
|
470
|
+
status: "pending"
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// src/queryObserver.ts
|
|
476
|
+
var QueryObserver = class extends Subscribable {
|
|
477
|
+
constructor(client, options) {
|
|
478
|
+
super();
|
|
479
|
+
this.options = options;
|
|
480
|
+
this.#client = client;
|
|
481
|
+
this.#selectError = null;
|
|
482
|
+
this.bindMethods();
|
|
483
|
+
this.setOptions(options);
|
|
484
|
+
}
|
|
485
|
+
#client;
|
|
486
|
+
#currentQuery = void 0;
|
|
487
|
+
#currentQueryInitialState = void 0;
|
|
488
|
+
#currentResult = void 0;
|
|
489
|
+
#currentResultState;
|
|
490
|
+
#currentResultOptions;
|
|
491
|
+
#selectError;
|
|
492
|
+
#selectFn;
|
|
493
|
+
#selectResult;
|
|
494
|
+
// This property keeps track of the last query with defined data.
|
|
495
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
496
|
+
#lastQueryWithDefinedData;
|
|
497
|
+
#staleTimeoutId;
|
|
498
|
+
#refetchIntervalId;
|
|
499
|
+
#currentRefetchInterval;
|
|
500
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
501
|
+
bindMethods() {
|
|
502
|
+
this.refetch = this.refetch.bind(this);
|
|
503
|
+
}
|
|
504
|
+
onSubscribe() {
|
|
505
|
+
if (this.listeners.size === 1) {
|
|
506
|
+
this.#currentQuery.addObserver(this);
|
|
507
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
508
|
+
this.#executeFetch();
|
|
509
|
+
} else {
|
|
510
|
+
this.updateResult();
|
|
511
|
+
}
|
|
512
|
+
this.#updateTimers();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
onUnsubscribe() {
|
|
516
|
+
if (!this.hasListeners()) {
|
|
517
|
+
this.destroy();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
shouldFetchOnReconnect() {
|
|
521
|
+
return shouldFetchOn(
|
|
522
|
+
this.#currentQuery,
|
|
523
|
+
this.options,
|
|
524
|
+
this.options.refetchOnReconnect
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
shouldFetchOnWindowFocus() {
|
|
528
|
+
return shouldFetchOn(
|
|
529
|
+
this.#currentQuery,
|
|
530
|
+
this.options,
|
|
531
|
+
this.options.refetchOnWindowFocus
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
destroy() {
|
|
535
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
536
|
+
this.#clearStaleTimeout();
|
|
537
|
+
this.#clearRefetchInterval();
|
|
538
|
+
this.#currentQuery.removeObserver(this);
|
|
539
|
+
}
|
|
540
|
+
setOptions(options, notifyOptions) {
|
|
541
|
+
const prevOptions = this.options;
|
|
542
|
+
const prevQuery = this.#currentQuery;
|
|
543
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
544
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean") {
|
|
545
|
+
throw new Error("Expected enabled to be a boolean");
|
|
546
|
+
}
|
|
547
|
+
this.#updateQuery();
|
|
548
|
+
this.#currentQuery.setOptions(this.options);
|
|
549
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
550
|
+
this.#client.getQueryCache().notify({
|
|
551
|
+
type: "observerOptionsUpdated",
|
|
552
|
+
query: this.#currentQuery,
|
|
553
|
+
observer: this
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
const mounted = this.hasListeners();
|
|
557
|
+
if (mounted && shouldFetchOptionally(
|
|
558
|
+
this.#currentQuery,
|
|
559
|
+
prevQuery,
|
|
560
|
+
this.options,
|
|
561
|
+
prevOptions
|
|
562
|
+
)) {
|
|
563
|
+
this.#executeFetch();
|
|
564
|
+
}
|
|
565
|
+
this.updateResult(notifyOptions);
|
|
566
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
567
|
+
this.#updateStaleTimeout();
|
|
568
|
+
}
|
|
569
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
570
|
+
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
571
|
+
this.#updateRefetchInterval(nextRefetchInterval);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
getOptimisticResult(options) {
|
|
575
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
576
|
+
const result = this.createResult(query, options);
|
|
577
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
578
|
+
this.#currentResult = result;
|
|
579
|
+
this.#currentResultOptions = this.options;
|
|
580
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
581
|
+
}
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
getCurrentResult() {
|
|
585
|
+
return this.#currentResult;
|
|
586
|
+
}
|
|
587
|
+
trackResult(result, onPropTracked) {
|
|
588
|
+
const trackedResult = {};
|
|
589
|
+
Object.keys(result).forEach((key) => {
|
|
590
|
+
Object.defineProperty(trackedResult, key, {
|
|
591
|
+
configurable: false,
|
|
592
|
+
enumerable: true,
|
|
593
|
+
get: () => {
|
|
594
|
+
this.trackProp(key);
|
|
595
|
+
onPropTracked?.(key);
|
|
596
|
+
return result[key];
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
return trackedResult;
|
|
601
|
+
}
|
|
602
|
+
trackProp(key) {
|
|
603
|
+
this.#trackedProps.add(key);
|
|
604
|
+
}
|
|
605
|
+
getCurrentQuery() {
|
|
606
|
+
return this.#currentQuery;
|
|
607
|
+
}
|
|
608
|
+
refetch({ ...options } = {}) {
|
|
609
|
+
return this.fetch({
|
|
610
|
+
...options
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
fetchOptimistic(options) {
|
|
614
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
615
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
616
|
+
query.isFetchingOptimistic = true;
|
|
617
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
618
|
+
}
|
|
619
|
+
fetch(fetchOptions) {
|
|
620
|
+
return this.#executeFetch({
|
|
621
|
+
...fetchOptions,
|
|
622
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
623
|
+
}).then(() => {
|
|
624
|
+
this.updateResult();
|
|
625
|
+
return this.#currentResult;
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
#executeFetch(fetchOptions) {
|
|
629
|
+
this.#updateQuery();
|
|
630
|
+
let promise = this.#currentQuery.fetch(
|
|
631
|
+
this.options,
|
|
632
|
+
fetchOptions
|
|
633
|
+
);
|
|
634
|
+
if (!fetchOptions?.throwOnError) {
|
|
635
|
+
promise = promise.catch(noop);
|
|
636
|
+
}
|
|
637
|
+
return promise;
|
|
638
|
+
}
|
|
639
|
+
#updateStaleTimeout() {
|
|
640
|
+
this.#clearStaleTimeout();
|
|
641
|
+
if (isServer || this.#currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const time = timeUntilStale(
|
|
645
|
+
this.#currentResult.dataUpdatedAt,
|
|
646
|
+
this.options.staleTime
|
|
647
|
+
);
|
|
648
|
+
const timeout = time + 1;
|
|
649
|
+
this.#staleTimeoutId = setTimeout(() => {
|
|
650
|
+
if (!this.#currentResult.isStale) {
|
|
651
|
+
this.updateResult();
|
|
652
|
+
}
|
|
653
|
+
}, timeout);
|
|
654
|
+
}
|
|
655
|
+
#computeRefetchInterval() {
|
|
656
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
657
|
+
}
|
|
658
|
+
#updateRefetchInterval(nextInterval) {
|
|
659
|
+
this.#clearRefetchInterval();
|
|
660
|
+
this.#currentRefetchInterval = nextInterval;
|
|
661
|
+
if (isServer || this.options.enabled === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
this.#refetchIntervalId = setInterval(() => {
|
|
665
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
666
|
+
this.#executeFetch();
|
|
667
|
+
}
|
|
668
|
+
}, this.#currentRefetchInterval);
|
|
669
|
+
}
|
|
670
|
+
#updateTimers() {
|
|
671
|
+
this.#updateStaleTimeout();
|
|
672
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
673
|
+
}
|
|
674
|
+
#clearStaleTimeout() {
|
|
675
|
+
if (this.#staleTimeoutId) {
|
|
676
|
+
clearTimeout(this.#staleTimeoutId);
|
|
677
|
+
this.#staleTimeoutId = void 0;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
#clearRefetchInterval() {
|
|
681
|
+
if (this.#refetchIntervalId) {
|
|
682
|
+
clearInterval(this.#refetchIntervalId);
|
|
683
|
+
this.#refetchIntervalId = void 0;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
createResult(query, options) {
|
|
687
|
+
const prevQuery = this.#currentQuery;
|
|
688
|
+
const prevOptions = this.options;
|
|
689
|
+
const prevResult = this.#currentResult;
|
|
690
|
+
const prevResultState = this.#currentResultState;
|
|
691
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
692
|
+
const queryChange = query !== prevQuery;
|
|
693
|
+
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
694
|
+
const { state } = query;
|
|
695
|
+
let newState = { ...state };
|
|
696
|
+
let isPlaceholderData = false;
|
|
697
|
+
let data;
|
|
698
|
+
if (options._optimisticResults) {
|
|
699
|
+
const mounted = this.hasListeners();
|
|
700
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
701
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
702
|
+
if (fetchOnMount || fetchOptionally) {
|
|
703
|
+
newState = {
|
|
704
|
+
...newState,
|
|
705
|
+
...fetchState(state.data, query.options)
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
if (options._optimisticResults === "isRestoring") {
|
|
709
|
+
newState.fetchStatus = "idle";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
713
|
+
if (options.select && newState.data !== void 0) {
|
|
714
|
+
if (prevResult && newState.data === prevResultState?.data && options.select === this.#selectFn) {
|
|
715
|
+
data = this.#selectResult;
|
|
716
|
+
} else {
|
|
717
|
+
try {
|
|
718
|
+
this.#selectFn = options.select;
|
|
719
|
+
data = options.select(newState.data);
|
|
720
|
+
data = replaceData(prevResult?.data, data, options);
|
|
721
|
+
this.#selectResult = data;
|
|
722
|
+
this.#selectError = null;
|
|
723
|
+
} catch (selectError) {
|
|
724
|
+
this.#selectError = selectError;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
} else {
|
|
728
|
+
data = newState.data;
|
|
729
|
+
}
|
|
730
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
731
|
+
let placeholderData;
|
|
732
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
733
|
+
placeholderData = prevResult.data;
|
|
734
|
+
} else {
|
|
735
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
736
|
+
this.#lastQueryWithDefinedData?.state.data,
|
|
737
|
+
this.#lastQueryWithDefinedData
|
|
738
|
+
) : options.placeholderData;
|
|
739
|
+
if (options.select && placeholderData !== void 0) {
|
|
740
|
+
try {
|
|
741
|
+
placeholderData = options.select(placeholderData);
|
|
742
|
+
this.#selectError = null;
|
|
743
|
+
} catch (selectError) {
|
|
744
|
+
this.#selectError = selectError;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (placeholderData !== void 0) {
|
|
749
|
+
status = "success";
|
|
750
|
+
data = replaceData(
|
|
751
|
+
prevResult?.data,
|
|
752
|
+
placeholderData,
|
|
753
|
+
options
|
|
754
|
+
);
|
|
755
|
+
isPlaceholderData = true;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
if (this.#selectError) {
|
|
759
|
+
error = this.#selectError;
|
|
760
|
+
data = this.#selectResult;
|
|
761
|
+
errorUpdatedAt = Date.now();
|
|
762
|
+
status = "error";
|
|
763
|
+
}
|
|
764
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
765
|
+
const isPending = status === "pending";
|
|
766
|
+
const isError = status === "error";
|
|
767
|
+
const isLoading = isPending && isFetching;
|
|
768
|
+
const hasData = data !== void 0;
|
|
769
|
+
const result = {
|
|
770
|
+
status,
|
|
771
|
+
fetchStatus: newState.fetchStatus,
|
|
772
|
+
isPending,
|
|
773
|
+
isSuccess: status === "success",
|
|
774
|
+
isError,
|
|
775
|
+
isInitialLoading: isLoading,
|
|
776
|
+
isLoading,
|
|
777
|
+
data,
|
|
778
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
779
|
+
error,
|
|
780
|
+
errorUpdatedAt,
|
|
781
|
+
failureCount: newState.fetchFailureCount,
|
|
782
|
+
failureReason: newState.fetchFailureReason,
|
|
783
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
784
|
+
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
785
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
786
|
+
isFetching,
|
|
787
|
+
isRefetching: isFetching && !isPending,
|
|
788
|
+
isLoadingError: isError && !hasData,
|
|
789
|
+
isPaused: newState.fetchStatus === "paused",
|
|
790
|
+
isPlaceholderData,
|
|
791
|
+
isRefetchError: isError && hasData,
|
|
792
|
+
isStale: isStale(query, options),
|
|
793
|
+
refetch: this.refetch
|
|
794
|
+
};
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
updateResult(notifyOptions) {
|
|
798
|
+
const prevResult = this.#currentResult;
|
|
799
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
800
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
801
|
+
this.#currentResultOptions = this.options;
|
|
802
|
+
if (this.#currentResultState.data !== void 0) {
|
|
803
|
+
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
804
|
+
}
|
|
805
|
+
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
this.#currentResult = nextResult;
|
|
809
|
+
const defaultNotifyOptions = {};
|
|
810
|
+
const shouldNotifyListeners = () => {
|
|
811
|
+
if (!prevResult) {
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
const { notifyOnChangeProps } = this.options;
|
|
815
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
816
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
817
|
+
return true;
|
|
818
|
+
}
|
|
819
|
+
const includedProps = new Set(
|
|
820
|
+
notifyOnChangePropsValue ?? this.#trackedProps
|
|
821
|
+
);
|
|
822
|
+
if (this.options.throwOnError) {
|
|
823
|
+
includedProps.add("error");
|
|
824
|
+
}
|
|
825
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
826
|
+
const typedKey = key;
|
|
827
|
+
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
828
|
+
return changed && includedProps.has(typedKey);
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
|
|
832
|
+
defaultNotifyOptions.listeners = true;
|
|
833
|
+
}
|
|
834
|
+
this.#notify({ ...defaultNotifyOptions, ...notifyOptions });
|
|
835
|
+
}
|
|
836
|
+
#updateQuery() {
|
|
837
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
838
|
+
if (query === this.#currentQuery) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const prevQuery = this.#currentQuery;
|
|
842
|
+
this.#currentQuery = query;
|
|
843
|
+
this.#currentQueryInitialState = query.state;
|
|
844
|
+
if (this.hasListeners()) {
|
|
845
|
+
prevQuery?.removeObserver(this);
|
|
846
|
+
query.addObserver(this);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
onQueryUpdate() {
|
|
850
|
+
this.updateResult();
|
|
851
|
+
if (this.hasListeners()) {
|
|
852
|
+
this.#updateTimers();
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
#notify(notifyOptions) {
|
|
856
|
+
notifyManager.batch(() => {
|
|
857
|
+
if (notifyOptions.listeners) {
|
|
858
|
+
this.listeners.forEach((listener) => {
|
|
859
|
+
listener(this.#currentResult);
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
this.#client.getQueryCache().notify({
|
|
863
|
+
query: this.#currentQuery,
|
|
864
|
+
type: "observerResultsUpdated"
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
function shouldLoadOnMount(query, options) {
|
|
870
|
+
return options.enabled !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
871
|
+
}
|
|
872
|
+
function shouldFetchOnMount(query, options) {
|
|
873
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
874
|
+
}
|
|
875
|
+
function shouldFetchOn(query, options, field) {
|
|
876
|
+
if (options.enabled !== false) {
|
|
877
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
878
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
879
|
+
}
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
883
|
+
return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
884
|
+
}
|
|
885
|
+
function isStale(query, options) {
|
|
886
|
+
return options.enabled !== false && query.isStaleByTime(options.staleTime);
|
|
887
|
+
}
|
|
888
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
889
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
var QueryClientContext = React.createContext(
|
|
896
|
+
void 0
|
|
897
|
+
);
|
|
898
|
+
var useQueryClient = (queryClient) => {
|
|
899
|
+
const client = React.useContext(QueryClientContext);
|
|
900
|
+
if (queryClient) {
|
|
901
|
+
return queryClient;
|
|
902
|
+
}
|
|
903
|
+
if (!client) {
|
|
904
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
905
|
+
}
|
|
906
|
+
return client;
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
var IsRestoringContext = React.createContext(false);
|
|
910
|
+
var useIsRestoring = () => React.useContext(IsRestoringContext);
|
|
911
|
+
IsRestoringContext.Provider;
|
|
912
|
+
|
|
913
|
+
function createValue() {
|
|
914
|
+
let isReset = false;
|
|
915
|
+
return {
|
|
916
|
+
clearReset: () => {
|
|
917
|
+
isReset = false;
|
|
918
|
+
},
|
|
919
|
+
reset: () => {
|
|
920
|
+
isReset = true;
|
|
921
|
+
},
|
|
922
|
+
isReset: () => {
|
|
923
|
+
return isReset;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
var QueryErrorResetBoundaryContext = React.createContext(createValue());
|
|
928
|
+
var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
929
|
+
|
|
930
|
+
// src/utils.ts
|
|
931
|
+
function shouldThrowError(throwError, params) {
|
|
932
|
+
if (typeof throwError === "function") {
|
|
933
|
+
return throwError(...params);
|
|
934
|
+
}
|
|
935
|
+
return !!throwError;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
939
|
+
if (options.suspense || options.throwOnError) {
|
|
940
|
+
if (!errorResetBoundary.isReset()) {
|
|
941
|
+
options.retryOnMount = false;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
946
|
+
React.useEffect(() => {
|
|
947
|
+
errorResetBoundary.clearReset();
|
|
948
|
+
}, [errorResetBoundary]);
|
|
949
|
+
};
|
|
950
|
+
var getHasError = ({
|
|
951
|
+
result,
|
|
952
|
+
errorResetBoundary,
|
|
953
|
+
throwOnError,
|
|
954
|
+
query
|
|
955
|
+
}) => {
|
|
956
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
// src/suspense.ts
|
|
960
|
+
var ensureStaleTime = (defaultedOptions) => {
|
|
961
|
+
if (defaultedOptions.suspense) {
|
|
962
|
+
if (typeof defaultedOptions.staleTime !== "number") {
|
|
963
|
+
defaultedOptions.staleTime = 1e3;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
968
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
969
|
+
errorResetBoundary.clearReset();
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
973
|
+
const client = useQueryClient(queryClient);
|
|
974
|
+
const isRestoring = useIsRestoring();
|
|
975
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
976
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
977
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
978
|
+
ensureStaleTime(defaultedOptions);
|
|
979
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
980
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
981
|
+
const [observer] = React.useState(
|
|
982
|
+
() => new Observer(
|
|
983
|
+
client,
|
|
984
|
+
defaultedOptions
|
|
985
|
+
)
|
|
986
|
+
);
|
|
987
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
988
|
+
React.useSyncExternalStore(
|
|
989
|
+
React.useCallback(
|
|
990
|
+
(onStoreChange) => {
|
|
991
|
+
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
992
|
+
observer.updateResult();
|
|
993
|
+
return unsubscribe;
|
|
994
|
+
},
|
|
995
|
+
[observer, isRestoring]
|
|
996
|
+
),
|
|
997
|
+
() => observer.getCurrentResult(),
|
|
998
|
+
() => observer.getCurrentResult()
|
|
999
|
+
);
|
|
1000
|
+
React.useEffect(() => {
|
|
1001
|
+
observer.setOptions(defaultedOptions, { listeners: false });
|
|
1002
|
+
}, [defaultedOptions, observer]);
|
|
1003
|
+
if (shouldSuspend(defaultedOptions, result)) {
|
|
1004
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
1005
|
+
}
|
|
1006
|
+
if (getHasError({
|
|
1007
|
+
result,
|
|
1008
|
+
errorResetBoundary,
|
|
1009
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
1010
|
+
query: client.getQueryCache().get(defaultedOptions.queryHash)
|
|
1011
|
+
})) {
|
|
1012
|
+
throw result.error;
|
|
1013
|
+
}
|
|
1014
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function useQuery(options, queryClient) {
|
|
1018
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
158
1021
|
var BASE_URL = "neeto_approvals";
|
|
159
1022
|
var TEMPLATE_URL = "".concat(BASE_URL, "/templates");
|
|
160
1023
|
|
|
@@ -192,23 +1055,20 @@ var useFetchRequests = function useFetchRequests(_ref) {
|
|
|
192
1055
|
params = _ref$params === void 0 ? {} : _ref$params,
|
|
193
1056
|
_ref$options = _ref.options,
|
|
194
1057
|
options = _ref$options === void 0 ? {} : _ref$options;
|
|
195
|
-
return useQuery(
|
|
196
|
-
|
|
197
|
-
|
|
1058
|
+
return useQuery(_objectSpread$b({
|
|
1059
|
+
queryKey: [QUERY_KEYS.REQUESTS, params],
|
|
1060
|
+
queryFn: function queryFn() {
|
|
1061
|
+
return requestsApi.fetch(params, requestUrl);
|
|
1062
|
+
},
|
|
198
1063
|
select: function select(response) {
|
|
199
1064
|
return response.data || response;
|
|
200
1065
|
},
|
|
201
|
-
|
|
202
|
-
onSuccess: function onSuccess(_ref2) {
|
|
203
|
-
var _options$onSuccess;
|
|
204
|
-
var requests = _ref2.requests;
|
|
205
|
-
return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, requests);
|
|
206
|
-
}
|
|
1066
|
+
placeholderData: keepPreviousData
|
|
207
1067
|
}, options));
|
|
208
1068
|
};
|
|
209
1069
|
var useUpdateRequest = function useUpdateRequest(options) {
|
|
210
1070
|
return useMutationWithInvalidation(requestsApi.update, _objectSpread$b({
|
|
211
|
-
keysToInvalidate: [QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
1071
|
+
keysToInvalidate: [[QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
212
1072
|
}, options));
|
|
213
1073
|
};
|
|
214
1074
|
|
|
@@ -289,7 +1149,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
289
1149
|
render: function render(approvalLabel, _ref) {
|
|
290
1150
|
var requestableUrl = _ref.requestableUrl;
|
|
291
1151
|
var url = new URL(requestableUrl || window.location.origin);
|
|
292
|
-
return /*#__PURE__*/
|
|
1152
|
+
return /*#__PURE__*/jsx(Button, {
|
|
293
1153
|
label: approvalLabel,
|
|
294
1154
|
style: "link",
|
|
295
1155
|
to: url.pathname
|
|
@@ -308,7 +1168,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
308
1168
|
width: "25%",
|
|
309
1169
|
title: t$1("neetoApprovals.common.status"),
|
|
310
1170
|
render: function render(status) {
|
|
311
|
-
return /*#__PURE__*/
|
|
1171
|
+
return /*#__PURE__*/jsx(Tag, {
|
|
312
1172
|
label: capitalize(status),
|
|
313
1173
|
style: STATUS_TAG_STYLE[status]
|
|
314
1174
|
});
|
|
@@ -320,7 +1180,7 @@ var HISTORY_TABLE_COLUMNS = [{
|
|
|
320
1180
|
width: "25%",
|
|
321
1181
|
title: t$1("neetoApprovals.common.created"),
|
|
322
1182
|
render: function render(createdAt) {
|
|
323
|
-
return /*#__PURE__*/
|
|
1183
|
+
return /*#__PURE__*/jsx(DateFormat.FromNow, {
|
|
324
1184
|
date: createdAt,
|
|
325
1185
|
typographyProps: {
|
|
326
1186
|
style: "body2"
|
|
@@ -338,34 +1198,36 @@ var Footer = function Footer(_ref) {
|
|
|
338
1198
|
t = _useTranslation.t;
|
|
339
1199
|
if (!isCurrentUserApprover && !isCurrentUserRequester) return null;
|
|
340
1200
|
if (isCurrentUserApprover) {
|
|
341
|
-
return /*#__PURE__*/
|
|
342
|
-
className: "flex gap-x-2"
|
|
343
|
-
|
|
344
|
-
|
|
1201
|
+
return /*#__PURE__*/jsxs(Pane.Footer, {
|
|
1202
|
+
className: "flex gap-x-2",
|
|
1203
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1204
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
1205
|
+
loading: isLoading,
|
|
1206
|
+
type: "submit",
|
|
1207
|
+
onClick: function onClick() {
|
|
1208
|
+
return handleSubmit(STATUSES.approved);
|
|
1209
|
+
}
|
|
1210
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1211
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
1212
|
+
loading: isLoading,
|
|
1213
|
+
style: "text",
|
|
1214
|
+
onClick: function onClick() {
|
|
1215
|
+
return handleSubmit(STATUSES.rejected);
|
|
1216
|
+
}
|
|
1217
|
+
})]
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
return /*#__PURE__*/jsx(Pane.Footer, {
|
|
1221
|
+
className: "flex gap-x-2",
|
|
1222
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1223
|
+
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
345
1224
|
loading: isLoading,
|
|
346
1225
|
type: "submit",
|
|
347
1226
|
onClick: function onClick() {
|
|
348
|
-
return handleSubmit(STATUSES.
|
|
1227
|
+
return handleSubmit(STATUSES.cancelled);
|
|
349
1228
|
}
|
|
350
|
-
})
|
|
351
|
-
|
|
352
|
-
loading: isLoading,
|
|
353
|
-
style: "text",
|
|
354
|
-
onClick: function onClick() {
|
|
355
|
-
return handleSubmit(STATUSES.rejected);
|
|
356
|
-
}
|
|
357
|
-
}));
|
|
358
|
-
}
|
|
359
|
-
return /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
360
|
-
className: "flex gap-x-2"
|
|
361
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
362
|
-
label: t("neetoApprovals.buttons.cancelRequest"),
|
|
363
|
-
loading: isLoading,
|
|
364
|
-
type: "submit",
|
|
365
|
-
onClick: function onClick() {
|
|
366
|
-
return handleSubmit(STATUSES.cancelled);
|
|
367
|
-
}
|
|
368
|
-
}));
|
|
1229
|
+
})
|
|
1230
|
+
});
|
|
369
1231
|
};
|
|
370
1232
|
|
|
371
1233
|
dayjs.extend(utc);
|
|
@@ -403,7 +1265,7 @@ var getApprovalFilter = function getApprovalFilter() {
|
|
|
403
1265
|
};
|
|
404
1266
|
};
|
|
405
1267
|
|
|
406
|
-
var MemoizedEditorContent$1 = /*#__PURE__*/
|
|
1268
|
+
var MemoizedEditorContent$1 = /*#__PURE__*/React__default.memo(EditorContent);
|
|
407
1269
|
var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
408
1270
|
var _window$globalProps, _window$globalProps2;
|
|
409
1271
|
var isOpen = _ref.isOpen,
|
|
@@ -430,7 +1292,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
430
1292
|
setNote = _useState2[1];
|
|
431
1293
|
var _useUpdateRequest = useUpdateRequest(),
|
|
432
1294
|
updatePendingRequest = _useUpdateRequest.mutate,
|
|
433
|
-
|
|
1295
|
+
isUpdateRequestPending = _useUpdateRequest.isPending;
|
|
434
1296
|
useEffect(function () {
|
|
435
1297
|
setNote(initialNote);
|
|
436
1298
|
}, [initialNote]);
|
|
@@ -458,65 +1320,82 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
|
|
|
458
1320
|
onSuccess: handleOnClose
|
|
459
1321
|
});
|
|
460
1322
|
};
|
|
461
|
-
return /*#__PURE__*/
|
|
1323
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
462
1324
|
isOpen: isOpen,
|
|
463
1325
|
size: "large",
|
|
464
|
-
onClose: handleOnClose
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
1326
|
+
onClose: handleOnClose,
|
|
1327
|
+
children: [/*#__PURE__*/jsxs(Pane.Header, {
|
|
1328
|
+
className: "space-y-2",
|
|
1329
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1330
|
+
style: "h2",
|
|
1331
|
+
children: title
|
|
1332
|
+
}), /*#__PURE__*/jsx(Tag, {
|
|
1333
|
+
label: capitalize(status),
|
|
1334
|
+
style: STATUS_TAG_STYLE[status]
|
|
1335
|
+
})]
|
|
1336
|
+
}), /*#__PURE__*/jsxs(Pane.Body, {
|
|
1337
|
+
className: "space-y-6",
|
|
1338
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1339
|
+
className: "w-full divide-y border px-3",
|
|
1340
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1341
|
+
className: "flex space-x-3 p-2",
|
|
1342
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1343
|
+
className: "font-normal",
|
|
1344
|
+
children: getStatusLabel()
|
|
1345
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1346
|
+
style: "body2",
|
|
1347
|
+
weight: "medium",
|
|
1348
|
+
children: requesterOrApproverDetails
|
|
1349
|
+
})]
|
|
1350
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1351
|
+
className: "flex space-x-3 p-2",
|
|
1352
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1353
|
+
className: "font-normal",
|
|
1354
|
+
children: t("neetoApprovals.common.created")
|
|
1355
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1356
|
+
style: "body2",
|
|
1357
|
+
weight: "medium",
|
|
1358
|
+
children: dateFormat.defaultWithTime(timeInZone(createdAt))
|
|
1359
|
+
})]
|
|
1360
|
+
})]
|
|
1361
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1362
|
+
className: "w-full space-y-2",
|
|
1363
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1364
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
1365
|
+
}), /*#__PURE__*/jsx(MemoizedEditorContent$1, {
|
|
1366
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
1367
|
+
content: message
|
|
1368
|
+
})]
|
|
1369
|
+
}), isPending && isCurrentUserApprover && /*#__PURE__*/jsx(Textarea, {
|
|
1370
|
+
className: "w-full",
|
|
1371
|
+
disabled: !isPending,
|
|
1372
|
+
label: t("neetoApprovals.common.note"),
|
|
1373
|
+
value: note,
|
|
1374
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
1375
|
+
what: t("neetoApprovals.common.note")
|
|
1376
|
+
}),
|
|
1377
|
+
onChange: withEventTargetValue(setNote)
|
|
1378
|
+
}), !isPending && note && /*#__PURE__*/jsxs("div", {
|
|
1379
|
+
className: "w-full space-y-2",
|
|
1380
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1381
|
+
children: t("neetoApprovals.common.note")
|
|
1382
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1383
|
+
className: "neeto-ui-bg-gray-100 p-4",
|
|
1384
|
+
children: note
|
|
1385
|
+
})]
|
|
1386
|
+
})]
|
|
1387
|
+
}), isPending && /*#__PURE__*/jsx(Footer, {
|
|
1388
|
+
handleSubmit: handleSubmit,
|
|
1389
|
+
isCurrentUserApprover: isCurrentUserApprover,
|
|
1390
|
+
isCurrentUserRequester: isCurrentUserRequester,
|
|
1391
|
+
isLoading: isUpdateRequestPending
|
|
1392
|
+
})]
|
|
1393
|
+
});
|
|
514
1394
|
};
|
|
515
1395
|
|
|
516
1396
|
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; }
|
|
517
1397
|
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; }
|
|
518
1398
|
var History = function History(_ref) {
|
|
519
|
-
var _t;
|
|
520
1399
|
var requestUrl = _ref.requestUrl;
|
|
521
1400
|
var _useState = useState(DEFAULT_FILTER_VALUES),
|
|
522
1401
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -537,64 +1416,66 @@ var History = function History(_ref) {
|
|
|
537
1416
|
searchTerm: debouncedSearchTerm.trim(),
|
|
538
1417
|
status: [STATUSES.approved, STATUSES.rejected, STATUSES.cancelled]
|
|
539
1418
|
}),
|
|
540
|
-
options: {
|
|
541
|
-
onSuccess: function onSuccess(_ref2) {
|
|
542
|
-
var requests = _ref2.requests;
|
|
543
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
544
|
-
setApprovalDetails(function (approvalDetails) {
|
|
545
|
-
return updateApprovalDetails({
|
|
546
|
-
requestsData: requests,
|
|
547
|
-
approvalDetails: approvalDetails
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
},
|
|
552
1419
|
requestUrl: requestUrl
|
|
553
1420
|
}),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
approvalHistories =
|
|
558
|
-
|
|
559
|
-
totalCount =
|
|
1421
|
+
data = _useFetchRequests.data;
|
|
1422
|
+
var _ref2 = data || {},
|
|
1423
|
+
_ref2$requests = _ref2.requests,
|
|
1424
|
+
approvalHistories = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
1425
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
1426
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
1427
|
+
useEffect(function () {
|
|
1428
|
+
if (!data) return;
|
|
1429
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
1430
|
+
setApprovalDetails(function (approvalDetails) {
|
|
1431
|
+
return updateApprovalDetails({
|
|
1432
|
+
requestsData: data === null || data === void 0 ? void 0 : data.requests,
|
|
1433
|
+
approvalDetails: approvalDetails
|
|
1434
|
+
});
|
|
1435
|
+
});
|
|
1436
|
+
}, [data]);
|
|
560
1437
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
561
1438
|
setFilters(_objectSpread$a(_objectSpread$a({}, filters), {}, {
|
|
562
1439
|
sortBy: camelToSnakeCase(sorter.field || ""),
|
|
563
1440
|
orderBy: SORT_ORDER[sorter.order]
|
|
564
1441
|
}));
|
|
565
1442
|
};
|
|
566
|
-
return /*#__PURE__*/
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
1443
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1444
|
+
children: [!isEmpty(approvalHistories) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
1445
|
+
className: "mt-6",
|
|
1446
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
1447
|
+
children: /*#__PURE__*/jsx(Table$1, {
|
|
1448
|
+
handlePageChange: handlePageChange,
|
|
1449
|
+
totalCount: totalCount,
|
|
1450
|
+
allowRowClick: true,
|
|
1451
|
+
fixedHeight: true,
|
|
1452
|
+
columnData: HISTORY_TABLE_COLUMNS,
|
|
1453
|
+
currentPageNumber: pageProperties.page,
|
|
1454
|
+
defaultPageSize: pageProperties.pageSize,
|
|
1455
|
+
rowData: approvalHistories,
|
|
1456
|
+
paginationProps: {
|
|
1457
|
+
hideOnSinglePage: (approvalHistories === null || approvalHistories === void 0 ? void 0 : approvalHistories.length) < DEFAULT_PAGE_SIZE + 1
|
|
1458
|
+
},
|
|
1459
|
+
onChange: handleTableChange,
|
|
1460
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
1461
|
+
return setApprovalDetails(approvalDetails);
|
|
1462
|
+
}
|
|
1463
|
+
})
|
|
1464
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
1465
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
1466
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
1467
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
1468
|
+
what: t("neetoApprovals.common.record", PLURAL)
|
|
1469
|
+
})
|
|
1470
|
+
})
|
|
1471
|
+
}), /*#__PURE__*/jsx(RequestDetailsPane, {
|
|
1472
|
+
approvalDetails: approvalDetails,
|
|
1473
|
+
isOpen: isPresent(approvalDetails),
|
|
1474
|
+
onClose: function onClose() {
|
|
1475
|
+
return setApprovalDetails({});
|
|
1476
|
+
}
|
|
1477
|
+
})]
|
|
1478
|
+
});
|
|
598
1479
|
};
|
|
599
1480
|
|
|
600
1481
|
var PENDING_TABLE_COLUMNS = removeBy({
|
|
@@ -604,7 +1485,6 @@ var PENDING_TABLE_COLUMNS = removeBy({
|
|
|
604
1485
|
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; }
|
|
605
1486
|
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; }
|
|
606
1487
|
var PendingRequests = function PendingRequests(_ref) {
|
|
607
|
-
var _t;
|
|
608
1488
|
var requestUrl = _ref.requestUrl;
|
|
609
1489
|
var _useState = useState(DEFAULT_FILTER_VALUES),
|
|
610
1490
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -625,75 +1505,62 @@ var PendingRequests = function PendingRequests(_ref) {
|
|
|
625
1505
|
searchTerm: debouncedSearchTerm.trim(),
|
|
626
1506
|
status: [STATUSES.pending]
|
|
627
1507
|
}),
|
|
628
|
-
options: {
|
|
629
|
-
onSuccess: function onSuccess(_ref2) {
|
|
630
|
-
var requests = _ref2.requests;
|
|
631
|
-
handleEmptyPage(requests, pageProperties, handlePageChange);
|
|
632
|
-
}
|
|
633
|
-
},
|
|
634
1508
|
requestUrl: requestUrl
|
|
635
1509
|
}),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
pendingRequests =
|
|
640
|
-
|
|
641
|
-
totalCount =
|
|
1510
|
+
data = _useFetchRequests.data;
|
|
1511
|
+
var _ref2 = data || {},
|
|
1512
|
+
_ref2$requests = _ref2.requests,
|
|
1513
|
+
pendingRequests = _ref2$requests === void 0 ? {} : _ref2$requests,
|
|
1514
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
1515
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
1516
|
+
useEffect(function () {
|
|
1517
|
+
if (!data) return;
|
|
1518
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.requests, pageProperties, handlePageChange);
|
|
1519
|
+
}, [data]);
|
|
642
1520
|
var handleTableChange = function handleTableChange(_, __, sorter) {
|
|
643
1521
|
setFilters(_objectSpread$9(_objectSpread$9({}, filters), {}, {
|
|
644
1522
|
sortBy: camelToSnakeCase(sorter.field || ""),
|
|
645
1523
|
orderBy: SORT_ORDER[sorter.order]
|
|
646
1524
|
}));
|
|
647
1525
|
};
|
|
648
|
-
return /*#__PURE__*/
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
668
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
669
|
-
}, /*#__PURE__*/React.createElement(NoData, {
|
|
670
|
-
title: t("neetoApprovals.common.notFound_", {
|
|
671
|
-
what: (_t = t("neetoApprovals.common.pendingApproval", PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
672
|
-
})
|
|
673
|
-
})), /*#__PURE__*/React.createElement(RequestDetailsPane, {
|
|
674
|
-
isPending: true,
|
|
675
|
-
approvalDetails: approvalDetails,
|
|
676
|
-
isOpen: isPresent(approvalDetails),
|
|
677
|
-
onClose: function onClose() {
|
|
678
|
-
return setApprovalDetails({});
|
|
679
|
-
}
|
|
680
|
-
}));
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
function _extends() {
|
|
684
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
685
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
686
|
-
var source = arguments[i];
|
|
687
|
-
for (var key in source) {
|
|
688
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
689
|
-
target[key] = source[key];
|
|
1526
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1527
|
+
children: [!isEmpty(pendingRequests) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
1528
|
+
className: "mt-6",
|
|
1529
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
1530
|
+
children: /*#__PURE__*/jsx(Table$1, {
|
|
1531
|
+
handlePageChange: handlePageChange,
|
|
1532
|
+
totalCount: totalCount,
|
|
1533
|
+
allowRowClick: true,
|
|
1534
|
+
fixedHeight: true,
|
|
1535
|
+
columnData: PENDING_TABLE_COLUMNS,
|
|
1536
|
+
currentPageNumber: pageProperties.page,
|
|
1537
|
+
defaultPageSize: pageProperties.pageSize,
|
|
1538
|
+
rowData: pendingRequests,
|
|
1539
|
+
paginationProps: {
|
|
1540
|
+
hideOnSinglePage: (pendingRequests === null || pendingRequests === void 0 ? void 0 : pendingRequests.length) < DEFAULT_PAGE_SIZE + 1
|
|
1541
|
+
},
|
|
1542
|
+
onChange: handleTableChange,
|
|
1543
|
+
onRowClick: function onRowClick(_, approvalDetails) {
|
|
1544
|
+
return setApprovalDetails(approvalDetails);
|
|
690
1545
|
}
|
|
1546
|
+
})
|
|
1547
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
1548
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
1549
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
1550
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
1551
|
+
what: t("neetoApprovals.common.pendingApproval", PLURAL)
|
|
1552
|
+
})
|
|
1553
|
+
})
|
|
1554
|
+
}), /*#__PURE__*/jsx(RequestDetailsPane, {
|
|
1555
|
+
approvalDetails: approvalDetails,
|
|
1556
|
+
isPending: true,
|
|
1557
|
+
isOpen: isPresent(approvalDetails),
|
|
1558
|
+
onClose: function onClose() {
|
|
1559
|
+
return setApprovalDetails({});
|
|
691
1560
|
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return _extends.apply(this, arguments);
|
|
696
|
-
}
|
|
1561
|
+
})]
|
|
1562
|
+
});
|
|
1563
|
+
};
|
|
697
1564
|
|
|
698
1565
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
699
1566
|
if (source == null) return {};
|
|
@@ -766,48 +1633,47 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
766
1633
|
var useFetchTemplates = function useFetchTemplates() {
|
|
767
1634
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
768
1635
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
769
|
-
return useQuery(
|
|
770
|
-
|
|
771
|
-
|
|
1636
|
+
return useQuery(_objectSpread$8({
|
|
1637
|
+
queryKey: [QUERY_KEYS.TEMPLATES, params],
|
|
1638
|
+
queryFn: function queryFn() {
|
|
1639
|
+
return templatesApi.fetch(params);
|
|
1640
|
+
},
|
|
772
1641
|
select: function select(response) {
|
|
773
1642
|
return response.data || response;
|
|
774
1643
|
},
|
|
775
|
-
|
|
776
|
-
onSuccess: function onSuccess(_ref) {
|
|
777
|
-
var _params$onSuccess;
|
|
778
|
-
var templates = _ref.templates;
|
|
779
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, templates);
|
|
780
|
-
}
|
|
1644
|
+
placeholderData: keepPreviousData
|
|
781
1645
|
}, options));
|
|
782
1646
|
};
|
|
783
|
-
var useFetchTemplate = function useFetchTemplate(
|
|
784
|
-
var id =
|
|
785
|
-
params =
|
|
786
|
-
return useQuery(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1647
|
+
var useFetchTemplate = function useFetchTemplate(_ref) {
|
|
1648
|
+
var id = _ref.id,
|
|
1649
|
+
params = _ref.params;
|
|
1650
|
+
return useQuery({
|
|
1651
|
+
queryKey: [QUERY_KEYS.SHOW_TEMPLATE, id, params],
|
|
1652
|
+
queryFn: function queryFn() {
|
|
1653
|
+
return templatesApi.show({
|
|
1654
|
+
id: id,
|
|
1655
|
+
params: params
|
|
1656
|
+
});
|
|
1657
|
+
},
|
|
792
1658
|
enabled: !!id
|
|
793
1659
|
});
|
|
794
1660
|
};
|
|
795
1661
|
var useCreateTemplate = function useCreateTemplate(options) {
|
|
796
1662
|
return useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
|
|
797
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1663
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
798
1664
|
}, options));
|
|
799
1665
|
};
|
|
800
1666
|
var useUpdateTemplate = function useUpdateTemplate(options) {
|
|
801
1667
|
return useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
|
|
802
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, function (_,
|
|
803
|
-
var id =
|
|
1668
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], function (_, _ref2) {
|
|
1669
|
+
var id = _ref2.id;
|
|
804
1670
|
return [QUERY_KEYS.SHOW_TEMPLATE, id];
|
|
805
1671
|
}]
|
|
806
1672
|
}, options));
|
|
807
1673
|
};
|
|
808
1674
|
var useDeleteTemplate = function useDeleteTemplate(options) {
|
|
809
1675
|
return useMutationWithInvalidation(templatesApi.destroy, _objectSpread$8({
|
|
810
|
-
keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
|
|
1676
|
+
keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
|
|
811
1677
|
}, options));
|
|
812
1678
|
};
|
|
813
1679
|
|
|
@@ -833,7 +1699,7 @@ var MessageEditor = withT(function (_ref) {
|
|
|
833
1699
|
placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
|
|
834
1700
|
_ref$initialValue = _ref.initialValue,
|
|
835
1701
|
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
|
|
836
|
-
return /*#__PURE__*/
|
|
1702
|
+
return /*#__PURE__*/jsx(FormikEditor, {
|
|
837
1703
|
initialValue: initialValue,
|
|
838
1704
|
required: true,
|
|
839
1705
|
label: t("neetoApprovals.inputs.labels.message"),
|
|
@@ -861,32 +1727,34 @@ var TemplateForm = function TemplateForm(_ref) {
|
|
|
861
1727
|
setFieldValue("description", "");
|
|
862
1728
|
}
|
|
863
1729
|
};
|
|
864
|
-
return /*#__PURE__*/
|
|
865
|
-
className: "flex w-full flex-col space-y-6"
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1730
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1731
|
+
className: "flex w-full flex-col space-y-6",
|
|
1732
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
1733
|
+
autoFocus: true,
|
|
1734
|
+
required: true,
|
|
1735
|
+
label: t("neetoApprovals.common.name"),
|
|
1736
|
+
name: "name",
|
|
1737
|
+
placeholder: t("neetoApprovals.inputs.placeholders.name")
|
|
1738
|
+
}), /*#__PURE__*/jsx(ToggleFeatureCard, {
|
|
1739
|
+
switchName: "descriptionEnabled",
|
|
1740
|
+
title: t("neetoApprovals.inputs.labels.description"),
|
|
1741
|
+
switchProps: {
|
|
1742
|
+
onChange: handleDescriptionToggle,
|
|
1743
|
+
tooltipProps: {
|
|
1744
|
+
enabledSwitchText: t("neetoApprovals.templates.descriptionToggle.enable"),
|
|
1745
|
+
disabledSwitchText: t("neetoApprovals.templates.descriptionToggle.disable")
|
|
1746
|
+
}
|
|
1747
|
+
},
|
|
1748
|
+
children: values.descriptionEnabled && /*#__PURE__*/jsx(Textarea$1, {
|
|
1749
|
+
className: "w-full",
|
|
1750
|
+
name: "description",
|
|
1751
|
+
placeholder: t("neetoApprovals.inputs.placeholders.description")
|
|
1752
|
+
})
|
|
1753
|
+
}), /*#__PURE__*/jsx(MessageEditor, {
|
|
1754
|
+
placeholders: placeholders,
|
|
1755
|
+
initialValue: initialData.message
|
|
1756
|
+
})]
|
|
1757
|
+
});
|
|
890
1758
|
};
|
|
891
1759
|
|
|
892
1760
|
var Form$2 = function Form(_ref) {
|
|
@@ -895,7 +1763,7 @@ var Form$2 = function Form(_ref) {
|
|
|
895
1763
|
_ref$initialData = _ref.initialData,
|
|
896
1764
|
initialData = _ref$initialData === void 0 ? {} : _ref$initialData,
|
|
897
1765
|
_ref$onSubmit = _ref.onSubmit,
|
|
898
|
-
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
1766
|
+
onSubmit = _ref$onSubmit === void 0 ? noop$1 : _ref$onSubmit,
|
|
899
1767
|
_ref$isLoading = _ref.isLoading,
|
|
900
1768
|
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
901
1769
|
placeholders = _ref.placeholders;
|
|
@@ -907,33 +1775,42 @@ var Form$2 = function Form(_ref) {
|
|
|
907
1775
|
}) : t("neetoApprovals.common.edit_", {
|
|
908
1776
|
what: t("neetoApprovals.common.template", SINGULAR)
|
|
909
1777
|
});
|
|
910
|
-
return /*#__PURE__*/
|
|
1778
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
911
1779
|
isOpen: isOpen,
|
|
912
1780
|
onClose: onClose,
|
|
913
1781
|
initialFocusRef: inputReference,
|
|
914
|
-
size: "large"
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1782
|
+
size: "large",
|
|
1783
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1784
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1785
|
+
style: "h2",
|
|
1786
|
+
children: header
|
|
1787
|
+
})
|
|
1788
|
+
}), /*#__PURE__*/jsxs(FormikForm, {
|
|
1789
|
+
formikProps: {
|
|
1790
|
+
enableReinitialize: true,
|
|
1791
|
+
initialValues: isPresent(initialData) ? initialData : TEMPLATE_FORM_INITIAL_VALUES,
|
|
1792
|
+
validationSchema: TEMPLATE_FORM_VALIDATION_SCHEMA,
|
|
1793
|
+
onSubmit: onSubmit
|
|
1794
|
+
},
|
|
1795
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
1796
|
+
children: /*#__PURE__*/jsx(TemplateForm, {
|
|
1797
|
+
initialData: initialData,
|
|
1798
|
+
placeholders: placeholders
|
|
1799
|
+
})
|
|
1800
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1801
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1802
|
+
isSubmitting: isLoading,
|
|
1803
|
+
cancelButtonProps: {
|
|
1804
|
+
"data-cy": "neeto-approvals-templates-close-template-form-btn",
|
|
1805
|
+
onClick: onClose
|
|
1806
|
+
},
|
|
1807
|
+
submitButtonProps: {
|
|
1808
|
+
"data-cy": "neeto-approvals-templates-save-template-btn"
|
|
1809
|
+
}
|
|
1810
|
+
})
|
|
1811
|
+
})]
|
|
1812
|
+
})]
|
|
1813
|
+
});
|
|
937
1814
|
};
|
|
938
1815
|
|
|
939
1816
|
var Create = function Create(_ref) {
|
|
@@ -943,7 +1820,7 @@ var Create = function Create(_ref) {
|
|
|
943
1820
|
templatePlaceholders = _ref.templatePlaceholders;
|
|
944
1821
|
var _useCreateTemplate = useCreateTemplate(),
|
|
945
1822
|
createTemplate = _useCreateTemplate.mutate,
|
|
946
|
-
|
|
1823
|
+
isPending = _useCreateTemplate.isPending;
|
|
947
1824
|
var onSubmit = function onSubmit(template) {
|
|
948
1825
|
var payload = {
|
|
949
1826
|
template: template
|
|
@@ -955,11 +1832,11 @@ var Create = function Create(_ref) {
|
|
|
955
1832
|
onSuccess: onClose
|
|
956
1833
|
});
|
|
957
1834
|
};
|
|
958
|
-
return /*#__PURE__*/
|
|
959
|
-
isLoading: isLoading,
|
|
1835
|
+
return /*#__PURE__*/jsx(Form$2, {
|
|
960
1836
|
isOpen: isOpen,
|
|
961
1837
|
onClose: onClose,
|
|
962
1838
|
onSubmit: onSubmit,
|
|
1839
|
+
isLoading: isPending,
|
|
963
1840
|
placeholders: templatePlaceholders
|
|
964
1841
|
});
|
|
965
1842
|
};
|
|
@@ -979,7 +1856,7 @@ var Edit = function Edit(_ref) {
|
|
|
979
1856
|
}
|
|
980
1857
|
}),
|
|
981
1858
|
updateTemplate = _useUpdateTemplate.mutate,
|
|
982
|
-
isUpdating = _useUpdateTemplate.
|
|
1859
|
+
isUpdating = _useUpdateTemplate.isPending;
|
|
983
1860
|
var onSubmit = function onSubmit(template) {
|
|
984
1861
|
var payload = {
|
|
985
1862
|
template: template
|
|
@@ -993,7 +1870,7 @@ var Edit = function Edit(_ref) {
|
|
|
993
1870
|
var initialData = _objectSpread$7(_objectSpread$7({}, template), {}, {
|
|
994
1871
|
descriptionEnabled: !!template.description
|
|
995
1872
|
});
|
|
996
|
-
return /*#__PURE__*/
|
|
1873
|
+
return /*#__PURE__*/jsx(Form$2, {
|
|
997
1874
|
initialData: initialData,
|
|
998
1875
|
isOpen: isOpen,
|
|
999
1876
|
onClose: onClose,
|
|
@@ -1006,18 +1883,21 @@ var Edit = function Edit(_ref) {
|
|
|
1006
1883
|
var Field = function Field(_ref) {
|
|
1007
1884
|
var label = _ref.label,
|
|
1008
1885
|
value = _ref.value;
|
|
1009
|
-
return /*#__PURE__*/
|
|
1010
|
-
className: "flex flex-col items-start justify-center"
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1886
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1887
|
+
className: "flex flex-col items-start justify-center",
|
|
1888
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1889
|
+
className: "mb-1 font-normal",
|
|
1890
|
+
children: label
|
|
1891
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1892
|
+
style: "body1",
|
|
1893
|
+
weight: "medium",
|
|
1894
|
+
children: value
|
|
1895
|
+
})]
|
|
1896
|
+
});
|
|
1897
|
+
};
|
|
1898
|
+
var Field$1 = /*#__PURE__*/React__default.memo(Field);
|
|
1899
|
+
|
|
1900
|
+
var MemoizedEditorContent = /*#__PURE__*/React__default.memo(EditorContent);
|
|
1021
1901
|
var TemplateDetails = function TemplateDetails(_ref) {
|
|
1022
1902
|
var isOpen = _ref.isOpen,
|
|
1023
1903
|
onClose = _ref.onClose,
|
|
@@ -1027,41 +1907,47 @@ var TemplateDetails = function TemplateDetails(_ref) {
|
|
|
1027
1907
|
var name = template.name,
|
|
1028
1908
|
description = template.description,
|
|
1029
1909
|
message = template.message;
|
|
1030
|
-
return /*#__PURE__*/
|
|
1910
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1031
1911
|
isOpen: isOpen,
|
|
1032
|
-
onClose: onClose
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1912
|
+
onClose: onClose,
|
|
1913
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1914
|
+
className: "space-y-2",
|
|
1915
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1916
|
+
style: "h2",
|
|
1917
|
+
children: t("neetoApprovals.common.templateDetails")
|
|
1918
|
+
})
|
|
1919
|
+
}), /*#__PURE__*/jsxs(Pane.Body, {
|
|
1920
|
+
className: "space-y-6",
|
|
1921
|
+
children: [/*#__PURE__*/jsx(Field$1, {
|
|
1922
|
+
label: t("neetoApprovals.common.name"),
|
|
1923
|
+
value: name
|
|
1924
|
+
}), /*#__PURE__*/jsx(Field$1, {
|
|
1925
|
+
label: t("neetoApprovals.inputs.labels.description"),
|
|
1926
|
+
value: description
|
|
1927
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1928
|
+
className: "flex w-full flex-col space-y-4",
|
|
1929
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
1930
|
+
className: "mb-1 font-normal",
|
|
1931
|
+
children: t("neetoApprovals.inputs.labels.message")
|
|
1932
|
+
}), /*#__PURE__*/jsx(MemoizedEditorContent, {
|
|
1933
|
+
className: "neeto-ui-bg-gray-100 neeto-ui-rounded-lg p-3",
|
|
1934
|
+
content: message
|
|
1935
|
+
})]
|
|
1936
|
+
})]
|
|
1937
|
+
})]
|
|
1938
|
+
});
|
|
1053
1939
|
};
|
|
1054
1940
|
|
|
1055
1941
|
var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
|
|
1056
1942
|
var entity = _ref.entity,
|
|
1057
1943
|
url = _ref.url;
|
|
1058
|
-
return /*#__PURE__*/
|
|
1944
|
+
return /*#__PURE__*/jsx(Trans, {
|
|
1059
1945
|
i18nKey: "neetoApprovals.common.noDataHelpText",
|
|
1060
1946
|
values: {
|
|
1061
1947
|
entity: entity
|
|
1062
1948
|
},
|
|
1063
1949
|
components: {
|
|
1064
|
-
a: /*#__PURE__*/
|
|
1950
|
+
a: /*#__PURE__*/jsx(Link, {
|
|
1065
1951
|
className: "neeto-ui-text-primary-600 underline",
|
|
1066
1952
|
target: "_blank",
|
|
1067
1953
|
to: {
|
|
@@ -1116,34 +2002,36 @@ var Table = function Table(_ref) {
|
|
|
1116
2002
|
})
|
|
1117
2003
|
};
|
|
1118
2004
|
if (isEmpty(rowData)) {
|
|
1119
|
-
return /*#__PURE__*/
|
|
1120
|
-
className: "flex h-full w-full flex-grow items-center justify-center"
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
2005
|
+
return /*#__PURE__*/jsx("div", {
|
|
2006
|
+
className: "flex h-full w-full flex-grow items-center justify-center",
|
|
2007
|
+
children: /*#__PURE__*/jsx(NoData, _objectSpread$6({
|
|
2008
|
+
title: t("neetoApprovals.common.notFound_", {
|
|
2009
|
+
what: entity
|
|
2010
|
+
})
|
|
2011
|
+
}, !filters.searchTerm && noDataProps))
|
|
2012
|
+
});
|
|
1126
2013
|
}
|
|
1127
|
-
return /*#__PURE__*/
|
|
2014
|
+
return /*#__PURE__*/jsx(TableWrapper, {
|
|
1128
2015
|
className: "mt-6",
|
|
1129
|
-
hasPagination: totalCount > pageProperties.pageSize
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
2016
|
+
hasPagination: totalCount > pageProperties.pageSize,
|
|
2017
|
+
children: /*#__PURE__*/jsx(Table$1, _objectSpread$6({
|
|
2018
|
+
fixedHeight: true,
|
|
2019
|
+
columnData: columns,
|
|
2020
|
+
currentPageNumber: pageProperties.page,
|
|
2021
|
+
defaultPageSize: pageProperties.pageSize,
|
|
2022
|
+
scroll: {
|
|
2023
|
+
x: 0
|
|
2024
|
+
},
|
|
2025
|
+
tableLayout: "fixed",
|
|
2026
|
+
paginationProps: {
|
|
2027
|
+
hideOnSinglePage: (rowData === null || rowData === void 0 ? void 0 : rowData.length) < DEFAULT_PAGE_SIZE + 1
|
|
2028
|
+
},
|
|
2029
|
+
onChange: handleTableChange
|
|
2030
|
+
}, _objectSpread$6({
|
|
2031
|
+
rowData: rowData,
|
|
2032
|
+
totalCount: totalCount
|
|
2033
|
+
}, otherProps)))
|
|
2034
|
+
});
|
|
1147
2035
|
};
|
|
1148
2036
|
|
|
1149
2037
|
var columnData = function columnData(_ref) {
|
|
@@ -1156,32 +2044,34 @@ var columnData = function columnData(_ref) {
|
|
|
1156
2044
|
title: i18next.t("neetoApprovals.common.name"),
|
|
1157
2045
|
ellipsis: true,
|
|
1158
2046
|
render: function render(_, template) {
|
|
1159
|
-
return /*#__PURE__*/
|
|
1160
|
-
className: "flex items-center justify-between gap-x-3"
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
2047
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2048
|
+
className: "flex items-center justify-between gap-x-3",
|
|
2049
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
2050
|
+
className: "truncate",
|
|
2051
|
+
style: "body2",
|
|
2052
|
+
children: template.name
|
|
2053
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
2054
|
+
dropdownProps: {
|
|
2055
|
+
strategy: "fixed",
|
|
2056
|
+
onClick: function onClick(e) {
|
|
2057
|
+
return e.stopPropagation();
|
|
2058
|
+
}
|
|
2059
|
+
},
|
|
2060
|
+
menuItems: [_defineProperty({
|
|
2061
|
+
key: "edit",
|
|
2062
|
+
label: i18next.t("neetoApprovals.common.edit"),
|
|
2063
|
+
onClick: function onClick(event) {
|
|
2064
|
+
return onEditClick(event, template);
|
|
2065
|
+
}
|
|
2066
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-edit-template-btn"), _defineProperty({
|
|
2067
|
+
key: "delete",
|
|
2068
|
+
label: i18next.t("neetoApprovals.common.delete"),
|
|
2069
|
+
onClick: function onClick(event) {
|
|
2070
|
+
return onDeleteClick(event, template);
|
|
2071
|
+
}
|
|
2072
|
+
}, DATA_CY_KEY, "neeto-approvals-templates-delete-template-btn")]
|
|
2073
|
+
})]
|
|
2074
|
+
});
|
|
1185
2075
|
}
|
|
1186
2076
|
}, {
|
|
1187
2077
|
dataIndex: "description",
|
|
@@ -1194,7 +2084,6 @@ var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpe
|
|
|
1194
2084
|
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; }
|
|
1195
2085
|
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; }
|
|
1196
2086
|
var Templates = function Templates(_ref) {
|
|
1197
|
-
var _t, _t2, _t3;
|
|
1198
2087
|
var searchTerm = _ref.searchTerm,
|
|
1199
2088
|
isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
|
|
1200
2089
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
|
|
@@ -1232,28 +2121,27 @@ var Templates = function Templates(_ref) {
|
|
|
1232
2121
|
}, [searchTerm]);
|
|
1233
2122
|
var _useFetchTemplates = useFetchTemplates(_objectSpread$5(_objectSpread$5(_objectSpread$5({}, pageProperties), filters), {}, {
|
|
1234
2123
|
searchTerm: debouncedSearchTerm.trim()
|
|
1235
|
-
}),
|
|
1236
|
-
|
|
1237
|
-
var templates = _ref2.templates;
|
|
1238
|
-
handleEmptyPage(templates, pageProperties, handlePageChange);
|
|
1239
|
-
}
|
|
1240
|
-
}),
|
|
1241
|
-
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
1242
|
-
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
1243
|
-
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
1244
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
1245
|
-
_useFetchTemplates$da4 = _useFetchTemplates$da2.totalCount,
|
|
1246
|
-
totalCount = _useFetchTemplates$da4 === void 0 ? 0 : _useFetchTemplates$da4,
|
|
2124
|
+
})),
|
|
2125
|
+
data = _useFetchTemplates.data,
|
|
1247
2126
|
isTemplateLoading = _useFetchTemplates.isLoading;
|
|
2127
|
+
var _ref2 = data || {},
|
|
2128
|
+
_ref2$templates = _ref2.templates,
|
|
2129
|
+
templates = _ref2$templates === void 0 ? [] : _ref2$templates,
|
|
2130
|
+
_ref2$totalCount = _ref2.totalCount,
|
|
2131
|
+
totalCount = _ref2$totalCount === void 0 ? 0 : _ref2$totalCount;
|
|
2132
|
+
useEffect(function () {
|
|
2133
|
+
if (data) {
|
|
2134
|
+
handleEmptyPage(data === null || data === void 0 ? void 0 : data.templates, pageProperties, handlePageChange);
|
|
2135
|
+
}
|
|
2136
|
+
}, [data]);
|
|
1248
2137
|
var _useDeleteTemplate = useDeleteTemplate(),
|
|
1249
2138
|
deleteTemplate = _useDeleteTemplate.mutate,
|
|
1250
|
-
isDeleting = _useDeleteTemplate.
|
|
2139
|
+
isDeleting = _useDeleteTemplate.isPending;
|
|
1251
2140
|
useEffect(function () {
|
|
1252
|
-
if (isEmpty(selectedTemplate))
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
}
|
|
2141
|
+
if (!isEmpty(selectedTemplate)) return;
|
|
2142
|
+
setIsDeleteAlertOpen(false);
|
|
2143
|
+
setIsEditPaneOpen(false);
|
|
2144
|
+
setIsShowPaneOpen(false);
|
|
1257
2145
|
}, [selectedTemplate]);
|
|
1258
2146
|
var onEditClick = function onEditClick(event, template) {
|
|
1259
2147
|
event.stopPropagation();
|
|
@@ -1275,62 +2163,64 @@ var Templates = function Templates(_ref) {
|
|
|
1275
2163
|
});
|
|
1276
2164
|
setSelectedTemplate({});
|
|
1277
2165
|
};
|
|
1278
|
-
var entity =
|
|
1279
|
-
return /*#__PURE__*/
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}, otherProps)), /*#__PURE__*/React.createElement(Edit, _extends({
|
|
1300
|
-
isOpen: isEditPaneOpen,
|
|
1301
|
-
setTemplate: setSelectedTemplate,
|
|
1302
|
-
template: selectedTemplate
|
|
1303
|
-
}, otherProps, {
|
|
1304
|
-
onClose: function onClose() {
|
|
1305
|
-
return setIsEditPaneOpen(false);
|
|
1306
|
-
}
|
|
1307
|
-
})), /*#__PURE__*/React.createElement(Alert, {
|
|
1308
|
-
isOpen: isDeleteAlertOpen,
|
|
1309
|
-
isSubmitting: isDeleting,
|
|
1310
|
-
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
1311
|
-
message: /*#__PURE__*/React.createElement(Trans, {
|
|
1312
|
-
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
1313
|
-
values: {
|
|
1314
|
-
what: (_t2 = t("neetoApprovals.common.template", SINGULAR)) === null || _t2 === void 0 ? void 0 : _t2.toLocaleLowerCase(),
|
|
1315
|
-
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
2166
|
+
var entity = t("neetoApprovals.common.template", PLURAL);
|
|
2167
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
2168
|
+
children: [isTemplateLoading ? /*#__PURE__*/jsx(PageLoader, {}) : /*#__PURE__*/jsx(Table, {
|
|
2169
|
+
columnData: columnData,
|
|
2170
|
+
entity: entity,
|
|
2171
|
+
filters: filters,
|
|
2172
|
+
handlePageChange: handlePageChange,
|
|
2173
|
+
helpDocUrl: helpDocUrl,
|
|
2174
|
+
onDeleteClick: onDeleteClick,
|
|
2175
|
+
onEditClick: onEditClick,
|
|
2176
|
+
onRowClick: onRowClick,
|
|
2177
|
+
pageProperties: pageProperties,
|
|
2178
|
+
searchTerm: searchTerm,
|
|
2179
|
+
setFilters: setFilters,
|
|
2180
|
+
totalCount: totalCount,
|
|
2181
|
+
rowData: templates,
|
|
2182
|
+
setIsPaneOpen: setIsNewTemplatePaneOpen
|
|
2183
|
+
}), /*#__PURE__*/jsx(Create, _objectSpread$5({
|
|
2184
|
+
isOpen: isNewTemplatePaneOpen,
|
|
2185
|
+
onClose: function onClose() {
|
|
2186
|
+
return setIsNewTemplatePaneOpen(false);
|
|
1316
2187
|
}
|
|
1317
|
-
}),
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
2188
|
+
}, otherProps)), /*#__PURE__*/jsx(Edit, _objectSpread$5(_objectSpread$5({
|
|
2189
|
+
isOpen: isEditPaneOpen,
|
|
2190
|
+
setTemplate: setSelectedTemplate,
|
|
2191
|
+
template: selectedTemplate
|
|
2192
|
+
}, otherProps), {}, {
|
|
2193
|
+
onClose: function onClose() {
|
|
2194
|
+
return setIsEditPaneOpen(false);
|
|
2195
|
+
}
|
|
2196
|
+
})), /*#__PURE__*/jsx(Alert, {
|
|
2197
|
+
isOpen: isDeleteAlertOpen,
|
|
2198
|
+
isSubmitting: isDeleting,
|
|
2199
|
+
submitButtonLabel: t("neetoApprovals.buttons.delete"),
|
|
2200
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
2201
|
+
i18nKey: "neetoApprovals.alerts.deleting_",
|
|
2202
|
+
values: {
|
|
2203
|
+
what: t("neetoApprovals.common.template", SINGULAR),
|
|
2204
|
+
name: selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.name
|
|
2205
|
+
}
|
|
2206
|
+
}),
|
|
2207
|
+
title: t("neetoApprovals.common.delete_", {
|
|
2208
|
+
what: t("neetoApprovals.common.template", SINGULAR)
|
|
2209
|
+
}),
|
|
2210
|
+
onClose: function onClose() {
|
|
2211
|
+
return setSelectedTemplate({});
|
|
2212
|
+
},
|
|
2213
|
+
onSubmit: function onSubmit() {
|
|
2214
|
+
return handleDelete(selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.id);
|
|
2215
|
+
}
|
|
2216
|
+
}), /*#__PURE__*/jsx(TemplateDetails, {
|
|
2217
|
+
isOpen: isShowPaneOpen,
|
|
2218
|
+
template: selectedTemplate,
|
|
2219
|
+
onClose: function onClose() {
|
|
2220
|
+
return setSelectedTemplate({});
|
|
2221
|
+
}
|
|
2222
|
+
})]
|
|
2223
|
+
});
|
|
1334
2224
|
};
|
|
1335
2225
|
|
|
1336
2226
|
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; }
|
|
@@ -1342,16 +2232,16 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1342
2232
|
setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
|
|
1343
2233
|
return [{
|
|
1344
2234
|
component: function component() {
|
|
1345
|
-
return /*#__PURE__*/
|
|
2235
|
+
return /*#__PURE__*/jsx(Templates, _objectSpread$4({}, _objectSpread$4({
|
|
1346
2236
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1347
2237
|
searchTerm: searchTerm,
|
|
1348
2238
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1349
|
-
}, config));
|
|
2239
|
+
}, config)));
|
|
1350
2240
|
},
|
|
1351
2241
|
path: "".concat(config.approvalsPath).concat(routes.templates.index),
|
|
1352
2242
|
actionBlock: function actionBlock() {
|
|
1353
2243
|
var _t;
|
|
1354
|
-
return /*#__PURE__*/
|
|
2244
|
+
return /*#__PURE__*/jsx(Button, {
|
|
1355
2245
|
"data-cy": "neeto-approvals-templates-add-new-button",
|
|
1356
2246
|
label: t$1("neetoApprovals.common.addNew_", {
|
|
1357
2247
|
what: (_t = t$1("neetoApprovals.common.template", SINGULAR)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
@@ -1366,12 +2256,12 @@ var createRoutes = function createRoutes(_ref) {
|
|
|
1366
2256
|
})
|
|
1367
2257
|
}, {
|
|
1368
2258
|
component: function component() {
|
|
1369
|
-
return /*#__PURE__*/
|
|
2259
|
+
return /*#__PURE__*/jsx(PendingRequests, _objectSpread$4({}, config));
|
|
1370
2260
|
},
|
|
1371
2261
|
path: "".concat(config.approvalsPath).concat(routes.pending)
|
|
1372
2262
|
}, {
|
|
1373
2263
|
component: function component() {
|
|
1374
|
-
return /*#__PURE__*/
|
|
2264
|
+
return /*#__PURE__*/jsx(History, _objectSpread$4({}, config));
|
|
1375
2265
|
},
|
|
1376
2266
|
path: "".concat(config.approvalsPath).concat(routes.history)
|
|
1377
2267
|
}];
|
|
@@ -1388,7 +2278,7 @@ var Header = function Header(_ref) {
|
|
|
1388
2278
|
var currentTab = findBy({
|
|
1389
2279
|
path: pathname
|
|
1390
2280
|
}, appRoutes);
|
|
1391
|
-
return /*#__PURE__*/
|
|
2281
|
+
return /*#__PURE__*/jsx(NeetoHeader, {
|
|
1392
2282
|
actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
|
|
1393
2283
|
title: t("neetoApprovals.common.approval", PLURAL),
|
|
1394
2284
|
searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
|
|
@@ -1409,9 +2299,9 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
|
|
|
1409
2299
|
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; }
|
|
1410
2300
|
var useFetchViews = function useFetchViews() {
|
|
1411
2301
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1412
|
-
return useQuery(
|
|
1413
|
-
|
|
1414
|
-
|
|
2302
|
+
return useQuery(_objectSpread$3({
|
|
2303
|
+
queryKey: [QUERY_KEYS.VIEWS],
|
|
2304
|
+
queryFn: viewsApi.fetch,
|
|
1415
2305
|
select: function select(response) {
|
|
1416
2306
|
return response.data || response;
|
|
1417
2307
|
}
|
|
@@ -1438,17 +2328,19 @@ var Tab = function Tab(_ref) {
|
|
|
1438
2328
|
_useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
|
|
1439
2329
|
_useFetchViews$data2$ = _useFetchViews$data2.views,
|
|
1440
2330
|
views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
|
|
1441
|
-
return /*#__PURE__*/
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
2331
|
+
return /*#__PURE__*/jsx(NeetoUITab, {
|
|
2332
|
+
children: approvalFilterKeys.map(function (filter) {
|
|
2333
|
+
return /*#__PURE__*/jsxs(NeetoUITab.Item, {
|
|
2334
|
+
active: isActive(filter),
|
|
2335
|
+
count: views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()],
|
|
2336
|
+
label: approvalFilter[filter].label,
|
|
2337
|
+
onClick: function onClick() {
|
|
2338
|
+
return history.push(getRoute(filter));
|
|
2339
|
+
},
|
|
2340
|
+
children: [approvalFilter[filter].label, " (", views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()] || 0, ")"]
|
|
2341
|
+
}, filter);
|
|
2342
|
+
})
|
|
2343
|
+
});
|
|
1452
2344
|
};
|
|
1453
2345
|
|
|
1454
2346
|
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; }
|
|
@@ -1468,28 +2360,33 @@ var Approvals = function Approvals(_ref) {
|
|
|
1468
2360
|
isNewTemplatePaneOpen: isNewTemplatePaneOpen,
|
|
1469
2361
|
setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
|
|
1470
2362
|
});
|
|
1471
|
-
return /*#__PURE__*/
|
|
1472
|
-
className: "w-full overflow-y-auto"
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
2363
|
+
return /*#__PURE__*/jsx("div", {
|
|
2364
|
+
className: "w-full overflow-y-auto",
|
|
2365
|
+
children: /*#__PURE__*/jsxs(Container, {
|
|
2366
|
+
children: [/*#__PURE__*/jsx(Header, _objectSpread$2({}, _objectSpread$2({
|
|
2367
|
+
appRoutes: appRoutes
|
|
2368
|
+
}, config))), /*#__PURE__*/jsx(Tab, {
|
|
2369
|
+
approvalsPath: config.approvalsPath
|
|
2370
|
+
}), /*#__PURE__*/jsxs(Switch, {
|
|
2371
|
+
children: [appRoutes.map(function (_ref2) {
|
|
2372
|
+
var path = _ref2.path,
|
|
2373
|
+
component = _ref2.component;
|
|
2374
|
+
return /*#__PURE__*/createElement(Route, {
|
|
2375
|
+
exact: true,
|
|
2376
|
+
component: component,
|
|
2377
|
+
path: path,
|
|
2378
|
+
key: path
|
|
2379
|
+
});
|
|
2380
|
+
}), /*#__PURE__*/jsx(Redirect, {
|
|
2381
|
+
exact: true,
|
|
2382
|
+
from: config.approvalsPath
|
|
2383
|
+
// eslint-disable-next-line @bigbinary/neeto/use-common-routes
|
|
2384
|
+
,
|
|
2385
|
+
to: "".concat(config.approvalsPath).concat(routes.pending)
|
|
2386
|
+
})]
|
|
2387
|
+
})]
|
|
2388
|
+
})
|
|
2389
|
+
});
|
|
1493
2390
|
};
|
|
1494
2391
|
|
|
1495
2392
|
var fetch = function fetch(params) {
|
|
@@ -1506,17 +2403,13 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
|
|
|
1506
2403
|
var useFetchApprovers = function useFetchApprovers() {
|
|
1507
2404
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1508
2405
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1509
|
-
return useQuery(
|
|
1510
|
-
|
|
1511
|
-
|
|
2406
|
+
return useQuery(_objectSpread$1({
|
|
2407
|
+
queryKey: [QUERY_KEYS.APPROVERS, params],
|
|
2408
|
+
queryFn: function queryFn() {
|
|
2409
|
+
return approversApi.fetch(params);
|
|
2410
|
+
},
|
|
1512
2411
|
select: function select(response) {
|
|
1513
2412
|
return response.data || response;
|
|
1514
|
-
},
|
|
1515
|
-
keepPreviousData: true,
|
|
1516
|
-
onSuccess: function onSuccess(_ref) {
|
|
1517
|
-
var _params$onSuccess;
|
|
1518
|
-
var approvers = _ref.approvers;
|
|
1519
|
-
return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, approvers);
|
|
1520
2413
|
}
|
|
1521
2414
|
}, options));
|
|
1522
2415
|
};
|
|
@@ -1595,37 +2488,42 @@ var Form$1 = function Form(_ref) {
|
|
|
1595
2488
|
setSelectedTemplateData(template);
|
|
1596
2489
|
updateMessage();
|
|
1597
2490
|
}, [template]);
|
|
1598
|
-
return /*#__PURE__*/
|
|
1599
|
-
className: "w-full space-y-6"
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
2491
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2492
|
+
className: "w-full space-y-6",
|
|
2493
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
2494
|
+
label: t("neetoApprovals.select.approval"),
|
|
2495
|
+
options: templateOptions,
|
|
2496
|
+
onChange: function onChange(selectedTemplate) {
|
|
2497
|
+
return handleTemplateChange(selectedTemplate);
|
|
2498
|
+
}
|
|
2499
|
+
}), (selectedTemplateData === null || selectedTemplateData === void 0 ? void 0 : selectedTemplateData.message) && /*#__PURE__*/jsxs(Fragment, {
|
|
2500
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
2501
|
+
className: "flex space-x-6",
|
|
2502
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
2503
|
+
required: true,
|
|
2504
|
+
label: t("neetoApprovals.inputs.labels.approver"),
|
|
2505
|
+
name: "approver",
|
|
2506
|
+
options: approverOptions,
|
|
2507
|
+
placeholder: t("neetoApprovals.inputs.placeholders.select_", {
|
|
2508
|
+
what: t("neetoApprovals.common.approver", SINGULAR)
|
|
2509
|
+
}),
|
|
2510
|
+
onChange: handleApproverChange
|
|
2511
|
+
})
|
|
2512
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2513
|
+
className: "space-y-2",
|
|
2514
|
+
children: /*#__PURE__*/jsx(FormikEditor, {
|
|
2515
|
+
required: true,
|
|
2516
|
+
label: t("neetoApprovals.inputs.labels.message"),
|
|
2517
|
+
name: "message",
|
|
2518
|
+
ref: inputRef,
|
|
2519
|
+
rows: 3,
|
|
2520
|
+
placeholder: t("neetoApprovals.inputs.placeholders.enter_", {
|
|
2521
|
+
what: t("neetoApprovals.inputs.labels.message")
|
|
2522
|
+
})
|
|
2523
|
+
})
|
|
2524
|
+
})]
|
|
2525
|
+
})]
|
|
2526
|
+
});
|
|
1629
2527
|
};
|
|
1630
2528
|
|
|
1631
2529
|
var Form = function Form(_ref) {
|
|
@@ -1651,29 +2549,38 @@ var Form = function Form(_ref) {
|
|
|
1651
2549
|
approverId: values.approver.value
|
|
1652
2550
|
}, selectedTemplateData, onClose);
|
|
1653
2551
|
};
|
|
1654
|
-
return /*#__PURE__*/
|
|
2552
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1655
2553
|
isOpen: isOpen,
|
|
1656
|
-
onClose: onClose
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
2554
|
+
onClose: onClose,
|
|
2555
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
2556
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
2557
|
+
style: "h2",
|
|
2558
|
+
children: t("neetoApprovals.common.add_", {
|
|
2559
|
+
what: t("neetoApprovals.common.approval", SINGULAR)
|
|
2560
|
+
})
|
|
2561
|
+
})
|
|
2562
|
+
}), /*#__PURE__*/jsxs(FormikForm, {
|
|
2563
|
+
formikProps: {
|
|
2564
|
+
onSubmit: handleSubmit,
|
|
2565
|
+
initialValues: APPROVAL_REQUEST_FORM_INITIAL_VALUES,
|
|
2566
|
+
validationSchema: REQUEST_FORM_VALIDATION_SCHEMA
|
|
2567
|
+
},
|
|
2568
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
2569
|
+
children: /*#__PURE__*/jsx(Form$1, {
|
|
2570
|
+
requestableId: requestableId,
|
|
2571
|
+
selectedTemplateData: selectedTemplateData,
|
|
2572
|
+
setSelectedTemplateData: setSelectedTemplateData
|
|
2573
|
+
})
|
|
2574
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
2575
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
2576
|
+
cancelButtonProps: {
|
|
2577
|
+
onClick: onClose
|
|
2578
|
+
},
|
|
2579
|
+
isSubmitting: isLoading
|
|
2580
|
+
})
|
|
2581
|
+
})]
|
|
2582
|
+
})]
|
|
2583
|
+
});
|
|
1677
2584
|
};
|
|
1678
2585
|
|
|
1679
2586
|
var show = function show(id) {
|
|
@@ -1703,20 +2610,21 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
1703
2610
|
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; }
|
|
1704
2611
|
var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
|
|
1705
2612
|
var requestId = _ref.requestId;
|
|
1706
|
-
return useQuery(
|
|
1707
|
-
|
|
1708
|
-
|
|
2613
|
+
return useQuery(_objectSpread({
|
|
2614
|
+
queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
|
|
2615
|
+
queryFn: function queryFn() {
|
|
2616
|
+
return publicRequestsApi.show(requestId);
|
|
2617
|
+
}
|
|
2618
|
+
}, options));
|
|
1709
2619
|
};
|
|
1710
2620
|
var useAcceptPendingRequest = function useAcceptPendingRequest(options) {
|
|
1711
|
-
useQueryClient();
|
|
1712
2621
|
return useMutationWithInvalidation(publicRequestsApi.accept, _objectSpread({
|
|
1713
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
2622
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1714
2623
|
}, options));
|
|
1715
2624
|
};
|
|
1716
2625
|
var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
|
|
1717
|
-
useQueryClient();
|
|
1718
2626
|
return useMutationWithInvalidation(publicRequestsApi.decline, _objectSpread({
|
|
1719
|
-
keysToInvalidate: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
|
|
2627
|
+
keysToInvalidate: [[QUERY_KEYS.SHOW_PUBLIC_REQUEST], [QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
|
|
1720
2628
|
}, options));
|
|
1721
2629
|
};
|
|
1722
2630
|
|
|
@@ -1732,84 +2640,96 @@ var Public = function Public() {
|
|
|
1732
2640
|
t = _useTranslation.t;
|
|
1733
2641
|
var _useFetchPublicReques = useFetchPublicRequest({
|
|
1734
2642
|
requestId: id
|
|
1735
|
-
}, {
|
|
1736
|
-
onSuccess: function onSuccess(_ref) {
|
|
1737
|
-
var note = _ref.approvalRequest.note;
|
|
1738
|
-
note && setNote(note);
|
|
1739
|
-
}
|
|
1740
2643
|
}),
|
|
1741
|
-
|
|
1742
|
-
_useFetchPublicReques3 = _useFetchPublicReques2 === void 0 ? {} : _useFetchPublicReques2,
|
|
1743
|
-
_useFetchPublicReques4 = _useFetchPublicReques3.approvalRequest,
|
|
1744
|
-
approvalRequest = _useFetchPublicReques4 === void 0 ? {} : _useFetchPublicReques4,
|
|
2644
|
+
data = _useFetchPublicReques.data,
|
|
1745
2645
|
isLoading = _useFetchPublicReques.isLoading;
|
|
2646
|
+
var _ref = data || {},
|
|
2647
|
+
_ref$approvalRequest = _ref.approvalRequest,
|
|
2648
|
+
approvalRequest = _ref$approvalRequest === void 0 ? {} : _ref$approvalRequest;
|
|
2649
|
+
useEffect(function () {
|
|
2650
|
+
var _data$approvalRequest;
|
|
2651
|
+
if (data !== null && data !== void 0 && (_data$approvalRequest = data.approvalRequest) !== null && _data$approvalRequest !== void 0 && _data$approvalRequest.note) {
|
|
2652
|
+
setNote(data.approvalRequest.note);
|
|
2653
|
+
}
|
|
2654
|
+
}, [data]);
|
|
1746
2655
|
var _useAcceptPendingRequ = useAcceptPendingRequest(),
|
|
1747
2656
|
acceptPendingRequest = _useAcceptPendingRequ.mutate,
|
|
1748
|
-
isAccepting = _useAcceptPendingRequ.
|
|
2657
|
+
isAccepting = _useAcceptPendingRequ.isPending;
|
|
1749
2658
|
var _useDeclinePendingReq = useDeclinePendingRequest(),
|
|
1750
2659
|
declinePendingRequest = _useDeclinePendingReq.mutate,
|
|
1751
|
-
isDeclining = _useDeclinePendingReq.
|
|
2660
|
+
isDeclining = _useDeclinePendingReq.isPending;
|
|
1752
2661
|
var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
|
|
1753
2662
|
var hideTextArea = approvalRequest.status !== STATUSES.pending && isEmpty(note);
|
|
1754
2663
|
if (isLoading) {
|
|
1755
|
-
return /*#__PURE__*/
|
|
1756
|
-
className: "h-screen items-center justify-center"
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
2664
|
+
return /*#__PURE__*/jsx("div", {
|
|
2665
|
+
className: "h-screen items-center justify-center",
|
|
2666
|
+
children: /*#__PURE__*/jsx(PageLoader, {})
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
2670
|
+
children: [/*#__PURE__*/jsx(NeetoHeader, {
|
|
2671
|
+
title: t("neetoApprovals.common.approval", PLURAL)
|
|
2672
|
+
}), /*#__PURE__*/jsx("div", {
|
|
2673
|
+
className: "flex h-screen w-full flex-col items-center",
|
|
2674
|
+
children: /*#__PURE__*/jsx("div", {
|
|
2675
|
+
className: "neeto-ui-shadow-s w-2/5 rounded border p-6",
|
|
2676
|
+
children: approvalRequest ? /*#__PURE__*/jsxs("div", {
|
|
2677
|
+
className: "flex w-full flex-col space-y-6",
|
|
2678
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
2679
|
+
style: "h2",
|
|
2680
|
+
children: approvalRequest.title
|
|
2681
|
+
}), /*#__PURE__*/jsx(EditorContent, {
|
|
2682
|
+
content: approvalRequest.message
|
|
2683
|
+
}), !hideTextArea && /*#__PURE__*/jsx(Textarea, {
|
|
2684
|
+
label: t("neetoApprovals.common.note"),
|
|
2685
|
+
placeholder: t("neetoApprovals.inputs.placeholders.add_", {
|
|
2686
|
+
what: (_t = t("neetoApprovals.common.note")) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
|
|
2687
|
+
}),
|
|
2688
|
+
value: note,
|
|
2689
|
+
disabled: approvalRequest.status !== STATUSES.pending,
|
|
2690
|
+
onChange: withEventTargetValue(setNote)
|
|
2691
|
+
}), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/jsxs("div", {
|
|
2692
|
+
className: "mx-auto mt-8 flex space-x-6",
|
|
2693
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
2694
|
+
label: t("neetoApprovals.buttons.approve"),
|
|
2695
|
+
onClick: function onClick() {
|
|
2696
|
+
return acceptPendingRequest({
|
|
2697
|
+
id: approvalRequest.id,
|
|
2698
|
+
note: note
|
|
2699
|
+
});
|
|
2700
|
+
},
|
|
2701
|
+
loading: isAccepting
|
|
2702
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
2703
|
+
label: t("neetoApprovals.buttons.decline"),
|
|
2704
|
+
onClick: function onClick() {
|
|
2705
|
+
return declinePendingRequest({
|
|
2706
|
+
id: approvalRequest.id,
|
|
2707
|
+
note: note
|
|
2708
|
+
});
|
|
2709
|
+
},
|
|
2710
|
+
style: "secondary",
|
|
2711
|
+
loading: isDeclining
|
|
2712
|
+
})]
|
|
2713
|
+
}) : /*#__PURE__*/jsx(Callout, {
|
|
2714
|
+
style: calloutStyle,
|
|
2715
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
2716
|
+
style: "body1",
|
|
2717
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
2718
|
+
i18nKey: "neetoApprovals.typography.approvalRequest",
|
|
2719
|
+
values: {
|
|
2720
|
+
status: approvalRequest.status
|
|
2721
|
+
}
|
|
2722
|
+
})
|
|
2723
|
+
})
|
|
2724
|
+
})]
|
|
2725
|
+
}) : /*#__PURE__*/jsx(Typography, {
|
|
2726
|
+
style: "h4",
|
|
2727
|
+
className: "text-center",
|
|
2728
|
+
children: t("neetoApprovals.common.notFound")
|
|
2729
|
+
})
|
|
2730
|
+
})
|
|
2731
|
+
})]
|
|
2732
|
+
});
|
|
1813
2733
|
};
|
|
1814
2734
|
|
|
1815
2735
|
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}}
|