From 50def152c7b485c654054b779c4fdaa6860447e0 Mon Sep 17 00:00:00 2001 From: EthanHealy01 Date: Fri, 15 Aug 2025 19:38:10 +0100 Subject: [PATCH] use enum values for category and subcategory --- frontend/src/data/toolRegistry.tsx | 295 ++++++++++++++------------ frontend/src/hooks/useToolSections.ts | 6 +- 2 files changed, 161 insertions(+), 140 deletions(-) diff --git a/frontend/src/data/toolRegistry.tsx b/frontend/src/data/toolRegistry.tsx index a86556f0c..e5c3b3881 100644 --- a/frontend/src/data/toolRegistry.tsx +++ b/frontend/src/data/toolRegistry.tsx @@ -5,14 +5,35 @@ import CompressPdfPanel from "../tools/Compress"; import OCRPanel from '../tools/OCR'; import ConvertPanel from '../tools/Convert'; +// Category and subcategory enums for type safety +export enum ToolCategory { + STANDARD_TOOLS = 'Standard Tools', + ADVANCED_TOOLS = 'Advanced Tools', + RECOMMENDED_TOOLS = 'Recommended Tools' +} + +export enum ToolSubcategory { + SIGNING = 'Signing', + DOCUMENT_SECURITY = 'Document Security', + VERIFICATION = 'Verification', + DOCUMENT_REVIEW = 'Document Review', + PAGE_FORMATTING = 'Page Formatting', + EXTRACTION = 'Extraction', + REMOVAL = 'Removal', + AUTOMATION = 'Automation', + GENERAL = 'General', + ADVANCED_FORMATTING = 'Advanced Formatting', + DEVELOPER_TOOLS = 'Developer Tools' +} + export type ToolRegistryEntry = { icon: React.ReactNode; name: string; component: React.ComponentType | null; view: string; description: string; - category: string; - subcategory: string; + category: ToolCategory; + subcategory: ToolSubcategory; // Optional custom props for tools maxFiles?: number; @@ -43,41 +64,41 @@ export type ToolRegistry = { */ // Ordered list used elsewhere for display ordering // Subcategory display order (top to bottom, left to right) -export const SUBCATEGORY_ORDER: string[] = [ - 'Signing', - 'Document Security', - 'Verification', - 'Document Review', - 'Page Formatting', - 'Extraction', - 'Removal', - 'Automation', - 'General', - 'Advanced Formatting', - 'Developer Tools', +export const SUBCATEGORY_ORDER: ToolSubcategory[] = [ + ToolSubcategory.SIGNING, + ToolSubcategory.DOCUMENT_SECURITY, + ToolSubcategory.VERIFICATION, + ToolSubcategory.DOCUMENT_REVIEW, + ToolSubcategory.PAGE_FORMATTING, + ToolSubcategory.EXTRACTION, + ToolSubcategory.REMOVAL, + ToolSubcategory.AUTOMATION, + ToolSubcategory.GENERAL, + ToolSubcategory.ADVANCED_FORMATTING, + ToolSubcategory.DEVELOPER_TOOLS, ]; // Color coding for subcategories (loosely resembling the v1 color palette) -export const SUBCATEGORY_COLOR_MAP: Record = { +export const SUBCATEGORY_COLOR_MAP: Record = { // Security & Signing (pink) - 'Signing': '#FF7892', - 'Document Security': '#FF7892', + [ToolSubcategory.SIGNING]: '#FF7892', + [ToolSubcategory.DOCUMENT_SECURITY]: '#FF7892', // Review / Verification (blue-green) - 'Verification': '#1BB1D4', - 'Document Review': '#48BD54', + [ToolSubcategory.VERIFICATION]: '#1BB1D4', + [ToolSubcategory.DOCUMENT_REVIEW]: '#48BD54', // Organize / Page operations (purple/organize + blue accents) - 'Page Formatting': '#7882FF', - 'Removal': '#7882FF', - 'Extraction': '#1BB1D4', + [ToolSubcategory.PAGE_FORMATTING]: '#7882FF', + [ToolSubcategory.REMOVAL]: '#7882FF', + [ToolSubcategory.EXTRACTION]: '#1BB1D4', // Automation / General quick actions (green) - 'Automation': '#69DC95', - 'General': '#69DC95', + [ToolSubcategory.AUTOMATION]: '#69DC95', + [ToolSubcategory.GENERAL]: '#69DC95', // Advanced buckets (red family) - 'Advanced Formatting': '#F55454', - 'Developer Tools': '#F55454', + [ToolSubcategory.ADVANCED_FORMATTING]: '#F55454', + [ToolSubcategory.DEVELOPER_TOOLS]: '#F55454', }; -export const getSubcategoryColor = (subcategory: string): string => { +export const getSubcategoryColor = (subcategory: ToolSubcategory): string => { return SUBCATEGORY_COLOR_MAP[subcategory] || '#7882FF'; }; @@ -98,8 +119,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "sign", description: t("home.certSign.desc", "Signs a PDF with a Certificate/Key (PEM/P12)"), - category: "Standard Tools", - subcategory: "Signing" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.SIGNING }, "sign": { icon: signature, @@ -107,8 +128,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "sign", description: t("home.sign.desc", "Adds signature to PDF by drawing, text or image"), - category: "Standard Tools", - subcategory: "Signing" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.SIGNING }, @@ -120,8 +141,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.addPassword.desc", "Encrypt your PDF document with a password."), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "add-watermark": { icon: branding_watermark, @@ -129,8 +150,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.watermark.desc", "Add a custom watermark to your PDF document."), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "add-stamp": { icon: approval, @@ -138,8 +159,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.AddStampRequest.desc", "Add text or add image stamps at set locations"), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "sanitize": { icon: sanitizer, @@ -147,8 +168,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.sanitizePdf.desc", "Remove scripts and other elements from PDF files"), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "flatten": { icon: layers_clear, @@ -156,8 +177,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.flatten.desc", "Remove all interactive elements and forms from a PDF"), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "unlock-pdf-forms": { icon: preview_off, @@ -165,8 +186,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.unlockPDFForms.desc", "Remove read-only property of form fields in a PDF document."), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, "manage-certificates": { icon: license, @@ -174,8 +195,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.manageCertificates.desc", "Import, export, or delete digital certificate files used for signing PDFs."), - category: "Standard Tools", - subcategory: "Document Security" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_SECURITY }, @@ -187,8 +208,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "extract", description: t("home.getPdfInfo.desc", "Grabs any and all information possible on PDFs"), - category: "Standard Tools", - subcategory: "Verification" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.VERIFICATION }, "validate-pdf-signature": { icon: verified, @@ -196,8 +217,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.validateSignature.desc", "Verify digital signatures and certificates in PDF documents"), - category: "Standard Tools", - subcategory: "Verification" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.VERIFICATION }, @@ -209,8 +230,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "view", description: t("home.read.desc", "View and annotate PDFs. Highlight text, draw, or insert comments for review and collaboration."), - category: "Standard Tools", - subcategory: "Document Review" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_REVIEW }, "change-metadata": { icon: assignment, @@ -218,8 +239,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.changeMetadata.desc", "Change/Remove/Add metadata from a PDF document"), - category: "Standard Tools", - subcategory: "Document Review" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_REVIEW }, "change-permissions": { icon: admin_panel_settings, @@ -227,8 +248,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.permissions.desc", "Change the permissions of your PDF document"), - category: "Standard Tools", - subcategory: "Document Review" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.DOCUMENT_REVIEW }, @@ -240,8 +261,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.crop.desc", "Crop a PDF to reduce its size (maintains text!)"), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "rotate": { icon: rotate_right, @@ -249,8 +270,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.rotate.desc", "Easily rotate your PDFs."), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "splitPdf": { icon: content_cut, @@ -258,8 +279,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: SplitPdfPanel, view: "split", description: t("home.split.desc", "Split PDFs into multiple documents"), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "reorganize-pages": { icon: move_down, @@ -267,8 +288,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "pageEditor", description: t("home.reorganizePages.desc", "Rearrange, duplicate, or delete PDF pages with visual drag-and-drop control."), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "adjust-page-size-scale": { icon: crop_free, @@ -276,8 +297,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.scalePages.desc", "Change the size/scale of a page and/or its contents."), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "add-page-numbers": { icon: 123, @@ -285,8 +306,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.add-page-numbers.desc", "Add Page numbers throughout a document in a set location"), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "multi-page-layout": { icon: dashboard, @@ -294,8 +315,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.pageLayout.desc", "Merge multiple pages of a PDF document into a single page"), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "single-large-page": { icon: looks_one, @@ -303,8 +324,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.PdfToSinglePage.desc", "Merges all PDF pages into one large single page"), - category: "Standard Tools", - subcategory: "Page Formatting" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING }, "add-attachments": { icon: attachment, @@ -312,8 +333,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.attachments.desc", "Add or remove embedded files (attachments) to/from a PDF"), - category: "Standard Tools", - subcategory: "Page Formatting", + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.PAGE_FORMATTING, }, @@ -325,8 +346,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "extract", description: t("home.extractPage.desc", "Extract specific pages from a PDF document"), - category: "Standard Tools", - subcategory: "Extraction" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.EXTRACTION }, "extract-images": { icon: filter, @@ -334,8 +355,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "extract", description: t("home.extractImages.desc", "Extract images from PDF documents"), - category: "Standard Tools", - subcategory: "Extraction" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.EXTRACTION }, @@ -347,8 +368,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "remove", description: t("home.removePages.desc", "Remove specific pages from a PDF document"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, "remove-blank-pages": { icon: scan_delete, @@ -356,8 +377,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "remove", description: t("home.removeBlanks.desc", "Remove blank pages from PDF documents"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, "remove-annotations": { icon: thread_unread, @@ -365,8 +386,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "remove", description: t("home.removeAnnotations.desc", "Remove annotations and comments from PDF documents"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, "remove-image": { icon: remove_selection, @@ -374,8 +395,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.removeImagePdf.desc", "Remove images from PDF documents"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, "remove-password": { icon: lock_open_right, @@ -383,8 +404,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.removePassword.desc", "Remove password protection from PDF documents"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, "remove-certificate-sign": { icon: remove_moderator, @@ -392,8 +413,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "security", description: t("home.removeCertSign.desc", "Remove digital signatures from PDF documents"), - category: "Standard Tools", - subcategory: "Removal" + category: ToolCategory.STANDARD_TOOLS, + subcategory: ToolSubcategory.REMOVAL }, @@ -405,8 +426,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.automate.desc", "Build multi-step workflows by chaining together PDF actions. Ideal for recurring tasks."), - category: "Advanced Tools", - subcategory: "Automation" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.AUTOMATION }, "auto-rename-pdf-file": { icon: match_word, @@ -414,8 +435,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.auto-rename.desc", "Automatically rename PDF files based on their content"), - category: "Advanced Tools", - subcategory: "Automation" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.AUTOMATION }, "auto-split-pages": { icon: split_scene_right, @@ -423,8 +444,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.autoSplitPDF.desc", "Automatically split PDF pages based on content detection"), - category: "Advanced Tools", - subcategory: "Automation" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.AUTOMATION }, "auto-split-by-size-count": { icon: content_cut, @@ -432,8 +453,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.autoSizeSplitPDF.desc", "Automatically split PDFs by file size or page count"), - category: "Advanced Tools", - subcategory: "Automation" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.AUTOMATION }, @@ -445,8 +466,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.adjust-contrast.desc", "Adjust colors and contrast of PDF documents"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "repair": { icon: build, @@ -454,8 +475,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.repair.desc", "Repair corrupted or damaged PDF files"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "detect-split-scanned-photos": { icon: scanner, @@ -463,8 +484,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.ScannerImageSplit.desc", "Detect and split scanned photos into separate pages"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "overlay-pdfs": { icon: layers, @@ -472,8 +493,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.overlay-pdfs.desc", "Overlay one PDF on top of another"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "replace-and-invert-color": { icon: format_color_fill, @@ -481,8 +502,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.replaceColorPdf.desc", "Replace or invert colors in PDF documents"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "add-image": { icon: image, @@ -490,8 +511,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.addImage.desc", "Add images to PDF documents"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "edit-table-of-contents": { icon: bookmark_add, @@ -499,8 +520,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.editTableOfContents.desc", "Add or edit bookmarks and table of contents in PDF documents"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, "scanner-effect": { icon: scanner, @@ -508,8 +529,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.fakeScan.desc", "Create a PDF that looks like it was scanned"), - category: "Advanced Tools", - subcategory: "Advanced Formatting" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.ADVANCED_FORMATTING }, @@ -521,8 +542,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "extract", description: t("home.showJS.desc", "Extract and display JavaScript code from PDF documents"), - category: "Advanced Tools", - subcategory: "Developer Tools" + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.DEVELOPER_TOOLS }, "dev-api": { icon: open_in_new, @@ -530,8 +551,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "external", description: t("home.devApi.desc", "Link to API documentation"), - category: "Advanced Tools", - subcategory: "Developer Tools", + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.DEVELOPER_TOOLS, link: "https://stirlingpdf.io/swagger-ui/5.21.0/index.html" }, "dev-folder-scanning": { @@ -540,8 +561,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "external", description: t("home.devFolderScanning.desc", "Link to automated folder scanning guide"), - category: "Advanced Tools", - subcategory: "Developer Tools", + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.DEVELOPER_TOOLS, link: "https://docs.stirlingpdf.com/Advanced%20Configuration/Folder%20Scanning/" }, "dev-sso-guide": { @@ -550,8 +571,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "external", description: t("home.devSsoGuide.desc", "Link to SSO guide"), - category: "Advanced Tools", - subcategory: "Developer Tools", + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.DEVELOPER_TOOLS, link: "https://docs.stirlingpdf.com/Advanced%20Configuration/Single%20Sign-On%20Configuration", }, "dev-airgapped": { @@ -560,8 +581,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "external", description: t("home.devAirgapped.desc", "Link to air-gapped setup guide"), - category: "Advanced Tools", - subcategory: "Developer Tools", + category: ToolCategory.ADVANCED_TOOLS, + subcategory: ToolSubcategory.DEVELOPER_TOOLS, link: "https://docs.stirlingpdf.com/Pro/#activation" }, @@ -573,8 +594,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "format", description: t("home.compare.desc", "Compare two PDF documents and highlight differences"), - category: "Recommended Tools", - subcategory: "General" + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL }, "compressPdfs": { icon: zoom_in_map, @@ -582,8 +603,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: CompressPdfPanel, view: "compress", description: t("home.compressPdfs.desc", "Compress PDFs to reduce their file size."), - category: "Recommended Tools", - subcategory: "General", + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL, maxFiles: -1 }, "convert": { @@ -592,8 +613,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: ConvertPanel, view: "convert", description: t("home.fileToPDF.desc", "Convert files to and from PDF format"), - category: "Recommended Tools", - subcategory: "General", + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL, maxFiles: -1, endpoints: [ "pdf-to-img", @@ -636,8 +657,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "merge", description: t("home.merge.desc", "Merge multiple PDFs into a single document"), - category: "Recommended Tools", - subcategory: "General", + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL, maxFiles: -1 }, "multi-tool": { @@ -646,8 +667,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "pageEditor", description: t("home.multiTool.desc", "Use multiple tools on a single PDF document"), - category: "Recommended Tools", - subcategory: "General", + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL, maxFiles: -1 }, "ocr": { @@ -656,8 +677,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: OCRPanel, view: "convert", description: t("home.ocr.desc", "Extract text from scanned PDFs using Optical Character Recognition"), - category: "Recommended Tools", - subcategory: "General", + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL, maxFiles: -1 }, "redact": { @@ -666,8 +687,8 @@ export function useFlatToolRegistry(): ToolRegistry { component: null, view: "redact", description: t("home.redact.desc", "Permanently remove sensitive information from PDF documents"), - category: "Recommended Tools", - subcategory: "General" + category: ToolCategory.RECOMMENDED_TOOLS, + subcategory: ToolSubcategory.GENERAL }, }; } diff --git a/frontend/src/hooks/useToolSections.ts b/frontend/src/hooks/useToolSections.ts index 12478b643..58cac8a79 100644 --- a/frontend/src/hooks/useToolSections.ts +++ b/frontend/src/hooks/useToolSections.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { type ToolRegistryEntry, SUBCATEGORY_ORDER } from '../data/toolRegistry'; +import { type ToolRegistryEntry, SUBCATEGORY_ORDER, ToolCategory } from '../data/toolRegistry'; import { useTranslation } from 'react-i18next'; type GroupedTools = { @@ -25,7 +25,7 @@ export function useToolSections(filteredTools: [string, ToolRegistryEntry][]) { const sections = useMemo(() => { const getOrderIndex = (name: string) => { - const idx = SUBCATEGORY_ORDER.indexOf(name); + const idx = SUBCATEGORY_ORDER.indexOf(name as any); return idx === -1 ? Number.MAX_SAFE_INTEGER : idx; }; @@ -40,7 +40,7 @@ export function useToolSections(filteredTools: [string, ToolRegistryEntry][]) { all[sub].push(...tools); }); - if (upperCat === 'RECOMMENDED TOOLS') { + if (upperCat === ToolCategory.RECOMMENDED_TOOLS.toUpperCase()) { Object.entries(subs).forEach(([sub, tools]) => { if (!quick[sub]) quick[sub] = []; quick[sub].push(...tools);