2025-08-15 14:43:30 +01:00
|
|
|
import { useMemo } from 'react';
|
2025-09-05 12:35:17 +01:00
|
|
|
import { useNavigationState } from '../contexts/NavigationContext';
|
|
|
|
import { useToolNavigation } from './useToolNavigation';
|
|
|
|
import { useToolManagement } from './useToolManagement';
|
2025-08-28 15:42:33 +01:00
|
|
|
import { ToolId } from '../types/toolId';
|
2025-08-15 14:43:30 +01:00
|
|
|
|
|
|
|
// Material UI Icons
|
|
|
|
import CompressIcon from '@mui/icons-material/Compress';
|
|
|
|
import SwapHorizIcon from '@mui/icons-material/SwapHoriz';
|
|
|
|
import CleaningServicesIcon from '@mui/icons-material/CleaningServices';
|
|
|
|
import CropIcon from '@mui/icons-material/Crop';
|
|
|
|
import TextFieldsIcon from '@mui/icons-material/TextFields';
|
|
|
|
|
|
|
|
export interface SuggestedTool {
|
2025-08-28 15:42:33 +01:00
|
|
|
id: ToolId;
|
2025-08-15 14:43:30 +01:00
|
|
|
title: string;
|
|
|
|
icon: React.ComponentType<any>;
|
2025-09-05 12:35:17 +01:00
|
|
|
href: string;
|
|
|
|
onClick: (e: React.MouseEvent) => void;
|
2025-08-15 14:43:30 +01:00
|
|
|
}
|
|
|
|
|
2025-09-05 12:35:17 +01:00
|
|
|
const ALL_SUGGESTED_TOOLS: Omit<SuggestedTool, 'href' | 'onClick'>[] = [
|
2025-08-15 14:43:30 +01:00
|
|
|
{
|
2025-08-22 13:53:06 +01:00
|
|
|
id: 'compress',
|
2025-08-15 14:43:30 +01:00
|
|
|
title: 'Compress',
|
|
|
|
icon: CompressIcon
|
|
|
|
},
|
|
|
|
{
|
2025-08-22 13:53:06 +01:00
|
|
|
id: 'convert',
|
2025-08-15 14:43:30 +01:00
|
|
|
title: 'Convert',
|
|
|
|
icon: SwapHorizIcon
|
|
|
|
},
|
|
|
|
{
|
2025-08-22 13:53:06 +01:00
|
|
|
id: 'sanitize',
|
2025-08-15 14:43:30 +01:00
|
|
|
title: 'Sanitize',
|
|
|
|
icon: CleaningServicesIcon
|
|
|
|
},
|
|
|
|
{
|
2025-08-28 15:42:33 +01:00
|
|
|
id: 'split',
|
2025-08-15 14:43:30 +01:00
|
|
|
title: 'Split',
|
|
|
|
icon: CropIcon
|
|
|
|
},
|
|
|
|
{
|
2025-08-22 13:53:06 +01:00
|
|
|
id: 'ocr',
|
2025-08-15 14:43:30 +01:00
|
|
|
title: 'OCR',
|
|
|
|
icon: TextFieldsIcon
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
export function useSuggestedTools(): SuggestedTool[] {
|
2025-08-28 15:42:33 +01:00
|
|
|
const { selectedTool } = useNavigationState();
|
2025-09-05 12:35:17 +01:00
|
|
|
const { getToolNavigation } = useToolNavigation();
|
|
|
|
const { getSelectedTool } = useToolManagement();
|
2025-08-15 14:43:30 +01:00
|
|
|
|
|
|
|
return useMemo(() => {
|
|
|
|
// Filter out the current tool
|
2025-08-28 15:42:33 +01:00
|
|
|
const filteredTools = ALL_SUGGESTED_TOOLS.filter(tool => tool.id !== selectedTool);
|
2025-08-22 13:53:06 +01:00
|
|
|
|
2025-09-05 12:35:17 +01:00
|
|
|
// Add navigation props to each tool
|
|
|
|
return filteredTools.map(tool => {
|
|
|
|
const toolRegistryEntry = getSelectedTool(tool.id);
|
|
|
|
if (!toolRegistryEntry) {
|
|
|
|
// Fallback for tools not in registry
|
|
|
|
return {
|
|
|
|
...tool,
|
|
|
|
href: `/${tool.id}`,
|
|
|
|
onClick: (e: React.MouseEvent) => { e.preventDefault(); }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const navProps = getToolNavigation(tool.id, toolRegistryEntry);
|
|
|
|
return {
|
|
|
|
...tool,
|
|
|
|
...navProps
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}, [selectedTool, getToolNavigation, getSelectedTool]);
|
2025-08-22 13:53:06 +01:00
|
|
|
}
|