Projekt

Obecné

Profil

Stáhnout (942 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1 5593c10b Dominik Poch
import { SubTagInfo, TagInfo } from '../../api';
2 ed01528f Dominik Poch
import { Container, Row } from 'react-bootstrap';
3
import { Button } from 'antd';
4 5593c10b Dominik Poch
import { useContext } from 'react';
5
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
6 ed01528f Dominik Poch
7
/**
8
 * Creates a single tag item in a tag panel.
9
 * @param props Properties should contain the tag.
10
 * @returns The item that represents the tag.
11
 */
12 5593c10b Dominik Poch
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
13 0441c314 Dominik Poch
    /**
14
     * Tag context.
15
     */
16 5593c10b Dominik Poch
    const { selectTag } = useContext(TagCategoryContext);
17
18 ed01528f Dominik Poch
    /**
19
     * Selects the sub tag.
20
     */
21 5593c10b Dominik Poch
    const onSelectSubTag = () => {
22
        selectTag(props.tag, props.subTag);
23
    };
24 ed01528f Dominik Poch
25
    return (
26
        <Container>
27
            <Row>
28 2c9bdf18 Dominik Poch
                <Button onClick={onSelectSubTag} className="w-100 text-start rounded">
29 ed01528f Dominik Poch
                    {props.subTag.name}
30
                </Button>
31
            </Row>
32
        </Container>
33
    );
34
}