Created
August 10, 2021 17:01
-
-
Save ernestofreyreg/3208be8c0a33e8000aac837e9a0e5258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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