Allow comments to reference answers
This commit is contained in:
parent
78997c1e45
commit
44c7c3db19
|
@ -4,6 +4,7 @@ export type Comment = {
|
|||
id: string
|
||||
contractId: string
|
||||
betId?: string
|
||||
answerOutcome?: string
|
||||
userId: string
|
||||
|
||||
text: string
|
||||
|
|
|
@ -223,8 +223,9 @@ export function CommentInput(props: {
|
|||
contract: Contract
|
||||
betsByCurrentUser: Bet[]
|
||||
comments: Comment[]
|
||||
answerOutcome?: string
|
||||
}) {
|
||||
const { contract, betsByCurrentUser, comments } = props
|
||||
const { contract, betsByCurrentUser, comments, answerOutcome } = props
|
||||
const user = useUser()
|
||||
const [comment, setComment] = useState('')
|
||||
|
||||
|
@ -233,7 +234,7 @@ export function CommentInput(props: {
|
|||
if (!user) {
|
||||
return await firebaseLogin()
|
||||
}
|
||||
await createComment(contract.id, comment, user)
|
||||
await createComment(contract.id, comment, user, undefined, answerOutcome)
|
||||
setComment('')
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ export async function createComment(
|
|||
contractId: string,
|
||||
text: string,
|
||||
commenter: User,
|
||||
betId?: string
|
||||
betId?: string,
|
||||
answerOutcome?: string
|
||||
) {
|
||||
const ref = betId
|
||||
? doc(getCommentsCollection(contractId), betId)
|
||||
|
@ -39,6 +40,9 @@ export async function createComment(
|
|||
if (betId) {
|
||||
comment.betId = betId
|
||||
}
|
||||
if (answerOutcome) {
|
||||
comment.answerOutcome = answerOutcome
|
||||
}
|
||||
return await setDoc(ref, comment)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user