incr/resources/js/components/Display/InlineForm.tsx
myrmidex 6e76ce9c68
All checks were successful
CI / ci (push) Successful in 14m47s
CI / build (push) Successful in 27s
34 - Frontend: AddEntryForm, generalize unit labels, update LedDisplay/StatsBox/ProgressBar/InlineForm
2026-05-02 18:33:41 +02:00

70 lines
2.3 KiB
TypeScript

import AddEntryForm from '@/components/Transactions/AddEntryForm';
import AddMilestoneForm from '@/components/Milestones/AddMilestoneForm';
import UpdatePriceForm from '@/components/Pricing/UpdatePriceForm';
import { cn } from '@/lib/utils';
interface InlineFormProps {
type: 'purchase' | 'milestone' | 'price' | null;
unit?: string;
priceTrackingEnabled?: boolean;
onClose: () => void;
onPurchaseSuccess?: () => void;
onMilestoneSuccess?: () => void;
onPriceSuccess?: () => void;
className?: string;
}
export default function InlineForm({
type,
unit = 'units',
priceTrackingEnabled = false,
onClose,
onPurchaseSuccess,
onMilestoneSuccess,
onPriceSuccess,
className,
}: InlineFormProps) {
if (!type) return null;
return (
<div
className={cn(
'bg-black p-8',
'transition-all duration-300',
className,
)}
>
<div className="w-full border-4 border-red-500 p-2 bg-black space-y-4 glow-red">
<div className="flex justify-center">
{type === 'purchase' ? (
<AddEntryForm
unit={unit}
priceTrackingEnabled={priceTrackingEnabled}
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>
);
}