@zeniai/client-epic-state 5.1.82 → 5.1.83
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/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +33 -9
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +35 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +32 -5
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +23 -3
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +20 -3
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +60 -17
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +29 -10
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +28 -5
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +22 -14
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +46 -7
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +26 -8
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +41 -9
- package/lib/index.d.ts +4 -3
- package/lib/index.js +7 -8
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -1
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +22 -8
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/view/invoicing/discountAction/discountActionEpic.d.ts +2 -1
- package/lib/view/invoicing/discountAction/discountActionEpic.js +32 -8
- package/lib/view/invoicing/dunningAction/dunningActionEpic.d.ts +2 -1
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +34 -8
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +31 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +22 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +19 -2
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +2 -1
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +59 -16
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +13 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +11 -31
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +15 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +2 -1
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +28 -9
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +27 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +24 -7
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +23 -16
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.d.ts +2 -1
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +45 -6
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +2 -1
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +25 -7
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +10 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +4 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +2 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +40 -8
- package/package.json +1 -1
|
@@ -4,10 +4,29 @@ exports.runInvoicingDunningActionEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const dunningCaseReducer_1 = require("../../../entity/invoicing/dunningCase/dunningCaseReducer");
|
|
7
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
7
8
|
const responsePayload_1 = require("../../../responsePayload");
|
|
8
9
|
const dunningActionReducer_1 = require("./dunningActionReducer");
|
|
10
|
+
/**
|
|
11
|
+
* Snackbar copy is per action kind; anything not listed here runs without one.
|
|
12
|
+
*/
|
|
13
|
+
const SNACKBAR_SECTION_BY_KIND = {
|
|
14
|
+
cancel: 'invoicing_dunning_cancel',
|
|
15
|
+
resolve: 'invoicing_dunning_case_resolved',
|
|
16
|
+
retry: 'invoicing_dunning_retry',
|
|
17
|
+
};
|
|
9
18
|
const runInvoicingDunningActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(dunningActionReducer_1.runInvoicingDunningAction.match), (0, operators_1.mergeMap)((action) => {
|
|
10
19
|
const { action: kind, body, id } = action.payload;
|
|
20
|
+
const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
|
|
21
|
+
const snackbar = (messageText) => snackbarSection == null
|
|
22
|
+
? []
|
|
23
|
+
: [
|
|
24
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
25
|
+
messageSection: snackbarSection,
|
|
26
|
+
messageText,
|
|
27
|
+
type: messageText === 'success' ? 'success' : 'error',
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
11
30
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${encodeURIComponent(id)}/${kind}`;
|
|
12
31
|
return zeniAPI
|
|
13
32
|
.postAndGetJSON(apiUrl, (body ?? {}))
|
|
@@ -16,16 +35,23 @@ const runInvoicingDunningActionEpic = (actions$, _state$, zeniAPI) => actions$.p
|
|
|
16
35
|
return [
|
|
17
36
|
(0, dunningCaseReducer_1.updateInvoicingDunningCases)([response.data], 'merge'),
|
|
18
37
|
(0, dunningActionReducer_1.runInvoicingDunningActionSuccess)({ id }),
|
|
38
|
+
...snackbar('success'),
|
|
19
39
|
];
|
|
20
40
|
}
|
|
21
|
-
return (0, rxjs_1.
|
|
22
|
-
|
|
41
|
+
return (0, rxjs_1.from)([
|
|
42
|
+
(0, dunningActionReducer_1.runInvoicingDunningActionFailure)({
|
|
43
|
+
error: response.status,
|
|
44
|
+
id,
|
|
45
|
+
}),
|
|
46
|
+
...snackbar('failed'),
|
|
47
|
+
]);
|
|
48
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
49
|
+
(0, dunningActionReducer_1.runInvoicingDunningActionFailure)({
|
|
50
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Dunning action REST API call errored out ' +
|
|
51
|
+
JSON.stringify(error)),
|
|
23
52
|
id,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
JSON.stringify(error)),
|
|
28
|
-
id,
|
|
29
|
-
}))));
|
|
53
|
+
}),
|
|
54
|
+
...snackbar('failed'),
|
|
55
|
+
])));
|
|
30
56
|
}));
|
|
31
57
|
exports.runInvoicingDunningActionEpic = runInvoicingDunningActionEpic;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
2
|
import type { InvoicingPlan } from '../../../entity/invoicing/plan/planState';
|
|
3
3
|
import type { InvoicingProduct } from '../../../entity/invoicing/product/productState';
|
|
4
|
-
import type { InvoicingCatalogItemFormSubFamily } from './editInvoicingCatalogItemDetailViewState';
|
|
4
|
+
import type { InvoicingCatalogItemFormSubFamily, InvoicingCatalogItemFormTier } from './editInvoicingCatalogItemDetailViewState';
|
|
5
5
|
export type CatalogDetailSubFamilyEditValues = InvoicingCatalogItemFormSubFamily;
|
|
6
6
|
export interface CatalogDetailEditValues {
|
|
7
7
|
applicableItems: string[];
|
|
@@ -46,6 +46,8 @@ export interface CreateSubFamilyFormValues {
|
|
|
46
46
|
trialPeriod: string;
|
|
47
47
|
trialPeriodUnit: string;
|
|
48
48
|
priceDollars?: Amount;
|
|
49
|
+
/** Only sent for the tiered pricing models, which price per tier. */
|
|
50
|
+
tiers?: InvoicingCatalogItemFormTier[];
|
|
49
51
|
}
|
|
50
52
|
/** Build POST /catalog/products body for Create sub-family. */
|
|
51
53
|
export declare const createSubFamilyFormToPayload: (itemId: string, itemType: string, values: CreateSubFamilyFormValues) => Record<string, unknown>;
|
|
@@ -121,17 +121,21 @@ exports.catalogDetailEditValuesToSavePayload = catalogDetailEditValuesToSavePayl
|
|
|
121
121
|
const createSubFamilyFormToPayload = (itemId, itemType, values) => {
|
|
122
122
|
const name = values.name.trim();
|
|
123
123
|
const priceCode = trimOrUndefined(values.priceCode) ?? toProductCode(name);
|
|
124
|
+
const tiered = (0, invoicingCatalogItemFormConfig_1.isTieredCatalogPricingModel)(values.pricingModel);
|
|
124
125
|
const payload = {
|
|
125
126
|
currency_code: 'USD',
|
|
126
127
|
free_quantity: Number(values.freeQuantity) || 0,
|
|
127
128
|
is_taxable: true,
|
|
128
129
|
item_id: itemId,
|
|
129
130
|
name,
|
|
130
|
-
price: values.priceDollars?.amount ?? 0,
|
|
131
|
+
price: tiered ? 0 : (values.priceDollars?.amount ?? 0),
|
|
131
132
|
price_code: priceCode,
|
|
132
133
|
pricing_model: values.pricingModel || 'flat_fee',
|
|
133
134
|
show_description_in_invoices: true,
|
|
134
135
|
};
|
|
136
|
+
if (tiered) {
|
|
137
|
+
payload.tiers = (values.tiers ?? []).map(tierToPayload);
|
|
138
|
+
}
|
|
135
139
|
const description = trimOrUndefined(values.description);
|
|
136
140
|
if (description != null) {
|
|
137
141
|
payload.description = description;
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { mergeInvoicingPlanSubFamily, updateInvoicingPlans } from '../../../entity/invoicing/plan/planReducer';
|
|
4
4
|
import { updateInvoicingProducts } from '../../../entity/invoicing/product/productReducer';
|
|
5
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { RootState } from '../../../reducer';
|
|
6
7
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
8
|
import { addInvoicingCatalogItem } from '../invoicingCatalogListView/invoicingCatalogListViewReducer';
|
|
8
9
|
import { saveInvoicingCatalogItem, submitInvoicingCatalogItemForm, submitInvoicingCatalogItemFormFailure, submitInvoicingCatalogItemFormSuccess } from './editInvoicingCatalogItemDetailViewReducer';
|
|
9
|
-
export type ActionType = ReturnType<typeof submitInvoicingCatalogItemForm> | ReturnType<typeof saveInvoicingCatalogItem> | ReturnType<typeof submitInvoicingCatalogItemFormSuccess> | ReturnType<typeof submitInvoicingCatalogItemFormFailure> | ReturnType<typeof updateInvoicingPlans> | ReturnType<typeof updateInvoicingProducts> | ReturnType<typeof mergeInvoicingPlanSubFamily> | ReturnType<typeof addInvoicingCatalogItem>;
|
|
10
|
+
export type ActionType = ReturnType<typeof submitInvoicingCatalogItemForm> | ReturnType<typeof saveInvoicingCatalogItem> | ReturnType<typeof submitInvoicingCatalogItemFormSuccess> | ReturnType<typeof submitInvoicingCatalogItemFormFailure> | ReturnType<typeof updateInvoicingPlans> | ReturnType<typeof updateInvoicingProducts> | ReturnType<typeof mergeInvoicingPlanSubFamily> | ReturnType<typeof addInvoicingCatalogItem> | ReturnType<typeof openSnackbar>;
|
|
10
11
|
export declare const saveInvoicingCatalogItemEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js
CHANGED
|
@@ -5,6 +5,7 @@ const rxjs_1 = require("rxjs");
|
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const planReducer_1 = require("../../../entity/invoicing/plan/planReducer");
|
|
7
7
|
const productReducer_1 = require("../../../entity/invoicing/product/productReducer");
|
|
8
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
8
9
|
const responsePayload_1 = require("../../../responsePayload");
|
|
9
10
|
const invoicingCatalogListViewReducer_1 = require("../invoicingCatalogListView/invoicingCatalogListViewReducer");
|
|
10
11
|
const editInvoicingCatalogItemDetailViewPayload_1 = require("./editInvoicingCatalogItemDetailViewPayload");
|
|
@@ -41,7 +42,14 @@ const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
41
42
|
const failedProductResponse = productResponses.find((productResponse) => !(0, responsePayload_1.isSuccessResponse)(productResponse) ||
|
|
42
43
|
productResponse.data == null);
|
|
43
44
|
if (failedProductResponse != null) {
|
|
44
|
-
return (0, rxjs_1.
|
|
45
|
+
return (0, rxjs_1.from)([
|
|
46
|
+
(0, editInvoicingCatalogItemDetailViewReducer_1.submitInvoicingCatalogItemFormFailure)(failedProductResponse.status),
|
|
47
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
48
|
+
messageSection: 'invoicing_catalog_item_saved',
|
|
49
|
+
messageText: 'failed',
|
|
50
|
+
type: 'error',
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
45
53
|
}
|
|
46
54
|
const savedProducts = productResponses.flatMap((productResponse) => productResponse.data != null ? [productResponse.data] : []);
|
|
47
55
|
const resultActions = [
|
|
@@ -68,6 +76,11 @@ const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
68
76
|
: 'plan';
|
|
69
77
|
resultActions.push((0, invoicingCatalogListViewReducer_1.addInvoicingCatalogItem)({ id: savedItem.id, type: itemType }));
|
|
70
78
|
}
|
|
79
|
+
resultActions.push((0, snackbarReducer_1.openSnackbar)({
|
|
80
|
+
messageSection: 'invoicing_catalog_item_saved',
|
|
81
|
+
messageText: 'success',
|
|
82
|
+
type: 'success',
|
|
83
|
+
}));
|
|
71
84
|
return resultActions;
|
|
72
85
|
};
|
|
73
86
|
const productUpdates = editInvoicingCatalogItemDetailViewReducer_1.saveInvoicingCatalogItem.match(action)
|
|
@@ -78,8 +91,22 @@ const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pip
|
|
|
78
91
|
}
|
|
79
92
|
return (0, rxjs_1.forkJoin)(productUpdates.map((productUpdate) => zeniAPI.putAndGetJSON(`${baseUrl}/catalog/products/${encodeURIComponent(productUpdate.id)}`, productUpdate.data))).pipe((0, operators_1.mergeMap)(completeSave));
|
|
80
93
|
}
|
|
81
|
-
return (0, rxjs_1.
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
return (0, rxjs_1.from)([
|
|
95
|
+
(0, editInvoicingCatalogItemDetailViewReducer_1.submitInvoicingCatalogItemFormFailure)(response.status),
|
|
96
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
97
|
+
messageSection: 'invoicing_catalog_item_saved',
|
|
98
|
+
messageText: 'failed',
|
|
99
|
+
type: 'error',
|
|
100
|
+
}),
|
|
101
|
+
]);
|
|
102
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
103
|
+
(0, editInvoicingCatalogItemDetailViewReducer_1.submitInvoicingCatalogItemFormFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save catalog item REST API call errored out ' +
|
|
104
|
+
JSON.stringify(error))),
|
|
105
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
106
|
+
messageSection: 'invoicing_catalog_item_saved',
|
|
107
|
+
messageText: 'failed',
|
|
108
|
+
type: 'error',
|
|
109
|
+
}),
|
|
110
|
+
])));
|
|
84
111
|
}));
|
|
85
112
|
exports.saveInvoicingCatalogItemEpic = saveInvoicingCatalogItemEpic;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { updateInvoicingCoupons } from '../../../entity/invoicing/coupon/couponReducer';
|
|
4
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
4
5
|
import { RootState } from '../../../reducer';
|
|
5
6
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
6
7
|
import { addInvoicingCouponToList } from '../couponView/couponViewReducer';
|
|
7
8
|
import { saveInvoicingCoupon, submitInvoicingCouponForm, submitInvoicingCouponFormFailure, submitInvoicingCouponFormSuccess } from './editInvoicingCouponDetailViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof submitInvoicingCouponForm> | ReturnType<typeof saveInvoicingCoupon> | ReturnType<typeof submitInvoicingCouponFormSuccess> | ReturnType<typeof submitInvoicingCouponFormFailure> | ReturnType<typeof updateInvoicingCoupons> | ReturnType<typeof addInvoicingCouponToList>;
|
|
9
|
+
export type ActionType = ReturnType<typeof submitInvoicingCouponForm> | ReturnType<typeof saveInvoicingCoupon> | ReturnType<typeof submitInvoicingCouponFormSuccess> | ReturnType<typeof submitInvoicingCouponFormFailure> | ReturnType<typeof updateInvoicingCoupons> | ReturnType<typeof addInvoicingCouponToList> | ReturnType<typeof openSnackbar>;
|
|
9
10
|
export declare const saveInvoicingCouponEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -4,6 +4,7 @@ exports.saveInvoicingCouponEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const couponReducer_1 = require("../../../entity/invoicing/coupon/couponReducer");
|
|
7
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
7
8
|
const responsePayload_1 = require("../../../responsePayload");
|
|
8
9
|
const couponViewReducer_1 = require("../couponView/couponViewReducer");
|
|
9
10
|
const editInvoicingCouponDetailViewPayload_1 = require("./editInvoicingCouponDetailViewPayload");
|
|
@@ -46,9 +47,28 @@ const saveInvoicingCouponEpic = (actions$, state$, zeniAPI) => actions$.pipe((0,
|
|
|
46
47
|
status: couponPayload.status,
|
|
47
48
|
}));
|
|
48
49
|
}
|
|
50
|
+
resultActions.push((0, snackbarReducer_1.openSnackbar)({
|
|
51
|
+
messageSection: 'invoicing_coupon_saved',
|
|
52
|
+
messageText: 'success',
|
|
53
|
+
type: 'success',
|
|
54
|
+
}));
|
|
49
55
|
return resultActions;
|
|
50
56
|
}
|
|
51
|
-
return (0, rxjs_1.
|
|
52
|
-
|
|
57
|
+
return (0, rxjs_1.from)([
|
|
58
|
+
(0, editInvoicingCouponDetailViewReducer_1.submitInvoicingCouponFormFailure)(response.status),
|
|
59
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
60
|
+
messageSection: 'invoicing_coupon_saved',
|
|
61
|
+
messageText: 'failed',
|
|
62
|
+
type: 'error',
|
|
63
|
+
}),
|
|
64
|
+
]);
|
|
65
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
66
|
+
(0, editInvoicingCouponDetailViewReducer_1.submitInvoicingCouponFormFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save coupon REST API call errored out ' + JSON.stringify(error))),
|
|
67
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
68
|
+
messageSection: 'invoicing_coupon_saved',
|
|
69
|
+
messageText: 'failed',
|
|
70
|
+
type: 'error',
|
|
71
|
+
}),
|
|
72
|
+
])));
|
|
53
73
|
}));
|
|
54
74
|
exports.saveInvoicingCouponEpic = saveInvoicingCouponEpic;
|
|
@@ -2,10 +2,11 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { updateInvoicingCustomers } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer';
|
|
5
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { RootState } from '../../../reducer';
|
|
6
7
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
8
|
import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
8
9
|
import { addInvoicingCustomerToList } from '../invoicingCustomerListView/invoicingCustomerListViewReducer';
|
|
9
10
|
import { submitInvoicingCustomerForm, submitInvoicingCustomerFormFailure, submitInvoicingCustomerFormSuccess } from './editInvoicingCustomerDetailViewReducer';
|
|
10
|
-
export type ActionType = ReturnType<typeof submitInvoicingCustomerForm> | ReturnType<typeof submitInvoicingCustomerFormSuccess> | ReturnType<typeof submitInvoicingCustomerFormFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingCustomers> | ReturnType<typeof addInvoicingCustomerToList>;
|
|
11
|
+
export type ActionType = ReturnType<typeof submitInvoicingCustomerForm> | ReturnType<typeof submitInvoicingCustomerFormSuccess> | ReturnType<typeof submitInvoicingCustomerFormFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingCustomers> | ReturnType<typeof addInvoicingCustomerToList> | ReturnType<typeof openSnackbar>;
|
|
11
12
|
export declare const saveInvoicingCustomerEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -6,6 +6,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const addressReducer_1 = require("../../../entity/address/addressReducer");
|
|
7
7
|
const invoicingCustomerPayload_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerPayload");
|
|
8
8
|
const invoicingCustomerReducer_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer");
|
|
9
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
10
11
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
11
12
|
const invoicingCustomerListViewReducer_1 = require("../invoicingCustomerListView/invoicingCustomerListViewReducer");
|
|
@@ -48,10 +49,29 @@ const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$.pipe((
|
|
|
48
49
|
status: response.data.status,
|
|
49
50
|
}));
|
|
50
51
|
}
|
|
52
|
+
resultActions.push((0, snackbarReducer_1.openSnackbar)({
|
|
53
|
+
messageSection: 'invoicing_customer_saved',
|
|
54
|
+
messageText: 'success',
|
|
55
|
+
type: 'success',
|
|
56
|
+
}));
|
|
51
57
|
return resultActions;
|
|
52
58
|
}
|
|
53
|
-
return (0, rxjs_1.
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
return (0, rxjs_1.from)([
|
|
60
|
+
(0, editInvoicingCustomerDetailViewReducer_1.submitInvoicingCustomerFormFailure)(response.status),
|
|
61
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
62
|
+
messageSection: 'invoicing_customer_saved',
|
|
63
|
+
messageText: 'failed',
|
|
64
|
+
type: 'error',
|
|
65
|
+
}),
|
|
66
|
+
]);
|
|
67
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
68
|
+
(0, editInvoicingCustomerDetailViewReducer_1.submitInvoicingCustomerFormFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save customer REST API call errored out ' +
|
|
69
|
+
JSON.stringify(error))),
|
|
70
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
71
|
+
messageSection: 'invoicing_customer_saved',
|
|
72
|
+
messageText: 'failed',
|
|
73
|
+
type: 'error',
|
|
74
|
+
}),
|
|
75
|
+
])));
|
|
56
76
|
}));
|
|
57
77
|
exports.saveInvoicingCustomerEpic = saveInvoicingCustomerEpic;
|
package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { updateInvoicingSubscriptions } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer';
|
|
5
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { RootState } from '../../../reducer';
|
|
6
7
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
8
|
import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
8
9
|
import { addInvoicingSubscriptionToList } from '../invoicingSubscriptionListView/invoicingSubscriptionListViewReducer';
|
|
9
10
|
import { submitInvoicingSubscriptionForm, submitInvoicingSubscriptionFormFailure, submitInvoicingSubscriptionFormSuccess, syncInvoicingSubscriptionCoupons } from './editInvoicingSubscriptionDetailViewReducer';
|
|
10
|
-
export type ActionType = ReturnType<typeof submitInvoicingSubscriptionForm> | ReturnType<typeof submitInvoicingSubscriptionFormSuccess> | ReturnType<typeof submitInvoicingSubscriptionFormFailure> | ReturnType<typeof syncInvoicingSubscriptionCoupons> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingSubscriptions> | ReturnType<typeof addInvoicingSubscriptionToList>;
|
|
11
|
+
export type ActionType = ReturnType<typeof submitInvoicingSubscriptionForm> | ReturnType<typeof submitInvoicingSubscriptionFormSuccess> | ReturnType<typeof submitInvoicingSubscriptionFormFailure> | ReturnType<typeof syncInvoicingSubscriptionCoupons> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingSubscriptions> | ReturnType<typeof addInvoicingSubscriptionToList> | ReturnType<typeof openSnackbar>;
|
|
11
12
|
export declare const saveInvoicingSubscriptionEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js
CHANGED
|
@@ -6,6 +6,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const addressReducer_1 = require("../../../entity/address/addressReducer");
|
|
7
7
|
const invoicingSubscriptionPayload_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload");
|
|
8
8
|
const invoicingSubscriptionReducer_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer");
|
|
9
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
10
11
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
11
12
|
const invoicingSubscriptionListViewReducer_1 = require("../invoicingSubscriptionListView/invoicingSubscriptionListViewReducer");
|
|
@@ -41,7 +42,14 @@ const saveInvoicingSubscriptionEpic = (actions$, state$, zeniAPI) => actions$.pi
|
|
|
41
42
|
: zeniAPI.postAndGetJSON(`${baseUrl}/subscriptions`, { ...data });
|
|
42
43
|
return request$.pipe((0, operators_1.mergeMap)((response) => {
|
|
43
44
|
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
44
|
-
return [
|
|
45
|
+
return [
|
|
46
|
+
(0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormFailure)(response.status),
|
|
47
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
48
|
+
messageSection: 'invoicing_subscription_saved',
|
|
49
|
+
messageText: 'failed',
|
|
50
|
+
type: 'error',
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
45
53
|
}
|
|
46
54
|
const saved = response.data;
|
|
47
55
|
const couponChanged = id != null &&
|
|
@@ -81,8 +89,20 @@ const saveInvoicingSubscriptionEpic = (actions$, state$, zeniAPI) => actions$.pi
|
|
|
81
89
|
status: saved.status,
|
|
82
90
|
}));
|
|
83
91
|
}
|
|
92
|
+
resultActions.push((0, snackbarReducer_1.openSnackbar)({
|
|
93
|
+
messageSection: 'invoicing_subscription_saved',
|
|
94
|
+
messageText: 'success',
|
|
95
|
+
type: 'success',
|
|
96
|
+
}));
|
|
84
97
|
return resultActions;
|
|
85
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.
|
|
86
|
-
|
|
98
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
99
|
+
(0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save subscription REST API call errored out ' +
|
|
100
|
+
JSON.stringify(error))),
|
|
101
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
102
|
+
messageSection: 'invoicing_subscription_saved',
|
|
103
|
+
messageText: 'failed',
|
|
104
|
+
type: 'error',
|
|
105
|
+
}),
|
|
106
|
+
])));
|
|
87
107
|
}));
|
|
88
108
|
exports.saveInvoicingSubscriptionEpic = saveInvoicingSubscriptionEpic;
|
|
@@ -2,11 +2,12 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { updateInvoicingSubscriptions } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer';
|
|
5
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { RootState } from '../../../reducer';
|
|
6
7
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
8
|
import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
|
|
8
9
|
import { submitInvoicingSubscriptionFormFailure, submitInvoicingSubscriptionFormSuccess, syncInvoicingSubscriptionCoupons } from './editInvoicingSubscriptionDetailViewReducer';
|
|
9
|
-
export type ActionType = ReturnType<typeof syncInvoicingSubscriptionCoupons> | ReturnType<typeof submitInvoicingSubscriptionFormSuccess> | ReturnType<typeof submitInvoicingSubscriptionFormFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingSubscriptions>;
|
|
10
|
+
export type ActionType = ReturnType<typeof syncInvoicingSubscriptionCoupons> | ReturnType<typeof submitInvoicingSubscriptionFormSuccess> | ReturnType<typeof submitInvoicingSubscriptionFormFailure> | ReturnType<typeof resetNewAddressDataInLocalStore> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoicingSubscriptions> | ReturnType<typeof openSnackbar>;
|
|
10
11
|
/**
|
|
11
12
|
* After a commercial PUT, sync coupon attach/detach via dedicated endpoints
|
|
12
13
|
* (PUT does not replace coupons). Runs remove-then-apply; on success finishes
|
|
@@ -6,6 +6,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const addressReducer_1 = require("../../../entity/address/addressReducer");
|
|
7
7
|
const invoicingSubscriptionPayload_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload");
|
|
8
8
|
const invoicingSubscriptionReducer_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer");
|
|
9
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
10
11
|
const addressViewReducer_1 = require("../../addressView/addressViewReducer");
|
|
11
12
|
const editInvoicingSubscriptionDetailViewReducer_1 = require("./editInvoicingSubscriptionDetailViewReducer");
|
|
@@ -42,7 +43,14 @@ const syncInvoicingSubscriptionCouponsEpic = (actions$, _state$, zeniAPI) => act
|
|
|
42
43
|
: couponMutation$(zeniAPI, baseUrl, subscriptionId, 'remove-coupon', prev);
|
|
43
44
|
return removeStep$.pipe((0, operators_1.mergeMap)((removeResult) => {
|
|
44
45
|
if (!removeResult.success) {
|
|
45
|
-
return (0, rxjs_1.
|
|
46
|
+
return (0, rxjs_1.from)([
|
|
47
|
+
(0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormFailure)(failureStatus(removeResult)),
|
|
48
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
49
|
+
messageSection: 'invoicing_subscription_saved',
|
|
50
|
+
messageText: 'failed',
|
|
51
|
+
type: 'error',
|
|
52
|
+
}),
|
|
53
|
+
]);
|
|
46
54
|
}
|
|
47
55
|
const applyStep$ = next === ''
|
|
48
56
|
? (0, rxjs_1.of)({
|
|
@@ -54,6 +62,11 @@ const syncInvoicingSubscriptionCouponsEpic = (actions$, _state$, zeniAPI) => act
|
|
|
54
62
|
if (!applyResult.success) {
|
|
55
63
|
return [
|
|
56
64
|
(0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormFailure)(failureStatus(applyResult)),
|
|
65
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
66
|
+
messageSection: 'invoicing_subscription_saved',
|
|
67
|
+
messageText: 'failed',
|
|
68
|
+
type: 'error',
|
|
69
|
+
}),
|
|
57
70
|
];
|
|
58
71
|
}
|
|
59
72
|
const couponUpdated = applyResult.payload ?? removeResult.payload;
|
|
@@ -61,7 +74,11 @@ const syncInvoicingSubscriptionCouponsEpic = (actions$, _state$, zeniAPI) => act
|
|
|
61
74
|
if (couponUpdated != null) {
|
|
62
75
|
resultActions.push((0, invoicingSubscriptionReducer_1.updateInvoicingSubscriptions)([couponUpdated], 'merge'), (0, addressReducer_1.updateAddresses)((0, invoicingSubscriptionPayload_1.extractInvoicingSubscriptionAddresses)([couponUpdated])));
|
|
63
76
|
}
|
|
64
|
-
resultActions.push((0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormSuccess)({ subscriptionId }), (0, addressViewReducer_1.resetNewAddressDataInLocalStore)(invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE))
|
|
77
|
+
resultActions.push((0, editInvoicingSubscriptionDetailViewReducer_1.submitInvoicingSubscriptionFormSuccess)({ subscriptionId }), (0, addressViewReducer_1.resetNewAddressDataInLocalStore)(invoicingSubscriptionFormConfig_1.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE), (0, snackbarReducer_1.openSnackbar)({
|
|
78
|
+
messageSection: 'invoicing_subscription_saved',
|
|
79
|
+
messageText: 'success',
|
|
80
|
+
type: 'success',
|
|
81
|
+
}));
|
|
65
82
|
return resultActions;
|
|
66
83
|
}));
|
|
67
84
|
}));
|
|
@@ -2,9 +2,10 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
4
|
import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
|
|
5
|
+
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
6
|
import { RootState } from '../../../reducer';
|
|
6
7
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
8
|
import { runInvoicingInvoiceAction, runInvoicingInvoiceActionFailure, runInvoicingInvoiceActionSuccess, updateInvoicingInvoice } from './invoiceActionReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof runInvoicingInvoiceAction> | ReturnType<typeof runInvoicingInvoiceActionSuccess> | ReturnType<typeof runInvoicingInvoiceActionFailure> | ReturnType<typeof updateInvoicingInvoice> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoices>;
|
|
9
|
+
export type ActionType = ReturnType<typeof runInvoicingInvoiceAction> | ReturnType<typeof runInvoicingInvoiceActionSuccess> | ReturnType<typeof runInvoicingInvoiceActionFailure> | ReturnType<typeof updateInvoicingInvoice> | ReturnType<typeof updateAddresses> | ReturnType<typeof updateInvoices> | ReturnType<typeof openSnackbar>;
|
|
9
10
|
export declare const runInvoicingInvoiceActionEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
10
11
|
export declare const updateInvoicingInvoiceEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -6,11 +6,28 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const addressReducer_1 = require("../../../entity/address/addressReducer");
|
|
7
7
|
const invoicePayload_1 = require("../../../entity/invoicing/invoice/invoicePayload");
|
|
8
8
|
const invoiceReducer_1 = require("../../../entity/invoicing/invoice/invoiceReducer");
|
|
9
|
+
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
10
11
|
const invoiceActionReducer_1 = require("./invoiceActionReducer");
|
|
12
|
+
/** Snackbar copy per action kind; unlisted kinds run without one. */
|
|
13
|
+
const SNACKBAR_SECTION_BY_KIND = {
|
|
14
|
+
regenerate: 'invoicing_invoice_regenerated',
|
|
15
|
+
'send-reminder': 'invoicing_invoice_reminder_sent',
|
|
16
|
+
void: 'invoicing_invoice_voided',
|
|
17
|
+
};
|
|
11
18
|
const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)((action) => invoiceActionReducer_1.runInvoicingInvoiceAction.match(action) &&
|
|
12
19
|
action.payload.action !== 'issue-credit-note'), (0, operators_1.mergeMap)((action) => {
|
|
13
20
|
const { action: kind, body, invoiceId } = action.payload;
|
|
21
|
+
const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
|
|
22
|
+
const snackbar = (messageText) => snackbarSection == null
|
|
23
|
+
? []
|
|
24
|
+
: [
|
|
25
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
26
|
+
messageSection: snackbarSection,
|
|
27
|
+
messageText,
|
|
28
|
+
type: messageText === 'success' ? 'success' : 'error',
|
|
29
|
+
}),
|
|
30
|
+
];
|
|
14
31
|
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(invoiceId)}/${kind}`;
|
|
15
32
|
return zeniAPI
|
|
16
33
|
.postAndGetJSON(apiUrl, (body ?? {}))
|
|
@@ -20,17 +37,24 @@ const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => actions$.p
|
|
|
20
37
|
(0, invoiceReducer_1.updateInvoices)([response.data], 'merge'),
|
|
21
38
|
(0, addressReducer_1.updateAddresses)((0, invoicePayload_1.extractInvoicingInvoiceAddresses)([response.data])),
|
|
22
39
|
(0, invoiceActionReducer_1.runInvoicingInvoiceActionSuccess)({ invoiceId }),
|
|
40
|
+
...snackbar('success'),
|
|
23
41
|
];
|
|
24
42
|
}
|
|
25
|
-
return (0, rxjs_1.
|
|
26
|
-
|
|
43
|
+
return (0, rxjs_1.from)([
|
|
44
|
+
(0, invoiceActionReducer_1.runInvoicingInvoiceActionFailure)({
|
|
45
|
+
error: response.status,
|
|
46
|
+
invoiceId,
|
|
47
|
+
}),
|
|
48
|
+
...snackbar('failed'),
|
|
49
|
+
]);
|
|
50
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
51
|
+
(0, invoiceActionReducer_1.runInvoicingInvoiceActionFailure)({
|
|
52
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Invoice action REST API call errored out ' +
|
|
53
|
+
JSON.stringify(error)),
|
|
27
54
|
invoiceId,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
JSON.stringify(error)),
|
|
32
|
-
invoiceId,
|
|
33
|
-
}))));
|
|
55
|
+
}),
|
|
56
|
+
...snackbar('failed'),
|
|
57
|
+
])));
|
|
34
58
|
}));
|
|
35
59
|
exports.runInvoicingInvoiceActionEpic = runInvoicingInvoiceActionEpic;
|
|
36
60
|
const updateInvoicingInvoiceEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(invoiceActionReducer_1.updateInvoicingInvoice.match), (0, operators_1.mergeMap)((action) => {
|
|
@@ -44,16 +68,35 @@ const updateInvoicingInvoiceEpic = (actions$, _state$, zeniAPI) => actions$.pipe
|
|
|
44
68
|
(0, invoiceReducer_1.updateInvoices)([response.data], 'merge'),
|
|
45
69
|
(0, addressReducer_1.updateAddresses)((0, invoicePayload_1.extractInvoicingInvoiceAddresses)([response.data])),
|
|
46
70
|
(0, invoiceActionReducer_1.runInvoicingInvoiceActionSuccess)({ invoiceId }),
|
|
71
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
72
|
+
messageSection: 'invoicing_invoice_saved',
|
|
73
|
+
messageText: 'success',
|
|
74
|
+
type: 'success',
|
|
75
|
+
}),
|
|
47
76
|
];
|
|
48
77
|
}
|
|
49
|
-
return (0, rxjs_1.
|
|
50
|
-
|
|
78
|
+
return (0, rxjs_1.from)([
|
|
79
|
+
(0, invoiceActionReducer_1.runInvoicingInvoiceActionFailure)({
|
|
80
|
+
error: response.status,
|
|
81
|
+
invoiceId,
|
|
82
|
+
}),
|
|
83
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
84
|
+
messageSection: 'invoicing_invoice_saved',
|
|
85
|
+
messageText: 'failed',
|
|
86
|
+
type: 'error',
|
|
87
|
+
}),
|
|
88
|
+
]);
|
|
89
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
90
|
+
(0, invoiceActionReducer_1.runInvoicingInvoiceActionFailure)({
|
|
91
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Invoice update REST API call errored out ' +
|
|
92
|
+
JSON.stringify(error)),
|
|
51
93
|
invoiceId,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
}),
|
|
95
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
96
|
+
messageSection: 'invoicing_invoice_saved',
|
|
97
|
+
messageText: 'failed',
|
|
98
|
+
type: 'error',
|
|
99
|
+
}),
|
|
100
|
+
])));
|
|
58
101
|
}));
|
|
59
102
|
exports.updateInvoicingInvoiceEpic = updateInvoicingInvoiceEpic;
|
|
@@ -21,15 +21,28 @@ export interface InvoicingConfigPayload {
|
|
|
21
21
|
subscription_edit_field_options: InvoicingSubscriptionEditFieldOptionWire[];
|
|
22
22
|
subscription_lifecycle_action_options: InvoicingSubscriptionLifecycleActionOptionWire[];
|
|
23
23
|
subscription_metadata_edit_allowed_from_statuses: string[];
|
|
24
|
+
auto_collection_options?: InvoicingNamedOptionWire[];
|
|
25
|
+
billing_period_unit_options?: InvoicingNamedOptionWire[];
|
|
26
|
+
catalog_trial_end_action_options?: InvoicingNamedOptionWire[];
|
|
27
|
+
catalog_trial_unit_options?: InvoicingNamedOptionWire[];
|
|
24
28
|
created_at?: string | null;
|
|
29
|
+
customer_type_options?: InvoicingNamedOptionWire[];
|
|
30
|
+
date_format_options?: InvoicingNamedOptionWire[];
|
|
31
|
+
discount_apply_on_options?: InvoicingNamedOptionWire[];
|
|
32
|
+
discount_duration_type_options?: InvoicingNamedOptionWire[];
|
|
33
|
+
discount_type_options?: InvoicingNamedOptionWire[];
|
|
25
34
|
invoicing_tos_acceptance_ip?: string | null;
|
|
26
35
|
invoicing_tos_acceptance_time?: string | null;
|
|
27
36
|
invoicing_tos_acceptance_user_agent?: string | null;
|
|
28
37
|
invoicing_tos_acceptance_user_id?: string | null;
|
|
29
38
|
is_invoicing_settings_seeded?: boolean;
|
|
39
|
+
manual_payment_method_options?: InvoicingNamedOptionWire[];
|
|
40
|
+
net_term_day_options?: InvoicingNamedOptionWire[];
|
|
41
|
+
payment_gateway_options?: InvoicingNamedOptionWire[];
|
|
30
42
|
qbo_account_mapping_kind_options?: InvoicingQboAccountMappingKindOptionWire[];
|
|
31
43
|
qbo_customer_matching_options?: InvoicingNamedOptionWire[];
|
|
32
44
|
qbo_sync_status_options?: InvoicingNamedOptionWire[];
|
|
45
|
+
taxability_options?: InvoicingNamedOptionWire[];
|
|
33
46
|
updated_at?: string | null;
|
|
34
47
|
}
|
|
35
48
|
export type InvoicingConfigResponse = ZeniAPIResponse<InvoicingConfigPayload>;
|
|
@@ -2,7 +2,7 @@ import { ZeniAPIStatus } from '../../../responsePayload';
|
|
|
2
2
|
import { InvoicingConfigPayload } from './invoicingConfigViewPayload';
|
|
3
3
|
import { InvoicingConfigViewState } from './invoicingConfigViewState';
|
|
4
4
|
export declare const initialState: InvoicingConfigViewState;
|
|
5
|
-
export declare function mapInvoicingConfigPayloadToState(payload: InvoicingConfigPayload): Pick<InvoicingConfigViewState, 'auditLogEntityRouteOptions' | 'auditLogListSortFieldOptions' | 'auditLogSourceLabels' | 'dunningScheduleActionOptions' | 'subscriptionLifecycleActionOptions' | 'subscriptionCommercialEditAllowedFromStatuses' | 'subscriptionMetadataEditAllowedFromStatuses' | 'subscriptionEditFieldOptions' | 'subscriptionCancelTimingOptions' | 'subscriptionChangeOptionOptions' | 'catalogItemLifecycleActionOptions' | 'catalogProductLifecycleActionOptions' | 'discountLifecycleActionOptions' | 'qboAccountMappingKindOptions' | 'qboCustomerMatchingOptions' | 'qboSyncStatusOptions' | 'isInvoicingEnabled' | 'isInvoicingTosAccepted' | 'invoicingTosAcceptanceIp' | 'invoicingTosAcceptanceTime' | 'invoicingTosAcceptanceUserAgent' | 'invoicingTosAcceptanceUserId' | 'isInvoicingSettingsSeeded'>;
|
|
5
|
+
export declare function mapInvoicingConfigPayloadToState(payload: InvoicingConfigPayload): Pick<InvoicingConfigViewState, 'auditLogEntityRouteOptions' | 'auditLogListSortFieldOptions' | 'auditLogSourceLabels' | 'autoCollectionOptions' | 'billingPeriodUnitOptions' | 'catalogTrialEndActionOptions' | 'catalogTrialUnitOptions' | 'customerTypeOptions' | 'dateFormatOptions' | 'discountApplyOnOptions' | 'discountDurationTypeOptions' | 'discountTypeOptions' | 'manualPaymentMethodOptions' | 'netTermDayOptions' | 'paymentGatewayOptions' | 'taxabilityOptions' | 'createdAt' | 'updatedAt' | 'dunningScheduleActionOptions' | 'subscriptionLifecycleActionOptions' | 'subscriptionCommercialEditAllowedFromStatuses' | 'subscriptionMetadataEditAllowedFromStatuses' | 'subscriptionEditFieldOptions' | 'subscriptionCancelTimingOptions' | 'subscriptionChangeOptionOptions' | 'catalogItemLifecycleActionOptions' | 'catalogProductLifecycleActionOptions' | 'discountLifecycleActionOptions' | 'qboAccountMappingKindOptions' | 'qboCustomerMatchingOptions' | 'qboSyncStatusOptions' | 'isInvoicingEnabled' | 'isInvoicingTosAccepted' | 'invoicingTosAcceptanceIp' | 'invoicingTosAcceptanceTime' | 'invoicingTosAcceptanceUserAgent' | 'invoicingTosAcceptanceUserId' | 'isInvoicingSettingsSeeded'>;
|
|
6
6
|
export declare const fetchInvoicingConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
|
|
7
7
|
cacheOverride?: boolean;
|
|
8
8
|
} | undefined], {
|