mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-18 05:09:23 +00:00
chore: lint with tabwidth: 2
This commit is contained in:
@@ -2,89 +2,86 @@ import { Link } from 'react-router-dom'
|
||||
|
||||
import { Edit2Outline, PlayCircleOutline, TrashOutline } from '@/assets'
|
||||
import {
|
||||
Button,
|
||||
Column,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
Typography,
|
||||
Button,
|
||||
Column,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
Typography,
|
||||
} from '@/components'
|
||||
import { Deck } from '@/services/decks'
|
||||
import { formatDate } from '@/utils'
|
||||
|
||||
import s from './decks-table.module.scss'
|
||||
const columns: Column[] = [
|
||||
{
|
||||
key: 'name',
|
||||
title: 'Name',
|
||||
},
|
||||
{
|
||||
key: 'cardsCount',
|
||||
title: 'Cards',
|
||||
},
|
||||
{
|
||||
key: 'updated',
|
||||
title: 'Last Updated',
|
||||
},
|
||||
{
|
||||
key: 'author',
|
||||
title: 'Created By',
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
title: '',
|
||||
},
|
||||
{
|
||||
key: 'name',
|
||||
title: 'Name',
|
||||
},
|
||||
{
|
||||
key: 'cardsCount',
|
||||
title: 'Cards',
|
||||
},
|
||||
{
|
||||
key: 'updated',
|
||||
title: 'Last Updated',
|
||||
},
|
||||
{
|
||||
key: 'author',
|
||||
title: 'Created By',
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
title: '',
|
||||
},
|
||||
]
|
||||
|
||||
type Props = {
|
||||
currentUserId: string
|
||||
decks: Deck[] | undefined
|
||||
onDeleteClick: (id: string) => void
|
||||
onEditClick: (id: string) => void
|
||||
currentUserId: string
|
||||
decks: Deck[] | undefined
|
||||
onDeleteClick: (id: string) => void
|
||||
onEditClick: (id: string) => void
|
||||
}
|
||||
export const DecksTable = ({ currentUserId, decks, onDeleteClick, onEditClick }: Props) => {
|
||||
const handleEditClick = (id: string) => () => onEditClick(id)
|
||||
const handleDeleteClick = (id: string) => () => onDeleteClick(id)
|
||||
const handleEditClick = (id: string) => () => onEditClick(id)
|
||||
const handleDeleteClick = (id: string) => () => onDeleteClick(id)
|
||||
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader columns={columns} />
|
||||
<TableBody>
|
||||
{decks?.map(deck => (
|
||||
<TableRow key={deck.id}>
|
||||
<TableCell>
|
||||
<Typography as={Link} to={`/decks/${deck.id}`} variant={'body2'}>
|
||||
{deck.name}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
<TableCell>{deck.cardsCount}</TableCell>
|
||||
<TableCell>{formatDate(deck.updated)}</TableCell>
|
||||
<TableCell>{deck.author.name}</TableCell>
|
||||
<TableCell>
|
||||
<div className={s.iconsContainer}>
|
||||
<Button as={Link} to={`/decks/${deck.id}/learn`} variant={'icon'}>
|
||||
<PlayCircleOutline />
|
||||
</Button>
|
||||
{deck.author.id === currentUserId && (
|
||||
<>
|
||||
<Button onClick={handleEditClick(deck.id)} variant={'icon'}>
|
||||
<Edit2Outline />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleDeleteClick(deck.id)}
|
||||
variant={'icon'}
|
||||
>
|
||||
<TrashOutline />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader columns={columns} />
|
||||
<TableBody>
|
||||
{decks?.map(deck => (
|
||||
<TableRow key={deck.id}>
|
||||
<TableCell>
|
||||
<Typography as={Link} to={`/decks/${deck.id}`} variant={'body2'}>
|
||||
{deck.name}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
<TableCell>{deck.cardsCount}</TableCell>
|
||||
<TableCell>{formatDate(deck.updated)}</TableCell>
|
||||
<TableCell>{deck.author.name}</TableCell>
|
||||
<TableCell>
|
||||
<div className={s.iconsContainer}>
|
||||
<Button as={Link} to={`/decks/${deck.id}/learn`} variant={'icon'}>
|
||||
<PlayCircleOutline />
|
||||
</Button>
|
||||
{deck.author.id === currentUserId && (
|
||||
<>
|
||||
<Button onClick={handleEditClick(deck.id)} variant={'icon'}>
|
||||
<Edit2Outline />
|
||||
</Button>
|
||||
<Button onClick={handleDeleteClick(deck.id)} variant={'icon'}>
|
||||
<TrashOutline />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user