@zeniai/client-epic-state 5.0.87-betaJK2 → 5.0.87-betaVR1

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.
Files changed (40) hide show
  1. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  2. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  3. package/lib/entity/task/taskPayload.d.ts +0 -1
  4. package/lib/entity/task/taskPayload.js +0 -1
  5. package/lib/entity/task/taskReducer.d.ts +1 -5
  6. package/lib/entity/task/taskReducer.js +2 -8
  7. package/lib/entity/task/taskState.d.ts +0 -1
  8. package/lib/entity/transaction/stateTypes/transactionLine.d.ts +2 -1
  9. package/lib/entity/transaction/stateTypes/transactionLine.js +2 -1
  10. package/lib/epic.d.ts +1 -3
  11. package/lib/epic.js +1 -3
  12. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  13. package/lib/esm/entity/task/taskPayload.js +0 -1
  14. package/lib/esm/entity/task/taskReducer.js +1 -7
  15. package/lib/esm/entity/transaction/stateTypes/transactionLine.js +1 -0
  16. package/lib/esm/epic.js +1 -3
  17. package/lib/esm/index.js +5 -3
  18. package/lib/esm/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +0 -13
  19. package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +2 -51
  20. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +8 -19
  21. package/lib/esm/view/transactionDetail/journalEntryLinesViewModel.js +149 -0
  22. package/lib/index.d.ts +7 -4
  23. package/lib/index.js +25 -19
  24. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  25. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.d.ts +1 -2
  26. package/lib/view/taskManager/taskDetailView/epics/fetchTaskDetailEpic.js +0 -13
  27. package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -13
  28. package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +2 -14
  29. package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +3 -52
  30. package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +1 -2
  31. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +6 -17
  32. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +102 -0
  33. package/lib/view/transactionDetail/journalEntryLinesViewModel.js +160 -0
  34. package/package.json +1 -1
  35. package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -80
  36. package/lib/esm/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -36
  37. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +0 -9
  38. package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -84
  39. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.d.ts +0 -8
  40. package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -40
@@ -0,0 +1,102 @@
1
+ import { Amount } from '../../commonStateTypes/amount';
2
+ import { SortOrder } from '../../commonStateTypes/selectorTypes/sortOrderTypes';
3
+ import { JournalEntryTransactionLine, Line, TransactionLineBase } from '../../entity/transaction/stateTypes/transactionLine';
4
+ /**
5
+ * View-model helpers for the new Journal Entry table view (see
6
+ * web-components `journalEntryTable`). Keeps presentation-agnostic
7
+ * logic — totals, sort, line-filter — colocated in epic-state so it
8
+ * is testable and reusable.
9
+ */
10
+ export declare const JOURNAL_ENTRY_SORT_KEYS: readonly ["description", "name", "category", "class", "debit", "credit"];
11
+ export declare const toJournalEntrySortKey: (v: string) => "name" | "description" | "category" | "class" | "credit" | "debit";
12
+ export type JournalEntrySortKey = ReturnType<typeof toJournalEntrySortKey>;
13
+ export interface JournalEntryRowSortConfig {
14
+ sortKey: JournalEntrySortKey;
15
+ sortOrder: SortOrder;
16
+ }
17
+ export declare const journalEntryDefaultSortConfig: JournalEntryRowSortConfig;
18
+ type AmountBearer = Pick<TransactionLineBase, 'amount'>;
19
+ /**
20
+ * Sums the `amount.amount` field of every line and returns an `Amount`
21
+ * whose currencyCode/currencySymbol are taken from the first line.
22
+ * Returns `undefined` for an empty list, and also when the first line
23
+ * has no currency to carry — a stray bare number with no symbol is
24
+ * worse to render than nothing, so the caller is forced to handle the
25
+ * absence.
26
+ *
27
+ * **Precondition:** all input lines must share a currency. Journal
28
+ * entry lines on the same transaction always do, which is the only
29
+ * caller today. Mixed-currency input is summed numerically (no FX
30
+ * conversion) and tagged with the first line's currency, which will
31
+ * silently produce a wrong total — if this helper is ever reused for
32
+ * a cross-currency aggregate (e.g. a multi-transaction report), the
33
+ * caller must pre-group by currency before calling.
34
+ *
35
+ * Mirrors legacy `calculateTotal` in
36
+ * `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
37
+ * but without the `Object.assign` ceremony and with stable currency carry-over.
38
+ */
39
+ export declare const sumJournalEntryAmounts: (lines: ReadonlyArray<AmountBearer>) => Amount | undefined;
40
+ /**
41
+ * Splits `lines` by `postingType` into a single debit total and a
42
+ * single credit total — the shape the new flat-table totals row
43
+ * (`JournalEntryTotalsRow` in `web-components`, Figma frame
44
+ * `5177:12750`) needs.
45
+ *
46
+ * The legacy `TransactionLinesJournalEntry` grouped lines into six
47
+ * `JournalEntryItemType` buckets (`debit` / `uncategorizedDebit` /
48
+ * `miscategorizedDebit` plus the credit triplet) for *visual banner
49
+ * headers* in the line list; its bottom totals row was already two
50
+ * combined numbers. The new flat table folds those banners away by
51
+ * design, so we don't surface a per-status breakdown here. If the
52
+ * design ever asks for sub-totals per status, that's a richer shape
53
+ * (`{debit: {total, uncategorized, miscategorized}, credit: {…}}`)
54
+ * and a follow-up — not a v1 of this helper.
55
+ *
56
+ * As a side effect, the legacy `calculateCombinedTotalAmount`
57
+ * `??`/`+` precedence bug (`totalAmount?.amount ?? 0 + (uncat ?? 0) +
58
+ * (miscat ?? 0)` parses as `totalAmount?.amount ?? (0 + uncat +
59
+ * miscat)`, silently dropping the uncat/miscat pieces whenever
60
+ * `totalAmount` was non-nullish) is gone by construction here: there
61
+ * is no separate combine step, just one pass over the lines.
62
+ */
63
+ export declare const journalEntryTotalsByPostingSide: (lines: ReadonlyArray<Pick<JournalEntryTransactionLine, "amount" | "postingType">>) => {
64
+ creditTotal?: Amount;
65
+ debitTotal?: Amount;
66
+ };
67
+ /**
68
+ * Drops `linked_transaction_line` entries — equivalent to legacy
69
+ * `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
70
+ *
71
+ * The literal lives in `LINE_TYPE_LINKED` next to `LineType` so the
72
+ * filter discriminant stays bound to the union at the type level.
73
+ * Other sites still inlining the literal (see `transactionDetailLocalDataHelper`,
74
+ * `transactionDetailState`, `transactionCategorizationLocalDataHelper`,
75
+ * `transactionLinePayload`, and the mocks) are a known follow-up.
76
+ */
77
+ export declare const filterJournalEntryLinesExcludingLinked: <T extends Pick<Line, "type">>(lines?: ReadonlyArray<T>) => T[];
78
+ /**
79
+ * Accessor functions resolve the sort value for each column from a
80
+ * line. The new table reads display-formatted values from the form
81
+ * (selected option label, entity name, etc.), so callers pass in
82
+ * accessors that match their `LineInfo` shape rather than baking the
83
+ * column-to-form-field mapping into epic-state.
84
+ */
85
+ export interface JournalEntrySortAccessors<T> {
86
+ category: (line: T) => string;
87
+ class: (line: T) => string;
88
+ credit: (line: T) => number;
89
+ debit: (line: T) => number;
90
+ description: (line: T) => string;
91
+ name: (line: T) => string;
92
+ }
93
+ /**
94
+ * Stable, accessor-driven sort over arbitrary line shapes. Lines that
95
+ * resolve to the same key value preserve their original relative order
96
+ * thanks to lodash's stable `orderBy`.
97
+ *
98
+ * Strings are lower-cased before comparison so the order is predictable
99
+ * across mixed-case data. Numbers (debit/credit) compare directly.
100
+ */
101
+ export declare const sortJournalEntryLines: <T>(lines: ReadonlyArray<T>, config: JournalEntryRowSortConfig, accessors: JournalEntrySortAccessors<T>) => T[];
102
+ export {};
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.sortJournalEntryLines = exports.filterJournalEntryLinesExcludingLinked = exports.journalEntryTotalsByPostingSide = exports.sumJournalEntryAmounts = exports.journalEntryDefaultSortConfig = exports.toJournalEntrySortKey = exports.JOURNAL_ENTRY_SORT_KEYS = void 0;
7
+ const orderBy_1 = __importDefault(require("lodash/orderBy"));
8
+ const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
9
+ const transactionLine_1 = require("../../entity/transaction/stateTypes/transactionLine");
10
+ /**
11
+ * View-model helpers for the new Journal Entry table view (see
12
+ * web-components `journalEntryTable`). Keeps presentation-agnostic
13
+ * logic — totals, sort, line-filter — colocated in epic-state so it
14
+ * is testable and reusable.
15
+ */
16
+ // ---------------------------------------------------------------------------
17
+ // Sort keys
18
+ // ---------------------------------------------------------------------------
19
+ exports.JOURNAL_ENTRY_SORT_KEYS = [
20
+ 'description',
21
+ 'name',
22
+ 'category',
23
+ 'class',
24
+ 'debit',
25
+ 'credit',
26
+ ];
27
+ const toJournalEntrySortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.JOURNAL_ENTRY_SORT_KEYS);
28
+ exports.toJournalEntrySortKey = toJournalEntrySortKey;
29
+ exports.journalEntryDefaultSortConfig = {
30
+ sortKey: 'description',
31
+ sortOrder: 'ascending',
32
+ };
33
+ /**
34
+ * Sums the `amount.amount` field of every line and returns an `Amount`
35
+ * whose currencyCode/currencySymbol are taken from the first line.
36
+ * Returns `undefined` for an empty list, and also when the first line
37
+ * has no currency to carry — a stray bare number with no symbol is
38
+ * worse to render than nothing, so the caller is forced to handle the
39
+ * absence.
40
+ *
41
+ * **Precondition:** all input lines must share a currency. Journal
42
+ * entry lines on the same transaction always do, which is the only
43
+ * caller today. Mixed-currency input is summed numerically (no FX
44
+ * conversion) and tagged with the first line's currency, which will
45
+ * silently produce a wrong total — if this helper is ever reused for
46
+ * a cross-currency aggregate (e.g. a multi-transaction report), the
47
+ * caller must pre-group by currency before calling.
48
+ *
49
+ * Mirrors legacy `calculateTotal` in
50
+ * `web-components/src/components/transactionDetail/items/TransactionLinesJournalEntry.tsx`
51
+ * but without the `Object.assign` ceremony and with stable currency carry-over.
52
+ */
53
+ const sumJournalEntryAmounts = (lines) => {
54
+ if (lines.length === 0) {
55
+ return undefined;
56
+ }
57
+ const first = lines[0].amount;
58
+ if (first?.currencyCode == null || first?.currencySymbol == null) {
59
+ return undefined;
60
+ }
61
+ let total = 0;
62
+ for (const line of lines) {
63
+ total += line.amount?.amount ?? 0;
64
+ }
65
+ return {
66
+ amount: total,
67
+ currencyCode: first.currencyCode,
68
+ currencySymbol: first.currencySymbol,
69
+ };
70
+ };
71
+ exports.sumJournalEntryAmounts = sumJournalEntryAmounts;
72
+ /**
73
+ * Splits `lines` by `postingType` into a single debit total and a
74
+ * single credit total — the shape the new flat-table totals row
75
+ * (`JournalEntryTotalsRow` in `web-components`, Figma frame
76
+ * `5177:12750`) needs.
77
+ *
78
+ * The legacy `TransactionLinesJournalEntry` grouped lines into six
79
+ * `JournalEntryItemType` buckets (`debit` / `uncategorizedDebit` /
80
+ * `miscategorizedDebit` plus the credit triplet) for *visual banner
81
+ * headers* in the line list; its bottom totals row was already two
82
+ * combined numbers. The new flat table folds those banners away by
83
+ * design, so we don't surface a per-status breakdown here. If the
84
+ * design ever asks for sub-totals per status, that's a richer shape
85
+ * (`{debit: {total, uncategorized, miscategorized}, credit: {…}}`)
86
+ * and a follow-up — not a v1 of this helper.
87
+ *
88
+ * As a side effect, the legacy `calculateCombinedTotalAmount`
89
+ * `??`/`+` precedence bug (`totalAmount?.amount ?? 0 + (uncat ?? 0) +
90
+ * (miscat ?? 0)` parses as `totalAmount?.amount ?? (0 + uncat +
91
+ * miscat)`, silently dropping the uncat/miscat pieces whenever
92
+ * `totalAmount` was non-nullish) is gone by construction here: there
93
+ * is no separate combine step, just one pass over the lines.
94
+ */
95
+ const journalEntryTotalsByPostingSide = (lines) => {
96
+ const debitLines = [];
97
+ const creditLines = [];
98
+ for (const line of lines) {
99
+ if (line.postingType === 'debit') {
100
+ debitLines.push(line);
101
+ }
102
+ else if (line.postingType === 'credit') {
103
+ creditLines.push(line);
104
+ }
105
+ }
106
+ return {
107
+ debitTotal: (0, exports.sumJournalEntryAmounts)(debitLines),
108
+ creditTotal: (0, exports.sumJournalEntryAmounts)(creditLines),
109
+ };
110
+ };
111
+ exports.journalEntryTotalsByPostingSide = journalEntryTotalsByPostingSide;
112
+ // ---------------------------------------------------------------------------
113
+ // Filter
114
+ // ---------------------------------------------------------------------------
115
+ /**
116
+ * Drops `linked_transaction_line` entries — equivalent to legacy
117
+ * `filterOutLinkedTransactionLine` in `transactionDetail.helpers.ts`.
118
+ *
119
+ * The literal lives in `LINE_TYPE_LINKED` next to `LineType` so the
120
+ * filter discriminant stays bound to the union at the type level.
121
+ * Other sites still inlining the literal (see `transactionDetailLocalDataHelper`,
122
+ * `transactionDetailState`, `transactionCategorizationLocalDataHelper`,
123
+ * `transactionLinePayload`, and the mocks) are a known follow-up.
124
+ */
125
+ const filterJournalEntryLinesExcludingLinked = (lines) => lines?.filter((line) => line.type !== transactionLine_1.LINE_TYPE_LINKED) ?? [];
126
+ exports.filterJournalEntryLinesExcludingLinked = filterJournalEntryLinesExcludingLinked;
127
+ const sortOrderToLodash = (sortOrder) => sortOrder === 'descending' ? 'desc' : 'asc';
128
+ /**
129
+ * Stable, accessor-driven sort over arbitrary line shapes. Lines that
130
+ * resolve to the same key value preserve their original relative order
131
+ * thanks to lodash's stable `orderBy`.
132
+ *
133
+ * Strings are lower-cased before comparison so the order is predictable
134
+ * across mixed-case data. Numbers (debit/credit) compare directly.
135
+ */
136
+ const sortJournalEntryLines = (lines, config, accessors) => {
137
+ const accessor = (line) => {
138
+ switch (config.sortKey) {
139
+ case 'description':
140
+ return accessors.description(line).toLowerCase();
141
+ case 'name':
142
+ return accessors.name(line).toLowerCase();
143
+ case 'category':
144
+ return accessors.category(line).toLowerCase();
145
+ case 'class':
146
+ return accessors.class(line).toLowerCase();
147
+ case 'debit':
148
+ return accessors.debit(line);
149
+ case 'credit':
150
+ return accessors.credit(line);
151
+ default:
152
+ // stringToUnion narrows permissively (returns `s as StringUnion` for
153
+ // non-member input, see commonStateTypes/stringToUnion.ts), so this
154
+ // branch is reachable at runtime — keep it as a description fallback.
155
+ return accessors.description(line).toLowerCase();
156
+ }
157
+ };
158
+ return (0, orderBy_1.default)([...lines], [accessor], [sortOrderToLodash(config.sortOrder)]);
159
+ };
160
+ exports.sortJournalEntryLines = sortJournalEntryLines;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.87-betaJK2",
3
+ "version": "5.0.87-betaVR1",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,80 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap } from 'rxjs/operators';
3
- import { convertHHMMStrToMinutes } from '../../../../commonStateTypes/fiscalYearHelpers/formatMinutesToFromHHMM';
4
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
5
- import { appendSubTaskId, updateTasks, } from '../../../../entity/task/taskReducer';
6
- import { getTaskById } from '../../../../entity/task/taskSelector';
7
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
8
- import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
9
- import { createSubTask, createSubTaskSuccessOrFailure, } from '../taskDetailReducer';
10
- export const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(createSubTask.match), mergeMap((action) => {
11
- const state = state$.value;
12
- const parentTask = getTaskById(state.taskState, action.payload.parentTaskId);
13
- const parentTaskGroupId = parentTask?.taskGroupIds[0];
14
- const isTaskListFetched = state.taskListState.fetchState === 'Completed';
15
- const payload = prepareSubTaskPayload(action.payload, parentTaskGroupId);
16
- return zeniAPI
17
- .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
18
- .pipe(mergeMap((response) => {
19
- if (isSuccessResponse(response) &&
20
- response.data != null &&
21
- response.data.tasks.length > 0) {
22
- const newTaskId = response.data.tasks[0].task_id;
23
- const actions = [
24
- updateTasks(response.data.tasks),
25
- appendSubTaskId({
26
- parentTaskId: action.payload.parentTaskId,
27
- subTaskId: newTaskId,
28
- }),
29
- createSubTaskSuccessOrFailure({
30
- fetchState: 'Completed',
31
- newTaskId,
32
- }),
33
- openSnackbar({
34
- messageSection: 'create_sub_task',
35
- messageText: 'success',
36
- type: 'success',
37
- }),
38
- ];
39
- if (isTaskListFetched === true && parentTaskGroupId != null) {
40
- actions.push(updateTaskListOnNewTaskCreationSuccess({
41
- taskGroupId: parentTaskGroupId,
42
- task: response.data.tasks[0],
43
- }));
44
- }
45
- return from(actions);
46
- }
47
- else {
48
- return of(createSubTaskSuccessOrFailure({
49
- fetchState: 'Error',
50
- error: response.status,
51
- }), openSnackbar({
52
- messageSection: 'create_sub_task',
53
- messageText: 'failed',
54
- type: 'error',
55
- variables: [
56
- {
57
- variableName: '_api-error_',
58
- variableValue: response.status.message,
59
- },
60
- ],
61
- }));
62
- }
63
- }), catchError((error) => of(createSubTaskSuccessOrFailure({
64
- fetchState: 'Error',
65
- error: createZeniAPIStatus('Unexpected Error', 'Create Sub Task REST API call errored out' +
66
- JSON.stringify(error)),
67
- }))));
68
- }));
69
- const prepareSubTaskPayload = (subTask, parentTaskGroupId) => ({
70
- name: subTask.name,
71
- assignees: subTask.assignee,
72
- description: subTask.description,
73
- priority: subTask.priority,
74
- status: subTask.status,
75
- tags: subTask.tagIds,
76
- time_spent: convertHHMMStrToMinutes(subTask.timeSpent),
77
- group_assignees: subTask.groupAssignees,
78
- parent_task_id: subTask.parentTaskId,
79
- task_group_ids: parentTaskGroupId == null ? [] : [parentTaskGroupId],
80
- });
@@ -1,36 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateTasks } from '../../../../entity/task/taskReducer';
4
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
- import { fetchSubTasks, updateSubTasks, updateSubTasksFetchStatus, } from '../taskDetailReducer';
6
- export const fetchSubTasksEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchSubTasks.match), switchMap((action) => {
7
- const { parentTaskId } = action.payload;
8
- const query = JSON.stringify({
9
- task_type: 'subtasks',
10
- parent_task_id: parentTaskId,
11
- });
12
- return zeniAPI
13
- .getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(query)}`)
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response) && response.data != null) {
16
- const { tasks } = response.data;
17
- return of(updateTasks(tasks), updateSubTasks({
18
- parentTaskId,
19
- }));
20
- }
21
- else {
22
- return of(updateSubTasksFetchStatus({
23
- parentTaskId,
24
- fetchState: 'Error',
25
- error: response.status,
26
- }));
27
- }
28
- }), catchError((error) => {
29
- return of(updateSubTasksFetchStatus({
30
- parentTaskId,
31
- fetchState: 'Error',
32
- error: createZeniAPIStatus('Unexpected Error', 'Fetch Sub Tasks REST API call errored out' +
33
- JSON.stringify(error)),
34
- }));
35
- }));
36
- }));
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
3
- import { appendSubTaskId, updateTasks } from '../../../../entity/task/taskReducer';
4
- import { RootState } from '../../../../reducer';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
7
- import { createSubTask, createSubTaskSuccessOrFailure } from '../taskDetailReducer';
8
- export type ActionType = ReturnType<typeof createSubTask> | ReturnType<typeof updateTasks> | ReturnType<typeof appendSubTaskId> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateTaskListOnNewTaskCreationSuccess> | ReturnType<typeof createSubTaskSuccessOrFailure>;
9
- export declare const createSubTaskEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSubTaskEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const formatMinutesToFromHHMM_1 = require("../../../../commonStateTypes/fiscalYearHelpers/formatMinutesToFromHHMM");
7
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
8
- const taskReducer_1 = require("../../../../entity/task/taskReducer");
9
- const taskSelector_1 = require("../../../../entity/task/taskSelector");
10
- const responsePayload_1 = require("../../../../responsePayload");
11
- const taskListReducer_1 = require("../../taskListView/taskListReducer");
12
- const taskDetailReducer_1 = require("../taskDetailReducer");
13
- const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskDetailReducer_1.createSubTask.match), (0, operators_1.mergeMap)((action) => {
14
- const state = state$.value;
15
- const parentTask = (0, taskSelector_1.getTaskById)(state.taskState, action.payload.parentTaskId);
16
- const parentTaskGroupId = parentTask?.taskGroupIds[0];
17
- const isTaskListFetched = state.taskListState.fetchState === 'Completed';
18
- const payload = prepareSubTaskPayload(action.payload, parentTaskGroupId);
19
- return zeniAPI
20
- .postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
21
- .pipe((0, operators_1.mergeMap)((response) => {
22
- if ((0, responsePayload_1.isSuccessResponse)(response) &&
23
- response.data != null &&
24
- response.data.tasks.length > 0) {
25
- const newTaskId = response.data.tasks[0].task_id;
26
- const actions = [
27
- (0, taskReducer_1.updateTasks)(response.data.tasks),
28
- (0, taskReducer_1.appendSubTaskId)({
29
- parentTaskId: action.payload.parentTaskId,
30
- subTaskId: newTaskId,
31
- }),
32
- (0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
33
- fetchState: 'Completed',
34
- newTaskId,
35
- }),
36
- (0, snackbarReducer_1.openSnackbar)({
37
- messageSection: 'create_sub_task',
38
- messageText: 'success',
39
- type: 'success',
40
- }),
41
- ];
42
- if (isTaskListFetched === true && parentTaskGroupId != null) {
43
- actions.push((0, taskListReducer_1.updateTaskListOnNewTaskCreationSuccess)({
44
- taskGroupId: parentTaskGroupId,
45
- task: response.data.tasks[0],
46
- }));
47
- }
48
- return (0, rxjs_1.from)(actions);
49
- }
50
- else {
51
- return (0, rxjs_1.of)((0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
52
- fetchState: 'Error',
53
- error: response.status,
54
- }), (0, snackbarReducer_1.openSnackbar)({
55
- messageSection: 'create_sub_task',
56
- messageText: 'failed',
57
- type: 'error',
58
- variables: [
59
- {
60
- variableName: '_api-error_',
61
- variableValue: response.status.message,
62
- },
63
- ],
64
- }));
65
- }
66
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
67
- fetchState: 'Error',
68
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create Sub Task REST API call errored out' +
69
- JSON.stringify(error)),
70
- }))));
71
- }));
72
- exports.createSubTaskEpic = createSubTaskEpic;
73
- const prepareSubTaskPayload = (subTask, parentTaskGroupId) => ({
74
- name: subTask.name,
75
- assignees: subTask.assignee,
76
- description: subTask.description,
77
- priority: subTask.priority,
78
- status: subTask.status,
79
- tags: subTask.tagIds,
80
- time_spent: (0, formatMinutesToFromHHMM_1.convertHHMMStrToMinutes)(subTask.timeSpent),
81
- group_assignees: subTask.groupAssignees,
82
- parent_task_id: subTask.parentTaskId,
83
- task_group_ids: parentTaskGroupId == null ? [] : [parentTaskGroupId],
84
- });
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateTasks } from '../../../../entity/task/taskReducer';
4
- import { RootState } from '../../../../reducer';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { fetchSubTasks, updateSubTasks, updateSubTasksFetchStatus } from '../taskDetailReducer';
7
- export type ActionType = ReturnType<typeof fetchSubTasks> | ReturnType<typeof updateTasks> | ReturnType<typeof updateSubTasks> | ReturnType<typeof updateSubTasksFetchStatus>;
8
- export declare const fetchSubTasksEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchSubTasksEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const taskReducer_1 = require("../../../../entity/task/taskReducer");
7
- const responsePayload_1 = require("../../../../responsePayload");
8
- const taskDetailReducer_1 = require("../taskDetailReducer");
9
- const fetchSubTasksEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskDetailReducer_1.fetchSubTasks.match), (0, operators_1.switchMap)((action) => {
10
- const { parentTaskId } = action.payload;
11
- const query = JSON.stringify({
12
- task_type: 'subtasks',
13
- parent_task_id: parentTaskId,
14
- });
15
- return zeniAPI
16
- .getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(query)}`)
17
- .pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
- const { tasks } = response.data;
20
- return (0, rxjs_1.of)((0, taskReducer_1.updateTasks)(tasks), (0, taskDetailReducer_1.updateSubTasks)({
21
- parentTaskId,
22
- }));
23
- }
24
- else {
25
- return (0, rxjs_1.of)((0, taskDetailReducer_1.updateSubTasksFetchStatus)({
26
- parentTaskId,
27
- fetchState: 'Error',
28
- error: response.status,
29
- }));
30
- }
31
- }), (0, operators_1.catchError)((error) => {
32
- return (0, rxjs_1.of)((0, taskDetailReducer_1.updateSubTasksFetchStatus)({
33
- parentTaskId,
34
- fetchState: 'Error',
35
- error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch Sub Tasks REST API call errored out' +
36
- JSON.stringify(error)),
37
- }));
38
- }));
39
- }));
40
- exports.fetchSubTasksEpic = fetchSubTasksEpic;