Stirling-PDF/frontend/src/hooks/useSuggestedTools.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
TypeScript
Raw Normal View History

import { useMemo } from 'react';
// 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 {
name: string;
title: string;
icon: React.ComponentType<any>;
navigate: () => void;
}
const ALL_SUGGESTED_TOOLS: Omit<SuggestedTool, 'navigate'>[] = [
{
name: 'compress',
title: 'Compress',
icon: CompressIcon
},
{
name: 'convert',
title: 'Convert',
icon: SwapHorizIcon
},
{
name: 'sanitize',
title: 'Sanitize',
icon: CleaningServicesIcon
},
{
name: 'split',
title: 'Split',
icon: CropIcon
},
{
name: 'ocr',
title: 'OCR',
icon: TextFieldsIcon
}
];
2025-08-19 16:50:55 +01:00
export function useSuggestedTools(selectedToolKey?: string | null, handleToolSelect?: (toolId: string) => void): SuggestedTool[] {
return useMemo(() => {
// Filter out the current tool
const filteredTools = ALL_SUGGESTED_TOOLS.filter(tool => tool.name !== selectedToolKey);
// Add navigation function to each tool
return filteredTools.map(tool => ({
...tool,
2025-08-19 16:50:55 +01:00
navigate: handleToolSelect ? () => handleToolSelect(tool.name) : () => {}
}));
}, [selectedToolKey, handleToolSelect]);
}