mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-18 05:09:23 +00:00
add cards table and pagination
This commit is contained in:
47
src/components/decks/cards-table.tsx
Normal file
47
src/components/decks/cards-table.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Column, Table, TableBody, TableCell, TableHeader, TableRow } from '@/components'
|
||||
import { Card } from '@/services/decks'
|
||||
import { formatDate } from '@/utils'
|
||||
|
||||
const columns: Column[] = [
|
||||
{
|
||||
key: 'question',
|
||||
title: 'Question',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
key: 'answer',
|
||||
title: 'Answer',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
key: 'updated',
|
||||
title: 'Last Updated',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
key: 'grade',
|
||||
title: 'Grade',
|
||||
sortable: true,
|
||||
},
|
||||
]
|
||||
|
||||
type Props = {
|
||||
cards: Card[] | undefined
|
||||
}
|
||||
export const CardsTable = ({ cards }: Props) => {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader columns={columns} />
|
||||
<TableBody>
|
||||
{cards?.map(card => (
|
||||
<TableRow key={card.id}>
|
||||
<TableCell>{card.question}</TableCell>
|
||||
<TableCell>{card.answer}</TableCell>
|
||||
<TableCell>{formatDate(card.updated)}</TableCell>
|
||||
<TableCell>{card.grade}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user