From 97e0a7880643b3295fa5c7a7722d2ea733df525f Mon Sep 17 00:00:00 2001 From: mantikoros Date: Mon, 5 Sep 2022 16:51:09 -0500 Subject: [PATCH] "join group" => "follow" --- web/components/groups/groups-button.tsx | 6 +++--- web/pages/group/[...slugs]/index.tsx | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/web/components/groups/groups-button.tsx b/web/components/groups/groups-button.tsx index f60ed0af..e6271466 100644 --- a/web/components/groups/groups-button.tsx +++ b/web/components/groups/groups-button.tsx @@ -107,7 +107,7 @@ export function JoinOrLeaveGroupButton(props: { onClick={firebaseLogin} className={clsx('btn btn-sm', small && smallStyle, className)} > - Login to Join + Login to follow ) } @@ -132,7 +132,7 @@ export function JoinOrLeaveGroupButton(props: { )} onClick={withTracking(onLeaveGroup, 'leave group')} > - Leave + Unfollow ) } @@ -144,7 +144,7 @@ export function JoinOrLeaveGroupButton(props: { className={clsx('btn btn-sm', small && smallStyle, className)} onClick={withTracking(onJoinGroup, 'join group')} > - Join + Follow ) } diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx index b4046c4c..4df21faf 100644 --- a/web/pages/group/[...slugs]/index.tsx +++ b/web/pages/group/[...slugs]/index.tsx @@ -52,6 +52,7 @@ import { Post } from 'common/post' import { Spacer } from 'web/components/layout/spacer' import { usePost } from 'web/hooks/use-post' import { useAdmin } from 'web/hooks/use-admin' +import { track } from '@amplitude/analytics-browser' export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { params: { slugs: string[] } }) { @@ -659,22 +660,25 @@ function JoinGroupButton(props: { user: User | null | undefined }) { const { group, user } = props - function addUserToGroup() { - if (user) { - toast.promise(joinGroup(group, user.id), { - loading: 'Joining group...', - success: 'Joined group!', - error: "Couldn't join group, try again?", - }) - } + + const follow = async () => { + track('join group') + const userId = user ? user.id : (await firebaseLogin()).user.uid + + toast.promise(joinGroup(group, userId), { + loading: 'Following group...', + success: 'Followed', + error: "Couldn't follow group, try again?", + }) } + return (
)