Type errors

This commit is contained in:
Connor Yoh 2025-08-22 13:04:28 +01:00
parent ea7c8ee1c7
commit 577a866bf0
6 changed files with 62 additions and 31 deletions

View File

@ -38,7 +38,7 @@ export default function AutomationRun({ automation, onComplete, automateOperatio
id: `${op.operation}-${index}`,
operation: op.operation,
name: tool?.name || op.operation,
status: EXECUTION_STATUS.PENDING as const
status: EXECUTION_STATUS.PENDING
};
});
setExecutionSteps(steps);
@ -69,7 +69,7 @@ export default function AutomationRun({ automation, onComplete, automateOperatio
// Reset progress tracking
setCurrentStepIndex(0);
setExecutionSteps(prev => prev.map(step => ({ ...step, status: EXECUTION_STATUS.PENDING as const, error: undefined })));
setExecutionSteps(prev => prev.map(step => ({ ...step, status: EXECUTION_STATUS.PENDING, error: undefined })));
try {
// Use the automateOperation.executeOperation to handle file consumption properly
@ -79,17 +79,17 @@ export default function AutomationRun({ automation, onComplete, automateOperatio
onStepStart: (stepIndex: number, operationName: string) => {
setCurrentStepIndex(stepIndex);
setExecutionSteps(prev => prev.map((step, idx) =>
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.RUNNING as const } : step
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.RUNNING } : step
));
},
onStepComplete: (stepIndex: number, resultFiles: File[]) => {
setExecutionSteps(prev => prev.map((step, idx) =>
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.COMPLETED as const } : step
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.COMPLETED } : step
));
},
onStepError: (stepIndex: number, error: string) => {
setExecutionSteps(prev => prev.map((step, idx) =>
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.ERROR as const, error } : step
idx === stepIndex ? { ...step, status: EXECUTION_STATUS.ERROR, error } : step
));
}
},

View File

@ -64,7 +64,7 @@ export default function AutomationSelection({
<AutomationEntry
key={automation.id}
badgeIcon={automation.icon}
operations={automation.operations}
operations={automation.operations.map(op => op.operation)}
onClick={() => onRun(automation)}
/>
))}

View File

@ -41,7 +41,7 @@ export function useAutomationForm({ mode, existingAutomation, toolRegistry }: Us
id: `${operation}-${Date.now()}-${index}`,
operation: operation,
name: getToolName(operation),
configured: mode === AutomationMode.EDIT ? true : (typeof op === 'object' ? op.configured || false : false),
configured: mode === AutomationMode.EDIT ? true : false,
parameters: typeof op === 'object' ? op.parameters || {} : {}
};
});

View File

@ -1,33 +1,53 @@
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import StarIcon from '@mui/icons-material/Star';
export interface SuggestedAutomation {
id: string;
operations: string[];
icon: React.ComponentType<any>;
}
import { SuggestedAutomation } from '../../../types/automation';
export function useSuggestedAutomations(): SuggestedAutomation[] {
const { t } = useTranslation();
const suggestedAutomations = useMemo<SuggestedAutomation[]>(() => [
{
id: "compress-and-merge",
operations: ["compress", "merge"],
icon: StarIcon,
},
{
id: "ocr-and-convert",
operations: ["ocr", "convert"],
icon: StarIcon,
},
{
id: "secure-workflow",
operations: ["sanitize", "addPassword", "changePermissions"],
icon: StarIcon,
},
], [t]);
const suggestedAutomations = useMemo<SuggestedAutomation[]>(() => {
const now = new Date().toISOString();
return [
{
id: "compress-and-merge",
name: t("automation.suggested.compressAndMerge", "Compress & Merge"),
description: t("automation.suggested.compressAndMergeDesc", "Compress PDFs and merge them into one file"),
operations: [
{ operation: "compress", parameters: {} },
{ operation: "merge", parameters: {} }
],
createdAt: now,
updatedAt: now,
icon: StarIcon,
},
{
id: "ocr-and-convert",
name: t("automation.suggested.ocrAndConvert", "OCR & Convert"),
description: t("automation.suggested.ocrAndConvertDesc", "Extract text via OCR and convert to different format"),
operations: [
{ operation: "ocr", parameters: {} },
{ operation: "convert", parameters: {} }
],
createdAt: now,
updatedAt: now,
icon: StarIcon,
},
{
id: "secure-workflow",
name: t("automation.suggested.secureWorkflow", "Secure Workflow"),
description: t("automation.suggested.secureWorkflowDesc", "Sanitize, add password, and set permissions"),
operations: [
{ operation: "sanitize", parameters: {} },
{ operation: "addPassword", parameters: {} },
{ operation: "changePermissions", parameters: {} }
],
createdAt: now,
updatedAt: now,
icon: StarIcon,
},
];
}, [t]);
return suggestedAutomations;
}

View File

@ -75,6 +75,10 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
);
case 'creation':
if (!stepData.mode) {
console.error('Creation mode is undefined');
return null;
}
return (
<AutomationCreation
mode={stepData.mode}
@ -89,6 +93,10 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
);
case 'run':
if (!stepData.automation) {
console.error('Automation config is undefined');
return null;
}
return (
<AutomationRun
automation={stepData.automation}

View File

@ -57,7 +57,10 @@ export enum AutomationMode {
export interface SuggestedAutomation {
id: string;
name: string;
operations: string[];
description?: string;
operations: AutomationOperation[];
createdAt: string;
updatedAt: string;
icon: any; // MUI Icon component
}