From a23c744c3e1eeda0ada57b779c607555114161aa Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 6 Jul 2022 17:24:53 -0600 Subject: [PATCH] Small groups UX changes --- web/components/create-question-button.tsx | 14 +- web/components/groups/group-chat.tsx | 3 +- web/lib/firebase/groups.ts | 2 +- web/pages/group/[...slugs]/index.tsx | 154 ++++++++++++++-------- web/pages/notifications.tsx | 4 +- 5 files changed, 113 insertions(+), 64 deletions(-) diff --git a/web/components/create-question-button.tsx b/web/components/create-question-button.tsx index 564beb83..a9161ac6 100644 --- a/web/components/create-question-button.tsx +++ b/web/components/create-question-button.tsx @@ -3,6 +3,8 @@ import clsx from 'clsx' import { firebaseLogin, User } from 'web/lib/firebase/users' 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 @@ -12,20 +14,20 @@ export const CreateQuestionButton = (props: { const gradient = 'from-indigo-500 to-blue-500 hover:from-indigo-700 hover:to-blue-700' - const buttonStyle = - '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' - const { user, overrideText, className, query } = props return ( -
+
{user ? ( - ) : ( - )} diff --git a/web/components/groups/group-chat.tsx b/web/components/groups/group-chat.tsx index 114a9003..13028313 100644 --- a/web/components/groups/group-chat.tsx +++ b/web/components/groups/group-chat.tsx @@ -36,6 +36,7 @@ export function GroupChat(props: { const [inputRef, setInputRef] = useState(null) const [groupedMessages, setGroupedMessages] = useState([]) const router = useRouter() + const isMember = user && group.memberIds.includes(user?.id) useMemo(() => { // Group messages with createdTime within 2 minutes of each other. @@ -120,7 +121,7 @@ export function GroupChat(props: { ))} {messages.length === 0 && (
- No messages yet. Why not{' '} + No messages yet. Why not{isMember ? ` ` : ' join and '}
), href: groupPath(group.slug, 'questions'), }, + { + title: 'Leaderboards', + content: leaderboard, + href: groupPath(group.slug, 'rankings'), + }, { title: 'About', content: aboutTab, @@ -309,13 +319,16 @@ function JoinOrCreateButton(props: { isMember: boolean }) { const { group, user, isMember } = props - return isMember ? ( - + return user && isMember ? ( + + + + ) : group.anyoneCanJoin ? ( ) : null @@ -389,11 +402,51 @@ function GroupOverview(props: { )} + + + ) } +function SearchBar(props: { setQuery: (query: string) => void }) { + const { setQuery } = props + const debouncedQuery = debounce(setQuery, 50) + return ( +
+ + debouncedQuery(e.target.value)} + placeholder="Find a member" + className="input input-bordered mb-4 w-full pl-12" + /> +
+ ) +} + +function GroupMemberSearch(props: { group: Group }) { + const [query, setQuery] = useState('') + const members = useMembers(props.group) + + // TODO use find-active-contracts to sort by? + const matches = sortBy(members, [(member) => member.name]).filter( + (m) => + checkAgainstQuery(query, m.name) || checkAgainstQuery(query, m.username) + ) + return ( +
+ + + {matches.length > 0 && ( + m.id)} /> + )} + +
+ ) +} + export function GroupMembersList(props: { group: Group }) { const { group } = props const members = useMembers(group) @@ -449,32 +502,24 @@ function GroupLeaderboards(props: { }) { const { traderScores, creatorScores, members, topTraders, topCreators } = props - const [includeOutsiders, setIncludeOutsiders] = useState(false) // Consider hiding M$0 + // If it's just one member (curator), show all bettors, otherwise just show members return ( - - Include all users - - -
- {!includeOutsiders ? ( + {members.length > 1 ? ( <> traderScores[user.id] ?? 0} - title="🏅 Top bettors" + title="🏅 Bettor rankings" header="Profit" /> creatorScores[user.id] ?? 0} - title="🏅 Top creators" + title="🏅 Creator rankings" header="Market volume" /> @@ -543,16 +588,17 @@ function AddContractButton(props: { group: Group; user: User }) {
- +
- +
) } diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 382505e2..08ef9bb8 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -347,10 +347,10 @@ function IncomeNotificationItem(props: { let reasonText = '' if (sourceType === 'bonus' && sourceText) { reasonText = !simple - ? `bonus for ${ + ? `Bonus for ${ parseInt(sourceText) / UNIQUE_BETTOR_BONUS_AMOUNT } unique bettors` - : ' bonus for unique bettors on' + : 'bonus on' } else if (sourceType === 'tip') { reasonText = !simple ? `tipped you` : `in tips on` }