From a6706fcb0c1c8e0b7ebbfc6f37cad7ce981d56b2 Mon Sep 17 00:00:00 2001 From: James Brunton Date: Thu, 21 Aug 2025 08:48:25 +0100 Subject: [PATCH] V2 reduce boilerplate in param hooks (#4246) # Description of Changes Extend the base params in all tools param hooks, reducing boilerplate code. --- .../tools/compress/CompressSettings.tsx | 2 +- .../tools/ocr/AdvancedOCRSettings.tsx | 2 +- .../src/components/tools/ocr/OCRSettings.tsx | 12 +- .../src/constants/addWatermarkConstants.ts | 15 -- .../addPassword/useAddPasswordParameters.ts | 49 ++--- .../addWatermark/useAddWatermarkParameters.ts | 66 +++---- .../useChangePermissionsParameters.ts | 49 +---- .../tools/compress/useCompressOperation.ts | 12 +- .../tools/compress/useCompressParameters.ts | 58 ++---- .../convert/useConvertParameters.test.ts | 85 ++++---- .../tools/convert/useConvertParameters.ts | 184 ++++++++---------- .../src/hooks/tools/ocr/useOCROperation.ts | 2 +- .../src/hooks/tools/ocr/useOCRParameters.ts | 50 ++--- .../useRemovePasswordParameters.ts | 49 ++--- .../tools/sanitize/useSanitizeParameters.ts | 45 ++--- .../hooks/tools/shared/useBaseParameters.ts | 22 ++- .../hooks/tools/split/useSplitParameters.ts | 75 +++---- .../ConvertSmartDetectionIntegration.test.tsx | 9 +- 18 files changed, 308 insertions(+), 478 deletions(-) diff --git a/frontend/src/components/tools/compress/CompressSettings.tsx b/frontend/src/components/tools/compress/CompressSettings.tsx index 47ff4189e..d82a99453 100644 --- a/frontend/src/components/tools/compress/CompressSettings.tsx +++ b/frontend/src/components/tools/compress/CompressSettings.tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import { Button, Stack, Text, NumberInput, Select, Divider } from "@mantine/core"; import { useTranslation } from "react-i18next"; -import { CompressParameters } from "../../../hooks/tools/compress/useCompressOperation"; +import { CompressParameters } from "../../../hooks/tools/compress/useCompressParameters"; interface CompressSettingsProps { parameters: CompressParameters; diff --git a/frontend/src/components/tools/ocr/AdvancedOCRSettings.tsx b/frontend/src/components/tools/ocr/AdvancedOCRSettings.tsx index 3bd8c1569..a38926edf 100644 --- a/frontend/src/components/tools/ocr/AdvancedOCRSettings.tsx +++ b/frontend/src/components/tools/ocr/AdvancedOCRSettings.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Stack, Text, Checkbox } from '@mantine/core'; import { useTranslation } from 'react-i18next'; -import { OCRParameters } from './OCRSettings'; +import { OCRParameters } from '../../../hooks/tools/ocr/useOCRParameters'; export interface AdvancedOCRParameters { advancedOptions: string[]; diff --git a/frontend/src/components/tools/ocr/OCRSettings.tsx b/frontend/src/components/tools/ocr/OCRSettings.tsx index 588884889..b4d9aa766 100644 --- a/frontend/src/components/tools/ocr/OCRSettings.tsx +++ b/frontend/src/components/tools/ocr/OCRSettings.tsx @@ -2,13 +2,7 @@ import React from 'react'; import { Stack, Select, Text, Divider } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import LanguagePicker from './LanguagePicker'; - -export interface OCRParameters { - languages: string[]; - ocrType: string; - ocrRenderType: string; - additionalOptions: string[]; -} +import { OCRParameters } from '../../../hooks/tools/ocr/useOCRParameters'; interface OCRSettingsProps { parameters: OCRParameters; @@ -25,7 +19,7 @@ const OCRSettings: React.FC = ({ return ( - +