@zeniai/client-epic-state 5.0.10-betaVR1 → 5.0.10

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.
@@ -12,13 +12,7 @@ export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => act
12
12
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
13
13
  const periodId = toMonthYearPeriodId(selectedPeriod);
14
14
  const isInitialLoad = action.payload.pageToken == null;
15
- /**
16
- * Snapshot sort config + subTab at request time so success/failure write
17
- * into the same cache key the request was made under, even if the user
18
- * toggles sort while the request is in flight.
19
- */
20
- const { sortKey, sortOrder, completedSubTab } = bulkUpload;
21
- const cacheKey = getCompletedTransactionsCacheKey(periodId, sortKey, sortOrder, completedSubTab);
15
+ const cacheKey = getCompletedTransactionsCacheKey(periodId, bulkUpload.sortKey, bulkUpload.sortOrder, bulkUpload.completedSubTab);
22
16
  const existingData = bulkUpload.completedTransactionsByPeriod[cacheKey];
23
17
  if (isInitialLoad &&
24
18
  action.payload.cacheOverride !== true &&
@@ -30,13 +24,13 @@ export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => act
30
24
  const queryPayload = {
31
25
  start_date: period.start,
32
26
  end_date: period.end,
33
- sort_by: sortKey,
34
- sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
27
+ sort_by: bulkUpload.sortKey,
28
+ sort_order: bulkUpload.sortOrder === 'ascending' ? 'asc' : 'desc',
35
29
  page_token: action.payload.pageToken ?? null,
36
30
  page_size: 25,
37
31
  };
38
- if (completedSubTab !== 'all') {
39
- queryPayload.match_type = completedSubTab;
32
+ if (bulkUpload.completedSubTab !== 'all') {
33
+ queryPayload.match_type = bulkUpload.completedSubTab;
40
34
  }
41
35
  const encodedQuery = encodeURIComponent(JSON.stringify(queryPayload));
42
36
  return zeniAPI
@@ -52,25 +46,16 @@ export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => act
52
46
  nextPageToken: response.data.next_page_token,
53
47
  totalCount: response.data.total_count,
54
48
  selectedPeriod,
55
- sortKey,
56
- sortOrder,
57
- completedSubTab,
58
49
  }));
59
50
  return from(updateActions);
60
51
  }
61
52
  return of(fetchCompletedTransactionsFailure({
62
53
  error: response.status,
63
54
  selectedPeriod,
64
- sortKey,
65
- sortOrder,
66
- completedSubTab,
67
55
  }));
68
56
  }), catchError((error) => of(fetchCompletedTransactionsFailure({
69
57
  error: createZeniAPIStatus('Unexpected Error', 'Fetch completed transactions errored: ' +
70
58
  JSON.stringify(error)),
71
59
  selectedPeriod,
72
- sortKey,
73
- sortOrder,
74
- completedSubTab,
75
60
  }))));
76
61
  }));
@@ -5,7 +5,7 @@ import { updateTransactions } from '../../../../entity/transaction/transactionRe
5
5
  import { isSuccessResponse } from '../../../../responsePayload';
6
6
  import { BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS } from '../../helpers/bulkUploadTiming';
7
7
  import { extractTransactionPayloadsFromBatchFiles, isBatchDetailsApiStatusCompleted, toBatchDetails, } from '../../payload/missingReceiptsPayload';
8
- import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, restoreBulkUploadMatchingState, } from '../../reducers/missingReceiptsViewReducer';
8
+ import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetailsSuccess, fetchBulkUploadBatches, pusherBatchStatusUpdate, requestMissingReceiptsTabNavigation, restoreBulkUploadMatchingState, } from '../../reducers/missingReceiptsViewReducer';
9
9
  /** First poll after upload; then interval while batch not resolved via Pusher or API. */
10
10
  const FALLBACK_FIRST_DELAY_MS = 30000;
11
11
  /** Shorter first poll for restored sessions — batch may already be near completion. */
@@ -35,17 +35,9 @@ export const bulkUploadAutomatchingTimeoutEpic = (actions$, state$) => actions$.
35
35
  if (bulk.phase !== 'matching' || bulk.currentBatchId !== batchId) {
36
36
  return EMPTY;
37
37
  }
38
- /**
39
- * Also request the single-batch details directly so the "X out of Y Receipts Matched"
40
- * toast still fires when the backend actually completed between the last Pusher ping
41
- * and this timeout. If Pusher already tagged the batch as still `processing`,
42
- * `fetchBulkUploadBatchDetailsEpic`'s guard will skip the call and we simply rely on
43
- * the list refresh to eventually populate details via `fetchMultipleBatchDetailsEpic`.
44
- */
45
38
  return from([
46
39
  bulkUploadAutomatchingTimedOut(batchId),
47
40
  fetchBulkUploadBatches({ cacheOverride: true }),
48
- fetchBulkUploadBatchDetails(),
49
41
  ]);
50
42
  }), takeUntil(merge(actions$.pipe(filter(clearBulkUpload.match)), actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((a) => a.payload.batchId === batchId &&
51
43
  a.payload.status === 'completed')), actions$.pipe(filter(fetchBulkUploadBatchDetailsSuccess.match), filter((a) => a.payload.batchId === batchId)))));
@@ -522,9 +522,9 @@ const expenseAutomationMissingReceiptsView = createSlice({
522
522
  },
523
523
  },
524
524
  fetchCompletedTransactionsSuccess(draft, action) {
525
- const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad, sortKey, sortOrder, completedSubTab, } = action.payload;
525
+ const { transactionIds, nextPageToken, totalCount, selectedPeriod, isInitialLoad, } = action.payload;
526
526
  const periodId = toMonthYearPeriodId(selectedPeriod);
527
- const cacheKey = getCompletedTransactionsCacheKey(periodId, sortKey, sortOrder, completedSubTab);
527
+ const cacheKey = getCompletedTransactionsCacheKey(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
528
528
  if (isInitialLoad) {
529
529
  draft.bulkUpload.completedTransactionsByPeriod[cacheKey] = {
530
530
  transactionIds,
@@ -553,7 +553,7 @@ const expenseAutomationMissingReceiptsView = createSlice({
553
553
  },
554
554
  fetchCompletedTransactionsFailure(draft, action) {
555
555
  const periodId = toMonthYearPeriodId(action.payload.selectedPeriod);
556
- const cacheKey = getCompletedTransactionsCacheKey(periodId, action.payload.sortKey, action.payload.sortOrder, action.payload.completedSubTab);
556
+ const cacheKey = getCompletedTransactionsCacheKey(periodId, draft.bulkUpload.sortKey, draft.bulkUpload.sortOrder, draft.bulkUpload.completedSubTab);
557
557
  const existing = draft.bulkUpload.completedTransactionsByPeriod[cacheKey];
558
558
  if (existing != null) {
559
559
  existing.fetchState = {