Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(teams): improve ux for team invite when already on a team (#5435)
Will Hutchinsona7ad7b973704
diff --git a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsxindex f9c03d703c..ad476b28cb 100644--- a/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx+++ b/apps/web/src/features/team-invitations/TeamInviteAcceptance.tsx@@ -11,7 +11,7 @@ import {useRejectInvitationMutation,useUserInvitesQuery,} from '@queries/team/invitations';-import { useTeamQuery } from '@queries/team/teams';+import { useCurrentTeamQuery, useTeamQuery } from '@queries/team/teams';import { useNavigate, useSearchParams } from '@solidjs/router';import { Button, Surface } from '@ui';import { createMemo, Match, Show, Switch } from 'solid-js';@@ -36,6 +36,16 @@ export function TeamInviteAcceptance() {const teamName = createMemo(() => teamQuery.data?.team.name);+ // If the invite is gone but the user already belongs to a team (e.g. a+ // domain auto-join consumed the invite between clicking the link and+ // landing here), show that instead of "Invite Not Found". Only fetched+ // once the invite lookup has settled without a match — a valid invite+ // never waits on (or triggers) this request.+ const currentTeamQuery = useCurrentTeamQuery(+ () => !!userInfo()?.authenticated && invitesQuery.isSuccess && !invite()+ );+ const currentTeamName = createMemo(() => currentTeamQuery.data?.team.name);+const joinMutation = useJoinTeamMutation({onSuccess: () => {navigate('/', { replace: true });@@ -67,7 +77,10 @@ export function TeamInviteAcceptance() {};const isLoading = createMemo(- () => invitesQuery.isLoading || teamQuery.isLoading+ () =>+ invitesQuery.isLoading ||+ teamQuery.isLoading ||+ (!invite() && currentTeamQuery.isLoading));return (@@ -116,6 +129,9 @@ export function TeamInviteAcceptance() {<Match when={isLoading()}><LoadingBlock /></Match>+ <Match when={!invite() && currentTeamName()}>+ {(name) => <AlreadyOnTeam teamName={name()} />}+ </Match><Match when={!invite()}><InviteNotFound /></Match>@@ -182,6 +198,31 @@ function UnauthenticatedView(props: { onLogin: () => void }) {);}+function AlreadyOnTeam(props: { teamName: string }) {+ const navigate = useNavigate();+ return (+ <div class="w-full flex flex-col items-center gap-4 text-center">+ <h2 class="flex items-center justify-center gap-2 text-lg font-medium text-ink">+ <UsersThreeIcon class="size-5" />+ Already on Team {props.teamName}+ </h2>+ <p class="text-sm text-ink-muted">+ You're already a member of{' '}+ <span class="text-ink">{props.teamName}</span>, so there's nothing more+ to do here.+ </p>+ <Button+ variant="base"+ size="md"+ class="w-full rounded-xs"+ onClick={() => navigate('/')}+ >+ Go to Home+ </Button>+ </div>+ );+}+function InviteNotFound() {const navigate = useNavigate();return (diff --git a/apps/web/src/lib/queries/team/teams.ts b/apps/web/src/lib/queries/team/teams.tsindex 0dc58b0bac..af41cd1527 100644--- a/apps/web/src/lib/queries/team/teams.ts+++ b/apps/web/src/lib/queries/team/teams.ts@@ -39,10 +39,11 @@ export function useTeamQuery(teamId: Accessor<string>) {}/** The current user's team, or `null` if they don't belong to one. */-export function useCurrentTeamQuery() {+export function useCurrentTeamQuery(enabled?: Accessor<boolean>) {return useQuery(() => ({queryKey: teamKeys.currentTeam.queryKey,queryFn: async () => await throwOnErr(() => authServiceClient.getTeam()),+ enabled: enabled?.() ?? true,}));}