Skip to content

Commit

Permalink
✨ add copy result button
Browse files Browse the repository at this point in the history
  • Loading branch information
dxanh97 committed Oct 30, 2024
1 parent b7ac3c6 commit 86ef7fa
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/components/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
Box,
Button,
Card,
CopyButton,
Group,
Indicator,
ScrollArea,
Stack,
Text,
} from '@mantine/core';
import { Sparkline } from '@mantine/charts';
import { IconTableExport } from '@tabler/icons-react';
import { IconClipboardCopy, IconTableExport } from '@tabler/icons-react';

import { useAppSelector } from '../redux/store';
import { selectAllRoundsFromGameId } from '../redux/round.selector';
Expand Down Expand Up @@ -165,11 +166,33 @@ function Leaderboard(props: Props) {
</Card>
))}

<CopyButton
value={list
.map((x) => `${x.name}: ${formatNumber(x.stat)}`)
.map((s) => `${s}\n`)
.join('')}
>
{({ copied, copy }) => (
<Button
fullWidth
variant="light"
leftSection={<IconClipboardCopy size={14} />}
color={copied ? 'teal' : 'blue'}
onClick={copy}
mt="sm"
>
{copied
? 'Copy rồi nhé, paste vô group chat đi'
: 'Copy tổng kết'}
</Button>
)}
</CopyButton>
<Button
fullWidth
variant="light"
leftSection={<IconTableExport size={14} />}
onClick={exportCSV}
mt="sm"
>
Xuất CSV
</Button>
Expand Down

0 comments on commit 86ef7fa

Please sign in to comment.