2026-05-02 18:33:41 +02:00
|
|
|
import AddEntryForm from '@/components/Transactions/AddEntryForm';
|
2025-07-12 19:59:22 +02:00
|
|
|
import AddMilestoneForm from '@/components/Milestones/AddMilestoneForm';
|
2025-07-13 01:07:16 +02:00
|
|
|
import UpdatePriceForm from '@/components/Pricing/UpdatePriceForm';
|
2025-07-12 19:59:22 +02:00
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
|
2026-05-02 20:32:53 +02:00
|
|
|
type FormType = 'purchase' | 'milestone' | 'price';
|
|
|
|
|
|
2025-07-12 19:59:22 +02:00
|
|
|
interface InlineFormProps {
|
2026-05-02 20:32:53 +02:00
|
|
|
type: FormType | null;
|
2026-05-02 18:33:41 +02:00
|
|
|
unit?: string;
|
|
|
|
|
priceTrackingEnabled?: boolean;
|
2025-07-12 19:59:22 +02:00
|
|
|
onClose: () => void;
|
2026-05-02 20:32:53 +02:00
|
|
|
onSuccess?: (type: FormType) => void;
|
2025-07-12 19:59:22 +02:00
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-13 02:10:52 +02:00
|
|
|
export default function InlineForm({
|
|
|
|
|
type,
|
2026-05-02 18:33:41 +02:00
|
|
|
unit = 'units',
|
|
|
|
|
priceTrackingEnabled = false,
|
2025-07-13 02:10:52 +02:00
|
|
|
onClose,
|
2026-05-02 20:32:53 +02:00
|
|
|
onSuccess,
|
2026-05-02 18:33:41 +02:00
|
|
|
className,
|
2025-07-12 19:59:22 +02:00
|
|
|
}: InlineFormProps) {
|
|
|
|
|
if (!type) return null;
|
|
|
|
|
|
2026-05-02 20:32:53 +02:00
|
|
|
const handleSuccess = () => {
|
|
|
|
|
if (onSuccess) onSuccess(type);
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-12 19:59:22 +02:00
|
|
|
return (
|
2025-07-13 02:10:52 +02:00
|
|
|
<div
|
2025-07-12 19:59:22 +02:00
|
|
|
className={cn(
|
2026-05-02 18:33:41 +02:00
|
|
|
'bg-black p-8',
|
|
|
|
|
'transition-all duration-300',
|
|
|
|
|
className,
|
2025-07-12 19:59:22 +02:00
|
|
|
)}
|
|
|
|
|
>
|
2025-07-13 04:06:37 +02:00
|
|
|
<div className="w-full border-4 border-red-500 p-2 bg-black space-y-4 glow-red">
|
2025-07-13 02:10:52 +02:00
|
|
|
<div className="flex justify-center">
|
|
|
|
|
{type === 'purchase' ? (
|
2026-05-02 18:33:41 +02:00
|
|
|
<AddEntryForm
|
|
|
|
|
unit={unit}
|
|
|
|
|
priceTrackingEnabled={priceTrackingEnabled}
|
2026-05-02 20:32:53 +02:00
|
|
|
onSuccess={handleSuccess}
|
2025-07-13 04:06:37 +02:00
|
|
|
onCancel={onClose}
|
2025-07-13 02:10:52 +02:00
|
|
|
/>
|
|
|
|
|
) : type === 'milestone' ? (
|
|
|
|
|
<AddMilestoneForm
|
2026-05-02 20:32:53 +02:00
|
|
|
onSuccess={handleSuccess}
|
2025-07-13 04:06:37 +02:00
|
|
|
onCancel={onClose}
|
2025-07-13 02:10:52 +02:00
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<UpdatePriceForm
|
2026-05-02 20:32:53 +02:00
|
|
|
onSuccess={handleSuccess}
|
2025-07-13 04:06:37 +02:00
|
|
|
onCancel={onClose}
|
2025-07-13 02:10:52 +02:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-07-12 19:59:22 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-07-13 02:10:52 +02:00
|
|
|
}
|