File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,9 @@ export default function GuidesClient({
7777 guides : Guide [ ] ;
7878 categories : string [ ] ;
7979} ) {
80- const [ activeCategory , setActiveCategory ] = useState < string > ( categories [ 0 ] ) ;
80+ const ALL = "All" ;
81+ const [ activeCategory , setActiveCategory ] = useState < string > ( ALL ) ;
82+ const tabs = [ ALL , ...categories ] ;
8183
8284 const featured = useMemo (
8385 ( ) =>
@@ -88,12 +90,14 @@ export default function GuidesClient({
8890 ) ;
8991
9092 const countFor = ( category : string ) =>
91- guides . filter ( ( g ) => g . category === category ) . length ;
93+ category === ALL
94+ ? guides . length
95+ : guides . filter ( ( g ) => g . category === category ) . length ;
9296
9397 const visible = useMemo (
9498 ( ) =>
9599 guides
96- . filter ( ( g ) => g . category === activeCategory )
100+ . filter ( ( g ) => activeCategory === ALL || g . category === activeCategory )
97101 . sort ( ( a , b ) => ( a . order ?? 999 ) - ( b . order ?? 999 ) ) ,
98102 [ guides , activeCategory ]
99103 ) ;
@@ -169,7 +173,7 @@ export default function GuidesClient({
169173
170174 { /* ================= TABS ================= */ }
171175 < div className = "mb-12 flex flex-wrap gap-x-8 gap-y-3 border-b border-gray-200" >
172- { categories . map ( ( category ) => (
176+ { tabs . map ( ( category ) => (
173177 < button
174178 key = { category }
175179 onClick = { ( ) => setActiveCategory ( category ) }
You can’t perform that action at this time.
0 commit comments