Files
tm_panel/src/app/marketing/_components/ChallengesStep.tsx
T
AmirReza Jamali bd79b7ed14 refactor(marketing): Standardize marketing wizard steps with initial data support
- Add support for initial data in all marketing wizard step components
- Update step presenters to accept and handle initial data
- Modify forwardRef implementations to include initialData prop
- Add TypeScript interfaces for step component props
- Improve type safety and data handling across marketing wizard steps
- Prepare components for edit and create workflows with consistent data management
2025-11-11 10:43:32 +03:30

51 lines
1.1 KiB
TypeScript

"use client";
import { forwardRef, useImperativeHandle } from "react";
import SectionStep from "./SectionStep";
import useChallengesStepPresenter, {
IChallengesStepFields,
} from "./useChallengesStepPresenter";
interface ChallengesStepProps {
initialData?: IChallengesStepFields;
}
const ChallengesStep = forwardRef<unknown, ChallengesStepProps>(
({ initialData }, ref) => {
const {
errors,
handleSubmit,
onSubmit,
register,
fields,
append,
remove,
control,
getValues,
} = useChallengesStepPresenter(initialData);
useImperativeHandle(ref, () => ({
getData: () => getValues(),
}));
return (
<SectionStep<IChallengesStepFields>
title="Challenges"
fields={fields}
handleSubmit={handleSubmit}
onSubmit={onSubmit}
register={register}
errors={errors}
append={append}
remove={remove}
control={control}
fieldName="cards"
defaultValues={{ icon: "", title: "", description: "" }}
/>
);
},
);
ChallengesStep.displayName = "ChallengesStep";
export default ChallengesStep;