import { Link } from 'react-router-dom' import s from './decks-table.module.scss' import { Edit2Outline, PlayCircleOutline, TrashOutline } from '@/assets' import { Button, 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 onDeleteClick: (id: string) => void currentUserId: string onEditClick: (id: string) => void } export const DecksTable = ({ decks, onEditClick, onDeleteClick, currentUserId }: Props) => { const handleEditClick = (id: string) => () => onEditClick(id) const handleDeleteClick = (id: string) => () => onDeleteClick(id) return ( {decks?.map(deck => ( {deck.name} {deck.cardsCount} {formatDate(deck.updated)} {deck.author.name}
{deck.author.id === currentUserId && ( <> )}
))}
) }