diff --git a/web/components/contracts-list.tsx b/web/components/contracts-list.tsx index fa1bedd2..97e2c06a 100644 --- a/web/components/contracts-list.tsx +++ b/web/components/contracts-list.tsx @@ -1,5 +1,7 @@ import Link from 'next/link' -import { Contract, deleteContract } from '../lib/firebase/contracts' +import { useEffect, useState } from 'react' +import { useUser } from '../hooks/use-user' +import { Contract, deleteContract, listContracts } from '../lib/firebase/contracts' function ContractCard(props: { contract: Contract }) { const { contract } = props @@ -49,8 +51,17 @@ function ContractCard(props: { contract: Contract }) { ) } -export function ContractsList(props: { contracts: Contract[] }) { - const { contracts } = props +export function ContractsList(props: {}) { + const creator = useUser() + + const [contracts, setContracts] = useState([]) + + useEffect(() => { + if (creator?.id) { + listContracts(creator.id).then(setContracts) + } + }, [creator]) + return (