@bigbinary/neeto-approvals-frontend 0.3.10 → 0.4.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,27 +1,45 @@
1
- import React, { useState, useEffect, useRef, useMemo } from 'react';
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
- import { Button, Tag, Pane, Typography, Label, Textarea, Table as Table$1, NoData, Alert, Tab as Tab$1, Select, Callout } from '@bigbinary/neetoui';
8
- import { isEmpty, keys } from 'ramda';
9
- import { capitalize, isPresent, findBy, camelToSnakeCase, removeBy, noop } from '@bigbinary/neeto-cist';
8
+ import Button from '@bigbinary/neetoui/Button';
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
+ import Table$1 from '@bigbinary/neetoui/Table';
12
+ import NoData from '@bigbinary/neetoui/NoData';
13
+ import { isEmpty, keys } from 'ramda';
11
14
  import { useTranslation, Trans } from 'react-i18next';
12
- import { useQuery, useQueryClient } from 'react-query';
15
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
16
  import axios from 'axios';
17
+ import Tag from '@bigbinary/neetoui/Tag';
14
18
  import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
15
19
  import { isEditorEmpty, EditorContent, FormikEditor } from '@bigbinary/neeto-editor';
16
20
  import * as yup from 'yup';
17
21
  import { dateFormat, withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
22
+ import Label from '@bigbinary/neetoui/Label';
23
+ import Pane from '@bigbinary/neetoui/Pane';
24
+ import Textarea from '@bigbinary/neetoui/Textarea';
25
+ import Typography from '@bigbinary/neetoui/Typography';
26
+ import dayjs from 'dayjs';
27
+ import timezone from 'dayjs/plugin/timezone';
28
+ import utc from 'dayjs/plugin/utc';
18
29
  import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
19
30
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
20
- import { Input, Textarea as Textarea$1, Form as Form$3 } from '@bigbinary/neetoui/formik';
31
+ import Alert from '@bigbinary/neetoui/Alert';
32
+ import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
33
+ import FormikForm from '@bigbinary/neetoui/formik/Form';
21
34
  import { useFormikContext } from 'formik';
22
35
  import ToggleFeatureCard from '@bigbinary/neeto-molecules/ToggleFeatureCard';
36
+ import Input from '@bigbinary/neetoui/formik/Input';
37
+ import Textarea$1 from '@bigbinary/neetoui/formik/Textarea';
23
38
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
24
39
  import NeetoHeader from '@bigbinary/neeto-molecules/Header';
40
+ import NeetoUITab from '@bigbinary/neetoui/Tab';
41
+ import Select from '@bigbinary/neetoui/Select';
42
+ import Callout from '@bigbinary/neetoui/Callout';
25
43
 
26
44
  function _typeof(o) {
27
45
  "@babel/helpers - typeof";
@@ -138,6 +156,868 @@ var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageC
138
156
  }
139
157
  };
140
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
+
141
1021
  var BASE_URL = "neeto_approvals";
142
1022
  var TEMPLATE_URL = "".concat(BASE_URL, "/templates");
143
1023
 
@@ -175,23 +1055,20 @@ var useFetchRequests = function useFetchRequests(_ref) {
175
1055
  params = _ref$params === void 0 ? {} : _ref$params,
176
1056
  _ref$options = _ref.options,
177
1057
  options = _ref$options === void 0 ? {} : _ref$options;
178
- return useQuery([QUERY_KEYS.REQUESTS, params], function () {
179
- return requestsApi.fetch(params, requestUrl);
180
- }, _objectSpread$b({
1058
+ return useQuery(_objectSpread$b({
1059
+ queryKey: [QUERY_KEYS.REQUESTS, params],
1060
+ queryFn: function queryFn() {
1061
+ return requestsApi.fetch(params, requestUrl);
1062
+ },
181
1063
  select: function select(response) {
182
1064
  return response.data || response;
183
1065
  },
184
- keepPreviousData: true,
185
- onSuccess: function onSuccess(_ref2) {
186
- var _options$onSuccess;
187
- var requests = _ref2.requests;
188
- return (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, requests);
189
- }
1066
+ placeholderData: keepPreviousData
190
1067
  }, options));
191
1068
  };
192
1069
  var useUpdateRequest = function useUpdateRequest(options) {
193
1070
  return useMutationWithInvalidation(requestsApi.update, _objectSpread$b({
194
- keysToInvalidate: [QUERY_KEYS.REQUESTS, QUERY_KEYS.VIEWS]
1071
+ keysToInvalidate: [[QUERY_KEYS.REQUESTS], [QUERY_KEYS.VIEWS]]
195
1072
  }, options));
196
1073
  };
197
1074
 
@@ -272,7 +1149,7 @@ var HISTORY_TABLE_COLUMNS = [{
272
1149
  render: function render(approvalLabel, _ref) {
273
1150
  var requestableUrl = _ref.requestableUrl;
274
1151
  var url = new URL(requestableUrl || window.location.origin);
275
- return /*#__PURE__*/React.createElement(Button, {
1152
+ return /*#__PURE__*/jsx(Button, {
276
1153
  label: approvalLabel,
277
1154
  style: "link",
278
1155
  to: url.pathname
@@ -291,7 +1168,7 @@ var HISTORY_TABLE_COLUMNS = [{
291
1168
  width: "25%",
292
1169
  title: t$1("neetoApprovals.common.status"),
293
1170
  render: function render(status) {
294
- return /*#__PURE__*/React.createElement(Tag, {
1171
+ return /*#__PURE__*/jsx(Tag, {
295
1172
  label: capitalize(status),
296
1173
  style: STATUS_TAG_STYLE[status]
297
1174
  });
@@ -303,7 +1180,7 @@ var HISTORY_TABLE_COLUMNS = [{
303
1180
  width: "25%",
304
1181
  title: t$1("neetoApprovals.common.created"),
305
1182
  render: function render(createdAt) {
306
- return /*#__PURE__*/React.createElement(DateFormat.FromNow, {
1183
+ return /*#__PURE__*/jsx(DateFormat.FromNow, {
307
1184
  date: createdAt,
308
1185
  typographyProps: {
309
1186
  style: "body2"
@@ -321,75 +1198,38 @@ var Footer = function Footer(_ref) {
321
1198
  t = _useTranslation.t;
322
1199
  if (!isCurrentUserApprover && !isCurrentUserRequester) return null;
323
1200
  if (isCurrentUserApprover) {
324
- return /*#__PURE__*/React.createElement(Pane.Footer, {
325
- className: "flex gap-x-2"
326
- }, /*#__PURE__*/React.createElement(Button, {
327
- label: t("neetoApprovals.buttons.approve"),
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"),
328
1224
  loading: isLoading,
329
1225
  type: "submit",
330
1226
  onClick: function onClick() {
331
- return handleSubmit(STATUSES.approved);
1227
+ return handleSubmit(STATUSES.cancelled);
332
1228
  }
333
- }), /*#__PURE__*/React.createElement(Button, {
334
- label: t("neetoApprovals.buttons.decline"),
335
- loading: isLoading,
336
- style: "text",
337
- onClick: function onClick() {
338
- return handleSubmit(STATUSES.rejected);
339
- }
340
- }));
341
- }
342
- return /*#__PURE__*/React.createElement(Pane.Footer, {
343
- className: "flex gap-x-2"
344
- }, /*#__PURE__*/React.createElement(Button, {
345
- label: t("neetoApprovals.buttons.cancelRequest"),
346
- loading: isLoading,
347
- type: "submit",
348
- onClick: function onClick() {
349
- return handleSubmit(STATUSES.cancelled);
350
- }
351
- }));
1229
+ })
1230
+ });
352
1231
  };
353
1232
 
354
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
355
-
356
- function getDefaultExportFromCjs (x) {
357
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
358
- }
359
-
360
- var dayjs_min = {exports: {}};
361
-
362
- dayjs_min.exports;
363
-
364
- (function (module, exports) {
365
- !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
366
- } (dayjs_min, dayjs_min.exports));
367
-
368
- var dayjs_minExports = dayjs_min.exports;
369
- var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
370
-
371
- var timezone$1 = {exports: {}};
372
-
373
- timezone$1.exports;
374
-
375
- (function (module, exports) {
376
- !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];return r||(r=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10));}var d=r[3],l=24===d?0:d,h=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",v=+e;return (o.utc(h).valueOf()-(v-=v%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n=this.utcOffset(),i=this.toDate(),a=i.toLocaleString("en-US",{timeZone:t}),u=Math.round((i-new Date(a))/1e3/60),f=o(a,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-u,!0);if(e){var s=f.utcOffset();f=f.add(n-s,"minute");}return f.$x.$timezone=t,f},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return "timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return [i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t;};}}));
377
- } (timezone$1, timezone$1.exports));
378
-
379
- var timezoneExports = timezone$1.exports;
380
- var timezone = /*@__PURE__*/getDefaultExportFromCjs(timezoneExports);
381
-
382
- var utc$1 = {exports: {}};
383
-
384
- utc$1.exports;
385
-
386
- (function (module, exports) {
387
- !function(t,i){module.exports=i();}(commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
388
- } (utc$1, utc$1.exports));
389
-
390
- var utcExports = utc$1.exports;
391
- var utc = /*@__PURE__*/getDefaultExportFromCjs(utcExports);
392
-
393
1233
  dayjs.extend(utc);
394
1234
  dayjs.extend(timezone);
395
1235
  var updateApprovalDetails = function updateApprovalDetails(_ref) {
@@ -425,7 +1265,7 @@ var getApprovalFilter = function getApprovalFilter() {
425
1265
  };
426
1266
  };
427
1267
 
428
- var MemoizedEditorContent$1 = /*#__PURE__*/React.memo(EditorContent);
1268
+ var MemoizedEditorContent$1 = /*#__PURE__*/React__default.memo(EditorContent);
429
1269
  var RequestDetailsPane = function RequestDetailsPane(_ref) {
430
1270
  var _window$globalProps, _window$globalProps2;
431
1271
  var isOpen = _ref.isOpen,
@@ -452,7 +1292,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
452
1292
  setNote = _useState2[1];
453
1293
  var _useUpdateRequest = useUpdateRequest(),
454
1294
  updatePendingRequest = _useUpdateRequest.mutate,
455
- isLoading = _useUpdateRequest.isLoading;
1295
+ isUpdateRequestPending = _useUpdateRequest.isPending;
456
1296
  useEffect(function () {
457
1297
  setNote(initialNote);
458
1298
  }, [initialNote]);
@@ -480,65 +1320,82 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
480
1320
  onSuccess: handleOnClose
481
1321
  });
482
1322
  };
483
- return /*#__PURE__*/React.createElement(Pane, {
1323
+ return /*#__PURE__*/jsxs(Pane, {
484
1324
  isOpen: isOpen,
485
1325
  size: "large",
486
- onClose: handleOnClose
487
- }, /*#__PURE__*/React.createElement(Pane.Header, {
488
- className: "space-y-2"
489
- }, /*#__PURE__*/React.createElement(Typography, {
490
- style: "h2"
491
- }, title), /*#__PURE__*/React.createElement(Tag, {
492
- label: capitalize(status),
493
- style: STATUS_TAG_STYLE[status]
494
- })), /*#__PURE__*/React.createElement(Pane.Body, {
495
- className: "space-y-6"
496
- }, /*#__PURE__*/React.createElement("div", {
497
- className: "w-full divide-y border px-3"
498
- }, /*#__PURE__*/React.createElement("div", {
499
- className: "flex space-x-3 p-2"
500
- }, /*#__PURE__*/React.createElement(Label, {
501
- className: "font-normal"
502
- }, getStatusLabel()), /*#__PURE__*/React.createElement(Typography, {
503
- style: "body2",
504
- weight: "medium"
505
- }, requesterOrApproverDetails)), /*#__PURE__*/React.createElement("div", {
506
- className: "flex space-x-3 p-2"
507
- }, /*#__PURE__*/React.createElement(Label, {
508
- className: "font-normal"
509
- }, t("neetoApprovals.common.created")), /*#__PURE__*/React.createElement(Typography, {
510
- style: "body2",
511
- weight: "medium"
512
- }, dateFormat.defaultWithTime(timeInZone(createdAt))))), /*#__PURE__*/React.createElement("div", {
513
- className: "w-full space-y-2"
514
- }, /*#__PURE__*/React.createElement(Label, null, t("neetoApprovals.inputs.labels.message")), /*#__PURE__*/React.createElement(MemoizedEditorContent$1, {
515
- className: "neeto-ui-bg-gray-100 p-4",
516
- content: message
517
- })), isPending && isCurrentUserApprover && /*#__PURE__*/React.createElement(Textarea, {
518
- className: "w-full",
519
- disabled: !isPending,
520
- label: t("neetoApprovals.common.note"),
521
- value: note,
522
- placeholder: t("neetoApprovals.inputs.placeholders.add_", {
523
- what: t("neetoApprovals.common.note")
524
- }),
525
- onChange: withEventTargetValue(setNote)
526
- }), !isPending && note && /*#__PURE__*/React.createElement("div", {
527
- className: "w-full space-y-2"
528
- }, /*#__PURE__*/React.createElement(Label, null, t("neetoApprovals.common.note")), /*#__PURE__*/React.createElement("div", {
529
- className: "neeto-ui-bg-gray-100 p-4"
530
- }, note))), isPending && /*#__PURE__*/React.createElement(Footer, {
531
- handleSubmit: handleSubmit,
532
- isCurrentUserApprover: isCurrentUserApprover,
533
- isCurrentUserRequester: isCurrentUserRequester,
534
- isLoading: isLoading
535
- }));
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
+ });
536
1394
  };
537
1395
 
538
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; }
539
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; }
540
1398
  var History = function History(_ref) {
541
- var _t;
542
1399
  var requestUrl = _ref.requestUrl;
543
1400
  var _useState = useState(DEFAULT_FILTER_VALUES),
544
1401
  _useState2 = _slicedToArray(_useState, 2),
@@ -559,64 +1416,66 @@ var History = function History(_ref) {
559
1416
  searchTerm: debouncedSearchTerm.trim(),
560
1417
  status: [STATUSES.approved, STATUSES.rejected, STATUSES.cancelled]
561
1418
  }),
562
- options: {
563
- onSuccess: function onSuccess(_ref2) {
564
- var requests = _ref2.requests;
565
- handleEmptyPage(requests, pageProperties, handlePageChange);
566
- setApprovalDetails(function (approvalDetails) {
567
- return updateApprovalDetails({
568
- requestsData: requests,
569
- approvalDetails: approvalDetails
570
- });
571
- });
572
- }
573
- },
574
1419
  requestUrl: requestUrl
575
1420
  }),
576
- _useFetchRequests$dat = _useFetchRequests.data,
577
- _useFetchRequests$dat2 = _useFetchRequests$dat === void 0 ? {} : _useFetchRequests$dat,
578
- _useFetchRequests$dat3 = _useFetchRequests$dat2.requests,
579
- approvalHistories = _useFetchRequests$dat3 === void 0 ? {} : _useFetchRequests$dat3,
580
- _useFetchRequests$dat4 = _useFetchRequests$dat2.totalCount,
581
- totalCount = _useFetchRequests$dat4 === void 0 ? 0 : _useFetchRequests$dat4;
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]);
582
1437
  var handleTableChange = function handleTableChange(_, __, sorter) {
583
1438
  setFilters(_objectSpread$a(_objectSpread$a({}, filters), {}, {
584
1439
  sortBy: camelToSnakeCase(sorter.field || ""),
585
1440
  orderBy: SORT_ORDER[sorter.order]
586
1441
  }));
587
1442
  };
588
- return /*#__PURE__*/React.createElement(React.Fragment, null, !isEmpty(approvalHistories) ? /*#__PURE__*/React.createElement(TableWrapper, {
589
- className: "mt-6",
590
- hasPagination: totalCount > pageProperties.pageSize
591
- }, /*#__PURE__*/React.createElement(Table$1, {
592
- allowRowClick: true,
593
- fixedHeight: true,
594
- columnData: HISTORY_TABLE_COLUMNS,
595
- currentPageNumber: pageProperties.page,
596
- defaultPageSize: pageProperties.pageSize,
597
- rowData: approvalHistories,
598
- handlePageChange: handlePageChange,
599
- totalCount: totalCount,
600
- paginationProps: {
601
- hideOnSinglePage: (approvalHistories === null || approvalHistories === void 0 ? void 0 : approvalHistories.length) < DEFAULT_PAGE_SIZE + 1
602
- },
603
- onChange: handleTableChange,
604
- onRowClick: function onRowClick(_, approvalDetails) {
605
- return setApprovalDetails(approvalDetails);
606
- }
607
- })) : /*#__PURE__*/React.createElement("div", {
608
- className: "flex h-full w-full flex-grow items-center justify-center"
609
- }, /*#__PURE__*/React.createElement(NoData, {
610
- title: t("neetoApprovals.common.notFound_", {
611
- what: (_t = t("neetoApprovals.common.record", PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
612
- })
613
- })), /*#__PURE__*/React.createElement(RequestDetailsPane, {
614
- approvalDetails: approvalDetails,
615
- isOpen: isPresent(approvalDetails),
616
- onClose: function onClose() {
617
- return setApprovalDetails({});
618
- }
619
- }));
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
+ });
620
1479
  };
621
1480
 
622
1481
  var PENDING_TABLE_COLUMNS = removeBy({
@@ -626,7 +1485,6 @@ var PENDING_TABLE_COLUMNS = removeBy({
626
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; }
627
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; }
628
1487
  var PendingRequests = function PendingRequests(_ref) {
629
- var _t;
630
1488
  var requestUrl = _ref.requestUrl;
631
1489
  var _useState = useState(DEFAULT_FILTER_VALUES),
632
1490
  _useState2 = _slicedToArray(_useState, 2),
@@ -647,75 +1505,62 @@ var PendingRequests = function PendingRequests(_ref) {
647
1505
  searchTerm: debouncedSearchTerm.trim(),
648
1506
  status: [STATUSES.pending]
649
1507
  }),
650
- options: {
651
- onSuccess: function onSuccess(_ref2) {
652
- var requests = _ref2.requests;
653
- handleEmptyPage(requests, pageProperties, handlePageChange);
654
- }
655
- },
656
1508
  requestUrl: requestUrl
657
1509
  }),
658
- _useFetchRequests$dat = _useFetchRequests.data,
659
- _useFetchRequests$dat2 = _useFetchRequests$dat === void 0 ? {} : _useFetchRequests$dat,
660
- _useFetchRequests$dat3 = _useFetchRequests$dat2.requests,
661
- pendingRequests = _useFetchRequests$dat3 === void 0 ? {} : _useFetchRequests$dat3,
662
- _useFetchRequests$dat4 = _useFetchRequests$dat2.totalCount,
663
- totalCount = _useFetchRequests$dat4 === void 0 ? 0 : _useFetchRequests$dat4;
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]);
664
1520
  var handleTableChange = function handleTableChange(_, __, sorter) {
665
1521
  setFilters(_objectSpread$9(_objectSpread$9({}, filters), {}, {
666
1522
  sortBy: camelToSnakeCase(sorter.field || ""),
667
1523
  orderBy: SORT_ORDER[sorter.order]
668
1524
  }));
669
1525
  };
670
- return /*#__PURE__*/React.createElement(React.Fragment, null, !isEmpty(pendingRequests) ? /*#__PURE__*/React.createElement(TableWrapper, {
671
- className: "mt-6",
672
- hasPagination: totalCount > pageProperties.pageSize
673
- }, /*#__PURE__*/React.createElement(Table$1, {
674
- allowRowClick: true,
675
- fixedHeight: true,
676
- columnData: PENDING_TABLE_COLUMNS,
677
- currentPageNumber: pageProperties.page,
678
- defaultPageSize: pageProperties.pageSize,
679
- rowData: pendingRequests,
680
- handlePageChange: handlePageChange,
681
- totalCount: totalCount,
682
- paginationProps: {
683
- hideOnSinglePage: (pendingRequests === null || pendingRequests === void 0 ? void 0 : pendingRequests.length) < DEFAULT_PAGE_SIZE + 1
684
- },
685
- onChange: handleTableChange,
686
- onRowClick: function onRowClick(_, approvalDetails) {
687
- return setApprovalDetails(approvalDetails);
688
- }
689
- })) : /*#__PURE__*/React.createElement("div", {
690
- className: "flex h-full w-full flex-grow items-center justify-center"
691
- }, /*#__PURE__*/React.createElement(NoData, {
692
- title: t("neetoApprovals.common.notFound_", {
693
- what: (_t = t("neetoApprovals.common.pendingApproval", PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
694
- })
695
- })), /*#__PURE__*/React.createElement(RequestDetailsPane, {
696
- isPending: true,
697
- approvalDetails: approvalDetails,
698
- isOpen: isPresent(approvalDetails),
699
- onClose: function onClose() {
700
- return setApprovalDetails({});
701
- }
702
- }));
703
- };
704
-
705
- function _extends() {
706
- _extends = Object.assign ? Object.assign.bind() : function (target) {
707
- for (var i = 1; i < arguments.length; i++) {
708
- var source = arguments[i];
709
- for (var key in source) {
710
- if (Object.prototype.hasOwnProperty.call(source, key)) {
711
- 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);
712
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({});
713
1560
  }
714
- }
715
- return target;
716
- };
717
- return _extends.apply(this, arguments);
718
- }
1561
+ })]
1562
+ });
1563
+ };
719
1564
 
720
1565
  function _objectWithoutPropertiesLoose(source, excluded) {
721
1566
  if (source == null) return {};
@@ -788,48 +1633,47 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
788
1633
  var useFetchTemplates = function useFetchTemplates() {
789
1634
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
790
1635
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
791
- return useQuery([QUERY_KEYS.TEMPLATES, params], function () {
792
- return templatesApi.fetch(params);
793
- }, _objectSpread$8({
1636
+ return useQuery(_objectSpread$8({
1637
+ queryKey: [QUERY_KEYS.TEMPLATES, params],
1638
+ queryFn: function queryFn() {
1639
+ return templatesApi.fetch(params);
1640
+ },
794
1641
  select: function select(response) {
795
1642
  return response.data || response;
796
1643
  },
797
- keepPreviousData: true,
798
- onSuccess: function onSuccess(_ref) {
799
- var _params$onSuccess;
800
- var templates = _ref.templates;
801
- return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, templates);
802
- }
1644
+ placeholderData: keepPreviousData
803
1645
  }, options));
804
1646
  };
805
- var useFetchTemplate = function useFetchTemplate(_ref2) {
806
- var id = _ref2.id,
807
- params = _ref2.params;
808
- return useQuery([QUERY_KEYS.SHOW_TEMPLATE, id, params], function () {
809
- return templatesApi.show({
810
- id: id,
811
- params: params
812
- });
813
- }, {
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
+ },
814
1658
  enabled: !!id
815
1659
  });
816
1660
  };
817
1661
  var useCreateTemplate = function useCreateTemplate(options) {
818
1662
  return useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
819
- keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
1663
+ keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
820
1664
  }, options));
821
1665
  };
822
1666
  var useUpdateTemplate = function useUpdateTemplate(options) {
823
1667
  return useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
824
- keysToInvalidate: [QUERY_KEYS.TEMPLATES, function (_, _ref3) {
825
- var id = _ref3.id;
1668
+ keysToInvalidate: [[QUERY_KEYS.TEMPLATES], function (_, _ref2) {
1669
+ var id = _ref2.id;
826
1670
  return [QUERY_KEYS.SHOW_TEMPLATE, id];
827
1671
  }]
828
1672
  }, options));
829
1673
  };
830
1674
  var useDeleteTemplate = function useDeleteTemplate(options) {
831
1675
  return useMutationWithInvalidation(templatesApi.destroy, _objectSpread$8({
832
- keysToInvalidate: [QUERY_KEYS.TEMPLATES, QUERY_KEYS.VIEWS]
1676
+ keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
833
1677
  }, options));
834
1678
  };
835
1679
 
@@ -855,7 +1699,7 @@ var MessageEditor = withT(function (_ref) {
855
1699
  placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
856
1700
  _ref$initialValue = _ref.initialValue,
857
1701
  initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
858
- return /*#__PURE__*/React.createElement(FormikEditor, {
1702
+ return /*#__PURE__*/jsx(FormikEditor, {
859
1703
  initialValue: initialValue,
860
1704
  required: true,
861
1705
  label: t("neetoApprovals.inputs.labels.message"),
@@ -883,32 +1727,34 @@ var TemplateForm = function TemplateForm(_ref) {
883
1727
  setFieldValue("description", "");
884
1728
  }
885
1729
  };
886
- return /*#__PURE__*/React.createElement("div", {
887
- className: "flex w-full flex-col space-y-6"
888
- }, /*#__PURE__*/React.createElement(Input, {
889
- autoFocus: true,
890
- required: true,
891
- label: t("neetoApprovals.common.name"),
892
- name: "name",
893
- placeholder: t("neetoApprovals.inputs.placeholders.name")
894
- }), /*#__PURE__*/React.createElement(ToggleFeatureCard, {
895
- switchName: "descriptionEnabled",
896
- title: t("neetoApprovals.inputs.labels.description"),
897
- switchProps: {
898
- onChange: handleDescriptionToggle,
899
- tooltipProps: {
900
- enabledSwitchText: t("neetoApprovals.templates.descriptionToggle.enable"),
901
- disabledSwitchText: t("neetoApprovals.templates.descriptionToggle.disable")
902
- }
903
- }
904
- }, values.descriptionEnabled && /*#__PURE__*/React.createElement(Textarea$1, {
905
- className: "w-full",
906
- name: "description",
907
- placeholder: t("neetoApprovals.inputs.placeholders.description")
908
- })), /*#__PURE__*/React.createElement(MessageEditor, {
909
- placeholders: placeholders,
910
- initialValue: initialData.message
911
- }));
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
+ });
912
1758
  };
913
1759
 
914
1760
  var Form$2 = function Form(_ref) {
@@ -917,7 +1763,7 @@ var Form$2 = function Form(_ref) {
917
1763
  _ref$initialData = _ref.initialData,
918
1764
  initialData = _ref$initialData === void 0 ? {} : _ref$initialData,
919
1765
  _ref$onSubmit = _ref.onSubmit,
920
- onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
1766
+ onSubmit = _ref$onSubmit === void 0 ? noop$1 : _ref$onSubmit,
921
1767
  _ref$isLoading = _ref.isLoading,
922
1768
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
923
1769
  placeholders = _ref.placeholders;
@@ -929,36 +1775,42 @@ var Form$2 = function Form(_ref) {
929
1775
  }) : t("neetoApprovals.common.edit_", {
930
1776
  what: t("neetoApprovals.common.template", SINGULAR)
931
1777
  });
932
- return /*#__PURE__*/React.createElement(Pane, {
1778
+ return /*#__PURE__*/jsxs(Pane, {
933
1779
  isOpen: isOpen,
934
1780
  onClose: onClose,
935
1781
  initialFocusRef: inputReference,
936
- size: "large"
937
- }, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
938
- style: "h2"
939
- }, header)), /*#__PURE__*/React.createElement(Form$3, {
940
- formikProps: {
941
- enableReinitialize: true,
942
- initialValues: isPresent(initialData) ? initialData : TEMPLATE_FORM_INITIAL_VALUES,
943
- validationSchema: TEMPLATE_FORM_VALIDATION_SCHEMA,
944
- onSubmit: onSubmit
945
- }
946
- }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement(TemplateForm, {
947
- initialData: initialData,
948
- placeholders: placeholders
949
- })), /*#__PURE__*/React.createElement(Pane.Footer, {
950
- className: "flex gap-x-2"
951
- }, /*#__PURE__*/React.createElement(Button, {
952
- "data-cy": "neeto-approvals-templates-save-template-btn",
953
- label: t("neetoApprovals.buttons.saveChanges"),
954
- loading: isLoading,
955
- type: "submit"
956
- }), /*#__PURE__*/React.createElement(Button, {
957
- "data-cy": "neeto-approvals-templates-close-template-form-btn",
958
- label: t("neetoApprovals.buttons.cancel"),
959
- style: "text",
960
- onClick: onClose
961
- })))));
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
+ });
962
1814
  };
963
1815
 
964
1816
  var Create = function Create(_ref) {
@@ -968,7 +1820,7 @@ var Create = function Create(_ref) {
968
1820
  templatePlaceholders = _ref.templatePlaceholders;
969
1821
  var _useCreateTemplate = useCreateTemplate(),
970
1822
  createTemplate = _useCreateTemplate.mutate,
971
- isLoading = _useCreateTemplate.isLoading;
1823
+ isPending = _useCreateTemplate.isPending;
972
1824
  var onSubmit = function onSubmit(template) {
973
1825
  var payload = {
974
1826
  template: template
@@ -980,11 +1832,11 @@ var Create = function Create(_ref) {
980
1832
  onSuccess: onClose
981
1833
  });
982
1834
  };
983
- return /*#__PURE__*/React.createElement(Form$2, {
984
- isLoading: isLoading,
1835
+ return /*#__PURE__*/jsx(Form$2, {
985
1836
  isOpen: isOpen,
986
1837
  onClose: onClose,
987
1838
  onSubmit: onSubmit,
1839
+ isLoading: isPending,
988
1840
  placeholders: templatePlaceholders
989
1841
  });
990
1842
  };
@@ -1004,7 +1856,7 @@ var Edit = function Edit(_ref) {
1004
1856
  }
1005
1857
  }),
1006
1858
  updateTemplate = _useUpdateTemplate.mutate,
1007
- isUpdating = _useUpdateTemplate.isLoading;
1859
+ isUpdating = _useUpdateTemplate.isPending;
1008
1860
  var onSubmit = function onSubmit(template) {
1009
1861
  var payload = {
1010
1862
  template: template
@@ -1018,7 +1870,7 @@ var Edit = function Edit(_ref) {
1018
1870
  var initialData = _objectSpread$7(_objectSpread$7({}, template), {}, {
1019
1871
  descriptionEnabled: !!template.description
1020
1872
  });
1021
- return /*#__PURE__*/React.createElement(Form$2, {
1873
+ return /*#__PURE__*/jsx(Form$2, {
1022
1874
  initialData: initialData,
1023
1875
  isOpen: isOpen,
1024
1876
  onClose: onClose,
@@ -1031,18 +1883,21 @@ var Edit = function Edit(_ref) {
1031
1883
  var Field = function Field(_ref) {
1032
1884
  var label = _ref.label,
1033
1885
  value = _ref.value;
1034
- return /*#__PURE__*/React.createElement("div", {
1035
- className: "flex flex-col items-start justify-center"
1036
- }, /*#__PURE__*/React.createElement(Label, {
1037
- className: "mb-1 font-normal"
1038
- }, label), /*#__PURE__*/React.createElement(Typography, {
1039
- style: "body1",
1040
- weight: "medium"
1041
- }, value));
1042
- };
1043
- var Field$1 = /*#__PURE__*/React.memo(Field);
1044
-
1045
- var MemoizedEditorContent = /*#__PURE__*/React.memo(EditorContent);
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);
1046
1901
  var TemplateDetails = function TemplateDetails(_ref) {
1047
1902
  var isOpen = _ref.isOpen,
1048
1903
  onClose = _ref.onClose,
@@ -1052,41 +1907,47 @@ var TemplateDetails = function TemplateDetails(_ref) {
1052
1907
  var name = template.name,
1053
1908
  description = template.description,
1054
1909
  message = template.message;
1055
- return /*#__PURE__*/React.createElement(Pane, {
1910
+ return /*#__PURE__*/jsxs(Pane, {
1056
1911
  isOpen: isOpen,
1057
- onClose: onClose
1058
- }, /*#__PURE__*/React.createElement(Pane.Header, {
1059
- className: "space-y-2"
1060
- }, /*#__PURE__*/React.createElement(Typography, {
1061
- style: "h2"
1062
- }, t("neetoApprovals.common.templateDetails"))), /*#__PURE__*/React.createElement(Pane.Body, {
1063
- className: "space-y-6"
1064
- }, /*#__PURE__*/React.createElement(Field$1, {
1065
- label: t("neetoApprovals.common.name"),
1066
- value: name
1067
- }), /*#__PURE__*/React.createElement(Field$1, {
1068
- label: t("neetoApprovals.inputs.labels.description"),
1069
- value: description
1070
- }), /*#__PURE__*/React.createElement("div", {
1071
- className: "flex w-full flex-col space-y-4"
1072
- }, /*#__PURE__*/React.createElement(Label, {
1073
- className: "mb-1 font-normal"
1074
- }, t("neetoApprovals.inputs.labels.message")), /*#__PURE__*/React.createElement(MemoizedEditorContent, {
1075
- className: "neeto-ui-bg-gray-100 neeto-ui-rounded-lg p-3",
1076
- content: message
1077
- }))));
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
+ });
1078
1939
  };
1079
1940
 
1080
1941
  var renderNoDataHelpText = function renderNoDataHelpText(_ref) {
1081
1942
  var entity = _ref.entity,
1082
1943
  url = _ref.url;
1083
- return /*#__PURE__*/React.createElement(Trans, {
1944
+ return /*#__PURE__*/jsx(Trans, {
1084
1945
  i18nKey: "neetoApprovals.common.noDataHelpText",
1085
1946
  values: {
1086
1947
  entity: entity
1087
1948
  },
1088
1949
  components: {
1089
- a: /*#__PURE__*/React.createElement(Link, {
1950
+ a: /*#__PURE__*/jsx(Link, {
1090
1951
  className: "neeto-ui-text-primary-600 underline",
1091
1952
  target: "_blank",
1092
1953
  to: {
@@ -1141,34 +2002,36 @@ var Table = function Table(_ref) {
1141
2002
  })
1142
2003
  };
1143
2004
  if (isEmpty(rowData)) {
1144
- return /*#__PURE__*/React.createElement("div", {
1145
- className: "flex h-full w-full flex-grow items-center justify-center"
1146
- }, /*#__PURE__*/React.createElement(NoData, _extends({
1147
- title: t("neetoApprovals.common.notFound_", {
1148
- what: entity
1149
- })
1150
- }, !filters.searchTerm && noDataProps)));
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
+ });
1151
2013
  }
1152
- return /*#__PURE__*/React.createElement(TableWrapper, {
2014
+ return /*#__PURE__*/jsx(TableWrapper, {
1153
2015
  className: "mt-6",
1154
- hasPagination: totalCount > pageProperties.pageSize
1155
- }, /*#__PURE__*/React.createElement(Table$1, _extends({
1156
- fixedHeight: true,
1157
- columnData: columns,
1158
- currentPageNumber: pageProperties.page,
1159
- defaultPageSize: pageProperties.pageSize,
1160
- scroll: {
1161
- x: 0
1162
- },
1163
- tableLayout: "fixed",
1164
- paginationProps: {
1165
- hideOnSinglePage: (rowData === null || rowData === void 0 ? void 0 : rowData.length) < DEFAULT_PAGE_SIZE + 1
1166
- },
1167
- onChange: handleTableChange
1168
- }, _objectSpread$6({
1169
- rowData: rowData,
1170
- totalCount: totalCount
1171
- }, otherProps))));
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
+ });
1172
2035
  };
1173
2036
 
1174
2037
  var columnData = function columnData(_ref) {
@@ -1181,32 +2044,34 @@ var columnData = function columnData(_ref) {
1181
2044
  title: i18next.t("neetoApprovals.common.name"),
1182
2045
  ellipsis: true,
1183
2046
  render: function render(_, template) {
1184
- return /*#__PURE__*/React.createElement("div", {
1185
- className: "flex items-center justify-between gap-x-3"
1186
- }, /*#__PURE__*/React.createElement(Typography, {
1187
- className: "truncate",
1188
- style: "body2"
1189
- }, template.name), /*#__PURE__*/React.createElement(MoreDropdown, {
1190
- dropdownProps: {
1191
- strategy: "fixed",
1192
- onClick: function onClick(e) {
1193
- return e.stopPropagation();
1194
- }
1195
- },
1196
- menuItems: [_defineProperty({
1197
- key: "edit",
1198
- label: i18next.t("neetoApprovals.common.edit"),
1199
- onClick: function onClick(event) {
1200
- return onEditClick(event, template);
1201
- }
1202
- }, DATA_CY_KEY, "neeto-approvals-templates-edit-template-btn"), _defineProperty({
1203
- key: "delete",
1204
- label: i18next.t("neetoApprovals.common.delete"),
1205
- onClick: function onClick(event) {
1206
- return onDeleteClick(event, template);
1207
- }
1208
- }, DATA_CY_KEY, "neeto-approvals-templates-delete-template-btn")]
1209
- }));
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
+ });
1210
2075
  }
1211
2076
  }, {
1212
2077
  dataIndex: "description",
@@ -1219,7 +2084,6 @@ var _excluded = ["searchTerm", "isNewTemplatePaneOpen", "setIsNewTemplatePaneOpe
1219
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; }
1220
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; }
1221
2086
  var Templates = function Templates(_ref) {
1222
- var _t, _t2, _t3;
1223
2087
  var searchTerm = _ref.searchTerm,
1224
2088
  isNewTemplatePaneOpen = _ref.isNewTemplatePaneOpen,
1225
2089
  setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen,
@@ -1257,28 +2121,27 @@ var Templates = function Templates(_ref) {
1257
2121
  }, [searchTerm]);
1258
2122
  var _useFetchTemplates = useFetchTemplates(_objectSpread$5(_objectSpread$5(_objectSpread$5({}, pageProperties), filters), {}, {
1259
2123
  searchTerm: debouncedSearchTerm.trim()
1260
- }), {
1261
- onSuccess: function onSuccess(_ref2) {
1262
- var templates = _ref2.templates;
1263
- handleEmptyPage(templates, pageProperties, handlePageChange);
1264
- }
1265
- }),
1266
- _useFetchTemplates$da = _useFetchTemplates.data,
1267
- _useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
1268
- _useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
1269
- templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
1270
- _useFetchTemplates$da4 = _useFetchTemplates$da2.totalCount,
1271
- totalCount = _useFetchTemplates$da4 === void 0 ? 0 : _useFetchTemplates$da4,
2124
+ })),
2125
+ data = _useFetchTemplates.data,
1272
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]);
1273
2137
  var _useDeleteTemplate = useDeleteTemplate(),
1274
2138
  deleteTemplate = _useDeleteTemplate.mutate,
1275
- isDeleting = _useDeleteTemplate.isLoading;
2139
+ isDeleting = _useDeleteTemplate.isPending;
1276
2140
  useEffect(function () {
1277
- if (isEmpty(selectedTemplate)) {
1278
- setIsDeleteAlertOpen(false);
1279
- setIsEditPaneOpen(false);
1280
- setIsShowPaneOpen(false);
1281
- }
2141
+ if (!isEmpty(selectedTemplate)) return;
2142
+ setIsDeleteAlertOpen(false);
2143
+ setIsEditPaneOpen(false);
2144
+ setIsShowPaneOpen(false);
1282
2145
  }, [selectedTemplate]);
1283
2146
  var onEditClick = function onEditClick(event, template) {
1284
2147
  event.stopPropagation();
@@ -1300,62 +2163,64 @@ var Templates = function Templates(_ref) {
1300
2163
  });
1301
2164
  setSelectedTemplate({});
1302
2165
  };
1303
- var entity = (_t = t("neetoApprovals.common.template", PLURAL)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase();
1304
- return /*#__PURE__*/React.createElement(React.Fragment, null, isTemplateLoading ? /*#__PURE__*/React.createElement(PageLoader, null) : /*#__PURE__*/React.createElement(Table, {
1305
- rowData: templates,
1306
- setIsPaneOpen: setIsNewTemplatePaneOpen,
1307
- columnData: columnData,
1308
- entity: entity,
1309
- filters: filters,
1310
- handlePageChange: handlePageChange,
1311
- helpDocUrl: helpDocUrl,
1312
- onDeleteClick: onDeleteClick,
1313
- onEditClick: onEditClick,
1314
- onRowClick: onRowClick,
1315
- pageProperties: pageProperties,
1316
- searchTerm: searchTerm,
1317
- setFilters: setFilters,
1318
- totalCount: totalCount
1319
- }), /*#__PURE__*/React.createElement(Create, _extends({
1320
- isOpen: isNewTemplatePaneOpen,
1321
- onClose: function onClose() {
1322
- return setIsNewTemplatePaneOpen(false);
1323
- }
1324
- }, otherProps)), /*#__PURE__*/React.createElement(Edit, _extends({
1325
- isOpen: isEditPaneOpen,
1326
- setTemplate: setSelectedTemplate,
1327
- template: selectedTemplate
1328
- }, otherProps, {
1329
- onClose: function onClose() {
1330
- return setIsEditPaneOpen(false);
1331
- }
1332
- })), /*#__PURE__*/React.createElement(Alert, {
1333
- isOpen: isDeleteAlertOpen,
1334
- isSubmitting: isDeleting,
1335
- submitButtonLabel: t("neetoApprovals.buttons.delete"),
1336
- message: /*#__PURE__*/React.createElement(Trans, {
1337
- i18nKey: "neetoApprovals.alerts.deleting_",
1338
- values: {
1339
- what: (_t2 = t("neetoApprovals.common.template", SINGULAR)) === null || _t2 === void 0 ? void 0 : _t2.toLocaleLowerCase(),
1340
- 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);
1341
2187
  }
1342
- }),
1343
- title: t("neetoApprovals.common.delete_", {
1344
- what: (_t3 = t("neetoApprovals.common.template", SINGULAR)) === null || _t3 === void 0 ? void 0 : _t3.toLocaleLowerCase()
1345
- }),
1346
- onClose: function onClose() {
1347
- return setSelectedTemplate({});
1348
- },
1349
- onSubmit: function onSubmit() {
1350
- return handleDelete(selectedTemplate === null || selectedTemplate === void 0 ? void 0 : selectedTemplate.id);
1351
- }
1352
- }), /*#__PURE__*/React.createElement(TemplateDetails, {
1353
- isOpen: isShowPaneOpen,
1354
- template: selectedTemplate,
1355
- onClose: function onClose() {
1356
- return setSelectedTemplate({});
1357
- }
1358
- }));
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
+ });
1359
2224
  };
1360
2225
 
1361
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; }
@@ -1367,16 +2232,16 @@ var createRoutes = function createRoutes(_ref) {
1367
2232
  setIsNewTemplatePaneOpen = _ref.setIsNewTemplatePaneOpen;
1368
2233
  return [{
1369
2234
  component: function component() {
1370
- return /*#__PURE__*/React.createElement(Templates, _objectSpread$4({
2235
+ return /*#__PURE__*/jsx(Templates, _objectSpread$4({}, _objectSpread$4({
1371
2236
  isNewTemplatePaneOpen: isNewTemplatePaneOpen,
1372
2237
  searchTerm: searchTerm,
1373
2238
  setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
1374
- }, config));
2239
+ }, config)));
1375
2240
  },
1376
2241
  path: "".concat(config.approvalsPath).concat(routes.templates.index),
1377
2242
  actionBlock: function actionBlock() {
1378
2243
  var _t;
1379
- return /*#__PURE__*/React.createElement(Button, {
2244
+ return /*#__PURE__*/jsx(Button, {
1380
2245
  "data-cy": "neeto-approvals-templates-add-new-button",
1381
2246
  label: t$1("neetoApprovals.common.addNew_", {
1382
2247
  what: (_t = t$1("neetoApprovals.common.template", SINGULAR)) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
@@ -1391,12 +2256,12 @@ var createRoutes = function createRoutes(_ref) {
1391
2256
  })
1392
2257
  }, {
1393
2258
  component: function component() {
1394
- return /*#__PURE__*/React.createElement(PendingRequests, config);
2259
+ return /*#__PURE__*/jsx(PendingRequests, _objectSpread$4({}, config));
1395
2260
  },
1396
2261
  path: "".concat(config.approvalsPath).concat(routes.pending)
1397
2262
  }, {
1398
2263
  component: function component() {
1399
- return /*#__PURE__*/React.createElement(History, config);
2264
+ return /*#__PURE__*/jsx(History, _objectSpread$4({}, config));
1400
2265
  },
1401
2266
  path: "".concat(config.approvalsPath).concat(routes.history)
1402
2267
  }];
@@ -1413,7 +2278,7 @@ var Header = function Header(_ref) {
1413
2278
  var currentTab = findBy({
1414
2279
  path: pathname
1415
2280
  }, appRoutes);
1416
- return /*#__PURE__*/React.createElement(NeetoHeader, {
2281
+ return /*#__PURE__*/jsx(NeetoHeader, {
1417
2282
  actionBlock: currentTab === null || currentTab === void 0 || (_currentTab$actionBlo = currentTab.actionBlock) === null || _currentTab$actionBlo === void 0 ? void 0 : _currentTab$actionBlo.call(currentTab),
1418
2283
  title: t("neetoApprovals.common.approval", PLURAL),
1419
2284
  searchProps: (currentTab === null || currentTab === void 0 ? void 0 : currentTab.searchPlaceholder) && {
@@ -1434,9 +2299,9 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
1434
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; }
1435
2300
  var useFetchViews = function useFetchViews() {
1436
2301
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1437
- return useQuery([QUERY_KEYS.VIEWS], function () {
1438
- return viewsApi.fetch();
1439
- }, _objectSpread$3({
2302
+ return useQuery(_objectSpread$3({
2303
+ queryKey: [QUERY_KEYS.VIEWS],
2304
+ queryFn: viewsApi.fetch,
1440
2305
  select: function select(response) {
1441
2306
  return response.data || response;
1442
2307
  }
@@ -1463,17 +2328,19 @@ var Tab = function Tab(_ref) {
1463
2328
  _useFetchViews$data2 = _useFetchViews$data === void 0 ? {} : _useFetchViews$data,
1464
2329
  _useFetchViews$data2$ = _useFetchViews$data2.views,
1465
2330
  views = _useFetchViews$data2$ === void 0 ? {} : _useFetchViews$data2$;
1466
- return /*#__PURE__*/React.createElement(Tab$1, null, approvalFilterKeys.map(function (filter) {
1467
- return /*#__PURE__*/React.createElement(Tab$1.Item, {
1468
- active: isActive(filter),
1469
- count: views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()],
1470
- key: filter,
1471
- label: approvalFilter[filter].label,
1472
- onClick: function onClick() {
1473
- return history.push(getRoute(filter));
1474
- }
1475
- }, approvalFilter[filter].label, " (", views[filter === null || filter === void 0 ? void 0 : filter.toLocaleLowerCase()] || 0, ")");
1476
- }));
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
+ });
1477
2344
  };
1478
2345
 
1479
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; }
@@ -1493,28 +2360,33 @@ var Approvals = function Approvals(_ref) {
1493
2360
  isNewTemplatePaneOpen: isNewTemplatePaneOpen,
1494
2361
  setIsNewTemplatePaneOpen: setIsNewTemplatePaneOpen
1495
2362
  });
1496
- return /*#__PURE__*/React.createElement("div", {
1497
- className: "w-full overflow-y-auto"
1498
- }, /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Header, _objectSpread$2({
1499
- appRoutes: appRoutes
1500
- }, config)), /*#__PURE__*/React.createElement(Tab, {
1501
- approvalsPath: config.approvalsPath
1502
- }), /*#__PURE__*/React.createElement(Switch, null, appRoutes.map(function (_ref2) {
1503
- var path = _ref2.path,
1504
- component = _ref2.component;
1505
- return /*#__PURE__*/React.createElement(Route, {
1506
- exact: true,
1507
- component: component,
1508
- path: path,
1509
- key: path
1510
- });
1511
- }), /*#__PURE__*/React.createElement(Redirect, {
1512
- exact: true,
1513
- from: config.approvalsPath
1514
- // eslint-disable-next-line @bigbinary/neeto/use-common-routes
1515
- ,
1516
- to: "".concat(config.approvalsPath).concat(routes.pending)
1517
- }))));
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
+ });
1518
2390
  };
1519
2391
 
1520
2392
  var fetch = function fetch(params) {
@@ -1531,17 +2403,13 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
1531
2403
  var useFetchApprovers = function useFetchApprovers() {
1532
2404
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1533
2405
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1534
- return useQuery([QUERY_KEYS.APPROVERS, params], function () {
1535
- return approversApi.fetch(params);
1536
- }, _objectSpread$1({
2406
+ return useQuery(_objectSpread$1({
2407
+ queryKey: [QUERY_KEYS.APPROVERS, params],
2408
+ queryFn: function queryFn() {
2409
+ return approversApi.fetch(params);
2410
+ },
1537
2411
  select: function select(response) {
1538
2412
  return response.data || response;
1539
- },
1540
- keepPreviousData: true,
1541
- onSuccess: function onSuccess(_ref) {
1542
- var _params$onSuccess;
1543
- var approvers = _ref.approvers;
1544
- return params === null || params === void 0 || (_params$onSuccess = params.onSuccess) === null || _params$onSuccess === void 0 ? void 0 : _params$onSuccess.call(params, approvers);
1545
2413
  }
1546
2414
  }, options));
1547
2415
  };
@@ -1620,37 +2488,42 @@ var Form$1 = function Form(_ref) {
1620
2488
  setSelectedTemplateData(template);
1621
2489
  updateMessage();
1622
2490
  }, [template]);
1623
- return /*#__PURE__*/React.createElement("div", {
1624
- className: "w-full space-y-6"
1625
- }, /*#__PURE__*/React.createElement(Select, {
1626
- label: t("neetoApprovals.select.approval"),
1627
- options: templateOptions,
1628
- onChange: function onChange(selectedTemplate) {
1629
- return handleTemplateChange(selectedTemplate);
1630
- }
1631
- }), (selectedTemplateData === null || selectedTemplateData === void 0 ? void 0 : selectedTemplateData.message) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1632
- className: "flex space-x-6"
1633
- }, /*#__PURE__*/React.createElement(Select, {
1634
- required: true,
1635
- label: t("neetoApprovals.inputs.labels.approver"),
1636
- name: "approver",
1637
- options: approverOptions,
1638
- placeholder: t("neetoApprovals.inputs.placeholders.select_", {
1639
- what: t("neetoApprovals.common.approver", SINGULAR)
1640
- }),
1641
- onChange: handleApproverChange
1642
- })), /*#__PURE__*/React.createElement("div", {
1643
- className: "space-y-2"
1644
- }, /*#__PURE__*/React.createElement(FormikEditor, {
1645
- required: true,
1646
- label: t("neetoApprovals.inputs.labels.message"),
1647
- name: "message",
1648
- ref: inputRef,
1649
- rows: 3,
1650
- placeholder: t("neetoApprovals.inputs.placeholders.enter_", {
1651
- what: t("neetoApprovals.inputs.labels.message")
1652
- })
1653
- }))));
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
+ });
1654
2527
  };
1655
2528
 
1656
2529
  var Form = function Form(_ref) {
@@ -1676,38 +2549,38 @@ var Form = function Form(_ref) {
1676
2549
  approverId: values.approver.value
1677
2550
  }, selectedTemplateData, onClose);
1678
2551
  };
1679
- return /*#__PURE__*/React.createElement(Pane, {
2552
+ return /*#__PURE__*/jsxs(Pane, {
1680
2553
  isOpen: isOpen,
1681
- onClose: onClose
1682
- }, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
1683
- style: "h2"
1684
- }, t("neetoApprovals.common.add_", {
1685
- what: t("neetoApprovals.common.approval", SINGULAR)
1686
- }))), /*#__PURE__*/React.createElement(Form$3, {
1687
- formikProps: {
1688
- onSubmit: handleSubmit,
1689
- initialValues: APPROVAL_REQUEST_FORM_INITIAL_VALUES,
1690
- validationSchema: REQUEST_FORM_VALIDATION_SCHEMA
1691
- }
1692
- }, function (_ref2) {
1693
- var dirty = _ref2.dirty;
1694
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement(Form$1, {
1695
- requestableId: requestableId,
1696
- selectedTemplateData: selectedTemplateData,
1697
- setSelectedTemplateData: setSelectedTemplateData
1698
- })), /*#__PURE__*/React.createElement(Pane.Footer, {
1699
- className: "flex gap-x-2"
1700
- }, /*#__PURE__*/React.createElement(Button, {
1701
- disabled: !dirty,
1702
- label: t("neetoApprovals.buttons.saveChanges"),
1703
- loading: isLoading,
1704
- type: "submit"
1705
- }), /*#__PURE__*/React.createElement(Button, {
1706
- label: t("neetoApprovals.buttons.cancel"),
1707
- style: "text",
1708
- onClick: onClose
1709
- })));
1710
- }));
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
+ });
1711
2584
  };
1712
2585
 
1713
2586
  var show = function show(id) {
@@ -1737,20 +2610,21 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
1737
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; }
1738
2611
  var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
1739
2612
  var requestId = _ref.requestId;
1740
- return useQuery([QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId], function () {
1741
- return publicRequestsApi.show(requestId);
1742
- }, _objectSpread({}, options));
2613
+ return useQuery(_objectSpread({
2614
+ queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
2615
+ queryFn: function queryFn() {
2616
+ return publicRequestsApi.show(requestId);
2617
+ }
2618
+ }, options));
1743
2619
  };
1744
2620
  var useAcceptPendingRequest = function useAcceptPendingRequest(options) {
1745
- useQueryClient();
1746
2621
  return useMutationWithInvalidation(publicRequestsApi.accept, _objectSpread({
1747
- 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]]
1748
2623
  }, options));
1749
2624
  };
1750
2625
  var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
1751
- useQueryClient();
1752
2626
  return useMutationWithInvalidation(publicRequestsApi.decline, _objectSpread({
1753
- 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]]
1754
2628
  }, options));
1755
2629
  };
1756
2630
 
@@ -1766,84 +2640,96 @@ var Public = function Public() {
1766
2640
  t = _useTranslation.t;
1767
2641
  var _useFetchPublicReques = useFetchPublicRequest({
1768
2642
  requestId: id
1769
- }, {
1770
- onSuccess: function onSuccess(_ref) {
1771
- var note = _ref.approvalRequest.note;
1772
- note && setNote(note);
1773
- }
1774
2643
  }),
1775
- _useFetchPublicReques2 = _useFetchPublicReques.data,
1776
- _useFetchPublicReques3 = _useFetchPublicReques2 === void 0 ? {} : _useFetchPublicReques2,
1777
- _useFetchPublicReques4 = _useFetchPublicReques3.approvalRequest,
1778
- approvalRequest = _useFetchPublicReques4 === void 0 ? {} : _useFetchPublicReques4,
2644
+ data = _useFetchPublicReques.data,
1779
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]);
1780
2655
  var _useAcceptPendingRequ = useAcceptPendingRequest(),
1781
2656
  acceptPendingRequest = _useAcceptPendingRequ.mutate,
1782
- isAccepting = _useAcceptPendingRequ.isLoading;
2657
+ isAccepting = _useAcceptPendingRequ.isPending;
1783
2658
  var _useDeclinePendingReq = useDeclinePendingRequest(),
1784
2659
  declinePendingRequest = _useDeclinePendingReq.mutate,
1785
- isDeclining = _useDeclinePendingReq.isLoading;
2660
+ isDeclining = _useDeclinePendingReq.isPending;
1786
2661
  var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
1787
2662
  var hideTextArea = approvalRequest.status !== STATUSES.pending && isEmpty(note);
1788
2663
  if (isLoading) {
1789
- return /*#__PURE__*/React.createElement("div", {
1790
- className: "h-screen items-center justify-center"
1791
- }, /*#__PURE__*/React.createElement(PageLoader, null));
1792
- }
1793
- return /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(NeetoHeader, {
1794
- title: t("neetoApprovals.common.approval", PLURAL)
1795
- }), /*#__PURE__*/React.createElement("div", {
1796
- className: "flex h-screen w-full flex-col items-center"
1797
- }, /*#__PURE__*/React.createElement("div", {
1798
- className: "neeto-ui-shadow-s w-2/5 rounded border p-6"
1799
- }, approvalRequest ? /*#__PURE__*/React.createElement("div", {
1800
- className: "flex w-full flex-col space-y-6"
1801
- }, /*#__PURE__*/React.createElement(Typography, {
1802
- style: "h2"
1803
- }, approvalRequest.title), /*#__PURE__*/React.createElement(EditorContent, {
1804
- content: approvalRequest.message
1805
- }), !hideTextArea && /*#__PURE__*/React.createElement(Textarea, {
1806
- label: t("neetoApprovals.common.note"),
1807
- placeholder: t("neetoApprovals.inputs.placeholders.add_", {
1808
- what: (_t = t("neetoApprovals.common.note")) === null || _t === void 0 ? void 0 : _t.toLocaleLowerCase()
1809
- }),
1810
- value: note,
1811
- disabled: approvalRequest.status !== STATUSES.pending,
1812
- onChange: withEventTargetValue(setNote)
1813
- }), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/React.createElement("div", {
1814
- className: "mx-auto mt-8 flex space-x-6"
1815
- }, /*#__PURE__*/React.createElement(Button, {
1816
- label: t("neetoApprovals.buttons.approve"),
1817
- onClick: function onClick() {
1818
- return acceptPendingRequest({
1819
- id: approvalRequest.id,
1820
- note: note
1821
- });
1822
- },
1823
- loading: isAccepting
1824
- }), /*#__PURE__*/React.createElement(Button, {
1825
- label: t("neetoApprovals.buttons.decline"),
1826
- onClick: function onClick() {
1827
- return declinePendingRequest({
1828
- id: approvalRequest.id,
1829
- note: note
1830
- });
1831
- },
1832
- style: "secondary",
1833
- loading: isDeclining
1834
- })) : /*#__PURE__*/React.createElement(Callout, {
1835
- style: calloutStyle
1836
- }, /*#__PURE__*/React.createElement(Typography, {
1837
- style: "body1"
1838
- }, /*#__PURE__*/React.createElement(Trans, {
1839
- i18nKey: "neetoApprovals.typography.approvalRequest",
1840
- values: {
1841
- status: approvalRequest.status
1842
- }
1843
- })))) : /*#__PURE__*/React.createElement(Typography, {
1844
- style: "h4",
1845
- className: "text-center"
1846
- }, t("neetoApprovals.common.notFound")))));
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
+ });
1847
2733
  };
1848
2734
 
1849
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}}