group: add question button

This commit is contained in:
mantikoros 2022-07-19 18:15:55 -05:00
parent 1f0983a145
commit bab828412b
2 changed files with 35 additions and 56 deletions

View File

@ -5,6 +5,7 @@ import React from 'react'
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'
export const CreateQuestionButton = (props: {
user: User | null | undefined
overrideText?: string

View File

@ -1,4 +1,5 @@
import { take, sortBy, debounce } from 'lodash'
import PlusSmIcon from '@heroicons/react/solid/PlusSmIcon'
import { Group, GROUP_CHAT_SLUG } from 'common/group'
import { Page } from 'web/components/page'
@ -32,10 +33,7 @@ import { SEO } from 'web/components/SEO'
import { Linkify } from 'web/components/linkify'
import { fromPropz, usePropz } from 'web/hooks/use-propz'
import { Tabs } from 'web/components/layout/tabs'
import {
createButtonStyle,
CreateQuestionButton,
} from 'web/components/create-question-button'
import { CreateQuestionButton } from 'web/components/create-question-button'
import React, { useEffect, useState } from 'react'
import { GroupChat } from 'web/components/groups/group-chat'
import { LoadingIndicator } from 'web/components/loading-indicator'
@ -265,9 +263,7 @@ export default function GroupPage(props: {
<Row className={'items-center justify-between gap-4'}>
<div className={'sm:mb-1'}>
<div
className={
'line-clamp-1 my-1 text-lg text-indigo-700 sm:my-3 sm:text-2xl'
}
className={'line-clamp-1 my-2 text-2xl text-indigo-700 sm:my-3'}
>
{group.name}
</div>
@ -275,7 +271,7 @@ export default function GroupPage(props: {
<Linkify text={group.about} />
</div>
</div>
<div className="hidden sm:block xl:hidden">
<div className="mt-2">
<JoinOrAddQuestionsButtons
group={group}
user={user}
@ -283,13 +279,6 @@ export default function GroupPage(props: {
/>
</div>
</Row>
<div className="block sm:hidden">
<JoinOrAddQuestionsButtons
group={group}
user={user}
isMember={!!isMember}
/>
</div>
</Col>
<Tabs
currentPageForAnalytics={groupPath(group.slug)}
@ -308,21 +297,7 @@ function JoinOrAddQuestionsButtons(props: {
}) {
const { group, user, isMember } = props
return user && isMember ? (
<Row
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}`}
/>
<Row className={'mt-0 justify-end'}>
<AddContractButton group={group} user={user} />
</Row>
) : group.anyoneCanJoin ? (
@ -559,7 +534,7 @@ function GroupLeaderboards(props: {
}
function AddContractButton(props: { group: Group; user: User }) {
const { group } = props
const { group, user } = props
const [open, setOpen] = useState(false)
async function addContractToCurrentGroup(contract: Contract) {
@ -569,16 +544,39 @@ function AddContractButton(props: { group: Group; user: User }) {
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'}>
<Col
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'}>
Add a question to your group
</div>
<div className={'overflow-y-scroll p-1'}>
<Col className="p-8 pb-0">
<div className={'text-xl text-indigo-700'}>
Add a question to your group
</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
hideOrderSelector={true}
onContractClick={addContractToCurrentGroup}
@ -590,26 +588,6 @@ function AddContractButton(props: { group: Group; user: User }) {
</div>
</Col>
</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>
</>
)
}