-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainContainerComponent.tsx
More file actions
45 lines (39 loc) · 1.49 KB
/
MainContainerComponent.tsx
File metadata and controls
45 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as React from 'react';
import { ITag } from './models';
import { IAnnotationService } from './services/IAnnotationService';
import { TagLoaderComponent } from './TagLoaderComponent';
import { WarningTagComponent } from './WarningTagComponent';
import { TagComponent } from './TagComponent';
export interface IMainContainerProps {
entityId: string | null;
clientUrl: string | null;
annotationService: IAnnotationService;
}
const MainContainerComponent: React.FC<IMainContainerProps> = ({entityId, clientUrl, annotationService}) => {
const [Loading, setLoading] = React.useState<boolean>(false);
const [tags, setTags] = React.useState<ITag[] | null >(null);
React.useEffect(() =>{
const fetchAnnotations = async () => {
if(entityId){
setLoading(true);
const data = await annotationService.getAnnotations(entityId);
setLoading(false);
setTags(data); // TODO: replace with actual data
}
}
fetchAnnotations().catch(console.error);
},[])
return (
<div className="tag-box">
{(Loading)
? <TagLoaderComponent></TagLoaderComponent>
: (tags === null || tags.length === 0 ) ? <WarningTagComponent></WarningTagComponent>
:
tags.map(tag => (
<TagComponent key={tag.key} tagKey={tag.key} name={tag.name} mimetype={tag.mimeType}
clientUrl={clientUrl!} annotationService={annotationService}></TagComponent>
))}
</div>
);
};
export { MainContainerComponent };