2
0

fix(editor): ✏️ Collab invite link

This commit is contained in:
Baptiste Arnaud
2022-05-31 10:19:19 +02:00
parent 61e4ca1313
commit c6bd3ea634
2 changed files with 5 additions and 3 deletions

View File

@ -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) =>

View File

@ -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({