import { useForm } from '@tanstack/react-form'; import { useEstimationSessions } from '../../lib/context/estimationSession'; import { useUser } from '../../lib/context/user'; import Input from '../Input'; import Button from '../Button'; interface CreateEstimationSessionFormProps { onCreated: () => void; } const CreateEstimationSessionForm: React.FC< CreateEstimationSessionFormProps > = ({ onCreated }) => { const user = useUser(); const estimationSessions = useEstimationSessions(); const form = useForm({ defaultValues: { name: '', }, onSubmit: async ({ value }) => { await estimationSessions?.add({ Name: value.name, UserId: user.current?.$id, }); onCreated(); }, }); return ( <>

Create a New Estimation Session

{ e.preventDefault(); e.stopPropagation(); form.handleSubmit(); }} > ( field.handleChange(e.target.value)} /> )} /> ); }; export default CreateEstimationSessionForm;