Experimental Home: Add links. Single layer carousel for < 6 cards
This commit is contained in:
parent
f83b62cf50
commit
3e1e84ee5e
|
@ -14,16 +14,16 @@ import { useSaveReferral } from 'web/hooks/use-save-referral'
|
||||||
import { GetServerSideProps } from 'next'
|
import { GetServerSideProps } from 'next'
|
||||||
import { Sort } from 'web/components/contract-search'
|
import { Sort } from 'web/components/contract-search'
|
||||||
import { Button } from 'web/components/button'
|
import { Button } from 'web/components/button'
|
||||||
import { Spacer } from 'web/components/layout/spacer'
|
|
||||||
import { useMemberGroups } from 'web/hooks/use-group'
|
import { useMemberGroups } from 'web/hooks/use-group'
|
||||||
import { Group } from 'common/group'
|
import { Group } from 'common/group'
|
||||||
import { Carousel } from 'web/components/carousel'
|
import { Carousel } from 'web/components/carousel'
|
||||||
import { LoadingIndicator } from 'web/components/loading-indicator'
|
import { LoadingIndicator } from 'web/components/loading-indicator'
|
||||||
import { ContractCard } from 'web/components/contract/contract-card'
|
import { ContractCard } from 'web/components/contract/contract-card'
|
||||||
import { range } from 'lodash'
|
import { range } from 'lodash'
|
||||||
import { Subtitle } from 'web/components/subtitle'
|
|
||||||
import { Contract } from 'common/contract'
|
import { Contract } from 'common/contract'
|
||||||
import { ShowTime } from 'web/components/contract/contract-details'
|
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) => {
|
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||||
const creds = await authenticateOnServer(ctx)
|
const creds = await authenticateOnServer(ctx)
|
||||||
|
@ -44,7 +44,7 @@ const Home = (props: { auth: { user: User } | null }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Col className="mx-4 mt-4 gap-2 sm:mx-10 xl:w-[125%]">
|
<Col className="mx-4 mt-4 gap-4 sm:mx-10 xl:w-[125%]">
|
||||||
<SearchSection label="Trending" sort="score" user={user} />
|
<SearchSection label="Trending" sort="score" user={user} />
|
||||||
<SearchSection label="Newest" sort="newest" user={user} />
|
<SearchSection label="Newest" sort="newest" user={user} />
|
||||||
<SearchSection label="Closing soon" sort="close-date" user={user} />
|
<SearchSection label="Closing soon" sort="close-date" user={user} />
|
||||||
|
@ -72,10 +72,13 @@ function SearchSection(props: {
|
||||||
sort: Sort
|
sort: Sort
|
||||||
}) {
|
}) {
|
||||||
const { label, user, sort } = props
|
const { label, user, sort } = props
|
||||||
|
const href = `/home?s=${sort}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col>
|
<Col>
|
||||||
<Subtitle className="mx-2 !mt-2 !text-gray-800 sm:mx-0" text={label} />
|
<SiteLink className="mb-2 text-xl" href={href}>
|
||||||
|
{label}
|
||||||
|
</SiteLink>
|
||||||
<ContractSearch
|
<ContractSearch
|
||||||
user={user}
|
user={user}
|
||||||
defaultSort={sort}
|
defaultSort={sort}
|
||||||
|
@ -85,7 +88,12 @@ function SearchSection(props: {
|
||||||
contracts ? (
|
contracts ? (
|
||||||
<DoubleCarousel
|
<DoubleCarousel
|
||||||
contracts={contracts}
|
contracts={contracts}
|
||||||
seeMoreUrl={`/home?s=${sort}`}
|
seeMoreUrl={href}
|
||||||
|
showTime={
|
||||||
|
sort === 'close-date' || sort === 'resolve-date'
|
||||||
|
? sort
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<LoadingIndicator />
|
<LoadingIndicator />
|
||||||
|
@ -100,9 +108,8 @@ function GroupSection(props: { group: Group; user: User | null }) {
|
||||||
const { group, user } = props
|
const { group, user } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className="">
|
<Col>
|
||||||
<Subtitle className="mx-2 !text-gray-800 sm:mx-0" text={group.name} />
|
<GroupLinkItem className="mb-2 text-xl" group={group} />
|
||||||
<Spacer h={2} />
|
|
||||||
<ContractSearch
|
<ContractSearch
|
||||||
user={user}
|
user={user}
|
||||||
defaultSort={'score'}
|
defaultSort={'score'}
|
||||||
|
@ -133,8 +140,8 @@ function DoubleCarousel(props: {
|
||||||
return (
|
return (
|
||||||
<Carousel className="-mx-4 mt-2 sm:-mx-10">
|
<Carousel className="-mx-4 mt-2 sm:-mx-10">
|
||||||
<div className="shrink-0 sm:w-6" />
|
<div className="shrink-0 sm:w-6" />
|
||||||
{contracts &&
|
{contracts.length >= 6
|
||||||
range(0, Math.floor(contracts.length / 2)).map((col) => {
|
? range(0, Math.floor(contracts.length / 2)).map((col) => {
|
||||||
const i = col * 2
|
const i = col * 2
|
||||||
return (
|
return (
|
||||||
<Col>
|
<Col>
|
||||||
|
@ -156,7 +163,17 @@ function DoubleCarousel(props: {
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
})}
|
})
|
||||||
|
: contracts.map((c) => (
|
||||||
|
<ContractCard
|
||||||
|
key={c.id}
|
||||||
|
contract={c}
|
||||||
|
className="mb-2 max-h-[200px] w-96 shrink-0"
|
||||||
|
questionClass="line-clamp-3"
|
||||||
|
trackingPostfix=" tournament"
|
||||||
|
showTime={showTime}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
<Button
|
<Button
|
||||||
className="self-center whitespace-nowrap"
|
className="self-center whitespace-nowrap"
|
||||||
color="blue"
|
color="blue"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user