diff --git a/src/application/services/js-services/http/http_api.ts b/src/application/services/js-services/http/http_api.ts index 7b889ff4..91ffa725 100644 --- a/src/application/services/js-services/http/http_api.ts +++ b/src/application/services/js-services/http/http_api.ts @@ -2045,12 +2045,14 @@ export async function getGuestInvitation (workspaceId: string, code: string) { return Promise.reject(response?.data); } -export async function acceptGuestInvitation (workspaceId: string) { +export async function acceptGuestInvitation (workspaceId: string, code: string) { const url = `/api/sharing/workspace/${workspaceId}/join-by-guest-invite-code`; const response = await axiosInstance?.post<{ code: number; message: string; - }>(url); + }>(url, { + code, + }); if (response?.data.code === 0) { return; diff --git a/src/application/services/js-services/index.ts b/src/application/services/js-services/index.ts index e2f6e841..fb93a741 100644 --- a/src/application/services/js-services/index.ts +++ b/src/application/services/js-services/index.ts @@ -696,8 +696,8 @@ export class AFClientService implements AFService { return APIService.getGuestInvitation(workspaceId, code); } - async acceptGuestInvitation (workspaceId: string) { - return APIService.acceptGuestInvitation(workspaceId); + async acceptGuestInvitation (workspaceId: string, code: string) { + return APIService.acceptGuestInvitation(workspaceId, code); } async getGuestToMemberConversionInfo (workspaceId: string, code: string) { diff --git a/src/application/services/services.type.ts b/src/application/services/services.type.ts index e5df7715..07fd6c10 100644 --- a/src/application/services/services.type.ts +++ b/src/application/services/services.type.ts @@ -76,7 +76,7 @@ export interface WorkspaceService { inviteMembers: (workspaceId: string, emails: string[]) => Promise; searchWorkspace: (workspaceId: string, searchTerm: string) => Promise; getGuestInvitation: (workspaceId: string, code: string) => Promise; - acceptGuestInvitation: (workspaceId: string) => Promise; + acceptGuestInvitation: (workspaceId: string, code: string) => Promise; getGuestToMemberConversionInfo: (workspaceId: string, code: string) => Promise; approveTurnGuestToMember: (workspaceId: string, code: string) => Promise; } @@ -217,4 +217,4 @@ export interface AIChatService { chatId: string, limit?: number | undefined, ) => Promise; -} \ No newline at end of file +} diff --git a/src/components/app/landing-pages/AsGuest.tsx b/src/components/app/landing-pages/AsGuest.tsx index 6eb9dce6..2eeaf807 100644 --- a/src/components/app/landing-pages/AsGuest.tsx +++ b/src/components/app/landing-pages/AsGuest.tsx @@ -41,10 +41,6 @@ export function AsGuest() { try { const info = await service.getGuestInvitation(workspaceId, code); - if (info.is_existing_member) { - return; - } - setWorkspace({ id: info.workspace_id, name: info.workspace_name, @@ -59,7 +55,11 @@ export function AsGuest() { name: info.page_name, }); - await service.acceptGuestInvitation(workspaceId); + if (info.is_existing_member) { + return; + } + + await service.acceptGuestInvitation(workspaceId, code); // eslint-disable-next-line } catch (e: any) {