From 5096545e20261312d398451d531d47b3e075b3f6 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Wed, 1 Oct 2025 14:32:01 +0100 Subject: [PATCH] Rotatiton --- .../public/locales/en-GB/translation.json | 1 + .../tools/rotate/RotateAutomationSettings.tsx | 43 +++++++++++++++++++ .../src/data/useTranslatedToolRegistry.tsx | 3 +- .../tools/automate/useSuggestedAutomations.ts | 7 +-- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/tools/rotate/RotateAutomationSettings.tsx diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 334231987..c1182a600 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -850,6 +850,7 @@ "rotate": { "title": "Rotate PDF", "submit": "Apply Rotation", + "selectRotation": "Select Rotation Angle (Clockwise)", "error": { "failed": "An error occurred while rotating the PDF." }, diff --git a/frontend/src/components/tools/rotate/RotateAutomationSettings.tsx b/frontend/src/components/tools/rotate/RotateAutomationSettings.tsx new file mode 100644 index 000000000..8449c2000 --- /dev/null +++ b/frontend/src/components/tools/rotate/RotateAutomationSettings.tsx @@ -0,0 +1,43 @@ +/** + * RotateAutomationSettings - Used for automation only + * + * Simplified rotation settings for automation that allows selecting + * one of four 90-degree rotation angles. + */ + +import { Stack, Text } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { RotateParameters } from "../../../hooks/tools/rotate/useRotateParameters"; +import ButtonSelector from "../../shared/ButtonSelector"; + +interface RotateAutomationSettingsProps { + parameters: RotateParameters; + onParameterChange: (key: K, value: RotateParameters[K]) => void; + disabled?: boolean; +} + +const RotateAutomationSettings = ({ parameters, onParameterChange, disabled = false }: RotateAutomationSettingsProps) => { + const { t } = useTranslation(); + + return ( + + + {t("rotate.selectRotation", "Select Rotation Angle (Clockwise)")} + + + onParameterChange('angle', value)} + options={[ + { value: 0, label: "0°" }, + { value: 90, label: "90°" }, + { value: 180, label: "180°" }, + { value: 270, label: "270°" }, + ]} + disabled={disabled} + /> + + ); +}; + +export default RotateAutomationSettings; diff --git a/frontend/src/data/useTranslatedToolRegistry.tsx b/frontend/src/data/useTranslatedToolRegistry.tsx index 53008f03e..85e01b818 100644 --- a/frontend/src/data/useTranslatedToolRegistry.tsx +++ b/frontend/src/data/useTranslatedToolRegistry.tsx @@ -95,6 +95,7 @@ import ReplaceColorSettings from "../components/tools/replaceColor/ReplaceColorS import AddStampAutomationSettings from "../components/tools/addStamp/AddStampAutomationSettings"; import CertSignAutomationSettings from "../components/tools/certSign/CertSignAutomationSettings"; import CropAutomationSettings from "../components/tools/crop/CropAutomationSettings"; +import RotateAutomationSettings from "../components/tools/rotate/RotateAutomationSettings"; const showPlaceholderTools = true; // Show all tools; grey out unavailable ones in UI @@ -408,7 +409,7 @@ export function useFlatToolRegistry(): ToolRegistry { maxFiles: -1, endpoints: ["rotate-pdf"], operationConfig: rotateOperationConfig, - automationSettings: RotateSettings, //TODO:: Fix + automationSettings: RotateAutomationSettings, synonyms: getSynonyms(t, "rotate") }, split: { diff --git a/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts b/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts index 970c14375..dfa2b79b5 100644 --- a/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts +++ b/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next'; import React from 'react'; import LocalIcon from '../../../components/shared/LocalIcon'; import { SuggestedAutomation } from '../../../types/automation'; +import { SPLIT_METHODS } from '../../../constants/splitConstants'; // Create icon components const CompressIcon = () => React.createElement(LocalIcon, { icon: 'compress', width: '1.5rem', height: '1.5rem' }); @@ -83,18 +84,18 @@ export function useSuggestedAutomations(): SuggestedAutomation[] { } }, { - operation: "splitPdf", + operation: "split", parameters: { - mode: 'bySizeOrCount', + method: SPLIT_METHODS.BY_SIZE, pages: '', hDiv: '1', vDiv: '1', merge: false, - splitType: 'size', splitValue: '20MB', bookmarkLevel: '1', includeMetadata: false, allowDuplicates: false, + duplexMode: false, } }, {