Revize 669ffe38
Přidáno uživatelem Jaroslav Hrubý před asi 2 roky(ů)
webapp/components/modals/UserDocumentsModal.tsx | ||
---|---|---|
1 |
import { List, Modal } from 'antd'; |
|
1 |
import { List, Modal, Skeleton, Tag } from 'antd';
|
|
2 | 2 |
import 'antd/dist/antd.css'; |
3 | 3 |
import React, { useContext, useEffect, useState } from 'react'; |
4 |
import { AnnotationListInfo } from '../../api'; |
|
4 |
import { AnnotationListInfo, EState } from '../../api';
|
|
5 | 5 |
import { userController } from '../../controllers'; |
6 | 6 |
import { useUnauthRedirect } from '../../hooks'; |
7 | 7 |
import { LoggedUserContext } from '../../contexts/LoggedUserContext'; |
8 |
import { |
|
9 |
CheckCircleOutlined, |
|
10 |
ClockCircleOutlined, |
|
11 |
SyncOutlined, |
|
12 |
} from '@ant-design/icons'; |
|
8 | 13 |
|
9 | 14 |
interface ModalProps { |
10 | 15 |
onCancel: () => void; |
... | ... | |
24 | 29 |
onCancel(); |
25 | 30 |
}; |
26 | 31 |
|
32 |
const getStateTag = (state: EState) => { |
|
33 |
let color = 'green'; |
|
34 |
let label = 'Hotovo'; |
|
35 |
let icon = <CheckCircleOutlined />; |
|
36 |
if (state === EState.New) { |
|
37 |
color = 'volcano'; |
|
38 |
label = 'Nový'; |
|
39 |
icon = <ClockCircleOutlined />; |
|
40 |
} |
|
41 |
if (state === EState.InProgress) { |
|
42 |
color = 'orange'; |
|
43 |
label = 'Rozpracováno'; |
|
44 |
icon = <SyncOutlined spin />; |
|
45 |
} |
|
46 |
return ( |
|
47 |
<Tag icon={icon} color={color} key={label}> |
|
48 |
{label.toUpperCase()} |
|
49 |
</Tag> |
|
50 |
); |
|
51 |
}; |
|
52 |
|
|
27 | 53 |
useEffect(() => { |
28 | 54 |
if (!redirecting && role === 'ADMINISTRATOR' && userId) { |
29 | 55 |
userController |
... | ... | |
49 | 75 |
style={{ maxHeight: 400, overflowY: 'auto', overflowX: 'hidden' }} |
50 | 76 |
renderItem={(item) => ( |
51 | 77 |
<List.Item key={item.annotationId}> |
52 |
<List.Item.Meta title={item.documentName} /> |
|
78 |
<List.Item.Meta |
|
79 |
title={item.documentName} |
|
80 |
// @ts-ignore |
|
81 |
avatar={getStateTag(item.state)} |
|
82 |
/> |
|
53 | 83 |
</List.Item> |
54 | 84 |
)} |
55 | 85 |
/> |
Také k dispozici: Unified diff
Refactoring after code review