-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathindex.tsx
More file actions
76 lines (71 loc) · 2.85 KB
/
Copy pathindex.tsx
File metadata and controls
76 lines (71 loc) · 2.85 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Paper,
Button,
Typography,
Box
} from '@mui/material';
import {ReactComponent as CheckCircleOutlineIcon} from '../../../assets/icons/check-circle-green.svg';
import { downloadResource } from '../../../../application/tools/downloadResource';
import { aiTrustCenterTableCell } from '../style';
const Resources = ({ data, loading, error, hash }: { data: any; loading: boolean; error: string | null; hash: string | null }) => {
if (loading) return <Typography>Loading...</Typography>;
if (error) return <Typography color="error">{error}</Typography>;
if (!data || !data.resources || data.resources.length === 0) return <Typography>No resources available.</Typography>;
const handleDownload = async (id: string) => {
if (hash) {
await downloadResource(id, hash);
}
};
return (
<Box width="100%">
<Typography variant="subtitle2" color="#13715B" sx={{ fontWeight: 600, mb: 2 }}>
Resources
</Typography>
<TableContainer component={Paper} sx={{ border: '1px solid #EEEEEE', borderRadius: 1, boxShadow: 'none'}}>
<Table>
<TableHead>
<TableRow sx={{ background: '#FAFAFA' }}>
<TableCell sx={{ fontWeight: 400, color: '#667085', fontSize: 12, textTransform: 'uppercase', paddingLeft: 4 }}>document name</TableCell>
<TableCell sx={{ fontWeight: 400, color: '#667085', fontSize: 12, textTransform: 'uppercase', paddingRight: 11 }} align="right">action</TableCell>
</TableRow>
</TableHead>
<TableBody>
{data.resources.map((resource: any, idx: number) => (
<TableRow key={idx}>
<TableCell sx={aiTrustCenterTableCell}>
<Box display="flex" alignItems="center" gap={1}>
<CheckCircleOutlineIcon style={{ width: "24px", height:"24px" }} />
<Typography color="#344054" sx={{ fontSize: 13 }}>{resource.name}</Typography>
</Box>
</TableCell>
<TableCell align="right" sx={aiTrustCenterTableCell}>
<Button
onClick={() => handleDownload(resource.id)}
size="small"
sx={{
fontSize: 13,
minWidth: 100,
backgroundColor: '#fff',
color: '#344054',
border: '1px solid #D0D5DD',
borderRadius: 1,
}}
>
Download
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
</Box>
);
};
export default Resources;