@zeniai/client-epic-state 5.0.25 → 5.0.26

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.
@@ -30,15 +30,11 @@ export const fetchCompletedTransactionsEpic = (actions$, state$, zeniAPI) => act
30
30
  const queryPayload = {
31
31
  start_date: period.start,
32
32
  end_date: period.end,
33
+ sort_by: sortKey,
34
+ sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
33
35
  page_token: action.payload.pageToken ?? null,
34
36
  page_size: 25,
35
37
  };
36
- if (sortKey != null) {
37
- queryPayload.sort_by = sortKey;
38
- }
39
- if (sortOrder != null) {
40
- queryPayload.sort_order = sortOrder === 'ascending' ? 'asc' : 'desc';
41
- }
42
38
  if (completedSubTab !== 'all') {
43
39
  queryPayload.match_type = completedSubTab;
44
40
  }
@@ -32,17 +32,12 @@ export const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI)
32
32
  const state = state$.value;
33
33
  const { expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
34
34
  const { end, start } = rollingCalendarDateRangeInclusive(MANUAL_SEARCH_TRANSACTION_DATE_RANGE_DAYS);
35
- // Manual search is independent of the Completed tab's optional sort: when the
36
- // bulk upload sort is neutral (no user-applied sort), fall back to date/desc so
37
- // search results stay deterministic for the matching UX.
38
- const manualSearchSortKey = sortKey ?? 'date';
39
- const manualSearchSortOrder = sortOrder ?? 'descending';
40
35
  const queryParam = {
41
36
  start_date: start,
42
37
  end_date: end,
43
38
  auto_categorized: MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED,
44
- sort_by: toTransactionsSortKey(manualSearchSortKey),
45
- sort_order: manualSearchSortOrder === 'ascending' ? 'asc' : 'desc',
39
+ sort_by: toTransactionsSortKey(sortKey),
40
+ sort_order: sortOrder === 'ascending' ? 'asc' : 'desc',
46
41
  page_token: pageToken ?? null,
47
42
  page_size: manualSearch.pageSize,
48
43
  search_text: query,
@@ -5,23 +5,22 @@ 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, restoreBulkUploadMatchingState, } from '../../reducers/missingReceiptsViewReducer';
8
+ import { bulkUploadAutomatchingTimedOut, bulkUploadReceiptsSuccess, clearBulkUpload, fetchBulkUploadBatchDetails, 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. */
12
12
  const RESTORE_FIRST_DELAY_MS = 5000;
13
13
  const FALLBACK_POLL_INTERVAL_MS = 10000;
14
14
  /**
15
- * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs).
16
- * Debounced to reduce duplicate refreshes. The post-match tab decision
17
- * (Unmatched vs Completed) is made client-side in `ExpenseAutomationPage` once fresh
18
- * batch details land -- do not dispatch `requestMissingReceiptsTabNavigation` here.
15
+ * On Pusher batch completion: refresh batch list (then fetchMultipleBatchDetailsEpic runs),
16
+ * and request switching to the Unmatched tab. Debounced to reduce duplicate refreshes.
19
17
  */
20
18
  export const pusherBatchStatusCompletionEpic = (actions$) => actions$.pipe(filter(pusherBatchStatusUpdate.match), filter((action) => action.payload.status === 'completed'), debounceTime(300), mergeMap(() => from([
21
19
  fetchBulkUploadBatches({
22
20
  cacheOverride: true,
23
21
  invalidateBatchDetailsCache: true,
24
22
  }),
23
+ requestMissingReceiptsTabNavigation({ tab: 'unmatched' }),
25
24
  ])));
26
25
  /**
27
26
  * If Pusher and batch-details are delayed beyond {@link BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS},
@@ -77,6 +76,7 @@ export const pollBulkUploadBatchStatusEpic = (actions$, _state$, zeniAPI) => act
77
76
  }
78
77
  actions.push(fetchBulkUploadBatchDetailsSuccess(toBatchDetails(response.data, zeniAPI.apiEndPoints.fileMicroServiceBaseUrl)));
79
78
  actions.push(fetchBulkUploadBatches({ cacheOverride: true }));
79
+ actions.push(requestMissingReceiptsTabNavigation({ tab: 'unmatched' }));
80
80
  return from(actions);
81
81
  }
82
82
  }
@@ -1,11 +1,7 @@
1
1
  import { createAction, createSlice } from '@reduxjs/toolkit';
2
2
  import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
3
  import { MIN_MANUAL_TRANSACTION_SEARCH_LENGTH, } from '../types/missingReceiptsViewState';
4
- export const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => {
5
- const sortKeyPart = sortKey ?? 'none';
6
- const sortOrderPart = sortOrder == null ? 'none' : sortOrder === 'ascending' ? 'asc' : 'desc';
7
- return `completed-${subTab}-${sortKeyPart}-${sortOrderPart}-${periodId}`;
8
- };
4
+ export const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
9
5
  export const initialBulkUploadState = {
10
6
  batchDetailsById: {},
11
7
  batchDetailsPaginationState: { fetchState: 'Not-Started', error: undefined },
@@ -29,8 +25,8 @@ export const initialBulkUploadState = {
29
25
  totalCount: 0,
30
26
  },
31
27
  phase: 'idle',
32
- sortKey: undefined,
33
- sortOrder: undefined,
28
+ sortKey: 'date',
29
+ sortOrder: 'descending',
34
30
  uploadedFileCount: 0,
35
31
  uploadProgress: 0,
36
32
  uploadStatus: { fetchState: 'Not-Started', error: undefined },
@@ -199,8 +199,6 @@ export function getExpenseAutomationMissingReceiptsView(state) {
199
199
  batchDetails: resolvedBatchDetails,
200
200
  completedSubTab: bulkUpload.completedSubTab,
201
201
  currentBatchId: bulkUpload.currentBatchId,
202
- currentBatchDetailsFetched: bulkUpload.currentBatchId != null &&
203
- bulkUpload.batchDetailsById[bulkUpload.currentBatchId] != null,
204
202
  completedTransactions: {
205
203
  fetchState: completedTransactionsForPeriod?.fetchState ?? {
206
204
  fetchState: 'Not-Started',