2022-07-19 07:50:11 +00:00
|
|
|
import { useRouter } from 'next/router'
|
2022-08-27 04:10:10 +00:00
|
|
|
import { PencilAltIcon } from '@heroicons/react/solid'
|
2022-05-19 17:42:03 +00:00
|
|
|
|
2022-05-09 13:04:36 +00:00
|
|
|
import { Page } from 'web/components/page'
|
|
|
|
import { Col } from 'web/components/layout/col'
|
2022-08-15 05:09:25 +00:00
|
|
|
import { ContractSearch } from 'web/components/contract-search'
|
2022-08-09 22:28:52 +00:00
|
|
|
import { User } from 'common/user'
|
2022-08-12 20:41:00 +00:00
|
|
|
import { getUserAndPrivateUser } from 'web/lib/firebase/users'
|
2022-06-15 21:34:34 +00:00
|
|
|
import { useTracking } from 'web/hooks/use-tracking'
|
|
|
|
import { track } from 'web/lib/service/analytics'
|
2022-08-18 06:15:25 +00:00
|
|
|
import { authenticateOnServer } from 'web/lib/firebase/server-auth'
|
2022-07-21 19:43:10 +00:00
|
|
|
import { useSaveReferral } from 'web/hooks/use-save-referral'
|
2022-08-18 06:15:25 +00:00
|
|
|
import { GetServerSideProps } from 'next'
|
2022-08-28 23:03:00 +00:00
|
|
|
import { usePrefetch } from 'web/hooks/use-prefetch'
|
2022-07-19 07:50:11 +00:00
|
|
|
|
2022-08-18 06:15:25 +00:00
|
|
|
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
|
|
|
const creds = await authenticateOnServer(ctx)
|
2022-09-01 05:13:26 +00:00
|
|
|
const auth = creds ? await getUserAndPrivateUser(creds.uid) : null
|
2022-08-18 06:15:25 +00:00
|
|
|
return { props: { auth } }
|
|
|
|
}
|
2022-01-23 00:16:23 +00:00
|
|
|
|
2022-08-18 06:15:25 +00:00
|
|
|
const Home = (props: { auth: { user: User } | null }) => {
|
|
|
|
const user = props.auth ? props.auth.user : null
|
2022-06-10 16:22:36 +00:00
|
|
|
const router = useRouter()
|
2022-06-15 21:34:34 +00:00
|
|
|
useTracking('view home')
|
|
|
|
|
2022-07-21 19:43:10 +00:00
|
|
|
useSaveReferral()
|
2022-08-28 23:03:00 +00:00
|
|
|
usePrefetch(user?.id)
|
2022-07-21 19:43:10 +00:00
|
|
|
|
2022-01-23 00:16:23 +00:00
|
|
|
return (
|
2022-06-05 00:00:13 +00:00
|
|
|
<>
|
2022-08-30 04:56:11 +00:00
|
|
|
<Page>
|
2022-06-05 00:00:13 +00:00
|
|
|
<Col className="mx-auto w-full p-2">
|
|
|
|
<ContractSearch
|
2022-08-09 22:28:52 +00:00
|
|
|
user={user}
|
2022-08-30 04:56:11 +00:00
|
|
|
persistPrefix="home-search"
|
|
|
|
useQueryUrlParam={true}
|
2022-06-05 00:00:13 +00:00
|
|
|
/>
|
|
|
|
</Col>
|
2022-06-10 16:22:36 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2022-08-27 04:10:10 +00:00
|
|
|
className="fixed bottom-[70px] right-3 z-20 inline-flex items-center rounded-full border border-transparent bg-indigo-600 p-4 text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 lg:hidden"
|
2022-06-15 21:34:34 +00:00
|
|
|
onClick={() => {
|
|
|
|
router.push('/create')
|
|
|
|
track('mobile create button')
|
|
|
|
}}
|
2022-06-10 16:22:36 +00:00
|
|
|
>
|
2022-08-27 04:10:10 +00:00
|
|
|
<PencilAltIcon className="h-7 w-7" aria-hidden="true" />
|
2022-06-10 16:22:36 +00:00
|
|
|
</button>
|
2022-06-05 00:00:13 +00:00
|
|
|
</Page>
|
|
|
|
</>
|
2022-01-23 00:16:23 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Home
|