hooks.ts


Overview

The hooks.ts file provides custom React hooks and utility functions focused on selecting and managing document parsers based on file types and user interactions. It primarily facilitates:

This file integrates tightly with user settings and form state management within the application, enabling dynamic and context-sensitive parser selection in document processing workflows.


Detailed Explanations

Constants and Utility Functions

ParserListMap


getParserList(values, parserList)


Hook: useFetchParserListOnMount

useFetchParserListOnMount(
  documentId: string,
  parserId: DocumentParserType,
  documentExtension: string,
  form: FormInstance,
)

Constant: hideAutoKeywords


Hook: useShowAutoKeywords

useShowAutoKeywords()

Important Implementation Details and Algorithms


Interaction with Other Parts of the System


Diagram: File Structure and Hook Relationships

flowchart TD
    A[ParserListMap] -->|lookup by extension| B[getParserList]
    B --> C[useFetchParserListOnMount]
    C --> D[selectedTag state]
    C --> E[handleChange function]
    E --> F[useHandleChunkMethodSelectChange]
    C --> G[useSelectParserList]
    H[hideAutoKeywords] --> I[useShowAutoKeywords]
    I --> J{Check selectedTag against hideAutoKeywords}

    style A fill:#f9f,stroke:#333,stroke-width:1px
    style B fill:#bbf,stroke:#333,stroke-width:1px
    style C fill:#bfb,stroke:#333,stroke-width:1px
    style I fill:#fbf,stroke:#333,stroke-width:1px

Summary

The hooks.ts file plays a critical role in managing parser selection logic in a document processing system. It encapsulates:

This modular and reactive design supports extensibility for new parsers or file types and maintains consistent UX aligned with user permissions and document context.