import React from 'react' import Router from 'next/router' import { PlusSmIcon } from '@heroicons/react/solid' import { Page } from 'web/components/page' import { Col } from 'web/components/layout/col' import { ContractSearch } from 'web/components/contract-search' import { User } from 'common/user' import { getUserAndPrivateUser } from 'web/lib/firebase/users' import { useTracking } from 'web/hooks/use-tracking' import { track } from 'web/lib/service/analytics' import { authenticateOnServer } from 'web/lib/firebase/server-auth' import { useSaveReferral } from 'web/hooks/use-save-referral' import { GetServerSideProps } from 'next' import { Sort } from 'web/components/contract-search' import { Button } from 'web/components/button' import { useMemberGroups } from 'web/hooks/use-group' import { Group } from 'common/group' import { Carousel } from 'web/components/carousel' import { LoadingIndicator } from 'web/components/loading-indicator' import { ContractCard } from 'web/components/contract/contract-card' import { range } from 'lodash' import { Contract } from 'common/contract' import { ShowTime } from 'web/components/contract/contract-details' import { GroupLinkItem } from '../groups' import { SiteLink } from 'web/components/site-link' export const getServerSideProps: GetServerSideProps = async (ctx) => { const creds = await authenticateOnServer(ctx) const auth = creds ? await getUserAndPrivateUser(creds.user.uid) : null return { props: { auth } } } const Home = (props: { auth: { user: User } | null }) => { const user = props.auth ? props.auth.user : null useTracking('view home') useSaveReferral() const memberGroups = (useMemberGroups(user?.id) ?? []).filter( (group) => group.contractIds.length > 0 ) return ( {memberGroups.map((group) => ( ))} ) } function SearchSection(props: { label: string user: User | null sort: Sort }) { const { label, user, sort } = props const href = `/home?s=${sort}` return ( {label} contracts ? ( ) : ( ) } /> ) } function GroupSection(props: { group: Group; user: User | null }) { const { group, user } = props return ( contracts ? ( ) : ( ) } /> ) } function DoubleCarousel(props: { contracts: Contract[] seeMoreUrl?: string showTime?: ShowTime }) { const { contracts, seeMoreUrl, showTime } = props return (
{contracts.length >= 6 ? range(0, Math.floor(contracts.length / 2)).map((col) => { const i = col * 2 return ( ) }) : contracts.map((c) => ( ))} ) } export default Home