@zeniai/client-epic-state 5.2.52-betaRD1 → 5.2.52
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.
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +1 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +5 -47
- package/lib/epic.d.ts +1 -2
- package/lib/epic.js +4 -6
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +4 -46
- package/lib/esm/epic.js +4 -6
- package/lib/esm/index.js +3 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +1 -9
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +13 -10
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -60
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
- package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +49 -50
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +11 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/initializeJeScheduleLocalDataEpic.js +15 -34
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/retryJeSchedulesEpic.js +1 -12
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -18
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -62
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +12 -20
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -15
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
- package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
- package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
- package/lib/view/invoicing/invoicingFormDraft.js +14 -0
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -40
- package/lib/tsconfig.mocks.tsbuildinfo +0 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.d.ts +0 -20
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchFailedJePostingsEpic.js +0 -44
|
@@ -7,34 +7,60 @@ const addressSelector_1 = require("../../../entity/address/addressSelector");
|
|
|
7
7
|
const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector");
|
|
8
8
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
9
9
|
const editInvoicingSubscriptionDetailViewReducer_1 = require("./editInvoicingSubscriptionDetailViewReducer");
|
|
10
|
-
const editInvoicingSubscriptionDetailViewReducer_2 = require("./editInvoicingSubscriptionDetailViewReducer");
|
|
11
10
|
const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
|
|
12
11
|
/**
|
|
13
|
-
* Seed the shared Address screen with
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* Seed the shared Address screen with the subscription's saved shipping address, and
|
|
13
|
+
* record that the slot is this subscription's. Runs when a detail request is issued
|
|
14
|
+
* (every path that loads a record issues one — the detail page when not cached,
|
|
15
|
+
* the create/edit form always), when the page opens, when the detail load
|
|
16
|
+
* lands, and on an explicit initialize trigger.
|
|
17
|
+
*
|
|
18
|
+
* The address store slot is keyed by address type alone, so it can still hold
|
|
19
|
+
* another subscription's draft. Only a draft this subscription owns is left alone —
|
|
20
|
+
* that is what lets an address the user just entered survive a trip to the
|
|
21
|
+
* Address screen. Anything else is replaced by this subscription's saved address,
|
|
22
|
+
* or cleared when it has none. Opening the page counts as a trigger because a
|
|
23
|
+
* record already loaded this session issues no detail request at all.
|
|
20
24
|
*/
|
|
21
|
-
const initializeInvoicingSubscriptionAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) =>
|
|
22
|
-
editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action)
|
|
25
|
+
const initializeInvoicingSubscriptionAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingSubscriptionDetailViewReducer_1.initializeInvoicingSubscriptionAddress.match(action) ||
|
|
26
|
+
editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action) ||
|
|
27
|
+
editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionDetailPage.match(action) ||
|
|
28
|
+
editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionDetail.match(action)), (0, operators_1.mergeMap)((action) => {
|
|
23
29
|
const { id } = action.payload;
|
|
30
|
+
if (id == null) {
|
|
31
|
+
return rxjs_1.EMPTY;
|
|
32
|
+
}
|
|
24
33
|
const rootState = state$.value;
|
|
25
|
-
const
|
|
26
|
-
|
|
34
|
+
const pending = rootState.addressViewState.newAddressState?.[invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE]?.addressToCreate;
|
|
35
|
+
const ownerId = rootState.editInvoicingSubscriptionDetailViewState
|
|
36
|
+
.shippingAddressOwnerId;
|
|
37
|
+
// A detail response speaks for the record it loaded, which may no longer
|
|
38
|
+
// be the one on screen: its request keeps running when the user moves on
|
|
39
|
+
// to a cached record, which issues no request of its own to cancel it.
|
|
40
|
+
// Only the page-open and explicit triggers define the current record.
|
|
41
|
+
if (editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionDetail.match(action) &&
|
|
42
|
+
ownerId != null &&
|
|
43
|
+
ownerId !== id) {
|
|
44
|
+
return rxjs_1.EMPTY;
|
|
45
|
+
}
|
|
46
|
+
if (pending != null && ownerId === id) {
|
|
27
47
|
return rxjs_1.EMPTY;
|
|
28
48
|
}
|
|
29
49
|
const subscription = (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionById)(rootState.invoicingSubscriptionState, id);
|
|
30
50
|
const address = subscription?.shippingAddressId != null
|
|
31
51
|
? (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, subscription.shippingAddressId)
|
|
32
52
|
: undefined;
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
const actions = [];
|
|
54
|
+
if (address != null) {
|
|
55
|
+
actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
|
|
35
56
|
addressType: invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE,
|
|
36
57
|
addressToCreate: address,
|
|
37
|
-
}))
|
|
38
|
-
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
else if (pending != null) {
|
|
61
|
+
actions.push((0, addressViewReducer_1.removeNewAddressDataInLocalStore)(invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE));
|
|
62
|
+
}
|
|
63
|
+
actions.push((0, editInvoicingSubscriptionDetailViewReducer_1.claimInvoicingSubscriptionShippingAddress)({ id }));
|
|
64
|
+
return (0, rxjs_1.from)(actions);
|
|
39
65
|
}));
|
|
40
66
|
exports.initializeInvoicingSubscriptionAddressEpic = initializeInvoicingSubscriptionAddressEpic;
|
|
@@ -8,7 +8,9 @@ import { FetchState, ID } from '../../commonStateTypes/common';
|
|
|
8
8
|
* whole state back on every change, so a change made before the record landed
|
|
9
9
|
* leaves a draft that looks seeded but holds nothing.
|
|
10
10
|
*
|
|
11
|
-
* `Not-Started` —
|
|
11
|
+
* `Not-Started` — not (or no longer) the loaded record's values: written by the
|
|
12
|
+
* form before the record landed, or just saved and awaiting the
|
|
13
|
+
* refetch that follows. A successful load replaces it.
|
|
12
14
|
* `Completed` — filled from the loaded record; the form may have edited it since.
|
|
13
15
|
* `Error` — the record's fetch failed, so the form starts blank and a
|
|
14
16
|
* later successful fetch is still allowed to seed it.
|
|
@@ -41,6 +43,13 @@ export declare function applyInvoicingFormDraftSeed<TLocalData>(draftById: Invoi
|
|
|
41
43
|
* counting as still loading, and a later successful fetch can still seed it.
|
|
42
44
|
*/
|
|
43
45
|
export declare function applyInvoicingFormDraftFailure<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID, blankLocalData: TLocalData): void;
|
|
46
|
+
/**
|
|
47
|
+
* The record behind this draft was just saved and is about to be refetched.
|
|
48
|
+
* Keep the values on screen — dropping them would blank the form for the round
|
|
49
|
+
* trip, and the form remounts on the response anyway — but stop counting them
|
|
50
|
+
* as the loaded record's, so that response is allowed to replace them.
|
|
51
|
+
*/
|
|
52
|
+
export declare function applyInvoicingFormDraftSaved<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID): void;
|
|
44
53
|
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
45
54
|
export declare function getInvoicingFormDraftLocalData<TLocalData>(draftById: InvoicingFormDraftById<TLocalData>, id: ID | undefined, blankLocalData: TLocalData): TLocalData;
|
|
46
55
|
/**
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.applyInvoicingFormDraftEdit = applyInvoicingFormDraftEdit;
|
|
4
4
|
exports.applyInvoicingFormDraftSeed = applyInvoicingFormDraftSeed;
|
|
5
5
|
exports.applyInvoicingFormDraftFailure = applyInvoicingFormDraftFailure;
|
|
6
|
+
exports.applyInvoicingFormDraftSaved = applyInvoicingFormDraftSaved;
|
|
6
7
|
exports.getInvoicingFormDraftLocalData = getInvoicingFormDraftLocalData;
|
|
7
8
|
exports.isInvoicingFormDraftPending = isInvoicingFormDraftPending;
|
|
8
9
|
/**
|
|
@@ -48,6 +49,19 @@ function applyInvoicingFormDraftFailure(draftById, id, blankLocalData) {
|
|
|
48
49
|
}
|
|
49
50
|
existing.fetchState = 'Error';
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The record behind this draft was just saved and is about to be refetched.
|
|
54
|
+
* Keep the values on screen — dropping them would blank the form for the round
|
|
55
|
+
* trip, and the form remounts on the response anyway — but stop counting them
|
|
56
|
+
* as the loaded record's, so that response is allowed to replace them.
|
|
57
|
+
*/
|
|
58
|
+
function applyInvoicingFormDraftSaved(draftById, id) {
|
|
59
|
+
const existing = draftById[id];
|
|
60
|
+
if (existing == null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
existing.fetchState = 'Not-Started';
|
|
64
|
+
}
|
|
51
65
|
/** The draft's values, or the blank form when nothing is drafted yet. */
|
|
52
66
|
function getInvoicingFormDraftLocalData(draftById, id, blankLocalData) {
|
|
53
67
|
if (id == null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.52
|
|
3
|
+
"version": "5.2.52",
|
|
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",
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, switchMap, takeUntil } from 'rxjs/operators';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { clearAll } from '../../../../rootActions';
|
|
6
|
-
import { fetchFailedJePostings, fetchFailedJePostingsFailure, fetchFailedJePostingsSuccess, initializeJeScheduleLocalData, } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
/**
|
|
8
|
-
* Fetches every currently-failing posting for the tenant, on its own endpoint and with no window.
|
|
9
|
-
*
|
|
10
|
-
* Sends no query at all. The endpoint takes an optional `expected_post_start_date` floor and the
|
|
11
|
-
* client deliberately omits it: a failure is outstanding work until someone resolves it, whatever
|
|
12
|
-
* month it belongs to, and windowing this list is exactly what kept older failures off the only
|
|
13
|
-
* screen that can resolve them.
|
|
14
|
-
*
|
|
15
|
-
* `switchMap`, not `mergeMap`: there is one list per tenant, so a second trigger supersedes the
|
|
16
|
-
* first rather than racing it.
|
|
17
|
-
*/
|
|
18
|
-
export const fetchFailedJePostingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchFailedJePostings.match), switchMap(() => zeniAPI
|
|
19
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/failed_je_postings`)
|
|
20
|
-
.pipe(switchMap((response) => {
|
|
21
|
-
if (!isSuccessResponse(response) || response.data == null) {
|
|
22
|
-
return of(fetchFailedJePostingsFailure(response.status));
|
|
23
|
-
}
|
|
24
|
-
const failedJeSchedules = response.data.failed_je_postings?.je_schedules ?? [];
|
|
25
|
-
const failedScheduledJournalEntries = response.data.failed_je_postings?.scheduled_journal_entries ?? [];
|
|
26
|
-
// Order matters and matches fetchJeSchedulesEpic: updateJESchedules fans out to the
|
|
27
|
-
// vendor / account / class / user entities, updateJESchedulesDetails then attaches the
|
|
28
|
-
// journal entries, and only then can initializeJeScheduleLocalData read them back.
|
|
29
|
-
return from([
|
|
30
|
-
updateJESchedules(failedJeSchedules),
|
|
31
|
-
updateJESchedulesDetails(failedJeSchedules, failedScheduledJournalEntries),
|
|
32
|
-
initializeJeScheduleLocalData(failedJeSchedules),
|
|
33
|
-
fetchFailedJePostingsSuccess(failedJeSchedules),
|
|
34
|
-
]);
|
|
35
|
-
}), catchError((error) => of(fetchFailedJePostingsFailure(createZeniAPIStatus('Unexpected Error', 'fetch failed JE postings REST API call errored out' +
|
|
36
|
-
JSON.stringify(error))))),
|
|
37
|
-
// A tenant switch clears the store while this request is still in flight. Without this
|
|
38
|
-
// the old tenant's rows are written back into the freshly cleared store and stay on
|
|
39
|
-
// screen under the new tenant until a manual refresh.
|
|
40
|
-
takeUntil(actions$.pipe(filter(clearAll.match))))));
|