Skip to content

Commit cb6171d

Browse files
committed
Merge remote-tracking branch 'origin/issue-166-360Page' into issue-166-360Page
# Conflicts: # src/server/api/common_api.py
2 parents d6bf1ed + e599078 commit cb6171d

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

src/client/src/pages/DataView360/DataView360.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class DataView360 extends Component {
124124
<TableBody>
125125
{
126126
_.map(participantListGrouped, (row_group, index) => {
127-
return _.map(row_group, row => {
128-
return <TableRow key={row.source_id}
127+
return _.map(row_group, (row, idx) => {
128+
return <TableRow key={`${row.source_id}${idx}`}
129129
className={tableRowColors[index % _.size(tableRowColors)]}
130130
onClick={() => this.handleGetParticipant(row.matching_id)}>
131131
<TableCell align="left">{row.matching_id}</TableCell>
@@ -185,15 +185,15 @@ class DataView360 extends Component {
185185
this.state.showParticipant === true) && (
186186
<Paper className={styles.main} elevation={1} style={{"padding": "1em"}}>
187187
<ContactInfo participant={_.get(this.state, 'participantData.contact_details')}/>
188-
<Container>
189-
<Grid container direction="row" justify="center" alignItems="center" style={{"margin-top": "1em"}}>
190-
<Button variant="contained" color="primary"
191-
onClick={() => {
192-
this.setState({showParticipant: false, showTable: true, showSearchBar: true })
193-
}}>Back to Results
194-
</Button>
188+
<Grid container direction="row" justify="center">
189+
<Grid item style={{"marginTop": "1em", "position": "fixed"}}>
190+
<Button variant="contained" color="primary"
191+
onClick={() => {
192+
this.setState({showParticipant: false, showTable: true, showSearchBar: true })
193+
}}>Back to Results
194+
</Button>
195+
</Grid>
195196
</Grid>
196-
</Container>
197197
<Donations donations={_.get(this.state, 'participantData.donations')}/>
198198
<Adoptions adoptions={_.get(this.state, 'participantData.adoptions')}/>
199199
<Volunteer volunteer={_.get(this.state, 'participantData.shifts')}

src/client/src/pages/DataView360/components/Adoptions.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,36 @@ class Adoptions extends Component {
4141
render() {
4242
// todo: update when we add pet info
4343
// todo: clean array of animal_id
44+
const numAdoptions = _.size(this.props.adoptions);
4445
return (<Container className={styles.adoptions} style={{"marginTop":"1em"}}>
45-
<Typography className={styles.adoptions_title} variant='h4'>Adoption/Foster Records (Top 3)</Typography>
46+
<Typography className={styles.adoptions_title} variant='h4'>Adoption/Foster Records {(numAdoptions > 3) && "(Showing latest 3 out of " + numAdoptions + ")"}</Typography>
4647
<TableContainer className="main_table_container" style={{"marginTop":"1em"}} component={Paper} variant='outlined'>
4748
<Table className="main_table">
4849
<TableHead>
4950
<TableRow>
50-
<StyledTableCell align="center">Number of Adoptions</StyledTableCell>
51+
<StyledTableCell align="center">Name</StyledTableCell>
52+
<StyledTableCell align="center">Adoption Type</StyledTableCell>
53+
<StyledTableCell align="center">Adoption Subtype</StyledTableCell>
54+
<StyledTableCell align="center">Animal Type</StyledTableCell>
55+
<StyledTableCell align="center">Breed</StyledTableCell>
56+
<StyledTableCell align="center">Age</StyledTableCell>
57+
<StyledTableCell align="center">Photo</StyledTableCell>
5158
</TableRow>
5259
</TableHead>
5360
<TableBody>
54-
<StyledTableRow>
55-
<TableCell align="center"> {_.size(this.props.adoptions)}</TableCell>
61+
{_.map(this.props.adoptions, (adoptionInfo, index) => {
62+
const photoLink = adoptionInfo["animal_details"]["Photos"][0]
63+
const photo = <img src={photoLink} style={{"maxWidth": "100px"}}/>;
64+
return <StyledTableRow key={adoptionInfo["Time"] + index}>
65+
<TableCell align="center">{adoptionInfo["animal_details"]["Name"]}</TableCell>
66+
<TableCell align="center">{adoptionInfo["Type"]}</TableCell>
67+
<TableCell align="center">{adoptionInfo["Subtype"]}</TableCell>
68+
<TableCell align="center">{adoptionInfo["animal_details"]["Type"]}</TableCell>
69+
<TableCell align="center">{adoptionInfo["animal_details"]["Breed"]}</TableCell>
70+
<TableCell align="center">{(parseInt(adoptionInfo["animal_details"]["Age"])/12).toFixed(2)}</TableCell>
71+
<TableCell align="center">{photo}</TableCell>
5672
</StyledTableRow>
73+
})}
5774
</TableBody>
5875
</Table>
5976
</TableContainer>

src/client/src/pages/DataView360/components/ContactInfo.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ const StyledContact = withStyles((theme)=>({
1616

1717
class ContactInfo extends Component {
1818
render() {
19-
const participantArray = _.get(this.props, "participant")
20-
const participant = participantArray[0]
19+
// TODO: move to the backend
20+
let participantArray = _.get(this.props, "participant");
21+
let participant = {};
22+
if (participantArray.length === 1) {
23+
participant = participantArray[0];
24+
} else {
25+
participantArray = _.filter(participantArray, function(p) {
26+
if (p["source_type"] === "salesforcecontacts") {
27+
return p;
28+
}
29+
});
30+
participant = participantArray[0];
31+
}
2132
const phoneStr = participant.mobile;
2233
let phone = _.isEmpty(phoneStr) ? '-' : phoneStr.split(" ").join("");
2334
return (<Container className={styles.contact_info}>

0 commit comments

Comments
 (0)