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

56 lines
1.5 KiB
TypeScript
Raw Normal View History

import AddEntryForm from '@/components/Transactions/AddEntryForm';
2025-07-12 19:59:22 +02:00
import AddMilestoneForm from '@/components/Milestones/AddMilestoneForm';
import { cn } from '@/lib/utils';
type FormType = 'purchase' | 'milestone';
2025-07-12 19:59:22 +02:00
interface InlineFormProps {
type: FormType | null;
unit?: string;
2025-07-12 19:59:22 +02:00
onClose: () => void;
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,
unit = 'units',
2025-07-13 02:10:52 +02:00
onClose,
onSuccess,
className,
2025-07-12 19:59:22 +02:00
}: InlineFormProps) {
if (!type) return null;
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(
'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' ? (
<AddEntryForm
unit={unit}
onSuccess={handleSuccess}
2025-07-13 04:06:37 +02:00
onCancel={onClose}
2025-07-13 02:10:52 +02:00
/>
) : (
<AddMilestoneForm
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
}