Skip to content

Commit

Permalink
Merge pull request #589 from CruGlobal/MHP-2022
Browse files Browse the repository at this point in the history
Mhp 2022 -- Hide contact report for User-Created Communities
  • Loading branch information
reldredge71 authored Oct 26, 2018
2 parents 679f37e + ecae59e commit ed4a695
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 26 deletions.
19 changes: 19 additions & 0 deletions __tests__/components/GroupCardItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const uncontactedCount = 56;
let group = {
name: 'Group Name',
contactReport: {},
user_created: false,
};

const test = () => {
Expand All @@ -21,6 +22,20 @@ describe('GroupCardItem', () => {
test();
});

it('renders with no report counts for user created org', () => {
group = {
...group,
contactReport: {
contactsCount,
unassignedCount,
uncontactedCount,
},
user_created: true,
};

test();
});

it('renders with all report counts', () => {
group = {
...group,
Expand All @@ -29,6 +44,7 @@ describe('GroupCardItem', () => {
unassignedCount,
uncontactedCount,
},
user_created: false,
};

test();
Expand All @@ -41,6 +57,7 @@ describe('GroupCardItem', () => {
contactsCount,
unassignedCount,
},
user_created: false,
};

test();
Expand All @@ -53,6 +70,7 @@ describe('GroupCardItem', () => {
contactsCount,
uncontactedCount,
},
user_created: false,
};

test();
Expand All @@ -64,6 +82,7 @@ describe('GroupCardItem', () => {
contactReport: {
contactsCount,
},
user_created: false,
};

test();
Expand Down
45 changes: 45 additions & 0 deletions __tests__/components/__snapshots__/GroupCardItem.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,48 @@ exports[`GroupCardItem renders with no report counts 1`] = `
</Flex>
</Card>
`;

exports[`GroupCardItem renders with no report counts for user created org 1`] = `
<Card
onPress={[Function]}
style={
Object {
"alignItems": "center",
"backgroundColor": "#ffffff",
"borderBottomColor": "#E6E8EC",
"borderBottomWidth": 1,
"flexDirection": "row",
"marginHorizontal": 16,
"marginVertical": 8,
"paddingHorizontal": 13,
"paddingVertical": 16,
}
}
>
<Flex>
<MyText
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"color": "#007398",
"fontSize": 16,
"fontWeight": "bold",
}
}
>
GROUP NAME
</MyText>
<Flex
align="center"
direction="row"
style={
Object {
"paddingTop": 4,
}
}
/>
</Flex>
</Card>
`;
56 changes: 30 additions & 26 deletions src/components/GroupCardItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,41 @@ export default class GroupCardItem extends Component {
const { t, group } = this.props;
const { contactsCount, unassignedCount, uncontactedCount } =
group.contactReport || {};
const { user_created } = group;

return (
<Card onPress={this.handlePress} style={styles.card}>
<Flex>
<Text style={styles.groupName}>{group.name.toUpperCase()}</Text>
<Flex align="center" direction="row" style={styles.contactRow}>
{contactsCount ? (
<Fragment>
<Text style={styles.contacts}>
{t('numContacts', { number: contactsCount })}
</Text>
{unassignedCount ? (
<Fragment>
<Dot />
<Text style={styles.unassigned}>
{t('numUnassigned', {
number: unassignedCount,
})}
</Text>
</Fragment>
) : null}
{uncontactedCount ? (
<Fragment>
<Dot />
<Text style={styles.unassigned}>
{t('numUncontacted', {
number: uncontactedCount,
})}
</Text>
</Fragment>
) : null}
</Fragment>
{!user_created ? (
contactsCount ? (
<Fragment>
<Text style={styles.contacts}>
{t('numContacts', { number: contactsCount })}
</Text>
{unassignedCount ? (
<Fragment>
<Dot />
<Text style={styles.unassigned}>
{t('numUnassigned', {
number: unassignedCount,
})}
</Text>
</Fragment>
) : null}
{uncontactedCount ? (
<Fragment>
<Dot />
<Text style={styles.unassigned}>
{t('numUncontacted', {
number: uncontactedCount,
})}
</Text>
</Fragment>
) : null}
</Fragment>
) : null
) : null}
</Flex>
</Flex>
Expand All @@ -61,5 +64,6 @@ GroupCardItem.propTypes = {
group: PropTypes.shape({
name: PropTypes.string.isRequired,
contactReport: PropTypes.object.isRequired,
user_created: PropTypes.bool,
}).isRequired,
};

0 comments on commit ed4a695

Please sign in to comment.