import AddMilestoneForm from '@/components/Milestones/AddMilestoneForm';
import AddPurchaseForm from '@/components/Transactions/AddPurchaseForm';
import UpdatePriceForm from '@/components/Pricing/UpdatePriceForm';
import { cn } from '@/lib/utils';
import ComponentTitle from '@/components/ui/ComponentTitle';

interface InlineFormProps {
    type: 'purchase' | 'milestone' | 'price' | null;
    onClose: () => void;
    onPurchaseSuccess?: () => void;
    onMilestoneSuccess?: () => void;
    onPriceSuccess?: () => void;
    className?: string;
}

export default function InlineForm({
    type,
    onClose,
    onPurchaseSuccess,
    onMilestoneSuccess,
    onPriceSuccess,
    className
}: InlineFormProps) {
    if (!type) return null;

    const title = type === 'purchase' ? 'ADD PURCHASE' : type === 'milestone' ? 'ADD MILESTONE' : 'UPDATE PRICE';

    return (
        <div
            className={cn(
                "bg-black p-8",
                "transition-all duration-300",
                className
            )}
        >
            {/* Header */}
            <div className="w-full border-4 border-red-500 p-2 bg-black space-y-4 glow-red">

                {/* Form Content */}
                <div className="flex justify-center">
                    {type === 'purchase' ? (
                        <AddPurchaseForm
                            onSuccess={() => {
                                if (onPurchaseSuccess) onPurchaseSuccess();
                                onClose();
                            }}
                            onCancel={onClose}
                        />
                    ) : type === 'milestone' ? (
                        <AddMilestoneForm
                            onSuccess={() => {
                                if (onMilestoneSuccess) onMilestoneSuccess();
                                onClose();
                            }}
                            onCancel={onClose}
                        />
                    ) : (
                        <UpdatePriceForm
                            onSuccess={() => {
                                if (onPriceSuccess) onPriceSuccess();
                                onClose();
                            }}
                            onCancel={onClose}
                        />
                    )}
                </div>
            </div>
        </div>
    );
}
