@@ -41,19 +41,36 @@ class Adoptions extends Component {
41
41
render ( ) {
42
42
// todo: update when we add pet info
43
43
// todo: clean array of animal_id
44
+ const numAdoptions = _ . size ( this . props . adoptions ) ;
44
45
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 >
46
47
< TableContainer className = "main_table_container" style = { { "marginTop" :"1em" } } component = { Paper } variant = 'outlined' >
47
48
< Table className = "main_table" >
48
49
< TableHead >
49
50
< 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 >
51
58
</ TableRow >
52
59
</ TableHead >
53
60
< 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 >
56
72
</ StyledTableRow >
73
+ } ) }
57
74
</ TableBody >
58
75
</ Table >
59
76
</ TableContainer >
0 commit comments