chore(env): update application version to 2.2.8 in production environment
feat(marketing): enhance step components with validity reporting - Added onValidityChange prop to multiple step components (BenefitsStep, ChallengesStep, ChartStep, ContactsStep, FeaturesStep, FooterStep, HeroStep) to handle form validity. - Updated respective presenter hooks to utilize the new onValidityChange functionality for real-time validity reporting. - Enhanced MarketingForm to manage step validity and disable the next button based on current step validity.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
import { ForwardedRef, useImperativeHandle } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import useReportStepValidity from "./useReportStepValidity";
|
||||
|
||||
export interface IHeroStepFields {
|
||||
title: string;
|
||||
@@ -13,17 +14,21 @@ export interface IHeroStepFields {
|
||||
const useHeroStepPresenter = (
|
||||
initialData?: IHeroStepFields,
|
||||
ref?: ForwardedRef<unknown>,
|
||||
onValidityChange?: (valid: boolean) => void,
|
||||
) => {
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
formState: { errors, isValid },
|
||||
getValues,
|
||||
trigger,
|
||||
} = useForm<IHeroStepFields>({
|
||||
defaultValues: initialData,
|
||||
mode: "onChange",
|
||||
});
|
||||
|
||||
useReportStepValidity(isValid, onValidityChange);
|
||||
|
||||
const onSubmit = (data: IHeroStepFields) => {
|
||||
console.log(data);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user