<commit_before>import React, { ReactElement, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Redirect, useParams } from 'react-router-dom';
import { get } from '../api/documents';
import { LoginContext } from '../shared/login';
import NotFound from '../shared/NotFound';


export default function DocumentRedirect(): ReactElement {

    const { id } = useParams<{ id: string }>();
    const [project, setProject] = useState<string>(null);
    const [error, setError] = useState<string>(null);
    const loginData = useContext(LoginContext);
    const { t } = useTranslation();

    useEffect (() => {
        
        getDocument(id, loginData.token)
            .then((project: string) => project ? setProject(project) : setError('Not found'))
            .catch(setError);
    }, [id, loginData]);

    return error
        ? <NotFound />
        : project
            ? <Redirect to={ `/project/hierarchy/${project}/${id}` } />
            : <div>{ t('redirect.waitForRedirection')}</div>;
}
<commit_msg>Fix link in DocumentRedirect<commit_after>import React, { ReactElement, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Redirect, useParams } from 'react-router-dom';
import { get } from '../api/documents';
import { LoginContext } from '../shared/login';
import NotFound from '../shared/NotFound';


export default function DocumentRedirect(): ReactElement {

    const { id } = useParams<{ id: string }>();
    const [project, setProject] = useState<string>(null);
    const [error, setError] = useState<string>(null);
    const loginData = useContext(LoginContext);
    const { t } = useTranslation();

    useEffect (() => {
        
        getDocument(id, loginData.token)
            .then((project: string) => project ? setProject(project) : setError('Not found'))
            .catch(setError);
    }, [id, loginData]);

    return error
        ? <NotFound />
        : project
            ? <Redirect to={ `/project/${project}/hierarchy/${id}` } />
            : <div>{ t('redirect.waitForRedirection')}</div>;
}

{'fraction_non_alphanumeric': 0.15865608959402708, 'fraction_numerical': 0.0018665422305179655, 'mean_word_length': 3.1875, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4137956', 'n_tokens_mistral': 600, 'n_tokens_neox': 600, 'n_words': 151}