48a249eaa9
* Add Firestore package and config * Upload basic Firebase Auth code * Basic ability to sign in and view profile * Move html head content to Next's _document * Apply dark theme to all DaisyUI components * Add contract page * Smaller width bet input * Add some buttons * Add Row, Col, and Spacer components * Implement skeleton ContractPage * Apply dark theme to all DaisyUI components * Fix hooks lints (#3) * Add background to bet panel * Changes based on review comments Co-authored-by: Austin Chen <akrolsmir@gmail.com>
24 lines
548 B
TypeScript
24 lines
548 B
TypeScript
import { collection, onSnapshot, doc } from '@firebase/firestore'
|
|
import { db } from './init'
|
|
|
|
export type Contract = {
|
|
id: string
|
|
creatorId: string
|
|
creatorName: string
|
|
question: string
|
|
description: string
|
|
}
|
|
|
|
const contractCollection = collection(db, 'contracts')
|
|
|
|
export function listenForContract(
|
|
contractId: string,
|
|
setContract: (contract: Contract) => void
|
|
) {
|
|
const contractRef = doc(contractCollection, contractId)
|
|
|
|
return onSnapshot(contractRef, (contractSnap) => {
|
|
setContract(contractSnap.data() as Contract)
|
|
})
|
|
}
|