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

Fixed : User settings shows uuids instead of names as sync attributes #968 #1091

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Changes from 2 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
28 changes: 25 additions & 3 deletions src/adminApp/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import Grid from "@material-ui/core/Grid";
import ConceptService from "../common/service/ConceptService";
import Select from "react-select";
import ReactSelectHelper from "../common/utils/ReactSelectHelper";
import { error } from "jquery";

export const UserCreate = ({ user, organisation, userInfo, ...props }) => (
<Paper>
Expand Down Expand Up @@ -184,13 +185,34 @@ const ConceptSyncAttributeShow = ({ subjectType, syncAttributeName, ...props })
const syncSettings = get(props.record, ["syncSettings", subjectType.name], {});
const conceptUUID = get(syncSettings, [syncAttributeName]);
if (isEmpty(conceptUUID)) return null;

const [valueMap, setValueMap] = useState(new Map());
useEffect(() => {
let isMounted = true;
const newValMap = new Map();

ConceptService.getAnswerConcepts(conceptUUID)
.then(content => {
content.forEach(val => newValMap.set(val.id, val.name));
if (isMounted) {
setValueMap(newValMap);
}
})
.catch(error => {
console.error("Error fetching data:", error);
});
// console.log("value============>",newValMap.size,newValMap);
return () => {
isMounted = false;
};
}, [conceptUUID]);
return (
<div>
<span style={{ color: "rgba(0, 0, 0, 0.54)", fontSize: "12px", marginRight: 10 }}>
{startCase(syncAttributeName)}
</span>
{map(get(syncSettings, `${syncAttributeName}Values`, []), value => (
<Chip label={value} key={value} />
<Chip style={{ margin: "0.2em" }} label={valueMap.get(value)} key={value} />
))}
</div>
);
Expand Down Expand Up @@ -297,8 +319,8 @@ const operatingScopes = Object.freeze({
CATCHMENT: "ByCatchment"
});

const catchmentChangeMessage = `Please ensure that the user has already synced all
data for their previous sync attributes. Changing sync attributes will ask the users to reset their sync.
const catchmentChangeMessage = `Please ensure that the user has already synced all
data for their previous sync attributes. Changing sync attributes will ask the users to reset their sync.
This might take time depending on the data.`;

const SubjectTypeSyncAttributes = ({ subjectType, ...props }) => (
Expand Down