File size: 1,391 Bytes
3bb377e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Wand2 } from "lucide-react";
import { Textarea } from "@/components/ui/textarea";
interface PromptInputProps {
onSubmit: (prompt: string) => void;
file: File | null;
}
export function PromptInput({ onSubmit, file }: PromptInputProps) {
const [prompt, setPrompt] = useState("");
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (prompt.trim()) {
onSubmit(prompt.trim());
}
};
return (
<form onSubmit={handleSubmit} className="space-y-4 rounded-lg">
<div className="space-y-2">
<p className="text-sm font-medium text-foreground">
Describe the structure and type of data you want to extract from the
PDF.
</p>
</div>
<Textarea
id="prompt"
className="min-h-[100px] border-secondary resize-none "
placeholder="Example: Extract all invoice details including invoice number, date, items, prices, and total amount..."
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
/>
<Button
type="submit"
disabled={!prompt.trim() || file === null}
className="w-full bg-primary hover:bg-primary/90"
>
<Wand2 className="w-4 h-4 mr-2" />
Extract Data
</Button>
</form>
);
}
|