mirror of https://github.com/buster-so/buster.git
ripped out organization
This commit is contained in:
parent
6204a2e827
commit
ceb0a2872e
|
@ -1,5 +1,5 @@
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getOrganizationUsers, getOrganizationUsers_server } from './requests';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { createOrganization, getOrganizationUsers, getOrganizationUsers_server } from './requests';
|
||||
import { useMemoizedFn } from '@/hooks';
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import { organizationQueryKeys } from '@/api/query_keys/organization';
|
||||
|
@ -36,3 +36,10 @@ export const prefetchGetOrganizationUsers = async (
|
|||
});
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
export const useCreateOrganization = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: createOrganization
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import type { BusterOrganization } from '@/api/asset_interfaces/organizations';
|
||||
import { serverFetch } from '../../createServerInstance';
|
||||
import { mainApi } from '../instances';
|
||||
import type { OrganizationUser } from '@/api/asset_interfaces/users';
|
||||
|
@ -19,3 +20,7 @@ export const getOrganizationUsers_server = async ({
|
|||
}): Promise<OrganizationUser[]> => {
|
||||
return serverFetch<OrganizationUser[]>(`/organizations/${organizationId}/users`);
|
||||
};
|
||||
|
||||
export const createOrganization = async (organization: { name: string }) => {
|
||||
return mainApi.post<BusterOrganization>('/organizations', organization).then((res) => res.data);
|
||||
};
|
||||
|
|
|
@ -3,11 +3,6 @@ import type { UserEmits, UserResponses, UserResponsesTypes } from './user';
|
|||
import type { TeamEmits, TeamResponses, TeamResponsesTypes } from './teams';
|
||||
import type { TermsEmits, TermsResponses, TermsResponseTypes } from './terms';
|
||||
import type { BusterSearchEmits, SearchResponses, SearchResponseTypes } from './search';
|
||||
import type {
|
||||
OrganizationResponses,
|
||||
OrganizationResponsesTypes,
|
||||
OrganizationsEmits
|
||||
} from './organizations';
|
||||
import type { ChatEmits, ChatResponseTypes, ChatsResponses } from './chats';
|
||||
|
||||
export type BusterSocketRequest =
|
||||
|
@ -16,7 +11,6 @@ export type BusterSocketRequest =
|
|||
| SQLEmits
|
||||
| TermsEmits
|
||||
| BusterSearchEmits
|
||||
| OrganizationsEmits
|
||||
| ChatEmits;
|
||||
|
||||
export type BusterSocketResponse =
|
||||
|
@ -25,7 +19,6 @@ export type BusterSocketResponse =
|
|||
| SQLResponsesTypes
|
||||
| TermsResponseTypes
|
||||
| SearchResponseTypes
|
||||
| OrganizationResponsesTypes
|
||||
| ChatResponseTypes;
|
||||
|
||||
export type BusterSocketResponseRoute =
|
||||
|
@ -34,7 +27,6 @@ export type BusterSocketResponseRoute =
|
|||
| keyof typeof SQLResponses
|
||||
| keyof typeof TermsResponses
|
||||
| keyof typeof SearchResponses
|
||||
| keyof typeof OrganizationResponses
|
||||
| keyof typeof ChatsResponses;
|
||||
|
||||
export type * from './shared_interfaces';
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
export * from './organizationRequests';
|
||||
export * from './organizationResponses';
|
|
@ -1,10 +0,0 @@
|
|||
import { BusterSocketRequestBase } from '../base_interfaces';
|
||||
|
||||
export type OrganizationPostRequest = BusterSocketRequestBase<
|
||||
'/organizations/post',
|
||||
{
|
||||
name: string;
|
||||
}
|
||||
>;
|
||||
|
||||
export type OrganizationsEmits = OrganizationPostRequest;
|
|
@ -1,13 +0,0 @@
|
|||
import type { BusterOrganization } from '@/api/asset_interfaces/organizations';
|
||||
|
||||
export enum OrganizationResponses {
|
||||
'/organizations/post:post' = '/organizations/post:post'
|
||||
}
|
||||
|
||||
export type OrganizationResponsesPost_postOrganization = {
|
||||
route: '/organizations/post:post';
|
||||
callback: (d: BusterOrganization) => void;
|
||||
onError?: (d: unknown) => void;
|
||||
};
|
||||
|
||||
export type OrganizationResponsesTypes = OrganizationResponsesPost_postOrganization;
|
|
@ -1,7 +1,6 @@
|
|||
import { useMemoizedFn } from '@/hooks';
|
||||
import { useSocketQueryMutation } from '@/api/buster_socket_query';
|
||||
import type { BusterUserResponse } from '@/api/asset_interfaces/users';
|
||||
import { useUpdateUser } from '@/api/buster_rest';
|
||||
import { useCreateOrganization, useUpdateUser } from '@/api/buster_rest';
|
||||
|
||||
export const useUserOrganization = ({
|
||||
userResponse,
|
||||
|
@ -10,10 +9,7 @@ export const useUserOrganization = ({
|
|||
userResponse: BusterUserResponse | null | undefined;
|
||||
refetchUserResponse: () => Promise<unknown>;
|
||||
}) => {
|
||||
const { mutateAsync: createOrganization } = useSocketQueryMutation({
|
||||
emitEvent: '/organizations/post',
|
||||
responseEvent: '/organizations/post:post'
|
||||
});
|
||||
const { mutateAsync: createOrganization } = useCreateOrganization();
|
||||
|
||||
const { mutateAsync: updateUserInfo } = useUpdateUser();
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { UserResponses } from '@/api/buster_socket/user';
|
|||
import { TermsResponses } from '@/api/buster_socket/terms/termsResponses';
|
||||
import { TeamResponses } from '@/api/buster_socket/teams/teamResponses';
|
||||
import { SearchResponses } from '@/api/buster_socket/search';
|
||||
import { OrganizationResponses } from '@/api/buster_socket/organizations';
|
||||
import { SQLResponses } from '@/api/buster_socket/sql';
|
||||
import type {
|
||||
BusterSocketResponseBase,
|
||||
|
@ -36,7 +35,6 @@ const isKnownMessageRoute = (parsedMessage: BusterSocketResponseMessage) => {
|
|||
...TermsResponses,
|
||||
...TeamResponses,
|
||||
...SearchResponses,
|
||||
...OrganizationResponses,
|
||||
...ChatsResponses
|
||||
};
|
||||
const event = parsedMessage?.event;
|
||||
|
|
Loading…
Reference in New Issue