import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import InputError from '@/components/InputError'; import { useForm } from '@inertiajs/react'; import { LoaderCircle } from 'lucide-react'; import { FormEventHandler } from 'react'; import ComponentTitle from '@/components/ui/ComponentTitle'; interface PriceUpdateFormData { date: string; price: string; [key: string]: string; } interface UpdatePriceFormProps { currentPrice?: number; className?: string; onSuccess?: () => void; onCancel?: () => void; } export default function UpdatePriceForm({ currentPrice, className, onSuccess, onCancel }: UpdatePriceFormProps) { const { data, setData, post, processing, errors } = useForm({ date: new Date().toISOString().split('T')[0], // Today's date in YYYY-MM-DD format price: currentPrice?.toString() || '', }); const submit: FormEventHandler = (e) => { e.preventDefault(); post(route('pricing.update'), { onSuccess: () => { // Keep the date, reset only price if needed // User might want to update same day multiple times if (onSuccess) onSuccess(); }, }); }; return (
UPDATE PRICE {currentPrice && (

[CURRENT] €{currentPrice.toFixed(4)}

)}
setData('date', e.target.value)} max={new Date().toISOString().split('T')[0]} className="bg-black border-red-500 text-red-400 focus:border-red-300 font-mono text-sm rounded-none border-2 focus:ring-0 focus:outline-none transition-all glow-red" />
setData('price', e.target.value)} className="bg-black border-red-500 text-red-400 focus:border-red-300 font-mono text-sm rounded-none border-2 focus:ring-0 focus:outline-none focus:shadow-[0_0_10px_rgba(239,68,68,0.5)] placeholder:text-red-400/40 transition-all" />

[UNIT] price per share

{onCancel && ( )}
); }