From 4ef751509a608e0aa5260141bbb87f95879fe04c Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 19 Mar 2026 13:32:44 +0530 Subject: [PATCH] feat: Add full CMS support for the 'Contact' page, including sections, default content factories, data fetching, and editing forms. --- src/app/dashboard/cms/page.tsx | 109 +++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 4 deletions(-) diff --git a/src/app/dashboard/cms/page.tsx b/src/app/dashboard/cms/page.tsx index dc57820..7970071 100644 --- a/src/app/dashboard/cms/page.tsx +++ b/src/app/dashboard/cms/page.tsx @@ -60,6 +60,11 @@ const FAQ_SECTIONS: SectionMeta[] = [ { pageSlug: 'faq', sectionKey: 'faqContent', label: 'FAQ Content', description: 'Categories, questions and answers' }, ]; +const CONTACT_SECTIONS: SectionMeta[] = [ + { pageSlug: 'contact', sectionKey: 'contactDetails', label: 'Contact Details', description: 'Email, phone, office address and map' }, + { pageSlug: 'contact', sectionKey: 'cta', label: 'Call to Action', description: 'Bottom CTA section text and button' }, +]; + // --------------------------------------------------------------------------- // Default content factories // --------------------------------------------------------------------------- @@ -95,6 +100,12 @@ function defaultContentFor(pageSlug: string, sectionKey: string): unknown { case 'faqContent': return { pageTitle: '', categories: [], faqs: [], supportTitle: '', supportDescription: '' } as FaqContent; } } + if (pageSlug === 'contact') { + switch (sectionKey) { + case 'contactDetails': return { title: '', description: '', email: '', phone: '', phoneHours: '', officeAddress: '', officeCity: '', mapUrl: '', directionsUrl: '' }; + case 'cta': return { title: '', description: '', buttonText: '', buttonLink: '' }; + } + } switch (sectionKey) { case 'hero': return defaultHero(); case 'features': return defaultFeatures(); @@ -132,10 +143,11 @@ const textareaCls = inputCls; export default function CmsPage() { const router = useRouter(); - const [activePage, setActivePage] = useState<'landing' | 'about' | 'faq'>('landing'); + const [activePage, setActivePage] = useState<'landing' | 'about' | 'faq' | 'contact'>('landing'); const [records, setRecords] = useState([]); const [aboutRecords, setAboutRecords] = useState([]); const [faqRecords, setFaqRecords] = useState([]); + const [contactRecords, setContactRecords] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(''); const [notification, setNotification] = useState<{ type: 'success' | 'error'; message: string } | null>(null); @@ -161,14 +173,16 @@ export default function CmsPage() { setIsLoading(true); setError(''); try { - const [landingData, aboutData, faqData] = await Promise.all([ + const [landingData, aboutData, faqData, contactData] = await Promise.all([ cmsService.getByPage('landing'), cmsService.getByPage('about'), cmsService.getByPage('faq'), + cmsService.getByPage('contact'), ]); setRecords(landingData); setAboutRecords(aboutData); setFaqRecords(faqData); + setContactRecords(contactData); } catch (err) { const msg = getErrorMessage(err); setError(msg); @@ -986,6 +1000,80 @@ export default function CmsPage() { ); } + // --------------------------------------------------------------------------- + // Contact page editors + // --------------------------------------------------------------------------- + + function renderContactDetailsForm() { + const data = editContent as Record; + const update = (patch: Record) => setEditContent({ ...data, ...patch }); + return ( +
+
+ + update({ title: e.target.value })} placeholder="Get In Touch" /> +
+
+ +