|
1 | 1 | import React from 'react' |
2 | | -import { Dialog, DialogContent, IconButton, Box, Typography, Link as MuiLink } from '@mui/material' |
| 2 | +import { Dialog, DialogContent, IconButton, Box, Typography, Link as MuiLink, Chip } from '@mui/material' |
3 | 3 | import CloseIcon from '@mui/icons-material/Close' |
4 | 4 | import OpenInNewIcon from '@mui/icons-material/OpenInNew' |
| 5 | +import VideocamIcon from '@mui/icons-material/Videocam' |
5 | 6 | import { ValidationDetailsDialogProps } from '../../types/certificate' |
6 | 7 | import { useTheme, useMediaQuery } from '@mui/material' |
7 | 8 |
|
8 | 9 | const ValidationDetailsDialog: React.FC<ValidationDetailsDialogProps> = ({ open, onClose, validation }) => { |
9 | 10 | const theme = useTheme() |
10 | | - const isXs = useMediaQuery(theme.breakpoints.down('sm')) |
| 11 | + const isMobile = useMediaQuery(theme.breakpoints.down('sm')) |
11 | 12 |
|
12 | 13 | if (!validation) return null |
13 | 14 |
|
| 15 | + // Get video from media array or legacy mediaUrl |
| 16 | + const videoUrl = validation.media?.find(m => m.type === 'video')?.url || validation.mediaUrl |
| 17 | + const hasVideo = !!videoUrl |
| 18 | + |
14 | 19 | return ( |
15 | 20 | <Dialog |
16 | 21 | open={open} |
17 | 22 | onClose={onClose} |
18 | | - maxWidth={false} |
| 23 | + maxWidth='sm' |
| 24 | + fullWidth |
19 | 25 | sx={{ |
20 | 26 | '& .MuiDialog-paper': { |
21 | | - width: { xs: '95%', sm: '90%', md: '85%' }, |
22 | | - maxWidth: '800px', |
23 | | - maxHeight: { xs: '95vh', sm: '90vh' }, |
24 | | - borderRadius: { xs: '8px', sm: '10px', md: '12px' }, |
25 | | - backgroundColor: '#FFFFFF', |
26 | | - overflowY: 'auto' |
| 27 | + borderRadius: 3, |
| 28 | + maxHeight: '90vh' |
27 | 29 | } |
28 | 30 | }} |
29 | 31 | > |
30 | | - <DialogContent sx={{ p: 0, position: 'relative' }}> |
| 32 | + <DialogContent sx={{ p: 0 }}> |
| 33 | + {/* Close button */} |
31 | 34 | <IconButton |
32 | 35 | onClick={onClose} |
33 | 36 | sx={{ |
34 | 37 | position: 'absolute', |
35 | | - right: { xs: 6, sm: 8 }, |
36 | | - top: { xs: 6, sm: 8 }, |
37 | | - color: '#212529', |
| 38 | + right: 8, |
| 39 | + top: 8, |
38 | 40 | zIndex: 1, |
39 | | - padding: { xs: '4px', sm: '8px' } |
| 41 | + bgcolor: 'background.paper', |
| 42 | + '&:hover': { bgcolor: 'action.hover' } |
40 | 43 | }} |
41 | | - size={isXs ? 'small' : 'medium'} |
| 44 | + size='small' |
42 | 45 | > |
43 | | - <CloseIcon fontSize={isXs ? 'small' : 'medium'} /> |
| 46 | + <CloseIcon fontSize='small' /> |
44 | 47 | </IconButton> |
45 | | - <Box sx={{ padding: { xs: 2, sm: 2.5, md: 3 } }}> |
46 | | - <Box sx={{ marginBottom: { xs: 2, sm: 2.5, md: 3 } }}> |
47 | | - {validation.subject && ( |
48 | | - <Box |
49 | | - sx={{ |
50 | | - fontSize: { xs: '16px', sm: '18px', md: '20px' }, |
51 | | - fontWeight: 500, |
52 | | - color: '#2D6A4F', |
53 | | - marginBottom: { xs: 1.5, sm: 2 }, |
54 | | - display: 'flex', |
55 | | - alignItems: 'center', |
56 | | - gap: '8px', |
57 | | - flexWrap: 'wrap' |
58 | | - }} |
59 | | - > |
60 | | - <MuiLink |
61 | | - href={validation.sourceURI} |
62 | | - target='_blank' |
63 | | - sx={{ |
64 | | - display: 'flex', |
65 | | - alignItems: 'center', |
66 | | - gap: '4px', |
67 | | - color: 'inherit', |
68 | | - textDecoration: 'none', |
69 | | - '&:hover': { |
70 | | - textDecoration: 'underline' |
71 | | - }, |
72 | | - wordBreak: 'break-word' |
73 | | - }} |
74 | | - > |
75 | | - {validation.sourceURI} |
76 | | - <OpenInNewIcon sx={{ fontSize: { xs: 16, sm: 18, md: 20 } }} /> |
77 | | - </MuiLink> |
78 | | - </Box> |
79 | | - )} |
80 | | - <Typography |
81 | | - sx={{ |
82 | | - fontSize: { xs: '18px', sm: '20px', md: '24px' }, |
83 | | - fontWeight: 500, |
84 | | - color: '#2D6A4F', |
85 | | - marginBottom: { xs: 1.5, sm: 2 } |
86 | | - }} |
87 | | - > |
88 | | - {validation.issuer_name} |
| 48 | + |
| 49 | + {/* Video section */} |
| 50 | + {hasVideo && ( |
| 51 | + <Box sx={{ bgcolor: 'black', width: '100%' }}> |
| 52 | + <video |
| 53 | + controls |
| 54 | + style={{ width: '100%', maxHeight: isMobile ? 200 : 300, display: 'block' }} |
| 55 | + src={videoUrl} |
| 56 | + /> |
| 57 | + </Box> |
| 58 | + )} |
| 59 | + |
| 60 | + {/* Content */} |
| 61 | + <Box sx={{ p: 3 }}> |
| 62 | + {/* Issuer name */} |
| 63 | + <Typography variant='h6' fontWeight={600} gutterBottom> |
| 64 | + {validation.issuer_name} |
| 65 | + </Typography> |
| 66 | + |
| 67 | + {/* How known chip */} |
| 68 | + {validation.howKnown && ( |
| 69 | + <Chip |
| 70 | + label={validation.howKnown.replace(/_/g, ' ').toLowerCase()} |
| 71 | + size='small' |
| 72 | + variant='outlined' |
| 73 | + sx={{ mb: 2, textTransform: 'capitalize' }} |
| 74 | + /> |
| 75 | + )} |
| 76 | + |
| 77 | + {/* Statement */} |
| 78 | + {validation.statement && ( |
| 79 | + <Typography variant='body1' color='text.secondary' sx={{ mb: 2, lineHeight: 1.6 }}> |
| 80 | + "{validation.statement}" |
89 | 81 | </Typography> |
90 | | - <Typography |
91 | | - sx={{ |
92 | | - fontSize: { xs: '14px', sm: '15px', md: '16px' }, |
93 | | - color: '#212529', |
94 | | - marginBottom: { xs: 1.5, sm: 2 }, |
95 | | - lineHeight: 1.6 |
96 | | - }} |
97 | | - > |
98 | | - {validation.statement} |
| 82 | + )} |
| 83 | + |
| 84 | + {/* Date */} |
| 85 | + {validation.effectiveDate && ( |
| 86 | + <Typography variant='body2' color='text.secondary' sx={{ mb: 2 }}> |
| 87 | + {new Date(validation.effectiveDate).toLocaleDateString('en-US', { |
| 88 | + year: 'numeric', |
| 89 | + month: 'long', |
| 90 | + day: 'numeric' |
| 91 | + })} |
99 | 92 | </Typography> |
100 | | - <Typography |
| 93 | + )} |
| 94 | + |
| 95 | + {/* Source link */} |
| 96 | + {validation.sourceURI && ( |
| 97 | + <MuiLink |
| 98 | + href={validation.sourceURI} |
| 99 | + target='_blank' |
| 100 | + rel='noopener noreferrer' |
101 | 101 | sx={{ |
102 | | - fontSize: { xs: '12px', sm: '13px', md: '14px' }, |
103 | | - color: '#495057', |
104 | | - display: 'flex', |
| 102 | + display: 'inline-flex', |
105 | 103 | alignItems: 'center', |
106 | | - gap: '8px' |
| 104 | + gap: 0.5, |
| 105 | + fontSize: '0.875rem', |
| 106 | + color: 'primary.main' |
107 | 107 | }} |
108 | 108 | > |
109 | | - {validation.effectiveDate && |
110 | | - new Date(validation.effectiveDate).toLocaleDateString('en-US', { |
111 | | - year: 'numeric', |
112 | | - month: 'long', |
113 | | - day: 'numeric' |
114 | | - })} |
115 | | - </Typography> |
116 | | - </Box> |
117 | | - <Box sx={{ marginTop: { xs: 2, sm: 2.5, md: 3 } }}> |
118 | | - {validation.howKnown && ( |
119 | | - <Box sx={{ marginBottom: { xs: 1.5, sm: 2 } }}> |
120 | | - <Typography |
121 | | - sx={{ |
122 | | - fontWeight: 500, |
123 | | - color: '#495057', |
124 | | - minWidth: { xs: '120px', sm: '140px', md: '150px' }, |
125 | | - display: { xs: 'block', sm: 'inline-block' }, |
126 | | - fontSize: { xs: '13px', sm: '14px' } |
127 | | - }} |
128 | | - > |
129 | | - How Known: |
130 | | - </Typography> |
131 | | - <Typography |
132 | | - sx={{ |
133 | | - color: '#212529', |
134 | | - fontSize: { xs: '13px', sm: '14px' } |
135 | | - }} |
136 | | - > |
137 | | - {validation.howKnown.replace(/_/g, ' ')} |
138 | | - </Typography> |
139 | | - </Box> |
140 | | - )} |
141 | | - {validation.sourceURI && ( |
142 | | - <Box sx={{ marginBottom: { xs: 1.5, sm: 2 } }}> |
143 | | - <Typography |
144 | | - sx={{ |
145 | | - fontWeight: 500, |
146 | | - color: '#495057', |
147 | | - minWidth: { xs: '120px', sm: '140px', md: '150px' }, |
148 | | - display: { xs: 'block', sm: 'inline-block' }, |
149 | | - fontSize: { xs: '13px', sm: '14px' } |
150 | | - }} |
151 | | - > |
152 | | - Source: |
153 | | - </Typography> |
154 | | - <Typography> |
155 | | - <MuiLink |
156 | | - href={validation.sourceURI} |
157 | | - target='_blank' |
158 | | - sx={{ |
159 | | - color: '#2D6A4F', |
160 | | - textDecoration: 'none', |
161 | | - fontSize: { xs: '13px', sm: '14px' }, |
162 | | - '&:hover': { |
163 | | - textDecoration: 'underline' |
164 | | - }, |
165 | | - wordBreak: 'break-word' |
166 | | - }} |
167 | | - > |
168 | | - {validation.sourceURI} |
169 | | - </MuiLink> |
170 | | - </Typography> |
171 | | - </Box> |
172 | | - )} |
173 | | - {validation.confidence !== undefined && ( |
174 | | - <Box sx={{ marginBottom: { xs: 1.5, sm: 2 } }}> |
175 | | - <Typography |
176 | | - sx={{ |
177 | | - fontWeight: 500, |
178 | | - color: '#495057', |
179 | | - minWidth: { xs: '120px', sm: '140px', md: '150px' }, |
180 | | - display: { xs: 'block', sm: 'inline-block' }, |
181 | | - fontSize: { xs: '13px', sm: '14px' } |
182 | | - }} |
183 | | - > |
184 | | - Confidence: |
185 | | - </Typography> |
186 | | - <Typography |
187 | | - sx={{ |
188 | | - color: '#212529', |
189 | | - fontSize: { xs: '13px', sm: '14px' } |
190 | | - }} |
191 | | - > |
192 | | - {validation.confidence} |
193 | | - </Typography> |
194 | | - </Box> |
195 | | - )} |
196 | | - </Box> |
| 109 | + View source |
| 110 | + <OpenInNewIcon sx={{ fontSize: 16 }} /> |
| 111 | + </MuiLink> |
| 112 | + )} |
| 113 | + |
| 114 | + {/* Video indicator if video exists but is above */} |
| 115 | + {hasVideo && ( |
| 116 | + <Box sx={{ mt: 2, display: 'flex', alignItems: 'center', gap: 1, color: 'text.secondary' }}> |
| 117 | + <VideocamIcon fontSize='small' /> |
| 118 | + <Typography variant='body2'>Video testimony</Typography> |
| 119 | + </Box> |
| 120 | + )} |
197 | 121 | </Box> |
198 | 122 | </DialogContent> |
199 | 123 | </Dialog> |
|
0 commit comments