@zeniai/client-epic-state 4.19.18 → 4.19.19-beta0ND

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.
@@ -184,6 +184,41 @@ exports.getDashboard = (0, toolkit_1.createSelector)(tenantSelector, cardBalance
184
184
  if (isTreasuryTOSAccepted === true || isTreasuryFeatureEnabled === false) {
185
185
  cardsToRemove.add('treasury_promo_card');
186
186
  }
187
+ // More than one promo card can't be shown in the dashboard(Priority: Treasury>Cards>Accounts>Bill> Remi)
188
+ // There is an exception when number of card accounts connected to QBO is zero, in that case we replace card_balance tile in 2nd position with zeni_promo_card,
189
+ // so 3rd position tile could be any other promo card based on priority order.
190
+ const PROMO_CARD_PRIORITY_ORDER = [
191
+ 'treasury_promo_card',
192
+ 'zeni_promo_card',
193
+ 'zeni_accounts_promo_card',
194
+ 'bill_pay_promo_card',
195
+ 'reimbursement_promo_card',
196
+ ];
197
+ const promoCards = PROMO_CARD_PRIORITY_ORDER;
198
+ const promoCardsTobeRetained = promoCards.filter((c) => !cardsToRemove.has(c));
199
+ if (promoCardsTobeRetained.length > 1) {
200
+ const cardsToKeep = new Set();
201
+ if (cardsToRemove.has('card_balance') &&
202
+ promoCardsTobeRetained.includes('zeni_promo_card')) {
203
+ // zeni_promo_card is the primary promo card when card_balance is removed
204
+ cardsToKeep.add('zeni_promo_card');
205
+ // Also keep the highest priority non-zeni promo card as the 2nd
206
+ const secondCard = promoCardsTobeRetained.find((card) => card !== 'zeni_promo_card');
207
+ if (secondCard != null) {
208
+ cardsToKeep.add(secondCard);
209
+ }
210
+ }
211
+ else {
212
+ // Keep only the highest priority promo card
213
+ cardsToKeep.add(promoCardsTobeRetained[0]);
214
+ }
215
+ // Remove all other promo cards not in cardsToKeep
216
+ promoCardsTobeRetained.forEach((card) => {
217
+ if (!cardsToKeep.has(card)) {
218
+ cardsToRemove.add(card);
219
+ }
220
+ });
221
+ }
187
222
  cardsCopy = cardsCopy.filter((c) => !cardsToRemove.has(c));
188
223
  const reportsInOrder = [
189
224
  cashBalance,
@@ -6,8 +6,8 @@ const toolkit_1 = require("@reduxjs/toolkit");
6
6
  exports.defaultCardsInOrder = [
7
7
  'cash_balance',
8
8
  'card_balance',
9
- 'treasury_promo_card',
10
9
  'zeni_promo_card',
10
+ 'treasury_promo_card',
11
11
  'expense_automation_card',
12
12
  'zeni_accounts_promo_card',
13
13
  'task_card',
@@ -12,14 +12,24 @@ const fetchDashboardLayoutEpic = (actions$, _, zeniAPI) => actions$.pipe((0, ope
12
12
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data) {
13
13
  const cardOrder = response.data.preferences
14
14
  .card_order;
15
- let updatedCardOrder = cardOrder;
16
- // if treasury promo card is not in the response, add it at third position
17
- // and update in the backend
18
- if (cardOrder.includes('treasury_promo_card') === false) {
15
+ let updatedCardOrder = [...cardOrder];
16
+ const treasuryIdx = updatedCardOrder.indexOf('treasury_promo_card');
17
+ const zeniPromoIdx = updatedCardOrder.indexOf('zeni_promo_card');
18
+ // Swap zeni_promo_card before treasury_promo_card if needed
19
+ if (treasuryIdx !== -1 &&
20
+ zeniPromoIdx !== -1 &&
21
+ zeniPromoIdx > treasuryIdx) {
22
+ updatedCardOrder[treasuryIdx] = 'zeni_promo_card';
23
+ updatedCardOrder[zeniPromoIdx] =
24
+ 'treasury_promo_card';
25
+ return (0, rxjs_1.of)((0, dashboardLayoutReducer_1.updateDashboardLayout)(updatedCardOrder));
26
+ }
27
+ // If treasury promo card is not in the response, add it at fourth position
28
+ if (treasuryIdx === -1) {
19
29
  updatedCardOrder = [
20
- ...cardOrder.slice(0, 2),
30
+ ...cardOrder.slice(0, 3),
21
31
  'treasury_promo_card',
22
- ...cardOrder.slice(2),
32
+ ...cardOrder.slice(3),
23
33
  ];
24
34
  return (0, rxjs_1.of)((0, dashboardLayoutReducer_1.updateDashboardLayout)(updatedCardOrder));
25
35
  }
@@ -110,7 +110,7 @@ const getBillDetailView = (state, billId) => {
110
110
  const previousBillsView = (0, previousBillsSelector_1.getPreviousBills)(state, (_e = (_d = transaction.vendor) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : '');
111
111
  //don't include current bill
112
112
  previousBills = Object.assign(Object.assign({}, previousBillsView), { bills: previousBillsView.bills.filter((bill) => bill.id !== billId) });
113
- fetchState = (0, reduceFetchState_1.reduceFetchState)([billTransactionDetails, previousBillsView]);
113
+ fetchState = (0, reduceFetchState_1.reduceFetchState)([billTransactionDetails]);
114
114
  }
115
115
  const realTimeApprovalkey = (0, realTimeApprovalState_1.getEntityRealTimeApprovalDetailKey)(billId, 'bill_pay');
116
116
  const { approverIds, attributes } = approverListState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.18",
3
+ "version": "4.19.19-beta0ND",
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",