Skip to content

Commit 11f5f77

Browse files
committed
Updating hearing-specific page to use new utterances subcollection
1 parent 710c5db commit 11f5f77

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

pages/hearing/[...hearingId].tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import { useEffect, useRef, useState } from "react"
22
import Head from "next/head"
33
import styles from "../../styles/VideoTranscription.module.css" // Adjust the path as necessary
44
import { firestore } from "../../components/firebase"
5-
import { doc, getDoc } from "firebase/firestore"
5+
import {
6+
collection,
7+
doc,
8+
getDoc,
9+
getDocs,
10+
where,
11+
orderBy,
12+
query as fbQuery
13+
} from "firebase/firestore"
614
import { z } from "zod"
715
import { GetServerSideProps } from "next"
816
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
@@ -132,7 +140,23 @@ export const getServerSideProps: GetServerSideProps = async ctx => {
132140
const transcription = rawTranscription.data() as any
133141

134142
const videoUrl = transcription.data().audio_url
135-
const utterances = transcription.data().utterances
143+
144+
const docRef = collection(
145+
firestore,
146+
`transcriptions/${transcriptionId}/utterances`
147+
)
148+
const q = fbQuery(docRef, orderBy("start", "asc"))
149+
150+
const rawUtterances = await getDocs(q)
151+
if (rawUtterances.empty) {
152+
console.log("No utterances found")
153+
return { notFound: true }
154+
}
155+
156+
const utterances = rawUtterances.docs.map(doc => ({
157+
...doc.data(),
158+
id: doc.id
159+
}))
136160

137161
return {
138162
props: {

0 commit comments

Comments
 (0)