mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00
Fix suggested tools
This commit is contained in:
parent
b2822c1d43
commit
065e120a3c
@ -732,7 +732,8 @@
|
|||||||
"officeDocs": "Office Documents (Word, Excel, PowerPoint)",
|
"officeDocs": "Office Documents (Word, Excel, PowerPoint)",
|
||||||
"imagesExt": "Images (JPG, PNG, etc.)",
|
"imagesExt": "Images (JPG, PNG, etc.)",
|
||||||
"markdown": "Markdown",
|
"markdown": "Markdown",
|
||||||
"textRtf": "Text/RTF"
|
"textRtf": "Text/RTF",
|
||||||
|
"grayscale": "Greyscale"
|
||||||
},
|
},
|
||||||
"imageToPdf": {
|
"imageToPdf": {
|
||||||
"tags": "conversion,img,jpg,picture,photo"
|
"tags": "conversion,img,jpg,picture,photo"
|
||||||
@ -2017,7 +2018,8 @@
|
|||||||
"downloadSelected": "Download Selected",
|
"downloadSelected": "Download Selected",
|
||||||
"selectedCount": "{{count}} selected",
|
"selectedCount": "{{count}} selected",
|
||||||
"download": "Download",
|
"download": "Download",
|
||||||
"delete": "Delete"
|
"delete": "Delete",
|
||||||
|
"unsupported":"Unsupported"
|
||||||
},
|
},
|
||||||
"storage": {
|
"storage": {
|
||||||
"temporaryNotice": "Files are stored temporarily in your browser and may be cleared automatically",
|
"temporaryNotice": "Files are stored temporarily in your browser and may be cleared automatically",
|
||||||
|
@ -1,22 +1,13 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React from 'react';
|
||||||
import { Stack, Text, Divider, Card, Group } from '@mantine/core';
|
import { Stack, Text, Divider, Card, Group } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSuggestedTools } from '../../../hooks/useSuggestedTools';
|
import { useSuggestedTools } from '../../../hooks/useSuggestedTools';
|
||||||
import { useNavigationActions, useNavigationState, type ModeType } from '../../../contexts/NavigationContext';
|
|
||||||
|
|
||||||
export interface SuggestedToolsSectionProps {}
|
export interface SuggestedToolsSectionProps {}
|
||||||
|
|
||||||
export function SuggestedToolsSection(): React.ReactElement {
|
export function SuggestedToolsSection(): React.ReactElement {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { actions } = useNavigationActions();
|
const suggestedTools = useSuggestedTools();
|
||||||
const { currentMode } = useNavigationState();
|
|
||||||
|
|
||||||
// Create handleToolSelect function that navigates to the tool
|
|
||||||
const handleToolSelect = useCallback((toolId: string) => {
|
|
||||||
actions.setMode(toolId as ModeType);
|
|
||||||
}, [actions]);
|
|
||||||
|
|
||||||
const suggestedTools = useSuggestedTools(currentMode, handleToolSelect);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import { useToolWorkflow } from '../contexts/ToolWorkflowContext';
|
||||||
|
|
||||||
// Material UI Icons
|
// Material UI Icons
|
||||||
import CompressIcon from '@mui/icons-material/Compress';
|
import CompressIcon from '@mui/icons-material/Compress';
|
||||||
@ -42,15 +43,17 @@ const ALL_SUGGESTED_TOOLS: Omit<SuggestedTool, 'navigate'>[] = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export function useSuggestedTools(selectedToolKey?: string | null, handleToolSelect?: (toolId: string) => void): SuggestedTool[] {
|
export function useSuggestedTools(): SuggestedTool[] {
|
||||||
|
const { handleToolSelect, selectedToolKey } = useToolWorkflow();
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
// Filter out the current tool
|
// Filter out the current tool
|
||||||
const filteredTools = ALL_SUGGESTED_TOOLS.filter(tool => tool.name !== selectedToolKey);
|
const filteredTools = ALL_SUGGESTED_TOOLS.filter(tool => tool.name !== selectedToolKey);
|
||||||
|
|
||||||
// Add navigation function to each tool
|
// Add navigation function to each tool
|
||||||
return filteredTools.map(tool => ({
|
return filteredTools.map(tool => ({
|
||||||
...tool,
|
...tool,
|
||||||
navigate: handleToolSelect ? () => handleToolSelect(tool.name) : () => {}
|
navigate: () => handleToolSelect(tool.name)
|
||||||
}));
|
}));
|
||||||
}, [selectedToolKey, handleToolSelect]);
|
}, [selectedToolKey, handleToolSelect]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user