RecentQueriesItem.tsx39 lines · main
| 1 | import { Play } from 'lucide-react' |
| 2 | import { useRouter } from 'next/router' |
| 3 | import { Button } from 'ui' |
| 4 | |
| 5 | import SqlSnippetCode from './Logs.SqlSnippetCode' |
| 6 | import Table from '@/components/to-be-cleaned/Table' |
| 7 | import type { LogSqlSnippets } from '@/types' |
| 8 | |
| 9 | interface Props { |
| 10 | item: LogSqlSnippets.Content |
| 11 | } |
| 12 | |
| 13 | const RecentQueriesItem: React.FC<Props> = ({ item }) => { |
| 14 | const router = useRouter() |
| 15 | const { ref } = router.query |
| 16 | |
| 17 | return ( |
| 18 | <Table.tr key={item.sql}> |
| 19 | <Table.td |
| 20 | className={`expanded-row-content border-l border-r bg-alternative px-3! pt-0! pb-0! transition-all`} |
| 21 | > |
| 22 | <SqlSnippetCode>{item.sql}</SqlSnippetCode> |
| 23 | </Table.td> |
| 24 | <Table.td className="text-right"> |
| 25 | <Button |
| 26 | type="alternative" |
| 27 | iconRight={<Play size={10} />} |
| 28 | onClick={() => |
| 29 | router.push(`/project/${ref}/logs/explorer?q=${encodeURIComponent(item.sql)}`) |
| 30 | } |
| 31 | > |
| 32 | Run |
| 33 | </Button> |
| 34 | </Table.td> |
| 35 | </Table.tr> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | export default RecentQueriesItem |