2025-08-20 11:34:28 +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 { UnlockPdfFormsParameters, defaultParameters } from './useUnlockPdfFormsParameters';
|
|
|
|
|
|
|
|
// Static function that can be used by both the hook and automation executor
|
|
|
|
export const buildUnlockPdfFormsFormData = (parameters: UnlockPdfFormsParameters, file: File): FormData => {
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append("fileInput", file);
|
|
|
|
return formData;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Static configuration object
|
|
|
|
export const unlockPdfFormsOperationConfig = {
|
2025-08-18 15:45:05 +01:00
|
|
|
toolType: 'singleFile',
|
|
|
|
buildFormData: buildUnlockPdfFormsFormData,
|
2025-08-22 14:40:27 +01:00
|
|
|
operationType: 'unlock-pdf-forms',
|
|
|
|
endpoint: '/api/v1/misc/unlock-pdf-forms',
|
|
|
|
filePrefix: 'unlocked_forms_', // Will be overridden in hook with translation
|
|
|
|
defaultParameters,
|
|
|
|
} as const;
|
2025-08-20 11:34:28 +01:00
|
|
|
|
|
|
|
export const useUnlockPdfFormsOperation = () => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return useToolOperation<UnlockPdfFormsParameters>({
|
2025-08-22 14:40:27 +01:00
|
|
|
...unlockPdfFormsOperationConfig,
|
2025-08-20 11:34:28 +01:00
|
|
|
filePrefix: t('unlockPDFForms.filenamePrefix', 'unlocked_forms') + '_',
|
|
|
|
getErrorMessage: createStandardErrorHandler(t('unlockPDFForms.error.failed', 'An error occurred while unlocking PDF forms.'))
|
|
|
|
});
|
2025-08-18 15:45:05 +01:00
|
|
|
};
|