File size: 654 Bytes
ae21b62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { IChunk } from '@/interfaces/database/knowledge';
import { api_host } from '@/utils/api';
import { buildChunkHighlights } from '@/utils/documentUtils';
import { useMemo } from 'react';
import { IHighlight } from 'react-pdf-highlighter';

export const useGetDocumentUrl = (documentId: string) => {
  const url = useMemo(() => {
    return `${api_host}/document/get/${documentId}`;
  }, [documentId]);

  return url;
};

export const useGetChunkHighlights = (selectedChunk: IChunk): IHighlight[] => {
  const highlights: IHighlight[] = useMemo(() => {
    return buildChunkHighlights(selectedChunk);
  }, [selectedChunk]);

  return highlights;
};