fix(editor): ✏️ Collab invite link
This commit is contained in:
@ -15,6 +15,7 @@ import {
|
|||||||
} from 'services/workspace/workspace'
|
} from 'services/workspace/workspace'
|
||||||
import { useUser } from './UserContext'
|
import { useUser } from './UserContext'
|
||||||
import { useTypebot } from './TypebotContext'
|
import { useTypebot } from './TypebotContext'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
export type WorkspaceWithMembers = Workspace & { members: MemberInWorkspace[] }
|
export type WorkspaceWithMembers = Workspace & { members: MemberInWorkspace[] }
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ const workspaceContext = createContext<{
|
|||||||
}>({})
|
}>({})
|
||||||
|
|
||||||
export const WorkspaceContext = ({ children }: { children: ReactNode }) => {
|
export const WorkspaceContext = ({ children }: { children: ReactNode }) => {
|
||||||
|
const { query } = useRouter()
|
||||||
const { user } = useUser()
|
const { user } = useUser()
|
||||||
const userId = user?.id
|
const userId = user?.id
|
||||||
const { typebot } = useTypebot()
|
const { typebot } = useTypebot()
|
||||||
@ -54,7 +56,8 @@ export const WorkspaceContext = ({ children }: { children: ReactNode }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!workspaces || workspaces.length === 0 || currentWorkspace) return
|
if (!workspaces || workspaces.length === 0 || currentWorkspace) return
|
||||||
const lastWorspaceId = localStorage.getItem('workspaceId')
|
const lastWorspaceId =
|
||||||
|
query.workspaceId?.toString() ?? localStorage.getItem('workspaceId')
|
||||||
const defaultWorkspace = lastWorspaceId
|
const defaultWorkspace = lastWorspaceId
|
||||||
? workspaces.find(byId(lastWorspaceId))
|
? workspaces.find(byId(lastWorspaceId))
|
||||||
: workspaces.find((w) =>
|
: workspaces.find((w) =>
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
badRequest,
|
badRequest,
|
||||||
forbidden,
|
forbidden,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isNotDefined,
|
|
||||||
methodNotAllowed,
|
methodNotAllowed,
|
||||||
notAuthenticated,
|
notAuthenticated,
|
||||||
} from 'utils'
|
} from 'utils'
|
||||||
@ -73,7 +72,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
subject: "You've been invited to collaborate 🤝",
|
subject: "You've been invited to collaborate 🤝",
|
||||||
content: invitationToCollaborate(
|
content: invitationToCollaborate(
|
||||||
user.email ?? '',
|
user.email ?? '',
|
||||||
`${process.env.NEXTAUTH_URL}/typebots/shared`
|
`${process.env.NEXTAUTH_URL}/typebots?workspaceId=${typebot.workspaceId}`
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
return res.send({
|
return res.send({
|
||||||
|
Reference in New Issue
Block a user