incr/resources/js/components/Display/InlineForm.tsx

71 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-07-12 19:59:22 +02:00
import AddMilestoneForm from '@/components/Milestones/AddMilestoneForm';
import AddPurchaseForm from '@/components/Transactions/AddPurchaseForm';
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';
2025-07-13 02:10:52 +02:00
import ComponentTitle from '@/components/ui/ComponentTitle';
2025-07-12 19:59:22 +02:00
interface InlineFormProps {
2025-07-13 01:07:16 +02:00
type: 'purchase' | 'milestone' | 'price' | null;
2025-07-12 19:59:22 +02:00
onClose: () => void;
onPurchaseSuccess?: () => void;
onMilestoneSuccess?: () => void;
2025-07-13 01:07:16 +02:00
onPriceSuccess?: () => void;
2025-07-12 19:59:22 +02:00
className?: string;
}
2025-07-13 02:10:52 +02:00
export default function InlineForm({
type,
onClose,
2025-07-12 19:59:22 +02:00
onPurchaseSuccess,
onMilestoneSuccess,
2025-07-13 01:07:16 +02:00
onPriceSuccess,
2025-07-13 02:10:52 +02:00
className
2025-07-12 19:59:22 +02:00
}: InlineFormProps) {
if (!type) return null;
2025-07-13 01:07:16 +02:00
const title = type === 'purchase' ? 'ADD PURCHASE' : type === 'milestone' ? 'ADD MILESTONE' : 'UPDATE PRICE';
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(
2025-07-13 02:10:52 +02:00
"bg-black p-8",
"transition-all duration-300",
2025-07-12 19:59:22 +02:00
className
)}
>
{/* Header */}
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-12 19:59:22 +02:00
2025-07-13 02:10:52 +02:00
{/* Form Content */}
<div className="flex justify-center">
{type === 'purchase' ? (
<AddPurchaseForm
onSuccess={() => {
if (onPurchaseSuccess) onPurchaseSuccess();
onClose();
}}
2025-07-13 04:06:37 +02:00
onCancel={onClose}
2025-07-13 02:10:52 +02:00
/>
) : type === 'milestone' ? (
<AddMilestoneForm
onSuccess={() => {
if (onMilestoneSuccess) onMilestoneSuccess();
onClose();
}}
2025-07-13 04:06:37 +02:00
onCancel={onClose}
2025-07-13 02:10:52 +02:00
/>
) : (
<UpdatePriceForm
onSuccess={() => {
if (onPriceSuccess) onPriceSuccess();
onClose();
}}
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
}