You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: expose form validation methods from EventTypePlatformWrapper (calcom#22655)
* feat: expose form validation methods from EventTypePlatformWrapper
- Add validateForm and handleFormSubmit methods to onFormStateChange prop
- Update useEventTypeForm hook to return validateForm method
- Add proper TypeScript types for form validation result
- Enable external form validation and submission capabilities
Co-Authored-By: somay@cal.com <somay@cal.com>
* fix: correct forwardRef syntax to resolve parsing errors
- Fix forwardRef parameter destructuring syntax
- Use proper props parameter pattern for forwardRef components
- Ensure prettier can parse the file correctly
Co-Authored-By: somay@cal.com <somay@cal.com>
* feat: add form validation and submission handlers to event types platform wrapper
* refactor: move form validation and submit handlers from hook to wrapper component
* fix: add ref to the save button for proper form validation
* feat: extend ref-based validation API to AvailabilitySettingsPlatformWrapper
- Add AvailabilityFormValidationResult and AvailabilitySettingsPlatformWrapperRef types
- Implement forwardRef pattern in AvailabilitySettings component with save button ref
- Add validateForm and handleFormSubmit methods using useImperativeHandle
- Update AvailabilitySettingsPlatformWrapper to support ref forwarding
- Add comprehensive documentation for ref-based validation API in both event-type.mdx and availability-settings.mdx
- Follow same patterns established in EventTypePlatformWrapper for consistency
Co-Authored-By: somay@cal.com <somay@cal.com>
* refactor: rename AvailabilitySettingsPlatformWrapperRef to AvailabilitySettingsFormRef
* feat: add ref-based validation pattern to availability example page
- Mirror the ref-based validation implementation from event-types.tsx
- Add useRef, handleValidate, and handleSubmit functions
- Demonstrate validateForm() and handleFormSubmit() methods
- Add validation and submit buttons to showcase the new API
- Use AvailabilitySettingsFormRef type for proper typing
Co-Authored-By: somay@cal.com <somay@cal.com>
* refactor: remove unused state variables
* docs: clarify form validation behavior for availability and event type atoms
* chore: remove console.logs
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: somay@cal.com <somay@cal.com>
Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
Copy file name to clipboardExpand all lines: docs/platform/atoms/availability-settings.mdx
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,3 +133,59 @@ Along with the props, Availability settings atom accepts custom styles via the *
133
133
| overridesModalClassNames | Adds styling to the date overrides modal |
134
134
135
135
<Info>Please ensure all custom classnames are valid [Tailwind CSS](https://tailwindcss.com/) classnames.</Info>
136
+
137
+
## Programmatic Form Validation and Submission
138
+
139
+
The AvailabilitySettings component supports programmatic form validation and submission through a ref-based API. This allows you to validate availability data and submit forms programmatically without user interaction.
| validateForm | Validates the current availability form state and returns a promise with validation results. |
185
+
| handleFormSubmit | Programmatically submits the availability form, triggering the same validation and submission flow as clicking the save button. Unlike `validateForm`, this method will check required fields and prevent submission unless all required fields are set |
186
+
187
+
The `validateForm` method returns an `AvailabilityFormValidationResult` object with:
188
+
- `isValid`: Boolean indicating if the form passed validation
189
+
- `errors`: Object containing any validation errors found
190
+
191
+
**Note:** If a required field is not filled in, the `validateForm` method will not return any error. The validation focuses on the format and consistency of provided data rather than enforcing required field completion.
Copy file name to clipboardExpand all lines: docs/platform/atoms/event-type.mdx
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,60 @@ Along with the props, event type settings atom accepts custom styles via the **c
196
196
Please ensure all custom classnames are valid [Tailwind CSS](https://tailwindcss.com/) classnames.
197
197
</Info>
198
198
199
+
## Programmatic Form Validation and Submission
200
+
201
+
The EventTypeSettings component supports programmatic form validation and submission through a ref-based API. This allows you to validate form data and submit forms programmatically without user interaction.
| validateForm | Validates the current event type form state and returns a promise with validation results. |
245
+
| handleFormSubmit | Programmatically submits the event type form, triggering the same validation and submission flow as clicking the save button. Unlike `validateForm`, this method will check required fields and prevent submission unless all required fields are set |
246
+
247
+
The `validateForm` method returns an `EventTypeFormValidationResult` object with:
248
+
- `isValid`: Boolean indicating if the form passed validation
249
+
- `errors`: Object containing any validation errors found
250
+
251
+
**Note:** If a required field is not filled in, the `validateForm` method will not return any error. The validation focuses on the format and consistency of provided data rather than enforcing required field completion.
252
+
199
253
Following are the tabs that are available in the event type settings atom:
0 commit comments