mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 04:09:22 +00:00

# Description of Changes - Add UI for Remove Password tool - Fix more translation warnings that were being thrown in the console - Add an encrypted PDF thumbnail and refactor thumbnail generation code
25 lines
1012 B
TypeScript
25 lines
1012 B
TypeScript
import { useTranslation } from 'react-i18next';
|
|
import { useToolOperation } from '../shared/useToolOperation';
|
|
import { createStandardErrorHandler } from '../../../utils/toolErrorHandler';
|
|
import { RemovePasswordParameters } from './useRemovePasswordParameters';
|
|
|
|
export const useRemovePasswordOperation = () => {
|
|
const { t } = useTranslation();
|
|
|
|
const buildFormData = (parameters: RemovePasswordParameters, file: File): FormData => {
|
|
const formData = new FormData();
|
|
formData.append("fileInput", file);
|
|
formData.append("password", parameters.password);
|
|
return formData;
|
|
};
|
|
|
|
return useToolOperation<RemovePasswordParameters>({
|
|
operationType: 'removePassword',
|
|
endpoint: '/api/v1/security/remove-password',
|
|
buildFormData,
|
|
filePrefix: t('removePassword.filenamePrefix', 'decrypted') + '_',
|
|
multiFileEndpoint: false,
|
|
getErrorMessage: createStandardErrorHandler(t('removePassword.error.failed', 'An error occurred while removing the password from the PDF.'))
|
|
});
|
|
};
|