@zeniai/client-epic-state 4.20.3-betaSS10 → 4.20.3-betaSS12
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/esm/view/creditAgentView/creditAgentViewReducer.js +1 -3
- package/lib/esm/view/creditAgentView/epics/downloadCreditReportEpic.js +49 -25
- package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +1 -1
- package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -3
- package/lib/view/creditAgentView/creditAgentViewReducer.js +1 -3
- package/lib/view/creditAgentView/epics/downloadCreditReportEpic.d.ts +1 -1
- package/lib/view/creditAgentView/epics/downloadCreditReportEpic.js +47 -23
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +1 -1
- package/package.json +1 -1
|
@@ -135,9 +135,7 @@ const creditAgentView = createSlice({
|
|
|
135
135
|
_action) {
|
|
136
136
|
// noop — the epic will surface the error via alert
|
|
137
137
|
},
|
|
138
|
-
downloadCreditReport(draft
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
140
|
-
_action) {
|
|
138
|
+
downloadCreditReport(draft) {
|
|
141
139
|
draft.cardProfiles.downloadState = 'In-Progress';
|
|
142
140
|
},
|
|
143
141
|
downloadCreditReportCompleted(draft) {
|
|
@@ -1,35 +1,59 @@
|
|
|
1
|
-
import { of
|
|
2
|
-
import { catchError, filter, switchMap
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { downloadCreditReport, downloadCreditReportCompleted, downloadCreditReportFailed, } from '../creditAgentViewReducer';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
const CSV_HEADERS = [
|
|
5
|
+
'Customer Name',
|
|
6
|
+
'Card Status',
|
|
7
|
+
'Credit Limit ($)',
|
|
8
|
+
'Credit Score',
|
|
9
|
+
'Recommended Amount ($)',
|
|
10
|
+
'Rationale',
|
|
11
|
+
'Report Date',
|
|
12
|
+
'Tenant Namespace',
|
|
13
|
+
'Tenant ID',
|
|
14
|
+
'Company ID',
|
|
15
|
+
'Updated By',
|
|
16
|
+
'Updated On',
|
|
17
|
+
];
|
|
18
|
+
function rowToCsvLine(row) {
|
|
19
|
+
const fields = [
|
|
20
|
+
row.customerName,
|
|
21
|
+
row.cardStatus,
|
|
22
|
+
row.creditLimit,
|
|
23
|
+
row.creditScore,
|
|
24
|
+
row.recommendedAmount,
|
|
25
|
+
row.rationale,
|
|
26
|
+
row.reportDate,
|
|
27
|
+
row.tenantNamespace,
|
|
28
|
+
row.tenantId,
|
|
29
|
+
row.companyId,
|
|
30
|
+
row.updatedByName,
|
|
31
|
+
row.updatedOn,
|
|
32
|
+
];
|
|
33
|
+
return fields
|
|
34
|
+
.map((f) => {
|
|
35
|
+
const val = f == null ? '' : String(f);
|
|
36
|
+
return `"${val.replace(/"/g, '""')}"`;
|
|
16
37
|
})
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
38
|
+
.join(',');
|
|
39
|
+
}
|
|
40
|
+
export const downloadCreditReportEpic = (actions$, state$, _zeniAPI) => actions$.pipe(filter(downloadCreditReport.match), switchMap(() => {
|
|
41
|
+
try {
|
|
42
|
+
const rows = state$.value.creditAgentViewState.cardProfiles.rows;
|
|
43
|
+
const csvLines = [CSV_HEADERS.join(','), ...rows.map(rowToCsvLine)];
|
|
44
|
+
const csv = csvLines.join('\n');
|
|
45
|
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
22
46
|
const objectUrl = URL.createObjectURL(blob);
|
|
23
47
|
const link = document.createElement('a');
|
|
24
48
|
link.href = objectUrl;
|
|
25
|
-
link.setAttribute('download', 'tenant-
|
|
49
|
+
link.setAttribute('download', 'card-tenant-profiles.csv');
|
|
26
50
|
document.body.appendChild(link);
|
|
27
51
|
link.click();
|
|
28
52
|
document.body.removeChild(link);
|
|
29
53
|
URL.revokeObjectURL(objectUrl);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
return of(downloadCreditReportCompleted());
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
33
57
|
return of(downloadCreditReportFailed());
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
58
|
+
}
|
|
59
|
+
}), catchError(() => of(downloadCreditReportFailed())));
|
|
@@ -3,7 +3,7 @@ import { catchError, filter, switchMap } from 'rxjs/operators';
|
|
|
3
3
|
import { isSuccessResponse } from '../../../responsePayload';
|
|
4
4
|
import { fetchCreditAgentAccess, fetchCreditAgentAccessCompleted, fetchCreditAgentAccessFailed, } from '../creditAgentViewReducer';
|
|
5
5
|
export const fetchCreditAgentAccessEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCreditAgentAccess.match), switchMap(() => {
|
|
6
|
-
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/
|
|
6
|
+
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/cards-cockpit-access`;
|
|
7
7
|
return zeniAPI.getJSON(url).pipe(switchMap((response) => {
|
|
8
8
|
if (isSuccessResponse(response) && response.data != null) {
|
|
9
9
|
return of(fetchCreditAgentAccessCompleted(response.data.is_allowed === true));
|
|
@@ -17,9 +17,7 @@ export declare const fetchCreditAgentAccess: import("@reduxjs/toolkit").ActionCr
|
|
|
17
17
|
}, "creditAgentView/updateCardProfile">, updateCardProfileCompleted: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
18
18
|
profile: Partial<CardTenantProfileRow>;
|
|
19
19
|
tenantNamespace: string;
|
|
20
|
-
}, "creditAgentView/updateCardProfileCompleted">, updateCardProfileFailed: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "creditAgentView/updateCardProfileFailed">, downloadCreditReport: import("@reduxjs/toolkit").
|
|
21
|
-
bffBaseUrl: string;
|
|
22
|
-
}, "creditAgentView/downloadCreditReport">, downloadCreditReportCompleted: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditAgentView/downloadCreditReportCompleted">, downloadCreditReportFailed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditAgentView/downloadCreditReportFailed">;
|
|
20
|
+
}, "creditAgentView/updateCardProfileCompleted">, updateCardProfileFailed: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "creditAgentView/updateCardProfileFailed">, downloadCreditReport: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditAgentView/downloadCreditReport">, downloadCreditReportCompleted: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditAgentView/downloadCreditReportCompleted">, downloadCreditReportFailed: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditAgentView/downloadCreditReportFailed">;
|
|
23
21
|
export { initialCreditAgentViewState as initialState, CreditAgentViewState };
|
|
24
22
|
declare const _default: import("redux").Reducer<CreditAgentViewState>;
|
|
25
23
|
export default _default;
|
|
@@ -141,9 +141,7 @@ const creditAgentView = (0, toolkit_1.createSlice)({
|
|
|
141
141
|
_action) {
|
|
142
142
|
// noop — the epic will surface the error via alert
|
|
143
143
|
},
|
|
144
|
-
downloadCreditReport(draft
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
146
|
-
_action) {
|
|
144
|
+
downloadCreditReport(draft) {
|
|
147
145
|
draft.cardProfiles.downloadState = 'In-Progress';
|
|
148
146
|
},
|
|
149
147
|
downloadCreditReportCompleted(draft) {
|
|
@@ -3,7 +3,7 @@ import { RootState } from '../../../reducer';
|
|
|
3
3
|
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
4
|
import { downloadCreditReport, downloadCreditReportCompleted, downloadCreditReportFailed } from '../creditAgentViewReducer';
|
|
5
5
|
export type ActionType = ReturnType<typeof downloadCreditReport> | ReturnType<typeof downloadCreditReportCompleted> | ReturnType<typeof downloadCreditReportFailed>;
|
|
6
|
-
export declare const downloadCreditReportEpic: (actions$: ActionsObservable<ActionType>,
|
|
6
|
+
export declare const downloadCreditReportEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, _zeniAPI: ZeniAPI) => import("rxjs").Observable<{
|
|
7
7
|
payload: undefined;
|
|
8
8
|
type: "creditAgentView/downloadCreditReportCompleted";
|
|
9
9
|
} | {
|
|
@@ -4,36 +4,60 @@ exports.downloadCreditReportEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const creditAgentViewReducer_1 = require("../creditAgentViewReducer");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
const CSV_HEADERS = [
|
|
8
|
+
'Customer Name',
|
|
9
|
+
'Card Status',
|
|
10
|
+
'Credit Limit ($)',
|
|
11
|
+
'Credit Score',
|
|
12
|
+
'Recommended Amount ($)',
|
|
13
|
+
'Rationale',
|
|
14
|
+
'Report Date',
|
|
15
|
+
'Tenant Namespace',
|
|
16
|
+
'Tenant ID',
|
|
17
|
+
'Company ID',
|
|
18
|
+
'Updated By',
|
|
19
|
+
'Updated On',
|
|
20
|
+
];
|
|
21
|
+
function rowToCsvLine(row) {
|
|
22
|
+
const fields = [
|
|
23
|
+
row.customerName,
|
|
24
|
+
row.cardStatus,
|
|
25
|
+
row.creditLimit,
|
|
26
|
+
row.creditScore,
|
|
27
|
+
row.recommendedAmount,
|
|
28
|
+
row.rationale,
|
|
29
|
+
row.reportDate,
|
|
30
|
+
row.tenantNamespace,
|
|
31
|
+
row.tenantId,
|
|
32
|
+
row.companyId,
|
|
33
|
+
row.updatedByName,
|
|
34
|
+
row.updatedOn,
|
|
35
|
+
];
|
|
36
|
+
return fields
|
|
37
|
+
.map((f) => {
|
|
38
|
+
const val = f == null ? '' : String(f);
|
|
39
|
+
return `"${val.replace(/"/g, '""')}"`;
|
|
19
40
|
})
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
41
|
+
.join(',');
|
|
42
|
+
}
|
|
43
|
+
const downloadCreditReportEpic = (actions$, state$, _zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.downloadCreditReport.match), (0, operators_1.switchMap)(() => {
|
|
44
|
+
try {
|
|
45
|
+
const rows = state$.value.creditAgentViewState.cardProfiles.rows;
|
|
46
|
+
const csvLines = [CSV_HEADERS.join(','), ...rows.map(rowToCsvLine)];
|
|
47
|
+
const csv = csvLines.join('\n');
|
|
48
|
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
25
49
|
const objectUrl = URL.createObjectURL(blob);
|
|
26
50
|
const link = document.createElement('a');
|
|
27
51
|
link.href = objectUrl;
|
|
28
|
-
link.setAttribute('download', 'tenant-
|
|
52
|
+
link.setAttribute('download', 'card-tenant-profiles.csv');
|
|
29
53
|
document.body.appendChild(link);
|
|
30
54
|
link.click();
|
|
31
55
|
document.body.removeChild(link);
|
|
32
56
|
URL.revokeObjectURL(objectUrl);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
return (0, rxjs_1.of)((0, creditAgentViewReducer_1.downloadCreditReportCompleted)());
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
36
60
|
return (0, rxjs_1.of)((0, creditAgentViewReducer_1.downloadCreditReportFailed)());
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
61
|
+
}
|
|
62
|
+
}), (0, operators_1.catchError)(() => (0, rxjs_1.of)((0, creditAgentViewReducer_1.downloadCreditReportFailed)())));
|
|
39
63
|
exports.downloadCreditReportEpic = downloadCreditReportEpic;
|
|
@@ -6,7 +6,7 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const responsePayload_1 = require("../../../responsePayload");
|
|
7
7
|
const creditAgentViewReducer_1 = require("../creditAgentViewReducer");
|
|
8
8
|
const fetchCreditAgentAccessEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(creditAgentViewReducer_1.fetchCreditAgentAccess.match), (0, operators_1.switchMap)(() => {
|
|
9
|
-
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/
|
|
9
|
+
const url = `${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/cards-cockpit-access`;
|
|
10
10
|
return zeniAPI.getJSON(url).pipe((0, operators_1.switchMap)((response) => {
|
|
11
11
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
12
12
|
return (0, rxjs_1.of)((0, creditAgentViewReducer_1.fetchCreditAgentAccessCompleted)(response.data.is_allowed === true));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.20.3-
|
|
3
|
+
"version": "4.20.3-betaSS12",
|
|
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",
|