diff --git a/src/actions.js b/src/actions.js index 98aee13..08bc47f 100644 --- a/src/actions.js +++ b/src/actions.js @@ -20,6 +20,7 @@ const INDIVIDUAL_FULL_PROJECTION = [ 'dob', 'jsonExt', 'version', + 'userUpdated {username}', ]; const GROUP_INDIVIDUAL_FULL_PROJECTION = [ @@ -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); @@ -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); } diff --git a/src/components/GroupHistorySearcher.js b/src/components/GroupHistorySearcher.js index ae923d0..61ebc18 100644 --- a/src/components/GroupHistorySearcher.js +++ b/src/components/GroupHistorySearcher.js @@ -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; @@ -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; diff --git a/src/components/IndividualHistorySearcher.js b/src/components/IndividualHistorySearcher.js index ece2c1d..45ba79e 100644 --- a/src/components/IndividualHistorySearcher.js +++ b/src/components/IndividualHistorySearcher.js @@ -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({ @@ -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; diff --git a/src/translations/en.json b/src/translations/en.json index b1af43c..9414aa0 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -63,7 +63,8 @@ }, "any": "ANY", "ok": "ok", - "jsonExt": "Additional fields" + "jsonExt": "Additional fields", + "userUpdated": "User Updated" }, "individuals": { "pageTitle": "Individuals", @@ -104,7 +105,8 @@ "any": "ANY", "ok": "ok", "jsonExt": "Additional fields", - "members": "Members" + "members": "Members", + "userUpdated": "User Updated" }, "groupHistoryList": { "pageTitle": "Groups History",