Module: PersonForm

PersonForm Component A form for registering a person. Handles field validation and submission. Displays validation errors and success notifications using react-toastify.
Parameters:
Name Type Description
props Object The component props.
Properties
Name Type Description
addPerson function Async callback function to add a person object to parent state or storage.
Source:
Returns:
The rendered registration form
Type
JSX.Element

Methods

(private, inner) handleChange(e)

Handles changes in form input fields. Updates the form state and triggers validation for the changed field.
Parameters:
Name Type Description
e React.ChangeEvent.<HTMLInputElement> The input change event.
Source:

(async, private, inner) handleSubmit(e)

Handles the form submission. Validates the entire person object, calls the addPerson API, and displays a success or error toast based on the result.
Parameters:
Name Type Description
e React.FormEvent.<HTMLFormElement> The form submission event.
Source:

(private, inner) validateField(name, value)

Validates a single form field and updates the component's error state.
Parameters:
Name Type Description
name string The name of the field to validate.
value string The current value of the field.
Source: