Stirling-PDF/frontend/src/components/tools/shared/SuggestedToolsSection.tsx

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

53 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-08-21 19:12:12 +01:00
import React, { useCallback } from 'react';
import { Stack, Text, Divider, Card, Group } from '@mantine/core';
import { useTranslation } from 'react-i18next';
import { useSuggestedTools } from '../../../hooks/useSuggestedTools';
2025-08-21 19:12:12 +01:00
import { useNavigationActions, useNavigationState, type ModeType } from '../../../contexts/NavigationContext';
2025-08-19 16:50:55 +01:00
export interface SuggestedToolsSectionProps {}
export function SuggestedToolsSection(): React.ReactElement {
const { t } = useTranslation();
2025-08-21 19:12:12 +01:00
const { actions } = useNavigationActions();
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 (
<Stack gap="md">
<Divider />
<Text size="lg" fw={600}>
{t('editYourNewFiles', 'Edit your new file(s)')}
</Text>
<Stack gap="xs">
{suggestedTools.map((tool) => {
const IconComponent = tool.icon;
return (
<Card
key={tool.name}
p="sm"
withBorder
style={{ cursor: 'pointer' }}
onClick={tool.navigate}
>
<Group gap="xs">
<IconComponent fontSize="small" />
<Text size="sm" fw={500}>
{tool.title}
</Text>
</Group>
</Card>
);
})}
</Stack>
</Stack>
);
}