mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Unify creditCosts.ts files (#5952)
Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
co-authored by
Anthony Stirling
parent
dbff05814f
commit
7f9bbebe5b
@@ -1,5 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Stack, Select, Checkbox } from '@mantine/core';
|
||||
import { Stack, Select } from '@mantine/core';
|
||||
import { ExtractImagesParameters } from '@app/hooks/tools/extractImages/useExtractImagesParameters';
|
||||
import { Z_INDEX_AUTOMATE_DROPDOWN } from "@app/styles/zIndex";
|
||||
|
||||
@@ -35,12 +35,12 @@ const ExtractImagesSettings = ({
|
||||
comboboxProps={{ withinPortal: true, zIndex: Z_INDEX_AUTOMATE_DROPDOWN }}
|
||||
/>
|
||||
|
||||
<Checkbox
|
||||
{/* <Checkbox
|
||||
label={t('extractImages.allowDuplicates', 'Allow Duplicate Images')}
|
||||
checked={parameters.allowDuplicates}
|
||||
onChange={(event) => onParameterChange('allowDuplicates', event.currentTarget.checked)}
|
||||
disabled={disabled}
|
||||
/>
|
||||
/> */}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ export const buildExtractImagesFormData = (parameters: ExtractImagesParameters,
|
||||
const formData = new FormData();
|
||||
formData.append("fileInput", file);
|
||||
formData.append("format", parameters.format);
|
||||
formData.append("allowDuplicates", parameters.allowDuplicates.toString());
|
||||
// formData.append("allowDuplicates", parameters.allowDuplicates.toString());
|
||||
return formData;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ import { useBaseParameters } from '@app/hooks/tools/shared/useBaseParameters';
|
||||
|
||||
export interface ExtractImagesParameters {
|
||||
format: 'png' | 'jpg' | 'gif';
|
||||
allowDuplicates: boolean;
|
||||
// allowDuplicates: boolean;
|
||||
}
|
||||
|
||||
export const defaultParameters: ExtractImagesParameters = {
|
||||
format: 'png',
|
||||
allowDuplicates: false,
|
||||
// allowDuplicates: false,
|
||||
};
|
||||
|
||||
export const useExtractImagesParameters = () => {
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
import { ToolId } from '@app/types/toolId'
|
||||
|
||||
// Credit costs based on ResourceWeight enum from backend
|
||||
export const CREDIT_COSTS = {
|
||||
NONE: 0,
|
||||
SMALL: 1,
|
||||
MEDIUM: 3,
|
||||
LARGE: 5,
|
||||
XLARGE: 10
|
||||
} as const
|
||||
|
||||
/**
|
||||
* Mapping of tool IDs to their credit costs
|
||||
* Based on backend ResourceWeight annotations
|
||||
*/
|
||||
export const TOOL_CREDIT_COSTS: Record<ToolId, number> = {
|
||||
// No cost operations (0 credits)
|
||||
showJS: CREDIT_COSTS.NONE,
|
||||
devApi: CREDIT_COSTS.NONE,
|
||||
devFolderScanning: CREDIT_COSTS.NONE,
|
||||
devSsoGuide: CREDIT_COSTS.NONE,
|
||||
devAirgapped: CREDIT_COSTS.NONE,
|
||||
|
||||
// Small operations (1 credit)
|
||||
rotate: CREDIT_COSTS.SMALL,
|
||||
removePages: CREDIT_COSTS.SMALL,
|
||||
addText: CREDIT_COSTS.SMALL,
|
||||
addPassword: CREDIT_COSTS.SMALL,
|
||||
removePassword: CREDIT_COSTS.SMALL,
|
||||
changePermissions: CREDIT_COSTS.SMALL,
|
||||
flatten: CREDIT_COSTS.SMALL,
|
||||
repair: CREDIT_COSTS.SMALL,
|
||||
unlockPDFForms: CREDIT_COSTS.SMALL,
|
||||
crop: CREDIT_COSTS.SMALL,
|
||||
addPageNumbers: CREDIT_COSTS.SMALL,
|
||||
extractPages: CREDIT_COSTS.SMALL,
|
||||
reorganizePages: CREDIT_COSTS.SMALL,
|
||||
scalePages: CREDIT_COSTS.SMALL,
|
||||
editTableOfContents: CREDIT_COSTS.SMALL,
|
||||
sign: CREDIT_COSTS.SMALL,
|
||||
annotate: CREDIT_COSTS.SMALL,
|
||||
formFill: CREDIT_COSTS.SMALL,
|
||||
removeAnnotations: CREDIT_COSTS.SMALL,
|
||||
removeImage: CREDIT_COSTS.SMALL,
|
||||
scannerImageSplit: CREDIT_COSTS.SMALL,
|
||||
adjustContrast: CREDIT_COSTS.SMALL,
|
||||
multiTool: CREDIT_COSTS.SMALL,
|
||||
compare: CREDIT_COSTS.SMALL,
|
||||
addAttachments: CREDIT_COSTS.SMALL,
|
||||
getPdfInfo: CREDIT_COSTS.MEDIUM,
|
||||
validateSignature: CREDIT_COSTS.SMALL,
|
||||
read: CREDIT_COSTS.SMALL,
|
||||
|
||||
// Medium operations (3 credits)
|
||||
split: CREDIT_COSTS.MEDIUM,
|
||||
merge: CREDIT_COSTS.MEDIUM,
|
||||
pdfTextEditor: CREDIT_COSTS.MEDIUM,
|
||||
changeMetadata: CREDIT_COSTS.MEDIUM,
|
||||
watermark: CREDIT_COSTS.MEDIUM,
|
||||
bookletImposition: CREDIT_COSTS.MEDIUM,
|
||||
pdfToSinglePage: CREDIT_COSTS.MEDIUM,
|
||||
removeBlanks: CREDIT_COSTS.MEDIUM,
|
||||
autoRename: CREDIT_COSTS.MEDIUM,
|
||||
sanitize: CREDIT_COSTS.MEDIUM,
|
||||
addImage: CREDIT_COSTS.MEDIUM,
|
||||
addStamp: CREDIT_COSTS.MEDIUM,
|
||||
extractImages: CREDIT_COSTS.MEDIUM,
|
||||
overlayPdfs: CREDIT_COSTS.MEDIUM,
|
||||
pageLayout: CREDIT_COSTS.MEDIUM,
|
||||
redact: CREDIT_COSTS.MEDIUM,
|
||||
removeCertSign: CREDIT_COSTS.MEDIUM,
|
||||
scannerEffect: CREDIT_COSTS.MEDIUM,
|
||||
replaceColor: CREDIT_COSTS.MEDIUM,
|
||||
|
||||
// Large operations (5 credits)
|
||||
compress: CREDIT_COSTS.LARGE,
|
||||
convert: CREDIT_COSTS.LARGE,
|
||||
ocr: CREDIT_COSTS.LARGE,
|
||||
certSign: CREDIT_COSTS.LARGE,
|
||||
|
||||
// Extra large operations (10 credits)
|
||||
automate: CREDIT_COSTS.XLARGE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the credit cost for a specific tool
|
||||
* @param toolId - The tool identifier
|
||||
* @returns The credit cost for the tool, defaults to MEDIUM if not found
|
||||
*/
|
||||
export const getToolCreditCost = (toolId: ToolId): number => {
|
||||
return TOOL_CREDIT_COSTS[toolId] ?? CREDIT_COSTS.MEDIUM
|
||||
}
|
||||
Reference in New Issue
Block a user