Skip to content

Commit

Permalink
CM-139: add core tasks fe (#2)
Browse files Browse the repository at this point in the history
* CM-139: add core tasks fe

* CM-143: fix eslint

* CM-139: add styles

* CM-139: address PR comments

* CM-139: remove intl
  • Loading branch information
jdolkowski authored Jul 6, 2023
1 parent 71d904b commit 4ef4687
Show file tree
Hide file tree
Showing 21 changed files with 367 additions and 576 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@ In development mode, you can use `npm link` and `npm start` to continuously scan

## Main Menu Contributions

**Tasks** (task.menu.tasks key), displayed if user has the right `191001`

## Other Contributions

* `core.Router`: registering `tasks`, `task`, `taskGroups`, `taskGroup`, routes in openIMIS client-side router

## Available Contribution Points

## Dispatched Redux Actions

* `SEARCH_TASK_GROUPS: 'TASK_MANAGEMENT_TASK_GROUPS_{REQ|RESP|ERR}'`
* `GET_TASK_GROUP: 'TASK_MANAGEMENT_TASK_GROUP_{REQ|RESP|ERR}_{REQ|RESP|ERR}'`
* `CREATE_TASK_GROUP: 'TASK_MANAGEMENT_CREATE_TASK_GROUP_{REQ|RESP|ERR}'`
* `UPDATE_TASK_GROUP: 'TASK_MANAGEMENT_UPDATE_TASK_GROUP_{REQ|RESP|ERR}'`
* `DELETE_TASK_GROUP: 'TASK_MANAGEMENT_DELETE_TASK_GROUP_{REQ|RESP|ERR}'`
* `GET_TASK: 'TASK_MANAGEMENT_TASK_{REQ|RESP|ERR}'`
* `UPDATE_TASK: 'TASK_MANAGEMENT_UPDATE_TASK_{REQ|RESP|ERR}'`

## Other Modules Listened Redux Actions
* `state.core.user`, to access user info (rights,...)

## Other Modules Redux State Bindings

Expand Down
30 changes: 15 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import babel from '@rollup/plugin-babel'
import json from '@rollup/plugin-json'
import pkg from './package.json'
import babel from '@rollup/plugin-babel';
import json from '@rollup/plugin-json';
import pkg from './package.json';

export default {
input: 'src/index.js',
output: [
{
file: pkg.module,
format: 'es',
sourcemap: true
sourcemap: true,
},
{
file: 'dist/index.js',
format: 'cjs',
sourcemap: true
}
sourcemap: true,
},
],
external: [
/^@babel.*/,
/^@date-io\/.*/,
/^@material-ui\/.*/,
/^@openimis.*/,
"classnames",
"clsx",
"history",
'classnames',
'clsx',
'history',
/^lodash.*/,
"moment",
"prop-types",
'moment',
'prop-types',
/^react.*/,
/^redux.*/
/^redux.*/,
],
plugins: [
json(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime'
babelHelpers: 'runtime',
}),
]
}
],
};
53 changes: 43 additions & 10 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
graphql,
formatPageQueryWithCount,
formatMutation,
formatGQLString,
decodeId,
formatGQLString,
formatMutation,
formatPageQueryWithCount,
graphql,
graphqlWithVariables,
} from '@openimis/fe-core';
import { ACTION_TYPE, MUTATION_SERVICE } from './reducer';
import {
REQUEST, SUCCESS, ERROR, CLEAR,
CLEAR, ERROR, REQUEST, SUCCESS,
} from './utils/action-type';

const TASK_GROUP_PROJECTION = () => [
Expand All @@ -19,18 +19,37 @@ const TASK_GROUP_PROJECTION = () => [
'taskexecutorSet { edges { node { user { id username lastName } } } }',
];

const TASK_FULL_PROJECTION = () => [
'id',
'entityId',
'source',
'status',
'executorActionEvent',
'businessEvent',
'dateCreated',
'isDeleted',
'taskGroup{id, code, completionPolicy}',
'data',
'currentEntityData',
];

export const formatTaskGroupGQL = (taskGroup) => {
const executors = taskGroup?.executors?.map((executor) => decodeId(executor.id));
const executorsString = executors ? `[${executors.map((executorUuid) => `"${executorUuid}"`).join(', ')}]` : '[]';
const GQLString = `
return `
${taskGroup?.code ? `code: "${formatGQLString(taskGroup.code)}"` : ''}
${taskGroup?.completionPolicy ? `completionPolicy: ${taskGroup.completionPolicy}` : ''}
${taskGroup?.id ? `id: "${decodeId(taskGroup.id)}"` : ''}
${taskGroup?.executors ? `userIds: ${executorsString}` : 'userIds: []'}
`;
return GQLString;
};

export const formatTaskGQL = (task) => `
${task?.id ? `id: "${task.id}"` : ''}
${task?.taskGroup?.id ? 'status: ACCEPTED' : ''}
${task?.taskGroup?.id ? `taskGroupId: "${decodeId(task.taskGroup.id)}"` : ''}
`;

const PERFORM_MUTATION = (mutationType, mutationInput, ACTION, clientMutationLabel) => {
const mutation = formatMutation(mutationType, mutationInput, ACTION);
const requestedDateTime = new Date();
Expand All @@ -51,6 +70,11 @@ export function fetchTaskGroups(modulesManager, params) {
return graphql(payload, ACTION_TYPE.SEARCH_TASK_GROUPS);
}

export function fetchTask(modulesManager, params) {
const payload = formatPageQueryWithCount('task', params, TASK_FULL_PROJECTION());
return graphql(payload, ACTION_TYPE.GET_TASK);
}

export function fetchTaskGroup(modulesManager, variables) {
return graphqlWithVariables(
`
Expand Down Expand Up @@ -84,7 +108,7 @@ export function deleteTaskGroup(taskGroup, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.TASK_GROUP.DELETE,
taskGroupsUuids,
'DELETE_TASK_GROUP',
ACTION_TYPE.DELETE_TASK_GROUP,
clientMutationLabel,
);
}
Expand All @@ -93,7 +117,7 @@ export function createTaskGroup(taskGroup, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.TASK_GROUP.CREATE,
formatTaskGroupGQL(taskGroup),
'CREATE_TASK_GROUP',
ACTION_TYPE.CREATE_TASK_GROUP,
clientMutationLabel,
);
}
Expand All @@ -102,7 +126,16 @@ export function updateTaskGroup(taskGroup, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.TASK_GROUP.UPDATE,
formatTaskGroupGQL(taskGroup),
'UPDATE_TASK_GROUP',
ACTION_TYPE.UPDATE_TASK_GROUP,
clientMutationLabel,
);
}

export function updateTask(task, clientMutationLabel) {
return PERFORM_MUTATION(
MUTATION_SERVICE.TASK.UPDATE,
formatTaskGQL(task),
ACTION_TYPE.UPDATE_TASK,
clientMutationLabel,
);
}
117 changes: 0 additions & 117 deletions src/components/BenefitPlanTasksFilter.js

This file was deleted.

Loading

0 comments on commit 4ef4687

Please sign in to comment.