From 5e6458f18c49c770eda7a5b56e1e3964a8cea567 Mon Sep 17 00:00:00 2001 From: "Somayeh.Ghanavati" Date: Wed, 23 Sep 2026 09:28:14 +0330 Subject: [PATCH] refactor(MyForm): add onSubmit prop for Storybook actions integration --- src/stories/myForm.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/stories/myForm.tsx b/src/stories/myForm.tsx index 2c0e529..9f50e47 100644 --- a/src/stories/myForm.tsx +++ b/src/stories/myForm.tsx @@ -1,14 +1,22 @@ -import React from "react"; import { useForm } from "@tanstack/react-form"; -export function MyForm() { +interface MyFormProps { + onSubmit?: (values: { + username?: string; + age?: string; + password?: string; + }) => void; +} +export function MyForm({ onSubmit }: MyFormProps) { const form = useForm({ defaultValues: { username: "", age: "", password: "", }, + onSubmit: async ({ value }) => { + onSubmit?.(value); console.log("Form submitted successfully:", value); alert(JSON.stringify(value, null, 2)); },