11import { Badge } from "@/app/components/ui/badge" ;
22import { Button } from "@/app/components/ui/button" ;
3- import { Card , CardContent , CardHeader , CardTitle } from "@/app/components/ui/card" ;
43import { Dialog , DialogContent , DialogHeader , DialogTitle , DialogTrigger } from "@/app/components/ui/dialog" ;
5- import { ScrollArea } from "@/app/components/ui/scroll-area" ;
6- import { Separator } from "@/app/components/ui/separator" ;
74import { Textarea } from "@/app/components/ui/textarea" ;
85import { getDb } from "@/app/lib/db-client" ;
96import { Database } from "lucide-react" ;
@@ -106,85 +103,6 @@ export function DatabaseStudio() {
106103 setIsOpen ( false ) ;
107104 } ;
108105
109- const renderTable = ( ) => {
110- if ( ! result ?. columns || ! result ?. rows ) return null ;
111-
112- return (
113- < div className = "rounded-md border" >
114- < ScrollArea className = "h-[400px]" >
115- < table className = "w-full text-sm" >
116- < thead className = "border-b bg-muted/50" >
117- < tr >
118- { result . columns . map ( ( column ) => (
119- < th key = { column } className = "p-2 text-left font-medium" >
120- { column }
121- </ th >
122- ) ) }
123- </ tr >
124- </ thead >
125- < tbody >
126- { result . rows . map ( ( row , rowIndex ) => (
127- < tr key = { `row-${ JSON . stringify ( row ) } -${ rowIndex } ` } className = "border-b hover:bg-muted/50" >
128- { result . columns ! . map ( ( column ) => (
129- < td key = { `${ rowIndex } -${ column } ` } className = "p-2" >
130- { row [ column ] !== null && row [ column ] !== undefined ? (
131- String ( row [ column ] )
132- ) : (
133- < span className = "text-muted-foreground italic" > NULL</ span >
134- ) }
135- </ td >
136- ) ) }
137- </ tr >
138- ) ) }
139- </ tbody >
140- </ table >
141- </ ScrollArea >
142- </ div >
143- ) ;
144- } ;
145-
146- const renderResult = ( ) => {
147- if ( ! result ) return null ;
148-
149- return (
150- < Card >
151- < CardHeader className = "flex flex-row items-center justify-between" >
152- < CardTitle className = "text-lg" > Query Results</ CardTitle >
153- < div className = "flex items-center gap-2" >
154- { result . executionTime && < Badge variant = "secondary" > { result . executionTime . toFixed ( 2 ) } ms</ Badge > }
155- < Button variant = "outline" size = "sm" onClick = { clearResult } >
156- Clear
157- </ Button >
158- </ div >
159- </ CardHeader >
160- < CardContent >
161- { result . error ? (
162- < div className = "rounded-md border border-destructive/20 bg-destructive/10 p-4" >
163- < p className = "font-medium text-destructive" > Error:</ p >
164- < p className = "mt-1 text-destructive/80 text-sm" > { result . error } </ p >
165- </ div >
166- ) : result . columns && result . rows ? (
167- < div >
168- < div className = "mb-4 flex items-center gap-4" >
169- < Badge variant = "outline" > { result . rows . length } rows</ Badge >
170- < Badge variant = "outline" > { result . columns . length } columns</ Badge >
171- </ div >
172- { renderTable ( ) }
173- </ div >
174- ) : (
175- < div >
176- < div className = "flex items-center gap-4" >
177- { typeof result . changes === "number" && < Badge variant = "outline" > Affected rows: { result . changes } </ Badge > }
178- { result . lastInsertRowid && < Badge variant = "outline" > Insert ID: { String ( result . lastInsertRowid ) } </ Badge > }
179- </ div >
180- < p className = "mt-2 text-muted-foreground" > Query execution completed</ p >
181- </ div >
182- ) }
183- </ CardContent >
184- </ Card >
185- ) ;
186- } ;
187-
188106 return (
189107 < >
190108 { /* Floating Button */ }
@@ -207,7 +125,7 @@ export function DatabaseStudio() {
207125 </ DialogTitle >
208126 </ DialogHeader >
209127
210- < div className = "flex h-[calc(100vh-80px)] flex-col" >
128+ < div className = "flex h-[calc(100vh-80px)] flex-col overflow-y-auto pb-6 " >
211129 { /* SQL Input Area */ }
212130 < div className = "flex-shrink-0 border-b p-6" >
213131 < p className = "mb-4 text-muted-foreground text-sm" >
@@ -254,7 +172,7 @@ export function DatabaseStudio() {
254172
255173 { /* Results Display Area - Fill remaining space */ }
256174 { result ? (
257- < div className = "flex flex-1 flex-col overflow-hidden " >
175+ < div className = "flex flex-1 flex-col" >
258176 { /* Results Header */ }
259177 < div className = "flex-shrink-0 border-b p-4" >
260178 < div className = "flex items-center justify-between" >
@@ -269,7 +187,7 @@ export function DatabaseStudio() {
269187 </ div >
270188
271189 { /* Results Content - Fill remaining space */ }
272- < div className = "flex-1 overflow-hidden " >
190+ < div className = "flex-1" >
273191 { result . error ? (
274192 < div className = "p-6" >
275193 < div className = "rounded-md border border-destructive/20 bg-destructive/10 p-4" >
@@ -289,7 +207,7 @@ export function DatabaseStudio() {
289207
290208 { /* Table - Fill remaining space */ }
291209 < div className = "w-full flex-1 overflow-hidden" >
292- < ScrollArea className = "h -full w-full " >
210+ < div className = "w -full overflow-x-auto pb-2 " >
293211 < table className = "w-full text-sm" style = { { tableLayout : "auto" , minWidth : "100%" } } >
294212 < thead className = "sticky top-0 border-b bg-muted/50" >
295213 < tr >
@@ -335,8 +253,7 @@ export function DatabaseStudio() {
335253 ) ) }
336254 </ tbody >
337255 </ table >
338- < div className = "h-6" />
339- </ ScrollArea >
256+ </ div >
340257 </ div >
341258 </ div >
342259 ) : (
0 commit comments