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

Added date of incident to the profile page #182

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions src/components/profileDetails/PersonProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {
Location,
Button,
H2,
Context
Context,
DateOfIncident
} from './styles';

const getSocialCopy = (info) => `Join me in donating to ${info.full_name}’s fund, and supporting their family’s fight for justice.
#SayTheirNames #BlackLivesMatter #${info.full_name.replace(/\s+/g, '')}`;


const PersonProfile = (props) => {
const { info, donation } = props;
const {
Expand All @@ -34,7 +34,8 @@ const PersonProfile = (props) => {
their_story,
outcome,
country,
donation_links
donation_links,
date_of_incident
} = info;

return (
Expand Down Expand Up @@ -66,6 +67,10 @@ const PersonProfile = (props) => {
<H4>{number_of_children === 1 ? 'CHILD' : 'CHILDREN'}</H4>
<H2>{number_of_children > 0 ? number_of_children : 'N/A'}</H2>
</Children>
<DateOfIncident>
<H4>DATE OF INCIDENT</H4>
<H2>{date_of_incident ?? 'N/A'}</H2>
</DateOfIncident>
</Div>
<Location>
<H4>LOCATION</H4>
Expand Down Expand Up @@ -123,7 +128,8 @@ PersonProfile.propTypes = {
their_story: PropTypes.string.isRequired,
country: PropTypes.string.isRequired,
outcome: PropTypes.string,
donation_links: PropTypes.array.isRequired
donation_links: PropTypes.array.isRequired,
date_of_incident: PropTypes.array.isRequired
}),
donation: PropTypes.shape({
identifier: PropTypes.string
Expand Down
20 changes: 19 additions & 1 deletion src/components/profileDetails/PersonProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('<PersonProfile />', () => {
their_story: 'sample story',
outcome: 'sample outcome',
country: 'country',
donation_links: ['https://www.google.com']
donation_links: ['https://www.google.com'],
date_of_incident: '2021-10-25'
};

test('renders PersonProfile', () => {
Expand All @@ -44,6 +45,8 @@ describe('<PersonProfile />', () => {
expect(getByText('sample story'));
expect(getByText('Context'));
expect(getByText('sample outcome'));
expect(getByText('DATE OF INCIDENT'));
expect(getByText('2021-10-25'));
});

test('renders PersonProfile with correct links', () => {
Expand Down Expand Up @@ -72,4 +75,19 @@ describe('<PersonProfile />', () => {
expect(getByText('CHILDREN'));
expect(getByText('N/A'));
});

test('renders N/A when date_of_incident is null', () => {
const history = createMemoryHistory();
const noChildrenInfo = {
...info,
date_of_incident: null
};
const { getByText } = render(
<Router history={history}>
<PersonProfile info={noChildrenInfo} donation={donation} />
</Router>
);
expect(getByText('DATE OF INCIDENT'));
expect(getByText('N/A'));
});
});
22 changes: 16 additions & 6 deletions src/components/profileDetails/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const H4 = styled.h4`

const Div = styled.div`
display: flex;
width: 50%;
width: 60%;
justify-content: flex-start;
margin: 10px;

Expand All @@ -131,7 +131,7 @@ const Age = styled.div`
display: flex;
flex-direction: column;
align-content: space-around;
width: 25%;
padding-right 15px;
border-right: 1px solid #d8d8d8;

h2 {
Expand All @@ -144,6 +144,18 @@ const Children = styled.div`
flex-direction: column;
align-content: space-around;
padding-left: 15px;
border-right: 1px solid #d8d8d8;
padding-right: 15px;
h2 {
margin: 0px;
}
`;

const DateOfIncident = styled.div`
display: inline;
flex-direction: column;
align-content: space-around;
padding-left: 15px;
h2 {
margin: 0px;
}
Expand Down Expand Up @@ -191,8 +203,6 @@ const ShareSection = styled.section`
p {
margin: 5px 0px;
}


`;

const Share = styled.div`
Expand All @@ -207,7 +217,6 @@ const Share = styled.div`
font-size: 17px;
line-height: 20px;
}

`;

const H2 = styled.h2`
Expand Down Expand Up @@ -261,5 +270,6 @@ export {
Button,
H2,
Share,
Context
Context,
DateOfIncident
};