"join group" => "follow"

This commit is contained in:
mantikoros 2022-09-05 16:51:09 -05:00
parent d812776357
commit 97e0a78806
2 changed files with 17 additions and 13 deletions

View File

@ -107,7 +107,7 @@ export function JoinOrLeaveGroupButton(props: {
onClick={firebaseLogin} onClick={firebaseLogin}
className={clsx('btn btn-sm', small && smallStyle, className)} className={clsx('btn btn-sm', small && smallStyle, className)}
> >
Login to Join Login to follow
</button> </button>
) )
} }
@ -132,7 +132,7 @@ export function JoinOrLeaveGroupButton(props: {
)} )}
onClick={withTracking(onLeaveGroup, 'leave group')} onClick={withTracking(onLeaveGroup, 'leave group')}
> >
Leave Unfollow
</button> </button>
) )
} }
@ -144,7 +144,7 @@ export function JoinOrLeaveGroupButton(props: {
className={clsx('btn btn-sm', small && smallStyle, className)} className={clsx('btn btn-sm', small && smallStyle, className)}
onClick={withTracking(onJoinGroup, 'join group')} onClick={withTracking(onJoinGroup, 'join group')}
> >
Join Follow
</button> </button>
) )
} }

View File

@ -52,6 +52,7 @@ import { Post } from 'common/post'
import { Spacer } from 'web/components/layout/spacer' import { Spacer } from 'web/components/layout/spacer'
import { usePost } from 'web/hooks/use-post' import { usePost } from 'web/hooks/use-post'
import { useAdmin } from 'web/hooks/use-admin' import { useAdmin } from 'web/hooks/use-admin'
import { track } from '@amplitude/analytics-browser'
export const getStaticProps = fromPropz(getStaticPropz) export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz(props: { params: { slugs: string[] } }) { export async function getStaticPropz(props: { params: { slugs: string[] } }) {
@ -659,22 +660,25 @@ function JoinGroupButton(props: {
user: User | null | undefined user: User | null | undefined
}) { }) {
const { group, user } = props const { group, user } = props
function addUserToGroup() {
if (user) { const follow = async () => {
toast.promise(joinGroup(group, user.id), { track('join group')
loading: 'Joining group...', const userId = user ? user.id : (await firebaseLogin()).user.uid
success: 'Joined group!',
error: "Couldn't join group, try again?", toast.promise(joinGroup(group, userId), {
}) loading: 'Following group...',
} success: 'Followed',
error: "Couldn't follow group, try again?",
})
} }
return ( return (
<div> <div>
<button <button
onClick={user ? addUserToGroup : firebaseLogin} onClick={follow}
className={'btn-md btn-outline btn whitespace-nowrap normal-case'} className={'btn-md btn-outline btn whitespace-nowrap normal-case'}
> >
{user ? 'Join group' : 'Login to join group'} Follow
</button> </button>
</div> </div>
) )