mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-27 06:39:24 +00:00
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
![]() |
import { useMemo } from 'react';
|
||
|
import { useToolWorkflow } from '../contexts/ToolWorkflowContext';
|
||
|
|
||
|
// 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
|
||
|
}
|
||
|
];
|
||
|
|
||
|
export function useSuggestedTools(): SuggestedTool[] {
|
||
|
const { handleToolSelect, selectedToolKey } = useToolWorkflow();
|
||
|
|
||
|
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,
|
||
|
navigate: () => handleToolSelect(tool.name)
|
||
|
}));
|
||
|
}, [selectedToolKey, handleToolSelect]);
|
||
|
}
|