Skip to content

Commit 6c931bd

Browse files
authored
faq (#116)
* faq ui * not found
1 parent f75001e commit 6c931bd

File tree

3 files changed

+23
-64
lines changed

3 files changed

+23
-64
lines changed

src/app/[lang]/faq/[id]/page.tsx

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { faq } from '@/faq';
22
import { notFound } from 'next/navigation';
33
import { defaultLocale, getDictionary, localeNames } from '@/lib/i18n';
44
import Link from 'next/link';
5-
import { ArrowLeft, ChevronLeft, ChevronRight } from 'lucide-react';
5+
import { ArrowLeft } from 'lucide-react';
66
import FAQCard from '@/components/faq/FAQCard';
77
import { showFAQ } from '@/constants';
88

@@ -28,11 +28,6 @@ export default async function FAQDetailPage({
2828

2929
// Get all FAQ entries
3030
const allFAQs = Object.entries(faq);
31-
const currentIndex = allFAQs.findIndex(([key]) => key === id);
32-
33-
// Get previous and next FAQs
34-
const prevFAQ = currentIndex > 0 ? allFAQs[currentIndex - 1] : null;
35-
const nextFAQ = currentIndex < allFAQs.length - 1 ? allFAQs[currentIndex + 1] : null;
3631

3732
// Get related FAQs (same category, excluding current)
3833
const relatedFAQs = allFAQs
@@ -72,50 +67,6 @@ export default async function FAQDetailPage({
7267
))}
7368
</div>
7469

75-
{/* Navigation: Previous & Next */}
76-
<div className="flex items-center justify-between gap-4 py-8 border-t border-b border-border mb-12">
77-
<div className="flex-1">
78-
{prevFAQ && (
79-
<Link
80-
href={`/${langName}/faq/${prevFAQ[0]}`}
81-
className="group flex items-center gap-2 text-sm hover:text-primary transition-colors"
82-
>
83-
<ChevronLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />
84-
<div>
85-
<div className="text-xs text-muted-foreground mb-1">
86-
{dict.FAQ?.previous || 'Previous'}
87-
</div>
88-
<div className="font-medium line-clamp-1">{prevFAQ[1].Question}</div>
89-
</div>
90-
</Link>
91-
)}
92-
</div>
93-
94-
<Link
95-
href={`/${langName}/faq`}
96-
className="px-4 py-2 text-sm font-medium rounded-md bg-secondary hover:bg-secondary/80 transition-colors"
97-
>
98-
{dict.FAQ?.backToList || 'Back to FAQ'}
99-
</Link>
100-
101-
<div className="flex-1 flex justify-end">
102-
{nextFAQ && (
103-
<Link
104-
href={`/${langName}/faq/${nextFAQ[0]}`}
105-
className="group flex items-center gap-2 text-sm hover:text-primary transition-colors text-right"
106-
>
107-
<div>
108-
<div className="text-xs text-muted-foreground mb-1">
109-
{dict.FAQ?.next || 'Next'}
110-
</div>
111-
<div className="font-medium line-clamp-1">{nextFAQ[1].Question}</div>
112-
</div>
113-
<ChevronRight className="w-4 h-4 group-hover:translate-x-1 transition-transform" />
114-
</Link>
115-
)}
116-
</div>
117-
</div>
118-
11970
{/* Related FAQs */}
12071
{relatedFAQs.length > 0 && (
12172
<section>

src/app/[lang]/not-found.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from 'next/link';
22
import { Search, Home } from 'lucide-react';
3+
import { showFAQ } from '@/constants';
34

45
export default function NotFound() {
56
// Note: We can't access params in not-found.tsx, so we'll use English as default
@@ -35,13 +36,16 @@ export default function NotFound() {
3536
<Home className="w-5 h-5" />
3637
Back to Home
3738
</Link>
38-
<Link
39-
href="/faq"
40-
className="inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium transition-colors"
41-
>
42-
<Search className="w-5 h-5" />
43-
View FAQ
44-
</Link>
39+
{
40+
showFAQ && <Link
41+
href="/faq"
42+
className="inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium transition-colors"
43+
>
44+
<Search className="w-5 h-5" />
45+
View FAQ
46+
</Link>
47+
}
48+
4549
</div>
4650

4751
{/* Additional Help */}

src/app/not-found.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from 'next/link';
22
import { Search, Home } from 'lucide-react';
3+
import { showFAQ } from '@/constants';
34

45
export default function NotFound() {
56
return (
@@ -32,13 +33,16 @@ export default function NotFound() {
3233
<Home className="w-5 h-5" />
3334
Back to Home
3435
</Link>
35-
<Link
36-
href="/faq"
37-
className="inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium transition-colors"
38-
>
39-
<Search className="w-5 h-5" />
40-
View FAQ
41-
</Link>
36+
{
37+
showFAQ && <Link
38+
href="/faq"
39+
className="inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-secondary text-secondary-foreground hover:bg-secondary/80 font-medium transition-colors"
40+
>
41+
<Search className="w-5 h-5" />
42+
View FAQ
43+
</Link>
44+
}
45+
4246
</div>
4347

4448
{/* Additional Help */}

0 commit comments

Comments
 (0)