-
-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathHearingDetails.tsx
More file actions
213 lines (194 loc) · 5.87 KB
/
Copy pathHearingDetails.tsx
File metadata and controls
213 lines (194 loc) · 5.87 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import { useRouter } from "next/router"
import { Trans, useTranslation } from "next-i18next"
import { useEffect, useRef, useState } from "react"
import styled from "styled-components"
import { Col, Container, Image, Row } from "../bootstrap"
import * as links from "../links"
import { committeeURL, External } from "../links"
import {
Back,
ButtonContainer,
FeatureCalloutButton
} from "../shared/CommonComponents"
import { HearingSidebar } from "./HearingSidebar"
import {
HearingData,
Paragraph,
convertToString,
fetchTranscriptionData
} from "./hearing"
import { Transcriptions } from "./Transcriptions"
const LegalContainer = styled(Container)`
background-color: white;
`
const VideoChild = styled.video`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
`
const VideoParent = styled.div`
position: relative;
width: 100%;
padding-top: 56.25%; /* For 16:9 aspect ratio */
overflow: hidden;
`
export const HearingDetails = ({
hearingData: {
billsInAgenda,
committeeCode,
committeeName,
description,
generalCourtNumber,
hearingDate,
hearingId,
videoTranscriptionId,
videoURL
}
}: {
hearingData: HearingData
}) => {
const { t } = useTranslation(["common", "hearing"])
const router = useRouter()
const [transcriptData, setTranscriptData] = useState<Paragraph[] | null>(null)
const [videoLoaded, setVideoLoaded] = useState(false)
const handleVideoLoad = () => {
setVideoLoaded(true)
}
const videoRef = useRef<HTMLVideoElement>(null)
function setCurTimeVideo(value: number) {
videoRef.current ? (videoRef.current.currentTime = value) : null
}
useEffect(() => {
const startTime = router.query.t
const resultString: string = convertToString(startTime)
if (startTime && videoRef.current) {
setCurTimeVideo(parseInt(resultString, 10))
}
}, [router.query.t, videoRef.current])
useEffect(() => {
;(async function () {
if (!videoTranscriptionId || transcriptData !== null) return
const docList = await fetchTranscriptionData(videoTranscriptionId)
setTranscriptData(docList)
})()
}, [videoTranscriptionId])
return (
<Container className="mt-3 mb-3">
<Row className={`mb-3`}>
<Col>
<Back href="/hearings">{t("back_to_hearings")}</Back>
</Col>
</Row>
{transcriptData ? (
<ButtonContainer className={`mb-2`}>
{/* ButtonContainer contrains clickable area of link so that it doesn't exceed
the button and strech invisibly across the width of the page */}
<FeatureCalloutButton
className={`btn btn-secondary d-flex text-nowrap mt-1 mx-1 p-1`}
>
{" "}
{t("video_and_transcription_feature_callout", { ns: "hearing" })}{" "}
</FeatureCalloutButton>
</ButtonContainer>
) : (
<></>
)}
{committeeName ? (
committeeCode ? (
<h1>
<External href={committeeURL(committeeCode)}>
{committeeName}
</External>
</h1>
) : (
<h1>{committeeName}</h1>
)
) : (
<></>
)}
<h5 className={`mb-3`}>{description}</h5>
<Row>
<Col className={`col-md-8 mt-4`}>
{transcriptData ? (
<LegalContainer className={`pb-2 rounded`}>
<Row
className={`d-flex align-items-center justify-content-between`}
fontSize={"12px"}
xs="auto"
>
<Col>
<div className={`fs-6 fw-bold mt-2`}>
<Image
src="/images/smart-summary.svg"
alt={t("bill.smart_tag")}
height={`34`}
width={`24`}
className={`me-2 pb-1`}
/>
{t("bill.smart_disclaimer2")}
</div>
</Col>
<Col>
<Trans
t={t}
i18nKey="bill.smart_disclaimer3"
components={[
// eslint-disable-next-line react/jsx-key
<links.Internal href="/about/how-maple-uses-ai" />
]}
/>
</Col>
</Row>
</LegalContainer>
) : (
<></>
)}
{videoURL ? (
<VideoParent className={`mt-3`}>
<VideoChild
ref={videoRef}
src={videoURL}
onLoadedData={handleVideoLoad}
controls
muted
/>
</VideoParent>
) : (
<LegalContainer className={`fs-6 fw-bold my-3 py-2 rounded`}>
{transcriptData
? t("no_video_on_file", { ns: "hearing" })
: t("no_video_or_transcript", { ns: "hearing" })}
</LegalContainer>
)}
{transcriptData ? (
<Transcriptions
hearingId={hearingId}
transcriptData={transcriptData}
setCurTimeVideo={setCurTimeVideo}
videoLoaded={videoLoaded}
videoRef={videoRef}
/>
) : videoURL ? (
<LegalContainer className={`fs-6 fw-bold mb-2 py-2 rounded-bottom`}>
<div>{t("no_transcript_on_file", { ns: "hearing" })}</div>
</LegalContainer>
) : null}
</Col>
<div className={`col-md-4`}>
<HearingSidebar
billsInAgenda={billsInAgenda}
committeeCode={committeeCode}
generalCourtNumber={generalCourtNumber}
hearingDate={hearingDate}
hearingId={hearingId}
transcriptData={transcriptData}
/>
</div>
</Row>
</Container>
)
}