From c6bd3ea634e9bbed086bf89177a86c7521cd6d06 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 31 May 2022 10:19:19 +0200 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E2=9C=8F=EF=B8=8F=20Collab=20in?= =?UTF-8?q?vite=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/builder/contexts/WorkspaceContext.tsx | 5 ++++- apps/builder/pages/api/typebots/[typebotId]/invitations.ts | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/builder/contexts/WorkspaceContext.tsx b/apps/builder/contexts/WorkspaceContext.tsx index 4dabd2de5..56326be7b 100644 --- a/apps/builder/contexts/WorkspaceContext.tsx +++ b/apps/builder/contexts/WorkspaceContext.tsx @@ -15,6 +15,7 @@ import { } from 'services/workspace/workspace' import { useUser } from './UserContext' import { useTypebot } from './TypebotContext' +import { useRouter } from 'next/router' export type WorkspaceWithMembers = Workspace & { members: MemberInWorkspace[] } @@ -36,6 +37,7 @@ const workspaceContext = createContext<{ }>({}) export const WorkspaceContext = ({ children }: { children: ReactNode }) => { + const { query } = useRouter() const { user } = useUser() const userId = user?.id const { typebot } = useTypebot() @@ -54,7 +56,8 @@ export const WorkspaceContext = ({ children }: { children: ReactNode }) => { useEffect(() => { if (!workspaces || workspaces.length === 0 || currentWorkspace) return - const lastWorspaceId = localStorage.getItem('workspaceId') + const lastWorspaceId = + query.workspaceId?.toString() ?? localStorage.getItem('workspaceId') const defaultWorkspace = lastWorspaceId ? workspaces.find(byId(lastWorspaceId)) : workspaces.find((w) => diff --git a/apps/builder/pages/api/typebots/[typebotId]/invitations.ts b/apps/builder/pages/api/typebots/[typebotId]/invitations.ts index ef5c6158f..ae328e225 100644 --- a/apps/builder/pages/api/typebots/[typebotId]/invitations.ts +++ b/apps/builder/pages/api/typebots/[typebotId]/invitations.ts @@ -10,7 +10,6 @@ import { badRequest, forbidden, isEmpty, - isNotDefined, methodNotAllowed, notAuthenticated, } from 'utils' @@ -73,7 +72,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { subject: "You've been invited to collaborate 🤝", content: invitationToCollaborate( user.email ?? '', - `${process.env.NEXTAUTH_URL}/typebots/shared` + `${process.env.NEXTAUTH_URL}/typebots?workspaceId=${typebot.workspaceId}` ), }) return res.send({