fix make-predictions

This commit is contained in:
mantikoros 2022-01-05 00:07:36 -06:00
parent 7c875f80da
commit 4386422f02

View File

@ -1,4 +1,5 @@
import clsx from 'clsx' import clsx from 'clsx'
import { getFunctions, httpsCallable } from 'firebase/functions'
import Link from 'next/link' import Link from 'next/link'
import { useState } from 'react' import { useState } from 'react'
import { Col } from '../components/layout/col' import { Col } from '../components/layout/col'
@ -9,7 +10,9 @@ import { Page } from '../components/page'
import { Title } from '../components/title' import { Title } from '../components/title'
import { useUser } from '../hooks/use-user' import { useUser } from '../hooks/use-user'
import { compute, Contract, path } from '../lib/firebase/contracts' import { compute, Contract, path } from '../lib/firebase/contracts'
import { createContract } from '../lib/service/create-contract'
const functions = getFunctions()
export const createContract = httpsCallable(functions, 'createContract')
type Prediction = { type Prediction = {
question: string question: string
@ -129,12 +132,12 @@ ${TEST_VALUE}
} }
setIsSubmitting(true) setIsSubmitting(true)
for (const prediction of predictions) { for (const prediction of predictions) {
const contract = await createContract( const contract = await createContract({
prediction.question, question: prediction.question,
prediction.description, description: prediction.description,
prediction.initialProb, initialProb: prediction.initialProb,
user }).then((r) => (r.data as any).contract)
)
setCreatedContracts((prev) => [...prev, contract]) setCreatedContracts((prev) => [...prev, contract])
} }
setPredictionsString('') setPredictionsString('')