mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-16 20:59:27 +00:00
63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
import { Link } from 'react-router-dom'
|
|
|
|
import {
|
|
Column,
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHeader,
|
|
TableRow,
|
|
Typography,
|
|
} from '@/components'
|
|
import { Deck } from '@/services/decks'
|
|
import { formatDate } from '@/utils'
|
|
|
|
const columns: Column[] = [
|
|
{
|
|
key: 'name',
|
|
title: 'Name',
|
|
},
|
|
{
|
|
key: 'cardsCount',
|
|
title: 'Cards',
|
|
},
|
|
{
|
|
key: 'updated',
|
|
title: 'Last Updated',
|
|
},
|
|
{
|
|
key: 'author',
|
|
title: 'Created By',
|
|
},
|
|
{
|
|
key: 'actions',
|
|
title: '',
|
|
},
|
|
]
|
|
|
|
type Props = {
|
|
decks: Deck[] | undefined
|
|
}
|
|
export const DecksTable = ({ decks }: Props) => {
|
|
return (
|
|
<Table>
|
|
<TableHeader columns={columns} />
|
|
<TableBody>
|
|
{decks?.map(deck => (
|
|
<TableRow key={deck.id}>
|
|
<TableCell>
|
|
<Typography variant={'body2'} as={Link} to={`/decks/${deck.id}`}>
|
|
{deck.name}
|
|
</Typography>
|
|
</TableCell>
|
|
<TableCell>{deck.cardsCount}</TableCell>
|
|
<TableCell>{formatDate(deck.updated)}</TableCell>
|
|
<TableCell>{deck.author.name}</TableCell>
|
|
<TableCell>...</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
)
|
|
}
|