"use client"; import React from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { generateBatchSchema } from "@/lib/utils/validators"; import { Input } from "@/components/ui/Input"; import { Select } from "@/components/ui/Select"; import { Button } from "@/components/ui/Button"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/Card"; import { IMAGE_MODELS, getModelCost, formatCost } from "@/lib/constants/models"; import type { Niche } from "@/types/api"; import { InfoButton } from "@/components/ui/InfoButton"; interface BatchFormProps { onSubmit: (data: { niche: Niche; count: number; image_model?: string | null; target_audience?: string | null; offer?: string | null }) => Promise; isLoading: boolean; } export const BatchForm: React.FC = ({ onSubmit, isLoading, }) => { const { register, handleSubmit, formState: { errors }, watch, } = useForm({ resolver: zodResolver(generateBatchSchema), defaultValues: { niche: "home_insurance" as const, count: 5, image_model: null, target_audience: "", offer: "", }, }); const count = watch("count"); const selectedModel = watch("image_model"); return (
Batch Generation
Generate multiple ads at once for testing and variety
{errors.target_audience && (

{errors.target_audience.message}

)}
{errors.offer && (

{errors.offer.message}

)}
1 100
{errors.count && (

{errors.count.message}

)} {/* Cost Estimator */}

💰 Estimated Cost: {formatCost(getModelCost(selectedModel || "", count))}

{count} total image{count > 1 ? 's' : ''} × {IMAGE_MODELS.find(m => m.value === (selectedModel || ""))?.label.split(' - ')[0] || "Default model"}

); };