71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
'use client';
|
|
|
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
import Link from 'next/link';
|
|
import { useParams } from 'next/navigation';
|
|
import { AnnouncementBar } from '@/layout/AnnouncementBar';
|
|
import { Header } from '@/layout/Header';
|
|
import { Navbar } from '@/layout/Navbar';
|
|
import { Footer } from '@/layout/Footer';
|
|
import { StickyHeaderSpacer } from '@/components/StickyHeaderSpacer';
|
|
import { FloatingButtons } from '@/components/FloatingButtons';
|
|
import { FaqCategoryPage } from '@/components/faq/FaqPageView';
|
|
import { storefrontService } from '@/services/api/storefrontService';
|
|
import { parseFaqPageData } from '@/lib/faqPageLayout';
|
|
import {
|
|
DEFAULT_FAQ_PAGE,
|
|
matchFaqCategory,
|
|
type FaqPageData,
|
|
} from '@/lib/faqDefaults';
|
|
|
|
export default function FaqCategoryRoutePage() {
|
|
const params = useParams<{ category: string }>();
|
|
const slug = String(params?.category || '');
|
|
const [data, setData] = useState<FaqPageData>(DEFAULT_FAQ_PAGE);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
storefrontService.getFaqLayout().then((raw) => {
|
|
if (!cancelled) setData(parseFaqPageData(raw));
|
|
});
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, []);
|
|
|
|
const category = useMemo(
|
|
() => matchFaqCategory(data.categories, slug),
|
|
[data.categories, slug]
|
|
);
|
|
|
|
return (
|
|
<div className="min-h-screen bg-[#F8F9FB] text-[#1E293B] flex flex-col font-sans">
|
|
<AnnouncementBar />
|
|
<Header />
|
|
<StickyHeaderSpacer />
|
|
<Navbar />
|
|
<main className="flex-grow py-10 pb-20">
|
|
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-[1400px]">
|
|
{category ? (
|
|
<FaqCategoryPage data={data} category={category} />
|
|
) : (
|
|
<div className="bg-white border border-gray-200 rounded-2xl p-10 text-center max-w-lg mx-auto">
|
|
<h1 className="text-lg font-bold text-[#1E293B]">FAQ category not found</h1>
|
|
<p className="text-[13px] text-gray-500 mt-2 mb-6">
|
|
This category is missing or no longer published.
|
|
</p>
|
|
<Link
|
|
href="/faqs"
|
|
className="inline-flex items-center justify-center h-10 px-5 rounded-lg bg-primary text-white text-[13px] font-semibold hover:bg-primary-hover"
|
|
>
|
|
Browse all FAQs
|
|
</Link>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</main>
|
|
<Footer />
|
|
<FloatingButtons />
|
|
</div>
|
|
);
|
|
}
|