Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM-406: add user updated #39

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const INDIVIDUAL_FULL_PROJECTION = [
'dob',
'jsonExt',
'version',
'userUpdated {username}',
];

const GROUP_INDIVIDUAL_FULL_PROJECTION = [
Expand All @@ -41,8 +42,13 @@ const GROUP_FULL_PROJECTION = [
'dateUpdated',
'jsonExt',
'version',
'userUpdated {username}',
];

const GROUP_HISTORY_FULL_PROJECTION = GROUP_FULL_PROJECTION.filter(
(item) => item !== 'head {firstName, lastName}',
);

export function fetchIndividuals(params) {
const payload = formatPageQueryWithCount('individual', params, INDIVIDUAL_FULL_PROJECTION);
return graphql(payload, ACTION_TYPE.SEARCH_INDIVIDUALS);
Expand Down Expand Up @@ -74,7 +80,7 @@ export function fetchGroup(params) {
}

export function fetchGroupHistory(params) {
const payload = formatPageQueryWithCount('groupHistory', params, GROUP_FULL_PROJECTION);
const payload = formatPageQueryWithCount('groupHistory', params, GROUP_HISTORY_FULL_PROJECTION);
return graphql(payload, ACTION_TYPE.SEARCH_GROUP_HISTORY);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/GroupHistorySearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ function GroupHistorySearcher({
const fetch = (params) => dispatch(fetchGroupHistory(params));

const headers = () => [
'groupHistory.id',
'groupHistory.head',
'groupHistory.dateUpdated',
'groupHistory.version',
'groupHistory.members',
'groupHistory.userUpdated',
];

const itemFormatters = () => [
(groupHistory) => groupHistory?.id || EMPTY_STRING,
(groupHistory) => {
const jsonExt = groupHistory?.jsonExt ? JSON.parse(groupHistory.jsonExt) : null;
return jsonExt?.head ?? EMPTY_STRING;
Expand All @@ -49,6 +48,7 @@ function GroupHistorySearcher({
const jsonExt = groupHistory?.jsonExt ? JSON.parse(groupHistory.jsonExt) : null;
return jsonExt?.members ? Object.values(jsonExt?.members).map((value) => `${value}, `) : EMPTY_STRING;
},
(groupHistory) => groupHistory?.userUpdated?.username,
];

const rowIdentifier = (groupHistory) => groupHistory.id;
Expand Down
58 changes: 25 additions & 33 deletions src/components/IndividualHistorySearcher.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import React from 'react';
import { injectIntl } from 'react-intl';
import {
withModulesManager,
formatDateFromISO,
formatMessageWithValues,
Searcher,
formatDateFromISO,
withHistory,
withModulesManager,
} from '@openimis/fe-core';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { fetchIndividualHistory } from '../actions';
import {
DEFAULT_PAGE_SIZE,
ROWS_PER_PAGE_OPTIONS,
EMPTY_STRING,
} from '../constants';
import { DEFAULT_PAGE_SIZE, EMPTY_STRING, ROWS_PER_PAGE_OPTIONS } from '../constants';
import IndividualHistoryFilter from './IndividualHistoryFilter';

function IndividualHistorySearcher({
Expand All @@ -31,33 +27,29 @@ function IndividualHistorySearcher({
}) {
const fetch = (params) => fetchIndividualHistory(params);

const headers = () => {
const headers = [
'individualHistory.firstName',
'individualHistory.lastName',
'individualHistory.dob',
'individualHistory.dateUpdated',
'individualHistory.version',
'individualHistory.jsonExt',
];
return headers;
};
const headers = () => [
'individualHistory.firstName',
'individualHistory.lastName',
'individualHistory.dob',
'individualHistory.dateUpdated',
'individualHistory.version',
'individualHistory.jsonExt',
'individualHistory.userUpdated',
];

const itemFormatters = () => {
const formatters = [
(individualHistory) => individualHistory.firstName,
(individualHistory) => individualHistory.lastName,
(individualHistory) => (individualHistory.dob
? formatDateFromISO(modulesManager, intl, individualHistory.dob) : EMPTY_STRING
),
(individualHistory) => (individualHistory.dateUpdated
? formatDateFromISO(modulesManager, intl, individualHistory.dateUpdated) : EMPTY_STRING
),
(individualHistory) => individualHistory.version,
(individualHistory) => individualHistory.jsonExt,
];
return formatters;
};
const itemFormatters = () => [
(individualHistory) => individualHistory.firstName,
(individualHistory) => individualHistory.lastName,
(individualHistory) => (individualHistory.dob
? formatDateFromISO(modulesManager, intl, individualHistory.dob) : EMPTY_STRING
),
(individualHistory) => (individualHistory.dateUpdated
? formatDateFromISO(modulesManager, intl, individualHistory.dateUpdated) : EMPTY_STRING
),
(individualHistory) => individualHistory.version,
(individualHistory) => individualHistory.jsonExt,
(individualHistory) => individualHistory?.userUpdated?.username,
];

const rowIdentifier = (individualHistory) => individualHistory.id;

Expand Down
6 changes: 4 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
},
"any": "ANY",
"ok": "ok",
"jsonExt": "Additional fields"
"jsonExt": "Additional fields",
"userUpdated": "User Updated"
},
"individuals": {
"pageTitle": "Individuals",
Expand Down Expand Up @@ -104,7 +105,8 @@
"any": "ANY",
"ok": "ok",
"jsonExt": "Additional fields",
"members": "Members"
"members": "Members",
"userUpdated": "User Updated"
},
"groupHistoryList": {
"pageTitle": "Groups History",
Expand Down
Loading