Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7595035c

Přidáno uživatelem Lukáš Vlček před více než 2 roky(ů)

AnnotationID as dynamic route part in annotation page

Zobrazit rozdíly:

webapp/contexts/AnnotationContext.tsx
115 115
 * @param props Children that should have access to the annotation context.
116 116
 * @returns Prepared html of the provider.
117 117
 */
118
const AnnotationProvider = (props: { children: React.ReactNode }) => {
118
const AnnotationProvider = (props: {
119
    children: React.ReactNode;
120
    annotationId: string;
121
}) => {
119 122
    /**
120 123
     * Tags managed by the context.
121 124
     */
......
168 171
     */
169 172
    useEffect(() => {
170 173
        //TODO: Implement initialization with values from the server
171
    }, []);
174
    }, [props.annotationId]);
172 175

  
173 176
    return (
174 177
        <AnnotationContext.Provider
webapp/pages/annotation/[id].tsx
5 5
import 'antd/dist/antd.css';
6 6
import styles from '/styles/Annotation.module.scss';
7 7
import AnnotationProvider from '../../contexts/AnnotationContext';
8
import { useRouter } from 'next/router';
8 9

  
9 10
/**
10 11
 * Creates an annotation screen.
11 12
 * @returns The annotation screen.
12 13
 */
13 14
function Annotation() {
15
    const router = useRouter();
16
    const { idRaw } = router.query;
17

  
18
    if (!idRaw || typeof idRaw === 'string') {
19
        (async () => {
20
            await router.push('/documents');
21
        })(); // TODO
22
        return;
23
    }
24

  
25
    const annotationId: string = Array.isArray(idRaw) ? idRaw[0] : idRaw;
26

  
14 27
    return (
15
        <AnnotationProvider>
28
        <AnnotationProvider annotationId={annotationId}>
16 29
            <MainLayout>
17 30
                <div className={styles.layoutWrapper}>
18 31
                    <div className={styles.tags}>

Také k dispozici: Unified diff