@@ -2,7 +2,16 @@ import { useEffect, useRef, useState } from "react"
2
2
import Head from "next/head"
3
3
import styles from "../styles/VideoTranscription.module.css"
4
4
import { firestore } from "../components/firebase"
5
- import { doc , getDoc } from "firebase/firestore"
5
+ import {
6
+ collection ,
7
+ doc ,
8
+ getDoc ,
9
+ getDocs ,
10
+ orderBy ,
11
+ query
12
+ } from "firebase/firestore"
13
+ import { useQuery } from "react-query"
14
+ import { useRouter } from "next/router"
6
15
7
16
export default function VideoTranscription ( { videoUrl, utterances } ) {
8
17
const [ currentTime , setCurrentTime ] = useState ( 0 )
@@ -102,19 +111,29 @@ function formatTime(ms) {
102
111
}
103
112
104
113
export async function getServerSideProps ( ) {
105
- const exampleTranscriptionId = "17c91397-c023-4f28-a621-4cef45c70749"
114
+ const hearingId = "hearing-5180"
115
+ const hearing = await getDoc ( doc ( firestore , `events/${ hearingId } ` ) )
116
+ const { videoTranscriptionId, videoURL } = hearing . data ( )
117
+
118
+ // should be
119
+ // const exampleTranscriptionId = "639e73ff-bd01-4902-bba7-88faaf39afa9"
106
120
const transcription = await getDoc (
107
- doc ( firestore , `transcriptions/${ exampleTranscriptionId } ` )
121
+ doc ( firestore , `transcriptions/${ videoTranscriptionId } ` )
122
+ )
123
+ const utterances = await getDocs (
124
+ query (
125
+ collection (
126
+ firestore ,
127
+ `transcriptions/${ videoTranscriptionId } /utterances`
128
+ ) ,
129
+ orderBy ( "start" , "asc" )
130
+ )
108
131
)
109
- console . log ( transcription . data ( ) )
110
-
111
- const videoUrl = transcription . data ( ) . audio_url
112
- const utterances = transcription . data ( ) . utterances
113
132
114
133
return {
115
134
props : {
116
- videoUrl,
117
- utterances
135
+ videoUrl : videoURL ,
136
+ utterances : utterances . docs . map ( doc => doc . data ( ) )
118
137
}
119
138
}
120
139
}
0 commit comments