group: add question button
This commit is contained in:
parent
1f0983a145
commit
bab828412b
|
@ -5,6 +5,7 @@ import React from 'react'
|
||||||
|
|
||||||
export const createButtonStyle =
|
export const createButtonStyle =
|
||||||
'border-w-0 mx-auto mt-4 -ml-1 w-full rounded-md bg-gradient-to-r py-2.5 text-base font-semibold text-white shadow-sm lg:-ml-0 h-11'
|
'border-w-0 mx-auto mt-4 -ml-1 w-full rounded-md bg-gradient-to-r py-2.5 text-base font-semibold text-white shadow-sm lg:-ml-0 h-11'
|
||||||
|
|
||||||
export const CreateQuestionButton = (props: {
|
export const CreateQuestionButton = (props: {
|
||||||
user: User | null | undefined
|
user: User | null | undefined
|
||||||
overrideText?: string
|
overrideText?: string
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { take, sortBy, debounce } from 'lodash'
|
import { take, sortBy, debounce } from 'lodash'
|
||||||
|
import PlusSmIcon from '@heroicons/react/solid/PlusSmIcon'
|
||||||
|
|
||||||
import { Group, GROUP_CHAT_SLUG } from 'common/group'
|
import { Group, GROUP_CHAT_SLUG } from 'common/group'
|
||||||
import { Page } from 'web/components/page'
|
import { Page } from 'web/components/page'
|
||||||
|
@ -32,10 +33,7 @@ import { SEO } from 'web/components/SEO'
|
||||||
import { Linkify } from 'web/components/linkify'
|
import { Linkify } from 'web/components/linkify'
|
||||||
import { fromPropz, usePropz } from 'web/hooks/use-propz'
|
import { fromPropz, usePropz } from 'web/hooks/use-propz'
|
||||||
import { Tabs } from 'web/components/layout/tabs'
|
import { Tabs } from 'web/components/layout/tabs'
|
||||||
import {
|
import { CreateQuestionButton } from 'web/components/create-question-button'
|
||||||
createButtonStyle,
|
|
||||||
CreateQuestionButton,
|
|
||||||
} from 'web/components/create-question-button'
|
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { GroupChat } from 'web/components/groups/group-chat'
|
import { GroupChat } from 'web/components/groups/group-chat'
|
||||||
import { LoadingIndicator } from 'web/components/loading-indicator'
|
import { LoadingIndicator } from 'web/components/loading-indicator'
|
||||||
|
@ -265,9 +263,7 @@ export default function GroupPage(props: {
|
||||||
<Row className={'items-center justify-between gap-4'}>
|
<Row className={'items-center justify-between gap-4'}>
|
||||||
<div className={'sm:mb-1'}>
|
<div className={'sm:mb-1'}>
|
||||||
<div
|
<div
|
||||||
className={
|
className={'line-clamp-1 my-2 text-2xl text-indigo-700 sm:my-3'}
|
||||||
'line-clamp-1 my-1 text-lg text-indigo-700 sm:my-3 sm:text-2xl'
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{group.name}
|
{group.name}
|
||||||
</div>
|
</div>
|
||||||
|
@ -275,7 +271,7 @@ export default function GroupPage(props: {
|
||||||
<Linkify text={group.about} />
|
<Linkify text={group.about} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="hidden sm:block xl:hidden">
|
<div className="mt-2">
|
||||||
<JoinOrAddQuestionsButtons
|
<JoinOrAddQuestionsButtons
|
||||||
group={group}
|
group={group}
|
||||||
user={user}
|
user={user}
|
||||||
|
@ -283,13 +279,6 @@ export default function GroupPage(props: {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
<div className="block sm:hidden">
|
|
||||||
<JoinOrAddQuestionsButtons
|
|
||||||
group={group}
|
|
||||||
user={user}
|
|
||||||
isMember={!!isMember}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Col>
|
</Col>
|
||||||
<Tabs
|
<Tabs
|
||||||
currentPageForAnalytics={groupPath(group.slug)}
|
currentPageForAnalytics={groupPath(group.slug)}
|
||||||
|
@ -308,21 +297,7 @@ function JoinOrAddQuestionsButtons(props: {
|
||||||
}) {
|
}) {
|
||||||
const { group, user, isMember } = props
|
const { group, user, isMember } = props
|
||||||
return user && isMember ? (
|
return user && isMember ? (
|
||||||
<Row
|
<Row className={'mt-0 justify-end'}>
|
||||||
className={'-mt-2 justify-between sm:mt-0 sm:flex-col sm:justify-center'}
|
|
||||||
>
|
|
||||||
<CreateQuestionButton
|
|
||||||
user={user}
|
|
||||||
overrideText={'Add a new question'}
|
|
||||||
className={'hidden w-48 flex-shrink-0 sm:block'}
|
|
||||||
query={`?groupId=${group.id}`}
|
|
||||||
/>
|
|
||||||
<CreateQuestionButton
|
|
||||||
user={user}
|
|
||||||
overrideText={'New question'}
|
|
||||||
className={'block w-40 flex-shrink-0 sm:hidden'}
|
|
||||||
query={`?groupId=${group.id}`}
|
|
||||||
/>
|
|
||||||
<AddContractButton group={group} user={user} />
|
<AddContractButton group={group} user={user} />
|
||||||
</Row>
|
</Row>
|
||||||
) : group.anyoneCanJoin ? (
|
) : group.anyoneCanJoin ? (
|
||||||
|
@ -559,7 +534,7 @@ function GroupLeaderboards(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddContractButton(props: { group: Group; user: User }) {
|
function AddContractButton(props: { group: Group; user: User }) {
|
||||||
const { group } = props
|
const { group, user } = props
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
async function addContractToCurrentGroup(contract: Contract) {
|
async function addContractToCurrentGroup(contract: Contract) {
|
||||||
|
@ -569,16 +544,39 @@ function AddContractButton(props: { group: Group; user: User }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div className={'flex justify-center'}>
|
||||||
|
<button
|
||||||
|
className={clsx('btn btn-sm btn-outline')}
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
>
|
||||||
|
<PlusSmIcon className="h-6 w-6" aria-hidden="true" /> question
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Modal open={open} setOpen={setOpen} className={'sm:p-0'}>
|
<Modal open={open} setOpen={setOpen} className={'sm:p-0'}>
|
||||||
<Col
|
<Col
|
||||||
className={
|
className={
|
||||||
'max-h-[60vh] min-h-[60vh] w-full gap-4 rounded-md bg-white p-8'
|
'max-h-[60vh] min-h-[60vh] w-full gap-4 rounded-md bg-white'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className={'text-lg text-indigo-700'}>
|
<Col className="p-8 pb-0">
|
||||||
Add a question to your group
|
<div className={'text-xl text-indigo-700'}>
|
||||||
</div>
|
Add a question to your group
|
||||||
<div className={'overflow-y-scroll p-1'}>
|
</div>
|
||||||
|
|
||||||
|
<Col className="items-center">
|
||||||
|
<CreateQuestionButton
|
||||||
|
user={user}
|
||||||
|
overrideText={'New question'}
|
||||||
|
className={'w-48 flex-shrink-0 '}
|
||||||
|
query={`?groupId=${group.id}`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className={'mt-2 text-lg text-indigo-700'}>or</div>
|
||||||
|
</Col>
|
||||||
|
</Col>
|
||||||
|
|
||||||
|
<div className={'overflow-y-scroll sm:px-8'}>
|
||||||
<ContractSearch
|
<ContractSearch
|
||||||
hideOrderSelector={true}
|
hideOrderSelector={true}
|
||||||
onContractClick={addContractToCurrentGroup}
|
onContractClick={addContractToCurrentGroup}
|
||||||
|
@ -590,26 +588,6 @@ function AddContractButton(props: { group: Group; user: User }) {
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Modal>
|
</Modal>
|
||||||
<div className={'flex justify-center'}>
|
|
||||||
<button
|
|
||||||
className={clsx(
|
|
||||||
createButtonStyle,
|
|
||||||
'hidden w-48 whitespace-nowrap border border-black text-black hover:bg-black hover:text-white sm:block'
|
|
||||||
)}
|
|
||||||
onClick={() => setOpen(true)}
|
|
||||||
>
|
|
||||||
Add an old question
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className={clsx(
|
|
||||||
createButtonStyle,
|
|
||||||
'block w-40 whitespace-nowrap border border-black text-black hover:bg-black hover:text-white sm:hidden'
|
|
||||||
)}
|
|
||||||
onClick={() => setOpen(true)}
|
|
||||||
>
|
|
||||||
Old question
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user