2025-08-20 11:38:41 +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 { SingleLargePageParameters, defaultParameters } from './useSingleLargePageParameters';
|
|
|
|
|
|
|
|
// Static function that can be used by both the hook and automation executor
|
|
|
|
export const buildSingleLargePageFormData = (parameters: SingleLargePageParameters, file: File): FormData => {
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append("fileInput", file);
|
|
|
|
return formData;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Static configuration object
|
|
|
|
export const singleLargePageOperationConfig = {
|
2025-08-18 15:45:05 +01:00
|
|
|
toolType: 'singleFile',
|
|
|
|
buildFormData: buildSingleLargePageFormData,
|
2025-08-22 14:40:27 +01:00
|
|
|
operationType: 'single-large-page',
|
|
|
|
endpoint: '/api/v1/general/pdf-to-single-page',
|
|
|
|
filePrefix: 'single_page_', // Will be overridden in hook with translation
|
|
|
|
defaultParameters,
|
|
|
|
} as const;
|
2025-08-20 11:38:41 +01:00
|
|
|
|
|
|
|
export const useSingleLargePageOperation = () => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return useToolOperation<SingleLargePageParameters>({
|
2025-08-22 14:40:27 +01:00
|
|
|
...singleLargePageOperationConfig,
|
2025-08-20 11:38:41 +01:00
|
|
|
filePrefix: t('pdfToSinglePage.filenamePrefix', 'single_page') + '_',
|
|
|
|
getErrorMessage: createStandardErrorHandler(t('pdfToSinglePage.error.failed', 'An error occurred while converting to single page.'))
|
|
|
|
});
|
2025-08-18 15:45:05 +01:00
|
|
|
};
|