11"use client" ;
22
3- import { Tool } from '@/lib/tool-utils ' ;
4- import { categoryDefinitions , MainCategory } from '@/config /tool-categories ' ;
3+ import type { Tool } from '@/types ' ;
4+ import { tools } from '@/lib /tool-utils ' ;
55import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card' ;
66import Link from 'next/link' ;
7- import { ArrowRightLeft , Minimize2 , Combine , Edit , BarChart , Sparkles } from 'lucide-react' ;
7+ import { ArrowRightLeft , Minimize2 , Combine , Download } from 'lucide-react' ;
88
99const categoryIcons = {
1010 convert : ArrowRightLeft ,
1111 compress : Minimize2 ,
1212 combine : Combine ,
13- edit : Edit ,
14- analyze : BarChart ,
15- generate : Sparkles ,
13+ download : Download ,
14+ } ;
15+
16+ type MainCategory = 'convert' | 'compress' | 'combine' | 'download' ;
17+
18+ const categoryDefinitions = {
19+ convert : { name : 'Convert' , color : 'blue' } ,
20+ compress : { name : 'Compress' , color : 'green' } ,
21+ combine : { name : 'Combine' , color : 'purple' } ,
22+ download : { name : 'Download' , color : 'red' } ,
1623} ;
1724
1825interface ToolsByCategoryProps {
@@ -23,16 +30,17 @@ interface ToolsByCategoryProps {
2330export function ToolsByCategory ( { tools, selectedCategory } : ToolsByCategoryProps ) {
2431 // Group tools by category
2532 const toolsByCategory = tools . reduce ( ( acc , tool ) => {
26- if ( ! acc [ tool . category ] ) {
27- acc [ tool . category ] = [ ] ;
33+ const category = tool . operation as MainCategory ;
34+ if ( ! acc [ category ] ) {
35+ acc [ category ] = [ ] ;
2836 }
29- acc [ tool . category ] . push ( tool ) ;
37+ acc [ category ] . push ( tool ) ;
3038 return acc ;
3139 } , { } as Record < MainCategory , Tool [ ] > ) ;
3240
3341 // Sort tools by priority within each category
3442 Object . keys ( toolsByCategory ) . forEach ( category => {
35- toolsByCategory [ category as MainCategory ] . sort ( ( a , b ) =>
43+ toolsByCategory [ category as MainCategory ] . sort ( ( a : Tool , b : Tool ) =>
3644 ( b . priority || 0 ) - ( a . priority || 0 )
3745 ) ;
3846 } ) ;
@@ -58,15 +66,14 @@ export function ToolsByCategory({ tools, selectedCategory }: ToolsByCategoryProp
5866 </ div >
5967 < div >
6068 < h2 className = "text-2xl font-bold" > { categoryInfo . name } Tools</ h2 >
61- < p className = "text-muted-foreground" > { categoryInfo . description } </ p >
6269 </ div >
6370 < span className = "ml-auto px-3 py-1 rounded-full bg-muted text-sm font-medium" >
6471 { categoryTools . length } tools
6572 </ span >
6673 </ div >
6774
6875 < div className = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4" >
69- { categoryTools . map ( tool => (
76+ { categoryTools . map ( ( tool : Tool ) => (
7077 < Link key = { tool . id } href = { tool . route } >
7178 < Card className = "h-full hover:shadow-lg transition-all hover:-translate-y-0.5 cursor-pointer" >
7279 < CardHeader className = "pb-3" >
@@ -83,16 +90,11 @@ export function ToolsByCategory({ tools, selectedCategory }: ToolsByCategoryProp
8390 < p className = "text-sm text-muted-foreground line-clamp-2" >
8491 { tool . description }
8592 </ p >
86- { tool . subcategory && (
93+ { tool . from && tool . to && (
8794 < div className = "mt-3 flex items-center gap-2" >
88- < span className = "text-xs px-2 py-1 rounded-full bg- muted" >
89- { tool . subcategory . replace ( / - / g , ' ' ) }
95+ < span className = "text-xs text- muted-foreground " >
96+ { tool . from . toUpperCase ( ) } → { tool . to . toUpperCase ( ) }
9097 </ span >
91- { tool . from && tool . to && (
92- < span className = "text-xs text-muted-foreground" >
93- { tool . from . toUpperCase ( ) } → { tool . to . toUpperCase ( ) }
94- </ span >
95- ) }
9698 </ div >
9799 ) }
98100 </ CardContent >
0 commit comments