2025-08-19 18:00:50 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useToolOperation } from '../shared/useToolOperation';
|
|
|
|
import { createStandardErrorHandler } from '../../../utils/toolErrorHandler';
|
2025-08-22 14:40:27 +01:00
|
|
|
import { RepairParameters, defaultParameters } from './useRepairParameters';
|
|
|
|
|
|
|
|
// Static function that can be used by both the hook and automation executor
|
|
|
|
export const buildRepairFormData = (parameters: RepairParameters, file: File): FormData => {
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append("fileInput", file);
|
|
|
|
return formData;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Static configuration object
|
|
|
|
export const repairOperationConfig = {
|
|
|
|
operationType: 'repair',
|
|
|
|
endpoint: '/api/v1/misc/repair',
|
|
|
|
buildFormData: buildRepairFormData,
|
|
|
|
filePrefix: 'repaired_', // Will be overridden in hook with translation
|
|
|
|
multiFileEndpoint: false,
|
|
|
|
defaultParameters,
|
|
|
|
} as const;
|
2025-08-19 18:00:50 +01:00
|
|
|
|
|
|
|
export const useRepairOperation = () => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return useToolOperation<RepairParameters>({
|
2025-08-22 14:40:27 +01:00
|
|
|
...repairOperationConfig,
|
2025-08-19 18:00:50 +01:00
|
|
|
filePrefix: t('repair.filenamePrefix', 'repaired') + '_',
|
|
|
|
getErrorMessage: createStandardErrorHandler(t('repair.error.failed', 'An error occurred while repairing the PDF.'))
|
|
|
|
});
|
|
|
|
};
|