mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-24 13:19:23 +00:00
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.'))
|
||
|
});
|
||
|
};
|