import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; 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'; interface PriceUpdateFormData { date: string; price: string; [key: string]: string; } interface UpdatePriceFormProps { currentPrice?: number; className?: string; } export default function UpdatePriceForm({ currentPrice, className }: 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 }, }); }; return ( Update Asset Price {currentPrice && (

Current price: €{currentPrice.toFixed(4)}

)}
setData('date', e.target.value)} max={new Date().toISOString().split('T')[0]} />
setData('price', e.target.value)} />

Price per unit/share of the asset

); }