Use ContractsGrid for your markets
This commit is contained in:
		
							parent
							
								
									f42e3c23da
								
							
						
					
					
						commit
						c900c1798b
					
				|  | @ -7,6 +7,7 @@ import { | ||||||
|   deleteContract, |   deleteContract, | ||||||
|   listContracts, |   listContracts, | ||||||
| } from '../lib/firebase/contracts' | } from '../lib/firebase/contracts' | ||||||
|  | import { ContractsGrid } from '../pages/markets' | ||||||
| 
 | 
 | ||||||
| function ContractCard(props: { contract: Contract }) { | function ContractCard(props: { contract: Contract }) { | ||||||
|   const { contract } = props |   const { contract } = props | ||||||
|  | @ -77,13 +78,5 @@ export function ContractsList(props: {}) { | ||||||
|     } |     } | ||||||
|   }, [creator]) |   }, [creator]) | ||||||
| 
 | 
 | ||||||
|   return ( |   return <ContractsGrid contracts={contracts} /> | ||||||
|     <div className="bg-gray-100 shadow-xl overflow-hidden sm:rounded-md max-w-4xl w-full"> |  | ||||||
|       <ul role="list" className="divide-y divide-gray-200"> |  | ||||||
|         {contracts.map((contract) => ( |  | ||||||
|           <ContractCard contract={contract} key={contract.id} /> |  | ||||||
|         ))} |  | ||||||
|       </ul> |  | ||||||
|     </div> |  | ||||||
|   ) |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ function ContractCard(props: { contract: Contract }) { | ||||||
|   return ( |   return ( | ||||||
|     <Link href={`/contract/${contract.id}`}> |     <Link href={`/contract/${contract.id}`}> | ||||||
|       <a> |       <a> | ||||||
|         <li className="col-span-1 bg-white hover:bg-gray-100 rounded-lg shadow divide-y divide-gray-200"> |         <li className="col-span-1 bg-white hover:bg-gray-100 shadow-xl rounded-lg divide-y divide-gray-200"> | ||||||
|           <div className="card"> |           <div className="card"> | ||||||
|             <div className="card-body p-6"> |             <div className="card-body p-6"> | ||||||
|               <div className="flex justify-between gap-2"> |               <div className="flex justify-between gap-2"> | ||||||
|  | @ -67,6 +67,21 @@ function ContractCard(props: { contract: Contract }) { | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export function ContractsGrid(props: { contracts: Contract[] }) { | ||||||
|  |   const { contracts } = props | ||||||
|  |   return ( | ||||||
|  |     <ul | ||||||
|  |       role="list" | ||||||
|  |       className="grid grid-cols-1 gap-6 sm:grid-cols-1 lg:grid-cols-2" | ||||||
|  |     > | ||||||
|  |       {contracts.map((contract) => ( | ||||||
|  |         <ContractCard contract={contract} key={contract.id} /> | ||||||
|  |       ))} | ||||||
|  |       {/* TODO: Show placeholder if empty */} | ||||||
|  |     </ul> | ||||||
|  |   ) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export default function Markets() { | export default function Markets() { | ||||||
|   const [contracts, setContracts] = useState<Contract[]>([]) |   const [contracts, setContracts] = useState<Contract[]>([]) | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|  | @ -78,28 +93,10 @@ export default function Markets() { | ||||||
|       <Header /> |       <Header /> | ||||||
|       <div className="max-w-4xl py-8 mx-auto"> |       <div className="max-w-4xl py-8 mx-auto"> | ||||||
|         <Title text="Open markets" /> |         <Title text="Open markets" /> | ||||||
|         <ul |         <ContractsGrid contracts={contracts.filter((c) => !c.resolution)} /> | ||||||
|           role="list" |  | ||||||
|           className="grid grid-cols-1 gap-6 sm:grid-cols-1 lg:grid-cols-2" |  | ||||||
|         > |  | ||||||
|           {contracts |  | ||||||
|             .filter((c) => !c.resolution) |  | ||||||
|             .map((contract) => ( |  | ||||||
|               <ContractCard contract={contract} key={contract.id} /> |  | ||||||
|             ))} |  | ||||||
|         </ul> |  | ||||||
| 
 | 
 | ||||||
|         <Title text="Resolved markets" className="mt-20" /> |         <Title text="Resolved markets" className="mt-20" /> | ||||||
|         <ul |         <ContractsGrid contracts={contracts.filter((c) => c.resolution)} /> | ||||||
|           role="list" |  | ||||||
|           className="grid grid-cols-1 gap-6 sm:grid-cols-1 lg:grid-cols-2" |  | ||||||
|         > |  | ||||||
|           {contracts |  | ||||||
|             .filter((c) => c.resolution) |  | ||||||
|             .map((contract) => ( |  | ||||||
|               <ContractCard contract={contract} key={contract.id} /> |  | ||||||
|             ))} |  | ||||||
|         </ul> |  | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user