Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Created August 10, 2021 17:01
Show Gist options
  • Save ernestofreyreg/3208be8c0a33e8000aac837e9a0e5258 to your computer and use it in GitHub Desktop.
Save ernestofreyreg/3208be8c0a33e8000aac837e9a0e5258 to your computer and use it in GitHub Desktop.
import {
createStyles,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Theme,
withStyles
} from '@material-ui/core'
import * as React from 'react'
export interface EmailSubscription {
email: string
updated: number
}
export interface SubscriptionListProps {
subscriptions: EmailSubscription[]
}
const StyledTableRow = withStyles((theme: Theme) =>
createStyles({
root: {
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover
}
}
})
)(TableRow)
export const SubscriptionList: React.FC<SubscriptionListProps> = ({ subscriptions }) => {
return (
<TableContainer component={Paper}>
<Table>
<TableHead>
<TableRow>
<TableCell>Email</TableCell>
<TableCell align='right'>Updated</TableCell>
</TableRow>
</TableHead>
<TableBody>
{subscriptions.map(row => (
<StyledTableRow key={row.email}>
<TableCell component='th' scope='row'>
{row.email}
</TableCell>
<TableCell align='right'>{new Date(row.updated).toISOString()}</TableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment