1
1
import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
2
import { makeStyles } from '@material-ui/core/styles' ;
4
3
import Box from '@material-ui/core/Box' ;
5
4
import Collapse from '@material-ui/core/Collapse' ;
@@ -31,10 +30,16 @@ function getAnimalAge(epochTime) {
31
30
return moment ( ) . diff ( dateOfBirth , 'years' ) ;
32
31
}
33
32
33
+ function showAnimalAge ( epochTime ) {
34
+ const age = getAnimalAge ( epochTime )
35
+ return ( age === 1 ) ? `${ age } year` : `${ age } years`
36
+ }
37
+
34
38
function Row ( props ) {
35
39
const [ open , setOpen ] = React . useState ( false ) ;
36
40
const classes = useRowStyles ( ) ;
37
41
const { row, events } = props ;
42
+ const photo = row . Photos [ 0 ]
38
43
return (
39
44
< React . Fragment >
40
45
< TableRow className = { classes . root } >
@@ -48,8 +53,8 @@ function Row(props) {
48
53
</ TableCell >
49
54
< TableCell align = "center" > { row . Type } </ TableCell >
50
55
< TableCell align = "center" > { row . Breed } </ TableCell >
51
- < TableCell align = "center" > { getAnimalAge ( row . DOBUnixTime ) } </ TableCell >
52
- < TableCell align = "center" > { < img src = { row . Photos [ 0 ] } alt = "animal" style = { { "maxWidth" : "100px" } } /> } </ TableCell >
56
+ < TableCell align = "center" > { showAnimalAge ( row . DOBUnixTime ) } </ TableCell >
57
+ < TableCell align = "center" > { < img src = { photo } alt = "animal" style = { { "maxWidth" : "100px" } } /> } </ TableCell >
53
58
</ TableRow >
54
59
< TableRow >
55
60
< TableCell style = { { paddingBottom : 0 , paddingTop : 0 } } colSpan = { 6 } >
@@ -62,7 +67,7 @@ function Row(props) {
62
67
< TableHead >
63
68
< TableRow >
64
69
< TableCell align = "center" > Subtype</ TableCell >
65
- < TableCell align = "center" > Time </ TableCell >
70
+ < TableCell align = "center" > Date </ TableCell >
66
71
< TableCell align = "center" > Type</ TableCell >
67
72
< TableCell align = "center" > User</ TableCell >
68
73
</ TableRow >
0 commit comments