11"use client" ;
22
3- import { TableInfos } from "@/types" ;
3+ import { invoke } from "@tauri-apps/api/tauri" ;
4+ import React , { useState } from "react" ;
5+
46import {
57 Table ,
68 TableBody ,
@@ -9,22 +11,8 @@ import {
911 TableHeader ,
1012 TableRow ,
1113} from "@/components/ui/table" ;
12- import {
13- Accordion ,
14- AccordionContent ,
15- AccordionItem ,
16- AccordionTrigger ,
17- } from "@/components/ui/accordion" ;
18-
1914import { Textarea } from "@/components/ui/textarea" ;
2015
21- import { invoke } from "@tauri-apps/api/tauri" ;
22- import React , { useState } from "react" ;
23-
24- type x =
25- | { result : { Ok : Array < { [ key : string ] : string } > } }
26- | { result : { Err : string } } ;
27-
2816export default function ExecuteSQL ( { table } : { table : string } ) {
2917 const [ sql , setSQL ] = useState ( "" ) ;
3018 const [ result , setResult ] = useState < string | string [ ] > ( ) ;
@@ -68,28 +56,28 @@ export default function ExecuteSQL({ table }: { table: string }) {
6856 { typeof result === "string" ? (
6957 < p > { result } </ p >
7058 ) : result instanceof Array ? (
71- < table className = "table-auto" >
72- < thead >
73- < tr >
59+ < Table className = "table-auto" >
60+ < TableHeader >
61+ < TableRow >
7462 { Object . keys ( result [ 0 ] ) . map ( ( key ) => (
75- < th key = { key } className = "border px-4 py-2" >
63+ < TableHead key = { key } className = "border px-4 py-2" >
7664 { key }
77- </ th >
65+ </ TableHead >
7866 ) ) }
79- </ tr >
80- </ thead >
81- < tbody >
67+ </ TableRow >
68+ </ TableHeader >
69+ < TableBody >
8270 { result . map ( ( row , index ) => (
83- < tr key = { index } >
71+ < TableRow key = { index } >
8472 { Object . values ( row ) . map ( ( value , index ) => (
85- < td key = { index } className = "border px-4 py-2" >
73+ < TableCell key = { index } className = "border px-4 py-2" >
8674 { value }
87- </ td >
75+ </ TableCell >
8876 ) ) }
89- </ tr >
77+ </ TableRow >
9078 ) ) }
91- </ tbody >
92- </ table >
79+ </ TableBody >
80+ </ Table >
9381 ) : null }
9482 </ form >
9583 </ div >
0 commit comments