@zeniai/client-epic-state 4.13.45 → 4.13.47

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.
@@ -58,10 +58,19 @@ const defaultMonthYearPeriod = {
58
58
  };
59
59
  const getDefaultSelectedPeriodsForTenants = (tenantsData) => {
60
60
  const defaultSelectedPeriodsForTenants = tenantsData.tenants.reduce((prev, currentTenant) => {
61
- const monthYearPeriod = currentTenant.zeni_book_close_month_and_year != null
61
+ const currentMonthYearPeriod = currentTenant.zeni_book_close_month_and_year != null
62
62
  ? (0, timePeriod_1.toMonthYearPeriod)(currentTenant.zeni_book_close_month_and_year)
63
- : defaultMonthYearPeriod;
64
- return Object.assign(Object.assign({}, prev), { [currentTenant.tenant_id]: monthYearPeriod });
63
+ : undefined;
64
+ if (currentMonthYearPeriod != null) {
65
+ const currentDate = (0, zeniDayJS_1.date)(`${currentMonthYearPeriod.year}-${currentMonthYearPeriod.month}-01`);
66
+ const nextMonthDate = currentDate.add(1, 'month');
67
+ const nextMonthPeriod = {
68
+ month: (0, timePeriod_1.toMonth)(nextMonthDate.month() + 1),
69
+ year: nextMonthDate.year(),
70
+ };
71
+ return Object.assign(Object.assign({}, prev), { [currentTenant.tenant_id]: nextMonthPeriod });
72
+ }
73
+ return Object.assign(Object.assign({}, prev), { [currentTenant.tenant_id]: defaultMonthYearPeriod });
65
74
  }, {});
66
75
  return defaultSelectedPeriodsForTenants;
67
76
  };
@@ -4,12 +4,14 @@ import { UserPayload } from '../../../../entity/user/userPayload';
4
4
  import { UserRolePayload } from '../../../../entity/userRole/userRolePayload';
5
5
  import { AddressPayload } from '../../../../entity/address/addressPayload';
6
6
  import { ZeniAPIResponse } from '../../../../responsePayload';
7
+ import { ActiveChargeCardCountPayload } from '../../../../view/userListView/userListViewPayload';
7
8
  export interface ChargeCardListPayload {
8
9
  cards: ChargeCardPayload[];
9
10
  unassigned_credit?: AmountPayload;
10
11
  users: UserPayload[];
11
12
  user_roles: UserRolePayload[];
12
13
  addresses: AddressPayload[];
14
+ cards_count_by_user_id?: ActiveChargeCardCountPayload[];
13
15
  }
14
16
  export declare type FetchChargeCardListResponse = ZeniAPIResponse<ChargeCardListPayload>;
15
17
  export interface CreditAccountPayload {
@@ -7,7 +7,7 @@ import { updateAllUsers } from '../../../../entity/user/userReducer';
7
7
  import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
8
8
  import { updateAddresses } from '../../../../entity/address/addressReducer';
9
9
  import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
10
- import { issueChargeCards, issueChargeCardSuccessOrFailure } from './issueChargeCardReducer';
10
+ import { issueChargeCards, updateCardCount, issueChargeCardSuccessOrFailure } from './issueChargeCardReducer';
11
11
  import { updateChargeCardList } from '../chargeCardList/chargeCardListReducer';
12
- export declare type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
12
+ export declare type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateCardCount> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
13
13
  export declare const issueChargeCardEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -44,12 +44,13 @@ const issueChargeCardEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
44
44
  return zeniAPI
45
45
  .postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`, { cards: payload })
46
46
  .pipe((0, operators_1.mergeMap)((response) => {
47
+ var _a, _b;
47
48
  if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
48
49
  const actions = [];
49
50
  actions.push((0, chargeCardReducer_1.updateChargeCards)(response.data.cards), (0, userReducer_1.updateAllUsers)({ users: response.data.users }), (0, userRoleReducer_1.updateUserRoles)(response.data.user_roles), (0, chargeCardListReducer_1.updateChargeCardList)({
50
51
  chargeCardListPayload: response.data,
51
52
  keepExistingListItems: true,
52
- }), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
53
+ }), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.updateCardCount)((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.cards_count_by_user_id) !== null && _b !== void 0 ? _b : []), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
53
54
  const cardHolderIds = response.data.cards.map((card) => card.holder_user_id);
54
55
  const names = response.data.users
55
56
  .filter((user) => cardHolderIds.includes(user.user_id))
@@ -11,9 +11,9 @@ export interface ActiveChargeCardCount {
11
11
  virtualCardCount: number;
12
12
  }
13
13
  export interface PhysicalCardData {
14
- addressType: ShippingAddressType;
15
14
  cardName: string;
16
15
  frequency: CreditLimitFrequencyCodeType;
16
+ addressType?: ShippingAddressType;
17
17
  addressId?: ID;
18
18
  amount?: Amount;
19
19
  userId?: ID;
@@ -6,12 +6,12 @@ exports.initialIssueChargeCardLocalData = [
6
6
  lineId: '1',
7
7
  cardType: 'business_virtual_credit_card',
8
8
  physicalCard: {
9
- addressType: 'company_address',
9
+ userId: undefined,
10
10
  cardName: '',
11
11
  frequency: 'monthly',
12
+ addressType: undefined,
12
13
  addressId: undefined,
13
14
  amount: undefined,
14
- userId: undefined,
15
15
  },
16
16
  virtualCard: {
17
17
  userIds: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.45",
3
+ "version": "4.13.47",
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
  "types": "lib/index.d.ts",