From 602e026984371958b72a024a01a71b44b9d9be20 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 10 Jan 2024 10:51:01 +0100 Subject: [PATCH 1/2] CM-406: add user updated --- src/actions.js | 8 +++++- src/components/GroupHistorySearcher.js | 4 +-- src/components/IndividualHistorySearcher.js | 30 +++++++++------------ src/translations/en.json | 6 +++-- 4 files changed, 26 insertions(+), 22 deletions(-) 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..0b0d06e 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 {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 {bindActionCreators} from 'redux'; +import {connect} from 'react-redux'; +import {fetchIndividualHistory} from '../actions'; +import {DEFAULT_PAGE_SIZE, EMPTY_STRING, ROWS_PER_PAGE_OPTIONS,} from '../constants'; import IndividualHistoryFilter from './IndividualHistoryFilter'; function IndividualHistorySearcher({ @@ -32,31 +28,31 @@ function IndividualHistorySearcher({ const fetch = (params) => fetchIndividualHistory(params); const headers = () => { - const headers = [ + return [ 'individualHistory.firstName', 'individualHistory.lastName', 'individualHistory.dob', 'individualHistory.dateUpdated', 'individualHistory.version', 'individualHistory.jsonExt', + 'individualHistory.userUpdated', ]; - return headers; }; const itemFormatters = () => { - const formatters = [ + return [ (individualHistory) => individualHistory.firstName, (individualHistory) => individualHistory.lastName, (individualHistory) => (individualHistory.dob - ? formatDateFromISO(modulesManager, intl, individualHistory.dob) : EMPTY_STRING + ? formatDateFromISO(modulesManager, intl, individualHistory.dob) : EMPTY_STRING ), (individualHistory) => (individualHistory.dateUpdated - ? formatDateFromISO(modulesManager, intl, individualHistory.dateUpdated) : EMPTY_STRING + ? formatDateFromISO(modulesManager, intl, individualHistory.dateUpdated) : EMPTY_STRING ), (individualHistory) => individualHistory.version, (individualHistory) => individualHistory.jsonExt, + (individualHistory) => individualHistory?.userUpdated?.username, ]; - return formatters; }; 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", From 994dedf290ab4535986b311062072996e7370201 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 10 Jan 2024 10:56:00 +0100 Subject: [PATCH 2/2] CM-406: fix eslint --- src/components/IndividualHistorySearcher.js | 58 ++++++++++----------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/src/components/IndividualHistorySearcher.js b/src/components/IndividualHistorySearcher.js index 0b0d06e..45ba79e 100644 --- a/src/components/IndividualHistorySearcher.js +++ b/src/components/IndividualHistorySearcher.js @@ -1,5 +1,5 @@ import React from 'react'; -import {injectIntl} from 'react-intl'; +import { injectIntl } from 'react-intl'; import { formatDateFromISO, formatMessageWithValues, @@ -7,10 +7,10 @@ import { withHistory, withModulesManager, } from '@openimis/fe-core'; -import {bindActionCreators} from 'redux'; -import {connect} from 'react-redux'; -import {fetchIndividualHistory} from '../actions'; -import {DEFAULT_PAGE_SIZE, EMPTY_STRING, ROWS_PER_PAGE_OPTIONS,} from '../constants'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; +import { fetchIndividualHistory } from '../actions'; +import { DEFAULT_PAGE_SIZE, EMPTY_STRING, ROWS_PER_PAGE_OPTIONS } from '../constants'; import IndividualHistoryFilter from './IndividualHistoryFilter'; function IndividualHistorySearcher({ @@ -27,33 +27,29 @@ function IndividualHistorySearcher({ }) { const fetch = (params) => fetchIndividualHistory(params); - const headers = () => { - return [ - 'individualHistory.firstName', - 'individualHistory.lastName', - 'individualHistory.dob', - 'individualHistory.dateUpdated', - 'individualHistory.version', - 'individualHistory.jsonExt', - 'individualHistory.userUpdated', - ]; - }; + const headers = () => [ + 'individualHistory.firstName', + 'individualHistory.lastName', + 'individualHistory.dob', + 'individualHistory.dateUpdated', + 'individualHistory.version', + 'individualHistory.jsonExt', + 'individualHistory.userUpdated', + ]; - const itemFormatters = () => { - return [ - (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 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;