@zeniai/client-epic-state 5.0.77-betaAS3 → 5.0.77-betaAS5

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.
@@ -1,9 +1,14 @@
1
- import { date } from '../../../zeniDayJS';
1
+ import { dateInUTC, dateLocal } from '../../../zeniDayJS';
2
2
  import { toHistoricEventUpdateDisplayType, toHistoricEventUpdateType, } from './commonHistory';
3
- export const toHistoricEvent = (payload) => ({
3
+ export const toHistoricEvent = (payload, keepTimeInUTC = false) => ({
4
4
  eventText: payload.event_text,
5
5
  eventSubText: payload.event_sub_text ?? [],
6
- timestamp: payload.timestamp != null ? date(payload.timestamp) : undefined,
6
+ // Bills: parse as UTC (dateInUTC). Other entities: convert to local (dateLocal).
7
+ timestamp: payload.timestamp != null
8
+ ? keepTimeInUTC
9
+ ? dateInUTC(payload.timestamp)
10
+ : dateLocal(payload.timestamp)
11
+ : undefined,
7
12
  updates: payload.updates.map((eventUpdatePayload) => toHistoricEventUpdate(eventUpdatePayload)),
8
13
  paymentTraceId: payload.metadata?.payment_trace_id ?? null,
9
14
  });
@@ -29,9 +29,10 @@ const commonHistory = createSlice({
29
29
  },
30
30
  },
31
31
  updateCommonHistory(draft, action) {
32
- const { entityId, entityType, historicEventsPayload } = action.payload;
32
+ const { entityId, entityType, historicEventsPayload, keepTimeInUTC } = action.payload;
33
33
  const key = getEntityHistoryDetailKey(entityId, entityType);
34
- const historicEvents = historicEventsPayload.map((historicEventPayload) => toHistoricEvent(historicEventPayload));
34
+ // Bills: keepTimeInUTC true → dateInUTC. Other entities: undefined → dateLocal.
35
+ const historicEvents = historicEventsPayload.map((historicEventPayload) => toHistoricEvent(historicEventPayload, keepTimeInUTC));
35
36
  draft.historyById[key] = {
36
37
  ...initialCommonHistory,
37
38
  fetchState: 'Completed',
@@ -27,6 +27,8 @@ export const fetchEntityHistoryEpic = (actions$, state$, zeniAPI) => actions$.pi
27
27
  entityId,
28
28
  entityType,
29
29
  historicEventsPayload: response.data.activities,
30
+ // Bills: parse timestamps as UTC. Other entities: convert to local.
31
+ keepTimeInUTC: entityType === 'bill_pay',
30
32
  }));
31
33
  }
32
34
  else {
@@ -22,6 +22,6 @@ interface HistoricEventMetaDataPayload {
22
22
  actor_name: string;
23
23
  payment_trace_id?: string | null;
24
24
  }
25
- export declare const toHistoricEvent: (payload: HistoricEventPayload) => HistoricEvent;
25
+ export declare const toHistoricEvent: (payload: HistoricEventPayload, keepTimeInUTC?: boolean) => HistoricEvent;
26
26
  export type FetchEntityHistoryResponse = ZeniAPIResponse<HistoryPayload>;
27
27
  export {};
@@ -3,10 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toHistoricEvent = void 0;
4
4
  const zeniDayJS_1 = require("../../../zeniDayJS");
5
5
  const commonHistory_1 = require("./commonHistory");
6
- const toHistoricEvent = (payload) => ({
6
+ const toHistoricEvent = (payload, keepTimeInUTC = false) => ({
7
7
  eventText: payload.event_text,
8
8
  eventSubText: payload.event_sub_text ?? [],
9
- timestamp: payload.timestamp != null ? (0, zeniDayJS_1.date)(payload.timestamp) : undefined,
9
+ // Bills: parse as UTC (dateInUTC). Other entities: convert to local (dateLocal).
10
+ timestamp: payload.timestamp != null
11
+ ? keepTimeInUTC
12
+ ? (0, zeniDayJS_1.dateInUTC)(payload.timestamp)
13
+ : (0, zeniDayJS_1.dateLocal)(payload.timestamp)
14
+ : undefined,
10
15
  updates: payload.updates.map((eventUpdatePayload) => toHistoricEventUpdate(eventUpdatePayload)),
11
16
  paymentTraceId: payload.metadata?.payment_trace_id ?? null,
12
17
  });
@@ -12,6 +12,7 @@ export declare const fetchEntityHistory: import("@reduxjs/toolkit").ActionCreato
12
12
  entityId: ID;
13
13
  entityType: SpendManagementEntityType;
14
14
  historicEventsPayload: HistoricEventPayload[];
15
+ keepTimeInUTC?: boolean;
15
16
  }, "commonHistory/updateCommonHistory">, updateCommonHistoryFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
16
17
  entityId: ID;
17
18
  entityType: SpendManagementEntityType;
@@ -36,9 +36,10 @@ const commonHistory = (0, toolkit_1.createSlice)({
36
36
  },
37
37
  },
38
38
  updateCommonHistory(draft, action) {
39
- const { entityId, entityType, historicEventsPayload } = action.payload;
39
+ const { entityId, entityType, historicEventsPayload, keepTimeInUTC } = action.payload;
40
40
  const key = (0, commonHistory_1.getEntityHistoryDetailKey)(entityId, entityType);
41
- const historicEvents = historicEventsPayload.map((historicEventPayload) => (0, commonHistoryPayload_1.toHistoricEvent)(historicEventPayload));
41
+ // Bills: keepTimeInUTC true → dateInUTC. Other entities: undefined → dateLocal.
42
+ const historicEvents = historicEventsPayload.map((historicEventPayload) => (0, commonHistoryPayload_1.toHistoricEvent)(historicEventPayload, keepTimeInUTC));
42
43
  draft.historyById[key] = {
43
44
  ...commonHistory_1.initialCommonHistory,
44
45
  fetchState: 'Completed',
@@ -33,6 +33,8 @@ const fetchEntityHistoryEpic = (actions$, state$, zeniAPI) => actions$.pipe((0,
33
33
  entityId,
34
34
  entityType,
35
35
  historicEventsPayload: response.data.activities,
36
+ // Bills: parse timestamps as UTC. Other entities: convert to local.
37
+ keepTimeInUTC: entityType === 'bill_pay',
36
38
  }));
37
39
  }
38
40
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.77-betaAS3",
3
+ "version": "5.0.77-betaAS5",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",