@zeniai/client-epic-state 5.0.36 → 5.0.37
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/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.d.ts +0 -1
- package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.js +1 -2
- package/lib/entity/file/fileState.d.ts +4 -4
- package/lib/entity/file/fileState.js +0 -4
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -4
- package/lib/entity/task/taskPayload.d.ts +0 -3
- package/lib/entity/task/taskPayload.js +0 -5
- package/lib/entity/task/taskState.d.ts +0 -3
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -4
- package/lib/entity/tenant/clearAllEpic.js +0 -4
- package/lib/entity/transaction/stateTypes/attachment.d.ts +2 -2
- package/lib/epic.d.ts +1 -7
- package/lib/epic.js +1 -7
- package/lib/esm/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.js +0 -1
- package/lib/esm/entity/file/fileState.js +0 -4
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -4
- package/lib/esm/entity/task/taskPayload.js +0 -5
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -4
- package/lib/esm/epic.js +1 -7
- package/lib/esm/index.js +4 -10
- package/lib/esm/init.js +16 -71
- package/lib/esm/reducer.js +0 -6
- package/lib/esm/view/taskManager/taskDetailView/epics/archiveTaskEpic.js +0 -3
- package/lib/esm/view/taskManager/taskDetailView/epics/deleteTaskEpic.js +0 -5
- package/lib/esm/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +0 -1
- package/lib/esm/view/taskManager/taskDetailView/taskDetail.js +0 -4
- package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +7 -60
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +0 -12
- package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +21 -56
- package/lib/esm/view/taskManager/taskListView/epics/dragNDropTasksEpic.js +0 -1
- package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +4 -13
- package/lib/esm/view/taskManager/taskListView/epics/updateTaskFromListViewEpic.js +2 -3
- package/lib/esm/view/taskManager/taskListView/taskList.js +0 -7
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +12 -106
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +39 -48
- package/lib/index.d.ts +4 -12
- package/lib/index.js +5 -28
- package/lib/init.d.ts +3 -5
- package/lib/init.js +16 -71
- package/lib/reducer.d.ts +0 -6
- package/lib/reducer.js +0 -6
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/taskManager/taskDetailView/epics/archiveTaskEpic.d.ts +1 -2
- package/lib/view/taskManager/taskDetailView/epics/archiveTaskEpic.js +0 -3
- package/lib/view/taskManager/taskDetailView/epics/deleteTaskEpic.d.ts +1 -2
- package/lib/view/taskManager/taskDetailView/epics/deleteTaskEpic.js +0 -5
- package/lib/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -1
- package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +0 -1
- package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -2
- package/lib/view/taskManager/taskDetailView/taskDetail.js +0 -4
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +1 -10
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +8 -61
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +0 -5
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +0 -12
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +7 -6
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +22 -56
- package/lib/view/taskManager/taskListView/epics/dragNDropTasksEpic.js +0 -1
- package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +4 -13
- package/lib/view/taskManager/taskListView/epics/updateTaskFromListViewEpic.js +2 -3
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -14
- package/lib/view/taskManager/taskListView/taskList.js +1 -8
- package/lib/view/taskManager/taskListView/taskListPayload.d.ts +0 -3
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +6 -9
- package/lib/view/taskManager/taskListView/taskListReducer.js +13 -107
- package/lib/view/taskManager/taskListView/taskListSelector.d.ts +3 -9
- package/lib/view/taskManager/taskListView/taskListSelector.js +39 -48
- package/package.json +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/cannedResponses.js +0 -1
- package/lib/esm/view/taskManager/cannedResponsesView/cannedResponsesPayload.js +0 -12
- package/lib/esm/view/taskManager/cannedResponsesView/cannedResponsesReducer.js +0 -64
- package/lib/esm/view/taskManager/cannedResponsesView/cannedResponsesSelector.js +0 -3
- package/lib/esm/view/taskManager/cannedResponsesView/epics/deleteCannedResponseEpic.js +0 -17
- package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +0 -21
- package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +0 -29
- package/lib/esm/view/taskManager/taskDetailView/epics/snoozeTaskEpic.js +0 -66
- package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +0 -57
- package/lib/esm/view/zeniOAuthView/epics/approveOAuthConsentEpic.js +0 -65
- package/lib/esm/view/zeniOAuthView/zeniOAuthParamsParser.js +0 -41
- package/lib/esm/view/zeniOAuthView/zeniOAuthReducer.js +0 -49
- package/lib/esm/view/zeniOAuthView/zeniOAuthSelector.js +0 -3
- package/lib/esm/view/zeniOAuthView/zeniOAuthState.js +0 -1
- package/lib/view/taskManager/cannedResponsesView/cannedResponses.d.ts +0 -19
- package/lib/view/taskManager/cannedResponsesView/cannedResponses.js +0 -2
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesPayload.d.ts +0 -21
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesPayload.js +0 -15
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesReducer.d.ts +0 -30
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesReducer.js +0 -68
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesSelector.d.ts +0 -3
- package/lib/view/taskManager/cannedResponsesView/cannedResponsesSelector.js +0 -6
- package/lib/view/taskManager/cannedResponsesView/epics/deleteCannedResponseEpic.d.ts +0 -7
- package/lib/view/taskManager/cannedResponsesView/epics/deleteCannedResponseEpic.js +0 -21
- package/lib/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.d.ts +0 -7
- package/lib/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +0 -25
- package/lib/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.d.ts +0 -7
- package/lib/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +0 -33
- package/lib/view/taskManager/taskDetailView/epics/snoozeTaskEpic.d.ts +0 -9
- package/lib/view/taskManager/taskDetailView/epics/snoozeTaskEpic.js +0 -70
- package/lib/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.d.ts +0 -9
- package/lib/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +0 -61
- package/lib/view/zeniOAuthView/epics/approveOAuthConsentEpic.d.ts +0 -27
- package/lib/view/zeniOAuthView/epics/approveOAuthConsentEpic.js +0 -69
- package/lib/view/zeniOAuthView/zeniOAuthParamsParser.d.ts +0 -16
- package/lib/view/zeniOAuthView/zeniOAuthParamsParser.js +0 -44
- package/lib/view/zeniOAuthView/zeniOAuthReducer.d.ts +0 -29
- package/lib/view/zeniOAuthView/zeniOAuthReducer.js +0 -53
- package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +0 -5
- package/lib/view/zeniOAuthView/zeniOAuthSelector.js +0 -9
- package/lib/view/zeniOAuthView/zeniOAuthState.d.ts +0 -4
- package/lib/view/zeniOAuthView/zeniOAuthState.js +0 -2
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
cannedResponses: [],
|
|
4
|
-
fetchState: 'Not-Started',
|
|
5
|
-
saveFetchState: 'Not-Started',
|
|
6
|
-
deleteFetchState: 'Not-Started',
|
|
7
|
-
error: undefined,
|
|
8
|
-
};
|
|
9
|
-
const cannedResponsesView = createSlice({
|
|
10
|
-
name: 'cannedResponsesView',
|
|
11
|
-
initialState,
|
|
12
|
-
reducers: {
|
|
13
|
-
fetchCannedResponses(draft) {
|
|
14
|
-
draft.fetchState =
|
|
15
|
-
draft.cannedResponses.length > 0 ? 'Completed' : 'In-Progress';
|
|
16
|
-
draft.error = undefined;
|
|
17
|
-
},
|
|
18
|
-
updateCannedResponses(draft, action) {
|
|
19
|
-
draft.cannedResponses = action.payload.cannedResponses;
|
|
20
|
-
draft.fetchState = 'Completed';
|
|
21
|
-
draft.error = undefined;
|
|
22
|
-
},
|
|
23
|
-
updateCannedResponsesFetchStatus(draft, action) {
|
|
24
|
-
draft.fetchState = action.payload.fetchState;
|
|
25
|
-
draft.error = action.payload.error;
|
|
26
|
-
},
|
|
27
|
-
saveCannedResponse: {
|
|
28
|
-
reducer(draft) {
|
|
29
|
-
draft.saveFetchState = 'In-Progress';
|
|
30
|
-
},
|
|
31
|
-
prepare(payload) {
|
|
32
|
-
return { payload };
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
saveCannedResponseSuccess(draft) {
|
|
36
|
-
draft.saveFetchState = 'Completed';
|
|
37
|
-
},
|
|
38
|
-
saveCannedResponseFailure(draft, action) {
|
|
39
|
-
draft.saveFetchState = 'Error';
|
|
40
|
-
draft.error = action.payload.error;
|
|
41
|
-
},
|
|
42
|
-
deleteCannedResponse: {
|
|
43
|
-
reducer(draft) {
|
|
44
|
-
draft.deleteFetchState = 'In-Progress';
|
|
45
|
-
},
|
|
46
|
-
prepare(payload) {
|
|
47
|
-
return { payload };
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
deleteCannedResponseSuccess(draft, action) {
|
|
51
|
-
draft.deleteFetchState = 'Completed';
|
|
52
|
-
draft.cannedResponses = draft.cannedResponses.filter((r) => r.cannedResponseId !== action.payload.cannedResponseId);
|
|
53
|
-
},
|
|
54
|
-
deleteCannedResponseFailure(draft, action) {
|
|
55
|
-
draft.deleteFetchState = 'Error';
|
|
56
|
-
draft.error = action.payload.error;
|
|
57
|
-
},
|
|
58
|
-
clearCannedResponses() {
|
|
59
|
-
return initialState;
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
export const { fetchCannedResponses, updateCannedResponses, updateCannedResponsesFetchStatus, saveCannedResponse, saveCannedResponseSuccess, saveCannedResponseFailure, deleteCannedResponse, deleteCannedResponseSuccess, deleteCannedResponseFailure, clearCannedResponses, } = cannedResponsesView.actions;
|
|
64
|
-
export default cannedResponsesView.reducer;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { deleteCannedResponse, deleteCannedResponseFailure, deleteCannedResponseSuccess, } from '../cannedResponsesReducer';
|
|
5
|
-
export const deleteCannedResponseEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteCannedResponse.match), mergeMap((action) => {
|
|
6
|
-
const { cannedResponseId } = action.payload;
|
|
7
|
-
return zeniAPI
|
|
8
|
-
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${cannedResponseId}`)
|
|
9
|
-
.pipe(mergeMap((response) => {
|
|
10
|
-
if (isSuccessResponse(response)) {
|
|
11
|
-
return of(deleteCannedResponseSuccess({ cannedResponseId }));
|
|
12
|
-
}
|
|
13
|
-
return of(deleteCannedResponseFailure({ error: response.status }));
|
|
14
|
-
}), catchError((error) => of(deleteCannedResponseFailure({
|
|
15
|
-
error: createZeniAPIStatus('Unexpected Error', 'Delete Canned Response errored: ' + JSON.stringify(error)),
|
|
16
|
-
}))));
|
|
17
|
-
}));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, switchMap, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { mapCannedResponsePayloadToCannedResponse, } from '../cannedResponsesPayload';
|
|
5
|
-
import { fetchCannedResponses, updateCannedResponses, updateCannedResponsesFetchStatus, } from '../cannedResponsesReducer';
|
|
6
|
-
export const fetchCannedResponsesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCannedResponses.match), switchMap(() => zeniAPI
|
|
7
|
-
.getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses`)
|
|
8
|
-
.pipe(mergeMap((response) => {
|
|
9
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
10
|
-
return of(updateCannedResponses({
|
|
11
|
-
cannedResponses: (response.data.canned_responses ?? []).map(mapCannedResponsePayloadToCannedResponse),
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
return of(updateCannedResponsesFetchStatus({
|
|
15
|
-
fetchState: 'Error',
|
|
16
|
-
error: response.status,
|
|
17
|
-
}));
|
|
18
|
-
}), catchError((error) => of(updateCannedResponsesFetchStatus({
|
|
19
|
-
fetchState: 'Error',
|
|
20
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch Canned Responses errored: ' + JSON.stringify(error)),
|
|
21
|
-
}))))));
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, switchMap, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
-
import { fetchCannedResponses, saveCannedResponse, saveCannedResponseFailure, saveCannedResponseSuccess, } from '../cannedResponsesReducer';
|
|
5
|
-
export const saveCannedResponseEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveCannedResponse.match), switchMap((action) => {
|
|
6
|
-
const { name, content, cannedResponseId } = action.payload;
|
|
7
|
-
const isUpdate = cannedResponseId != null;
|
|
8
|
-
const url = isUpdate
|
|
9
|
-
? `${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${cannedResponseId}`
|
|
10
|
-
: `${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses`;
|
|
11
|
-
const apiCall = isUpdate
|
|
12
|
-
? zeniAPI.putAndGetJSON(url, {
|
|
13
|
-
name,
|
|
14
|
-
content,
|
|
15
|
-
})
|
|
16
|
-
: zeniAPI.postAndGetJSON(url, {
|
|
17
|
-
name,
|
|
18
|
-
content,
|
|
19
|
-
});
|
|
20
|
-
return apiCall.pipe(mergeMap((response) => {
|
|
21
|
-
if (isSuccessResponse(response)) {
|
|
22
|
-
return of(saveCannedResponseSuccess(), fetchCannedResponses() // Refresh list after save
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
return of(saveCannedResponseFailure({ error: response.status }));
|
|
26
|
-
}), catchError((error) => of(saveCannedResponseFailure({
|
|
27
|
-
error: createZeniAPIStatus('Unexpected Error', 'Save Canned Response errored: ' + JSON.stringify(error)),
|
|
28
|
-
}))));
|
|
29
|
-
}));
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { SNOOZED_DISPLAY_FORMAT } from '../../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
4
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { updateTasks } from '../../../../entity/task/taskReducer';
|
|
6
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
7
|
-
import { date } from '../../../../zeniDayJS';
|
|
8
|
-
import { fetchTaskList, removeTaskFromList, } from '../../taskListView/taskListReducer';
|
|
9
|
-
import { snoozeTask, snoozeTaskSuccessOrFailure } from '../taskDetailReducer';
|
|
10
|
-
export const snoozeTaskEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(snoozeTask.match), mergeMap((action) => handleSnoozeTask(action.payload.taskId, action.payload.snoozedUntil, zeniAPI)));
|
|
11
|
-
const formatSnoozedUntilForDisplay = (snoozedUntil) => date(snoozedUntil).format(SNOOZED_DISPLAY_FORMAT);
|
|
12
|
-
const handleSnoozeTask = (taskId, snoozedUntil, zeniAPI) => {
|
|
13
|
-
const snoozeTaskApi$ = zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${taskId}/snooze`, { snoozed_until: snoozedUntil });
|
|
14
|
-
return snoozeTaskApi$.pipe(mergeMap((response) => handleApiResponse(response, taskId, snoozedUntil)), catchError((error) => of(snoozeTaskSuccessOrFailure({
|
|
15
|
-
fetchState: 'Error',
|
|
16
|
-
taskId,
|
|
17
|
-
error: createZeniAPIStatus('Unexpected Error', 'Snooze Task REST API call errored out: ' + JSON.stringify(error)),
|
|
18
|
-
}))));
|
|
19
|
-
};
|
|
20
|
-
const handleApiResponse = (response, taskId, snoozedUntil) => {
|
|
21
|
-
if (isSuccessResponse(response) &&
|
|
22
|
-
response.data != null &&
|
|
23
|
-
response.data.tasks.length > 0) {
|
|
24
|
-
const fetchActions = [
|
|
25
|
-
updateTasks(response.data.tasks),
|
|
26
|
-
removeTaskFromList(taskId),
|
|
27
|
-
fetchTaskList(),
|
|
28
|
-
snoozeTaskSuccessOrFailure({
|
|
29
|
-
fetchState: 'Completed',
|
|
30
|
-
taskId,
|
|
31
|
-
}),
|
|
32
|
-
openSnackbar({
|
|
33
|
-
messageSection: 'snooze_task',
|
|
34
|
-
messageText: 'success',
|
|
35
|
-
type: 'success',
|
|
36
|
-
variables: [
|
|
37
|
-
{
|
|
38
|
-
variableName: '_snoozed_until_',
|
|
39
|
-
variableValue: formatSnoozedUntilForDisplay(snoozedUntil),
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
}),
|
|
43
|
-
];
|
|
44
|
-
return from(fetchActions);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return from([
|
|
48
|
-
snoozeTaskSuccessOrFailure({
|
|
49
|
-
fetchState: 'Error',
|
|
50
|
-
taskId,
|
|
51
|
-
error: response.status,
|
|
52
|
-
}),
|
|
53
|
-
openSnackbar({
|
|
54
|
-
messageSection: 'snooze_task',
|
|
55
|
-
messageText: 'failed',
|
|
56
|
-
type: 'error',
|
|
57
|
-
variables: [
|
|
58
|
-
{
|
|
59
|
-
variableName: '_api-error_',
|
|
60
|
-
variableValue: response.status.message,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
}),
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { updateTasks } from '../../../../entity/task/taskReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
-
import { fetchTaskList, removeTaskFromList, } from '../../taskListView/taskListReducer';
|
|
7
|
-
import { snoozeTaskSuccessOrFailure, unsnoozeTask, } from '../taskDetailReducer';
|
|
8
|
-
export const unsnoozeTaskEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(unsnoozeTask.match), mergeMap((action) => handleUnsnoozeTask(action.payload.taskId, zeniAPI)));
|
|
9
|
-
const handleUnsnoozeTask = (taskId, zeniAPI) => {
|
|
10
|
-
const unsnoozeTaskApi$ = zeniAPI.deleteAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${taskId}/snooze`);
|
|
11
|
-
return unsnoozeTaskApi$.pipe(mergeMap((response) => handleApiResponse(response, taskId)), catchError((error) => of(snoozeTaskSuccessOrFailure({
|
|
12
|
-
fetchState: 'Error',
|
|
13
|
-
taskId,
|
|
14
|
-
error: createZeniAPIStatus('Unexpected Error', 'Unsnooze Task REST API call errored out: ' + JSON.stringify(error)),
|
|
15
|
-
}))));
|
|
16
|
-
};
|
|
17
|
-
const handleApiResponse = (response, taskId) => {
|
|
18
|
-
if (isSuccessResponse(response) &&
|
|
19
|
-
response.data != null &&
|
|
20
|
-
response.data.tasks.length > 0) {
|
|
21
|
-
const fetchActions = [
|
|
22
|
-
updateTasks(response.data.tasks),
|
|
23
|
-
removeTaskFromList(taskId),
|
|
24
|
-
fetchTaskList(),
|
|
25
|
-
snoozeTaskSuccessOrFailure({
|
|
26
|
-
fetchState: 'Completed',
|
|
27
|
-
taskId,
|
|
28
|
-
}),
|
|
29
|
-
openSnackbar({
|
|
30
|
-
messageSection: 'unsnooze_task',
|
|
31
|
-
messageText: 'success',
|
|
32
|
-
type: 'success',
|
|
33
|
-
}),
|
|
34
|
-
];
|
|
35
|
-
return from(fetchActions);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return from([
|
|
39
|
-
snoozeTaskSuccessOrFailure({
|
|
40
|
-
fetchState: 'Error',
|
|
41
|
-
taskId,
|
|
42
|
-
error: response.status,
|
|
43
|
-
}),
|
|
44
|
-
openSnackbar({
|
|
45
|
-
messageSection: 'unsnooze_task',
|
|
46
|
-
messageText: 'failed',
|
|
47
|
-
type: 'error',
|
|
48
|
-
variables: [
|
|
49
|
-
{
|
|
50
|
-
variableName: '_api-error_',
|
|
51
|
-
variableValue: response.status.message,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
}),
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, concatMap, exhaustMap, filter, mergeMap, } from 'rxjs/operators';
|
|
3
|
-
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { createZeniAPIStatus } from '../../../responsePayload';
|
|
5
|
-
import { approveOAuthConsent, approveOAuthConsentFailure, approveOAuthConsentSuccess, } from '../zeniOAuthReducer';
|
|
6
|
-
const failureSnackbar = (reason) => openSnackbar({
|
|
7
|
-
messageSection: 'oauth_consent_approve',
|
|
8
|
-
messageText: 'failed',
|
|
9
|
-
type: 'error',
|
|
10
|
-
variables: [{ variableName: '__reason__', variableValue: reason }],
|
|
11
|
-
});
|
|
12
|
-
export const approveOAuthConsentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(approveOAuthConsent.match),
|
|
13
|
-
// `approveOAuthConsent` reducer sets fetchState to In-Progress before epics
|
|
14
|
-
// run, so a guard on In-Progress would block every legitimate request.
|
|
15
|
-
// exhaustMap drops duplicate approve clicks while the HTTP call is in flight.
|
|
16
|
-
exhaustMap((action) => {
|
|
17
|
-
const { userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType, } = action.payload;
|
|
18
|
-
const authHeaders = {
|
|
19
|
-
'zeni-user-id': userId,
|
|
20
|
-
'zeni-tenant-id': tenantId,
|
|
21
|
-
};
|
|
22
|
-
if (zeniSessionId != null) {
|
|
23
|
-
authHeaders['zeni-session-id'] = zeniSessionId;
|
|
24
|
-
}
|
|
25
|
-
return zeniAPI
|
|
26
|
-
.postJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/oauth/authorize/approve`, {
|
|
27
|
-
client_id: clientId,
|
|
28
|
-
redirect_uri: redirectUri,
|
|
29
|
-
code_challenge: codeChallenge,
|
|
30
|
-
code_challenge_method: codeChallengeMethod,
|
|
31
|
-
state,
|
|
32
|
-
response_type: responseType,
|
|
33
|
-
tenant_id: tenantId,
|
|
34
|
-
}, authHeaders)
|
|
35
|
-
.pipe(concatMap((response) => from(response.json()).pipe(mergeMap((responseJson) => {
|
|
36
|
-
if (!response.ok) {
|
|
37
|
-
const errBody = responseJson;
|
|
38
|
-
const errorMessage = errBody?.error ??
|
|
39
|
-
errBody?.message ??
|
|
40
|
-
errBody?.status?.message ??
|
|
41
|
-
`Authorization failed (${response.status})`;
|
|
42
|
-
return from([
|
|
43
|
-
approveOAuthConsentFailure(createZeniAPIStatus(errorMessage)),
|
|
44
|
-
failureSnackbar(errorMessage),
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
|
-
const body = responseJson;
|
|
48
|
-
const redirectUrl = body?.redirect_url ?? body?.data?.redirect_url;
|
|
49
|
-
if (redirectUrl == null || redirectUrl === '') {
|
|
50
|
-
const noRedirectMessage = 'No redirect URL returned from authorization server';
|
|
51
|
-
return from([
|
|
52
|
-
approveOAuthConsentFailure(createZeniAPIStatus(noRedirectMessage)),
|
|
53
|
-
failureSnackbar(noRedirectMessage),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
return of(approveOAuthConsentSuccess({ redirectUrl }));
|
|
57
|
-
}))), catchError((error) => {
|
|
58
|
-
const errorDetail = error instanceof Error ? error.message : JSON.stringify(error);
|
|
59
|
-
const networkErrorMessage = 'OAuth approve request failed: ' + errorDetail;
|
|
60
|
-
return from([
|
|
61
|
-
approveOAuthConsentFailure(createZeniAPIStatus(networkErrorMessage)),
|
|
62
|
-
failureSnackbar(networkErrorMessage),
|
|
63
|
-
]);
|
|
64
|
-
}));
|
|
65
|
-
}));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export function parseOAuthParams(search) {
|
|
2
|
-
const searchParams = new URLSearchParams(search);
|
|
3
|
-
const clientId = searchParams.get('client_id');
|
|
4
|
-
const redirectUri = searchParams.get('redirect_uri');
|
|
5
|
-
const codeChallenge = searchParams.get('code_challenge');
|
|
6
|
-
const codeChallengeMethod = searchParams.get('code_challenge_method') ?? 'S256';
|
|
7
|
-
const state = searchParams.get('state');
|
|
8
|
-
const responseType = searchParams.get('response_type') ?? 'code';
|
|
9
|
-
if (clientId == null || clientId === '') {
|
|
10
|
-
return { params: null, error: 'Missing client_id parameter' };
|
|
11
|
-
}
|
|
12
|
-
if (redirectUri == null || redirectUri === '') {
|
|
13
|
-
return { params: null, error: 'Missing redirect_uri parameter' };
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
void new URL(redirectUri);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return { params: null, error: 'Invalid redirect_uri parameter' };
|
|
20
|
-
}
|
|
21
|
-
if (codeChallenge == null || codeChallenge === '') {
|
|
22
|
-
return {
|
|
23
|
-
params: null,
|
|
24
|
-
error: 'Missing code_challenge parameter (PKCE required)',
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (state == null || state === '') {
|
|
28
|
-
return { params: null, error: 'Missing state parameter' };
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
params: {
|
|
32
|
-
clientId,
|
|
33
|
-
redirectUri,
|
|
34
|
-
codeChallenge,
|
|
35
|
-
codeChallengeMethod,
|
|
36
|
-
state,
|
|
37
|
-
responseType,
|
|
38
|
-
},
|
|
39
|
-
error: null,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
fetchState: 'Not-Started',
|
|
4
|
-
error: undefined,
|
|
5
|
-
approveRedirectUrl: undefined,
|
|
6
|
-
};
|
|
7
|
-
const zeniOAuthView = createSlice({
|
|
8
|
-
name: 'zeniOAuthView',
|
|
9
|
-
initialState,
|
|
10
|
-
reducers: {
|
|
11
|
-
approveOAuthConsent: {
|
|
12
|
-
prepare(userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType) {
|
|
13
|
-
return {
|
|
14
|
-
payload: {
|
|
15
|
-
userId,
|
|
16
|
-
zeniSessionId,
|
|
17
|
-
tenantId,
|
|
18
|
-
clientId,
|
|
19
|
-
redirectUri,
|
|
20
|
-
codeChallenge,
|
|
21
|
-
codeChallengeMethod,
|
|
22
|
-
state,
|
|
23
|
-
responseType,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
reducer(draft) {
|
|
28
|
-
draft.fetchState = 'In-Progress';
|
|
29
|
-
draft.error = undefined;
|
|
30
|
-
draft.approveRedirectUrl = undefined;
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
approveOAuthConsentSuccess(draft, action) {
|
|
34
|
-
draft.fetchState = 'Completed';
|
|
35
|
-
draft.error = undefined;
|
|
36
|
-
draft.approveRedirectUrl = action.payload.redirectUrl;
|
|
37
|
-
},
|
|
38
|
-
approveOAuthConsentFailure(draft, action) {
|
|
39
|
-
draft.fetchState = 'Error';
|
|
40
|
-
draft.error = action.payload;
|
|
41
|
-
draft.approveRedirectUrl = undefined;
|
|
42
|
-
},
|
|
43
|
-
clearZeniOAuthView() {
|
|
44
|
-
return initialState;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
export const { approveOAuthConsent, approveOAuthConsentSuccess, approveOAuthConsentFailure, clearZeniOAuthView, } = zeniOAuthView.actions;
|
|
49
|
-
export default zeniOAuthView.reducer;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export const getZeniOAuthApproveFetchState = (state) => state.zeniOAuthViewState.fetchState;
|
|
2
|
-
export const getZeniOAuthApproveRedirectUrl = (state) => state.zeniOAuthViewState.approveRedirectUrl;
|
|
3
|
-
export const getZeniOAuthApproveError = (state) => state.zeniOAuthViewState.error?.message ?? null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FetchState, ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
3
|
-
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
-
export interface CannedResponse {
|
|
5
|
-
cannedResponseId: ID;
|
|
6
|
-
content: string;
|
|
7
|
-
createdBy: ID;
|
|
8
|
-
createTime: ZeniDate;
|
|
9
|
-
isDeleted: boolean;
|
|
10
|
-
name: string;
|
|
11
|
-
updateTime: ZeniDate;
|
|
12
|
-
}
|
|
13
|
-
export interface CannedResponsesViewState {
|
|
14
|
-
cannedResponses: CannedResponse[];
|
|
15
|
-
deleteFetchState: FetchState;
|
|
16
|
-
fetchState: FetchState;
|
|
17
|
-
saveFetchState: FetchState;
|
|
18
|
-
error?: ZeniAPIStatus;
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
2
|
-
import { CannedResponse } from './cannedResponses';
|
|
3
|
-
export interface CannedResponsePayload {
|
|
4
|
-
canned_response_id: string;
|
|
5
|
-
content: string;
|
|
6
|
-
create_time: string;
|
|
7
|
-
created_by: string;
|
|
8
|
-
is_deleted: boolean;
|
|
9
|
-
name: string;
|
|
10
|
-
update_time: string;
|
|
11
|
-
}
|
|
12
|
-
interface FetchCannedResponsesPayload {
|
|
13
|
-
canned_responses: CannedResponsePayload[];
|
|
14
|
-
}
|
|
15
|
-
export type FetchCannedResponsesResponse = ZeniAPIResponse<FetchCannedResponsesPayload>;
|
|
16
|
-
export type SaveCannedResponseResponse = ZeniAPIResponse<{
|
|
17
|
-
canned_response: CannedResponsePayload;
|
|
18
|
-
}>;
|
|
19
|
-
export type DeleteCannedResponseResponse = ZeniAPIResponse<unknown>;
|
|
20
|
-
export declare function mapCannedResponsePayloadToCannedResponse(payload: CannedResponsePayload): CannedResponse;
|
|
21
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapCannedResponsePayloadToCannedResponse = mapCannedResponsePayloadToCannedResponse;
|
|
4
|
-
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
|
-
function mapCannedResponsePayloadToCannedResponse(payload) {
|
|
6
|
-
return {
|
|
7
|
-
cannedResponseId: payload.canned_response_id,
|
|
8
|
-
content: payload.content,
|
|
9
|
-
createTime: (0, zeniDayJS_1.date)(payload.create_time),
|
|
10
|
-
createdBy: payload.created_by,
|
|
11
|
-
isDeleted: payload.is_deleted,
|
|
12
|
-
name: payload.name,
|
|
13
|
-
updateTime: (0, zeniDayJS_1.date)(payload.update_time),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FetchState, ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
3
|
-
import { CannedResponse, CannedResponsesViewState } from './cannedResponses';
|
|
4
|
-
export declare const initialState: CannedResponsesViewState;
|
|
5
|
-
export declare const fetchCannedResponses: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cannedResponsesView/fetchCannedResponses">, updateCannedResponses: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
6
|
-
cannedResponses: CannedResponse[];
|
|
7
|
-
}, "cannedResponsesView/updateCannedResponses">, updateCannedResponsesFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
8
|
-
fetchState: FetchState;
|
|
9
|
-
error?: ZeniAPIStatus;
|
|
10
|
-
}, "cannedResponsesView/updateCannedResponsesFetchStatus">, saveCannedResponse: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
|
|
11
|
-
content: string;
|
|
12
|
-
name: string;
|
|
13
|
-
cannedResponseId?: ID;
|
|
14
|
-
}], {
|
|
15
|
-
content: string;
|
|
16
|
-
name: string;
|
|
17
|
-
cannedResponseId?: ID;
|
|
18
|
-
}, "cannedResponsesView/saveCannedResponse", never, never>, saveCannedResponseSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cannedResponsesView/saveCannedResponseSuccess">, saveCannedResponseFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
19
|
-
error?: ZeniAPIStatus;
|
|
20
|
-
}, "cannedResponsesView/saveCannedResponseFailure">, deleteCannedResponse: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: {
|
|
21
|
-
cannedResponseId: ID;
|
|
22
|
-
}], {
|
|
23
|
-
cannedResponseId: ID;
|
|
24
|
-
}, "cannedResponsesView/deleteCannedResponse", never, never>, deleteCannedResponseSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
25
|
-
cannedResponseId: ID;
|
|
26
|
-
}, "cannedResponsesView/deleteCannedResponseSuccess">, deleteCannedResponseFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
27
|
-
error?: ZeniAPIStatus;
|
|
28
|
-
}, "cannedResponsesView/deleteCannedResponseFailure">, clearCannedResponses: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cannedResponsesView/clearCannedResponses">;
|
|
29
|
-
declare const _default: import("redux").Reducer<CannedResponsesViewState>;
|
|
30
|
-
export default _default;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearCannedResponses = exports.deleteCannedResponseFailure = exports.deleteCannedResponseSuccess = exports.deleteCannedResponse = exports.saveCannedResponseFailure = exports.saveCannedResponseSuccess = exports.saveCannedResponse = exports.updateCannedResponsesFetchStatus = exports.updateCannedResponses = exports.fetchCannedResponses = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialState = {
|
|
7
|
-
cannedResponses: [],
|
|
8
|
-
fetchState: 'Not-Started',
|
|
9
|
-
saveFetchState: 'Not-Started',
|
|
10
|
-
deleteFetchState: 'Not-Started',
|
|
11
|
-
error: undefined,
|
|
12
|
-
};
|
|
13
|
-
const cannedResponsesView = (0, toolkit_1.createSlice)({
|
|
14
|
-
name: 'cannedResponsesView',
|
|
15
|
-
initialState: exports.initialState,
|
|
16
|
-
reducers: {
|
|
17
|
-
fetchCannedResponses(draft) {
|
|
18
|
-
draft.fetchState =
|
|
19
|
-
draft.cannedResponses.length > 0 ? 'Completed' : 'In-Progress';
|
|
20
|
-
draft.error = undefined;
|
|
21
|
-
},
|
|
22
|
-
updateCannedResponses(draft, action) {
|
|
23
|
-
draft.cannedResponses = action.payload.cannedResponses;
|
|
24
|
-
draft.fetchState = 'Completed';
|
|
25
|
-
draft.error = undefined;
|
|
26
|
-
},
|
|
27
|
-
updateCannedResponsesFetchStatus(draft, action) {
|
|
28
|
-
draft.fetchState = action.payload.fetchState;
|
|
29
|
-
draft.error = action.payload.error;
|
|
30
|
-
},
|
|
31
|
-
saveCannedResponse: {
|
|
32
|
-
reducer(draft) {
|
|
33
|
-
draft.saveFetchState = 'In-Progress';
|
|
34
|
-
},
|
|
35
|
-
prepare(payload) {
|
|
36
|
-
return { payload };
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
saveCannedResponseSuccess(draft) {
|
|
40
|
-
draft.saveFetchState = 'Completed';
|
|
41
|
-
},
|
|
42
|
-
saveCannedResponseFailure(draft, action) {
|
|
43
|
-
draft.saveFetchState = 'Error';
|
|
44
|
-
draft.error = action.payload.error;
|
|
45
|
-
},
|
|
46
|
-
deleteCannedResponse: {
|
|
47
|
-
reducer(draft) {
|
|
48
|
-
draft.deleteFetchState = 'In-Progress';
|
|
49
|
-
},
|
|
50
|
-
prepare(payload) {
|
|
51
|
-
return { payload };
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
deleteCannedResponseSuccess(draft, action) {
|
|
55
|
-
draft.deleteFetchState = 'Completed';
|
|
56
|
-
draft.cannedResponses = draft.cannedResponses.filter((r) => r.cannedResponseId !== action.payload.cannedResponseId);
|
|
57
|
-
},
|
|
58
|
-
deleteCannedResponseFailure(draft, action) {
|
|
59
|
-
draft.deleteFetchState = 'Error';
|
|
60
|
-
draft.error = action.payload.error;
|
|
61
|
-
},
|
|
62
|
-
clearCannedResponses() {
|
|
63
|
-
return exports.initialState;
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
_a = cannedResponsesView.actions, exports.fetchCannedResponses = _a.fetchCannedResponses, exports.updateCannedResponses = _a.updateCannedResponses, exports.updateCannedResponsesFetchStatus = _a.updateCannedResponsesFetchStatus, exports.saveCannedResponse = _a.saveCannedResponse, exports.saveCannedResponseSuccess = _a.saveCannedResponseSuccess, exports.saveCannedResponseFailure = _a.saveCannedResponseFailure, exports.deleteCannedResponse = _a.deleteCannedResponse, exports.deleteCannedResponseSuccess = _a.deleteCannedResponseSuccess, exports.deleteCannedResponseFailure = _a.deleteCannedResponseFailure, exports.clearCannedResponses = _a.clearCannedResponses;
|
|
68
|
-
exports.default = cannedResponsesView.reducer;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../../../reducer';
|
|
4
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
-
import { deleteCannedResponse, deleteCannedResponseFailure, deleteCannedResponseSuccess } from '../cannedResponsesReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof deleteCannedResponse> | ReturnType<typeof deleteCannedResponseSuccess> | ReturnType<typeof deleteCannedResponseFailure>;
|
|
7
|
-
export declare const deleteCannedResponseEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteCannedResponseEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
-
const cannedResponsesReducer_1 = require("../cannedResponsesReducer");
|
|
8
|
-
const deleteCannedResponseEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cannedResponsesReducer_1.deleteCannedResponse.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
-
const { cannedResponseId } = action.payload;
|
|
10
|
-
return zeniAPI
|
|
11
|
-
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${cannedResponseId}`)
|
|
12
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
13
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
14
|
-
return (0, rxjs_1.of)((0, cannedResponsesReducer_1.deleteCannedResponseSuccess)({ cannedResponseId }));
|
|
15
|
-
}
|
|
16
|
-
return (0, rxjs_1.of)((0, cannedResponsesReducer_1.deleteCannedResponseFailure)({ error: response.status }));
|
|
17
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cannedResponsesReducer_1.deleteCannedResponseFailure)({
|
|
18
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Delete Canned Response errored: ' + JSON.stringify(error)),
|
|
19
|
-
}))));
|
|
20
|
-
}));
|
|
21
|
-
exports.deleteCannedResponseEpic = deleteCannedResponseEpic;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../../../reducer';
|
|
4
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
-
import { fetchCannedResponses, updateCannedResponses, updateCannedResponsesFetchStatus } from '../cannedResponsesReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchCannedResponses> | ReturnType<typeof updateCannedResponses> | ReturnType<typeof updateCannedResponsesFetchStatus>;
|
|
7
|
-
export declare const fetchCannedResponsesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|