From ed18d86960fd3a52a3d35d10951662df45e3344e Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Sun, 9 Nov 2025 17:01:52 +0330 Subject: [PATCH] feat(marketing): Add page type configuration and validation for marketing wizard - Add page type selection (company or organization) with dynamic form fields - Implement conditional validation for company-specific fields (language, company name, country) - Update HeroStep with URL pattern validation for GIF file input - Modify page submission to include page type and related configuration data - Enhance form handling with react-hook-form for page type configuration - Add input groups and select components for page type configuration section --- .../marketing/create/_components/HeroStep.tsx | 2 + src/app/marketing/create/page.tsx | 142 +++++++++++++++++- 2 files changed, 142 insertions(+), 2 deletions(-) diff --git a/src/app/marketing/create/_components/HeroStep.tsx b/src/app/marketing/create/_components/HeroStep.tsx index dbd9272..fd42846 100644 --- a/src/app/marketing/create/_components/HeroStep.tsx +++ b/src/app/marketing/create/_components/HeroStep.tsx @@ -2,6 +2,7 @@ import InputGroup from "@/components/FormElements/InputGroup"; import { TextAreaGroup } from "@/components/FormElements/InputGroup/text-area"; import { ShowcaseSection } from "@/components/Layouts/showcase-section"; +import { REGEX } from "@/constants/regex"; import { FormErrorMessages } from "@/constants/Texts"; import { forwardRef, useImperativeHandle } from "react"; import useHeroStepPresenter from "./useHeroStepPresenter"; @@ -113,6 +114,7 @@ const HeroStep = forwardRef((props, ref) => { { const [step, setStep] = useState(0); const [formData, setFormData] = useState({}); @@ -24,6 +35,20 @@ const Marketing = () => { const contactsRef = useRef(null); const footerRef = useRef(null); + const { + register: registerPageType, + watch: watchPageType, + formState: { errors: pageTypeErrors }, + getValues: getPageTypeValues, + } = useForm({ + defaultValues: { + page_type: "company", + }, + }); + + const pageType = watchPageType("page_type"); + const isCompany = pageType === "company"; + const { mutate: createCms, isPending } = useCreateCms(); const breadcrumbItems: BreadcrumbItem[] = [ @@ -120,9 +145,21 @@ const Marketing = () => { const handleSubmitAll = async () => { const allData = await collectAllStepsData(); - console.log("All collected data:", allData); + const pageTypeData = getPageTypeValues(); + + const finalData = { + ...allData, + page_type: pageTypeData.page_type, + ...(pageTypeData.page_type === "company" && { + language: pageTypeData.language, + company_name: pageTypeData.company_name, + country: pageTypeData.country, + }), + }; - createCms(allData, { + console.log("All collected data:", finalData); + + createCms(finalData, { onSuccess: () => { console.log("CMS created successfully"); }, @@ -179,6 +216,107 @@ const Marketing = () => { <> + {/* Page Type Selection */} +
+

+ Page Configuration +

+
+