1
|
import { SubTagInfo, TagInfo } from '../../api';
|
2
|
import { Container, Row } from 'react-bootstrap';
|
3
|
import { Button } from 'antd';
|
4
|
import { useContext } from 'react';
|
5
|
import { TagCategoryContext } from '../../contexts/TagCategoryContext';
|
6
|
|
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
|
export function SubTagItem(props: { tag: TagInfo; subTag: SubTagInfo }) {
|
13
|
/**
|
14
|
* Tag context.
|
15
|
*/
|
16
|
const { selectTag } = useContext(TagCategoryContext);
|
17
|
|
18
|
/**
|
19
|
* Selects the sub tag.
|
20
|
*/
|
21
|
const onSelectSubTag = () => {
|
22
|
selectTag(props.tag, props.subTag);
|
23
|
};
|
24
|
|
25
|
return (
|
26
|
<Container>
|
27
|
<Row>
|
28
|
<Button onClick={onSelectSubTag} className="w-100 text-start rounded">
|
29
|
{props.subTag.name}
|
30
|
</Button>
|
31
|
</Row>
|
32
|
</Container>
|
33
|
);
|
34
|
}
|