refactor(MyForm): add onSubmit prop for Storybook actions integration

This commit is contained in:
2026-09-23 09:28:14 +03:30
parent 12f8b70c2b
commit 5e6458f18c
+10 -2
View File
@@ -1,14 +1,22 @@
import React from "react";
import { useForm } from "@tanstack/react-form"; 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({ const form = useForm({
defaultValues: { defaultValues: {
username: "", username: "",
age: "", age: "",
password: "", password: "",
}, },
onSubmit: async ({ value }) => { onSubmit: async ({ value }) => {
onSubmit?.(value);
console.log("Form submitted successfully:", value); console.log("Form submitted successfully:", value);
alert(JSON.stringify(value, null, 2)); alert(JSON.stringify(value, null, 2));
}, },