"use client" import { useEffect, useRef, useState } from "react" import { Input } from "../ui/input" import { Button } from "../ui/button" import { Check, Loader2, RotateCw, Sparkles, X } from "lucide-react" export default function GenerateInput({ cancel, submit, width, onExpand, }: { cancel: () => void submit: (input: string) => void width: number onExpand: () => void }) { const inputRef = useRef(null) const [code, setCode] = useState(`function add(a: number, b: number): number { return a + b; } const result = add(2, 3); console.log(result);`) const [expanded, setExpanded] = useState(false) const [loading, setLoading] = useState(false) useEffect(() => { inputRef.current?.focus() }, []) const handleGenerate = async () => { setLoading(true) // const res = await generateCode() await new Promise((resolve) => setTimeout(resolve, 1000)) setExpanded(true) onExpand() setLoading(false) } return (
{expanded ? ( <>
{code}
) : null}
) }