File tree Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Expand file tree Collapse file tree 2 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export async function POST(request: NextRequest) {
29
29
const validatedFiles = benchifyFileSchema . parse ( generatedFiles ) ;
30
30
31
31
// // Repair the generated code using Benchify's API
32
- const repairedFiles = await repairCode ( validatedFiles ) ;
32
+ const { repairedFiles, buildOutput } = await repairCode ( validatedFiles ) ;
33
33
34
34
const { sbxId, template, url } = await createSandbox ( { files : generatedFiles } ) ;
35
35
@@ -39,7 +39,7 @@ export async function POST(request: NextRequest) {
39
39
return NextResponse . json ( {
40
40
originalFiles : generatedFiles ,
41
41
repairedFiles : repairedFiles ,
42
- // buildOutput: '', // We don't get build output from Benchify in our current setup
42
+ buildOutput : buildOutput ,
43
43
previewUrl : url ,
44
44
} ) ;
45
45
} catch ( error ) {
Original file line number Diff line number Diff line change 4
4
import { useEffect , useState } from 'react' ;
5
5
import { PromptForm } from '@/components/ui-builder/prompt-form' ;
6
6
import { Card , CardContent } from '@/components/ui/card' ;
7
+ import { benchifyFileSchema } from '@/lib/schemas' ;
8
+ import { z } from 'zod' ;
9
+
7
10
export default function Home ( ) {
8
- const [ result , setResult ] = useState < any > ( null ) ;
11
+ const [ result , setResult ] = useState < {
12
+ repairedFiles : z . infer < typeof benchifyFileSchema > ;
13
+ buildOutput : string ;
14
+ previewUrl : string ;
15
+ } | null > ( null ) ;
9
16
10
17
useEffect ( ( ) => {
11
18
if ( result ) {
@@ -22,11 +29,19 @@ export default function Home() {
22
29
< p className = "text-lg text-muted-foreground mb-8 text-center" >
23
30
Generate UI components with AI and automatically repair issues with Benchify
24
31
</ p >
25
- < Card className = "border-border bg-card" >
26
- < CardContent className = "pt-6" >
27
- < PromptForm onGenerate = { setResult } />
28
- </ CardContent >
29
- </ Card >
32
+ { ! result ? (
33
+ < Card className = "border-border bg-card" >
34
+ < CardContent className = "pt-6" >
35
+ < PromptForm onGenerate = { setResult } />
36
+ </ CardContent >
37
+ </ Card >
38
+ ) : (
39
+ < Card className = "border-border bg-card" >
40
+ < CardContent className = "pt-6" >
41
+ < iframe title = "Preview" src = { result . previewUrl } className = "w-full h-full" />
42
+ </ CardContent >
43
+ </ Card >
44
+ ) }
30
45
</ div >
31
46
</ main >
32
47
) ;
You can’t perform that action at this time.
0 commit comments