Skip to content

Commit

Permalink
fix(editor): ✏️ Collab invite link
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed May 31, 2022
1 parent 61e4ca1 commit c6bd3ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/builder/contexts/WorkspaceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[] }

Expand All @@ -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()
Expand All @@ -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) =>
Expand Down
3 changes: 1 addition & 2 deletions apps/builder/pages/api/typebots/[typebotId]/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
badRequest,
forbidden,
isEmpty,
isNotDefined,
methodNotAllowed,
notAuthenticated,
} from 'utils'
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit c6bd3ea

Please sign in to comment.