Denormalize the avatar URL on contract creation (#29)

This commit is contained in:
Austin Chen 2022-01-16 01:03:59 -05:00 committed by GitHub
parent 279437ba08
commit 7d7286b1c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 8 deletions

View File

@ -5,6 +5,7 @@ export type Contract = {
creatorId: string
creatorName: string
creatorUsername: string
creatorAvatarUrl?: string // Start requiring after Mar 01, 2022
question: string
description: string // More info about what the contract is about

View File

@ -24,6 +24,7 @@ export function getNewContract(
creatorId: creator.id,
creatorName: creator.name,
creatorUsername: creator.username,
creatorAvatarUrl: creator.avatarUrl,
question: question.trim(),
description: description.trim(),

View File

@ -69,14 +69,6 @@ export async function updateContract(
await updateDoc(docRef, update)
}
export async function pushNewContract(contract: Omit<Contract, 'id'>) {
const newContractRef = doc(contractCollection)
const fullContract: Contract = { ...contract, id: newContractRef.id }
await setDoc(newContractRef, fullContract)
return fullContract
}
export async function getContractFromId(contractId: string) {
const docRef = doc(db, 'contracts', contractId)
const result = await getDoc(docRef)