Update createWorkspace return type
This commit is contained in:
@@ -877,7 +877,7 @@ export type CreateWorkspaceMutationVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type CreateWorkspaceMutation = { __typename?: 'Mutation', createWorkspace: { __typename?: 'User', id: string, firstName: string, lastName: string, email: string, canImpersonate: boolean, supportUserHash?: string | null, workspaceMember?: { __typename?: 'WorkspaceMember', id: string, colorScheme: string, avatarUrl?: string | null, locale: string, name: { __typename?: 'FullName', firstName: string, lastName: string } } | null, defaultWorkspace?: { __typename?: 'Workspace', id: string, displayName?: string | null, logo?: string | null, domainName?: string | null, inviteHash?: string | null, allowImpersonation: boolean, subscriptionStatus: string, featureFlags?: Array<{ __typename?: 'FeatureFlag', id: string, key: string, value: boolean, workspaceId: string }> | null } | null } };
|
||||
export type CreateWorkspaceMutation = { __typename?: 'Mutation', createWorkspace: { __typename?: 'User', id: string, workspaceMember?: { __typename?: 'WorkspaceMember', id: string, colorScheme: string, avatarUrl?: string | null, locale: string, name: { __typename?: 'FullName', firstName: string, lastName: string } } | null, defaultWorkspace?: { __typename?: 'Workspace', id: string, displayName?: string | null, logo?: string | null, domainName?: string | null, inviteHash?: string | null, allowImpersonation: boolean, subscriptionStatus: string, featureFlags?: Array<{ __typename?: 'FeatureFlag', id: string, key: string, value: boolean, workspaceId: string }> | null } | null } };
|
||||
|
||||
export type DeleteCurrentWorkspaceMutationVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
@@ -1692,11 +1692,6 @@ export const CreateWorkspaceDocument = gql`
|
||||
mutation CreateWorkspace($input: CreateWorkspaceInput!) {
|
||||
createWorkspace(data: $input) {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
email
|
||||
canImpersonate
|
||||
supportUserHash
|
||||
workspaceMember {
|
||||
id
|
||||
name {
|
||||
|
||||
@@ -4,11 +4,6 @@ export const CREATE_WORKSPACE = gql`
|
||||
mutation CreateWorkspace($input: CreateWorkspaceInput!) {
|
||||
createWorkspace(data: $input) {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
email
|
||||
canImpersonate
|
||||
supportUserHash
|
||||
workspaceMember {
|
||||
id
|
||||
name {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { z } from 'zod';
|
||||
import { SubTitle } from '@/auth/components/SubTitle';
|
||||
import { Title } from '@/auth/components/Title';
|
||||
import { useOnboardingStatus } from '@/auth/hooks/useOnboardingStatus';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { OnboardingStatus } from '@/auth/utils/getOnboardingStatus';
|
||||
import { WorkspaceLogoUploader } from '@/settings/workspace/components/WorkspaceLogoUploader';
|
||||
@@ -48,6 +49,9 @@ export const CreateWorkspace = () => {
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
const onboardingStatus = useOnboardingStatus();
|
||||
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
|
||||
const setCurrentWorkspaceMember = useSetRecoilState(
|
||||
currentWorkspaceMemberState,
|
||||
);
|
||||
|
||||
const [createWorkspace] = useCreateWorkspaceMutation();
|
||||
|
||||
@@ -76,12 +80,27 @@ export const CreateWorkspace = () => {
|
||||
},
|
||||
});
|
||||
setCurrentWorkspace({
|
||||
id: result.data?.createWorkspace?.id ?? '',
|
||||
id: result.data?.createWorkspace?.defaultWorkspace?.id ?? '',
|
||||
displayName: data.name,
|
||||
subscriptionStatus:
|
||||
result.data?.createWorkspace?.subscriptionStatus ?? 'incomplete',
|
||||
result.data?.createWorkspace?.defaultWorkspace
|
||||
?.subscriptionStatus ?? 'incomplete',
|
||||
allowImpersonation:
|
||||
result.data?.createWorkspace?.allowImpersonation ?? false,
|
||||
result.data?.createWorkspace?.defaultWorkspace
|
||||
?.allowImpersonation ?? false,
|
||||
});
|
||||
setCurrentWorkspaceMember({
|
||||
id: result.data?.createWorkspace?.workspaceMember?.id ?? '',
|
||||
locale: result.data?.createWorkspace?.workspaceMember?.locale ?? 'en',
|
||||
name: {
|
||||
firstName:
|
||||
result.data?.createWorkspace?.workspaceMember?.name?.firstName ??
|
||||
'',
|
||||
lastName:
|
||||
result.data?.createWorkspace?.workspaceMember?.name?.lastName ??
|
||||
'',
|
||||
},
|
||||
avatarUrl: result.data?.createWorkspace?.workspaceMember?.avatarUrl,
|
||||
});
|
||||
|
||||
if (result.errors || !result.data?.createWorkspace) {
|
||||
@@ -97,7 +116,13 @@ export const CreateWorkspace = () => {
|
||||
});
|
||||
}
|
||||
},
|
||||
[enqueueSnackBar, navigate, setCurrentWorkspace, createWorkspace],
|
||||
[
|
||||
enqueueSnackBar,
|
||||
navigate,
|
||||
setCurrentWorkspace,
|
||||
setCurrentWorkspaceMember,
|
||||
createWorkspace,
|
||||
],
|
||||
);
|
||||
|
||||
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
|
||||
@@ -88,12 +88,11 @@ export class UserService extends TypeOrmQueryService<User> {
|
||||
);
|
||||
}
|
||||
|
||||
async updateUser(
|
||||
userId: string,
|
||||
data: QueryDeepPartialEntity<User>,
|
||||
): Promise<User> {
|
||||
async updateUser(userId: string, data: QueryDeepPartialEntity<User>) {
|
||||
await this.userRepository.update(userId, data);
|
||||
}
|
||||
|
||||
async getUser(userId: string): Promise<User> {
|
||||
return await this.userRepository.findOneOrFail({
|
||||
where: { id: userId },
|
||||
relations: ['defaultWorkspace'],
|
||||
|
||||
@@ -32,14 +32,16 @@ export class WorkspaceService extends TypeOrmQueryService<Workspace> {
|
||||
});
|
||||
const workspace = await this.workspaceRepository.save(workspaceToCreate);
|
||||
|
||||
const updatedUser = await this.userService.updateUser(user.id, {
|
||||
await this.userService.updateUser(user.id, {
|
||||
defaultWorkspace: workspace,
|
||||
});
|
||||
|
||||
await this.workspaceManagerService.init(workspace.id);
|
||||
const updatedUser = await this.userService.getUser(user.id);
|
||||
|
||||
await this.userService.createWorkspaceMember(updatedUser);
|
||||
|
||||
return workspace;
|
||||
return updatedUser;
|
||||
}
|
||||
|
||||
async deleteWorkspace(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user