Convert market to lite market for Phil

This commit is contained in:
Ian Philips 2022-09-07 07:13:34 -06:00
parent ad18987e65
commit 87060488f5
2 changed files with 6 additions and 2 deletions

View File

@ -86,9 +86,10 @@ export async function listGroupContracts(groupId: string) {
contractId: string
createdTime: number
}>(groupContracts(groupId))
return Promise.all(
const contracts = await Promise.all(
contractDocs.map((doc) => getContractFromId(doc.contractId))
)
return filterDefined(contracts)
}
export function listenForOpenGroups(setGroups: (groups: Group[]) => void) {

View File

@ -1,6 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { applyCorsHeaders, CORS_UNRESTRICTED } from 'web/lib/api/cors'
import { listGroupContracts } from 'web/lib/firebase/groups'
import { toLiteMarket } from 'web/pages/api/v0/_types'
export default async function handler(
req: NextApiRequest,
@ -8,7 +9,9 @@ export default async function handler(
) {
await applyCorsHeaders(req, res, CORS_UNRESTRICTED)
const { id } = req.query
const contracts = await listGroupContracts(id as string)
const contracts = (await listGroupContracts(id as string)).map((contract) =>
toLiteMarket(contract)
)
if (!contracts) {
res.status(404).json({ error: 'Group not found' })
return