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

fixes to group display #598

Merged
merged 1 commit into from
Oct 12, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const ContactDescription: React.FC<ContactDescriptionProps> = ({
groups,
lastMessage,
}: ContactDescriptionProps) => {
// list of groups that the contact is assigned
let assignedToGroup: any = Array.from(
new Set([].concat(...groups.map((group: any) => group.users.map((user: any) => user.name))))
);
Expand All @@ -27,19 +28,22 @@ export const ContactDescription: React.FC<ContactDescriptionProps> = ({
assignedToGroup = assignedToGroup.join(', ');
}

// list of groups that the contact belongs
let groupList = groups.map((group: any) => group.label).join(', ');

const groupDetails = [
{ label: 'Groups', value: groups.map((group: any) => group.label).join(', ') },
{ label: 'Groups', value: groupList ? groupList : 'None' },
{
label: 'Assigned to',
value: assignedToGroup ? assignedToGroup : 'None',
},
];

if (typeof settings === "string") {
if (typeof settings === 'string') {
settings = JSON.parse(settings);
}

if (typeof fields === "string") {
if (typeof fields === 'string') {
fields = JSON.parse(fields);
}

Expand Down Expand Up @@ -67,22 +71,30 @@ export const ContactDescription: React.FC<ContactDescriptionProps> = ({
</div>

<div className={styles.DetailBlock}>
{settings && typeof settings === "object" && Object.keys(settings).map((key) => (
<div key={key}>
<div className={styles.DescriptionItem}>{key}</div>
<div className={styles.DescriptionItemValue}>
{Object.keys(settings[key]).filter((settingKey) => {
return settings[key][settingKey] === true;
}).join(', ')}
{settings &&
typeof settings === 'object' &&
Object.keys(settings).map((key) => (
<div key={key}>
<div className={styles.DescriptionItem}>{key}</div>
<div className={styles.DescriptionItemValue}>
{Object.keys(settings[key])
.filter((settingKey) => {
return settings[key][settingKey] === true;
})
.join(', ')}
</div>
</div>
</div>
))}
{fields && typeof fields === "object" && Object.keys(fields).map((key) => (
<div key={key}>
<div className={styles.DescriptionItem}>{fields[key].label ? fields[key].label : key.replace('_', ' ')}</div>
<div className={styles.DescriptionItemValue}>{fields[key].value}</div>
</div>
))}
))}
{fields &&
typeof fields === 'object' &&
Object.keys(fields).map((key) => (
<div key={key}>
<div className={styles.DescriptionItem}>
{fields[key].label ? fields[key].label : key.replace('_', ' ')}
</div>
<div className={styles.DescriptionItemValue}>{fields[key].value}</div>
</div>
))}
</div>
</div>
);
Expand Down