ripped out organization

This commit is contained in:
Nate Kelley 2025-03-10 21:28:06 -06:00
parent 6204a2e827
commit ceb0a2872e
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
8 changed files with 16 additions and 43 deletions

View File

@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { getOrganizationUsers, getOrganizationUsers_server } from './requests'; import { createOrganization, getOrganizationUsers, getOrganizationUsers_server } from './requests';
import { useMemoizedFn } from '@/hooks'; import { useMemoizedFn } from '@/hooks';
import { QueryClient } from '@tanstack/react-query'; import { QueryClient } from '@tanstack/react-query';
import { organizationQueryKeys } from '@/api/query_keys/organization'; import { organizationQueryKeys } from '@/api/query_keys/organization';
@ -36,3 +36,10 @@ export const prefetchGetOrganizationUsers = async (
}); });
return queryClient; return queryClient;
}; };
export const useCreateOrganization = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: createOrganization
});
};

View File

@ -1,3 +1,4 @@
import type { BusterOrganization } from '@/api/asset_interfaces/organizations';
import { serverFetch } from '../../createServerInstance'; import { serverFetch } from '../../createServerInstance';
import { mainApi } from '../instances'; import { mainApi } from '../instances';
import type { OrganizationUser } from '@/api/asset_interfaces/users'; import type { OrganizationUser } from '@/api/asset_interfaces/users';
@ -19,3 +20,7 @@ export const getOrganizationUsers_server = async ({
}): Promise<OrganizationUser[]> => { }): Promise<OrganizationUser[]> => {
return serverFetch<OrganizationUser[]>(`/organizations/${organizationId}/users`); return serverFetch<OrganizationUser[]>(`/organizations/${organizationId}/users`);
}; };
export const createOrganization = async (organization: { name: string }) => {
return mainApi.post<BusterOrganization>('/organizations', organization).then((res) => res.data);
};

View File

@ -3,11 +3,6 @@ import type { UserEmits, UserResponses, UserResponsesTypes } from './user';
import type { TeamEmits, TeamResponses, TeamResponsesTypes } from './teams'; import type { TeamEmits, TeamResponses, TeamResponsesTypes } from './teams';
import type { TermsEmits, TermsResponses, TermsResponseTypes } from './terms'; import type { TermsEmits, TermsResponses, TermsResponseTypes } from './terms';
import type { BusterSearchEmits, SearchResponses, SearchResponseTypes } from './search'; import type { BusterSearchEmits, SearchResponses, SearchResponseTypes } from './search';
import type {
OrganizationResponses,
OrganizationResponsesTypes,
OrganizationsEmits
} from './organizations';
import type { ChatEmits, ChatResponseTypes, ChatsResponses } from './chats'; import type { ChatEmits, ChatResponseTypes, ChatsResponses } from './chats';
export type BusterSocketRequest = export type BusterSocketRequest =
@ -16,7 +11,6 @@ export type BusterSocketRequest =
| SQLEmits | SQLEmits
| TermsEmits | TermsEmits
| BusterSearchEmits | BusterSearchEmits
| OrganizationsEmits
| ChatEmits; | ChatEmits;
export type BusterSocketResponse = export type BusterSocketResponse =
@ -25,7 +19,6 @@ export type BusterSocketResponse =
| SQLResponsesTypes | SQLResponsesTypes
| TermsResponseTypes | TermsResponseTypes
| SearchResponseTypes | SearchResponseTypes
| OrganizationResponsesTypes
| ChatResponseTypes; | ChatResponseTypes;
export type BusterSocketResponseRoute = export type BusterSocketResponseRoute =
@ -34,7 +27,6 @@ export type BusterSocketResponseRoute =
| keyof typeof SQLResponses | keyof typeof SQLResponses
| keyof typeof TermsResponses | keyof typeof TermsResponses
| keyof typeof SearchResponses | keyof typeof SearchResponses
| keyof typeof OrganizationResponses
| keyof typeof ChatsResponses; | keyof typeof ChatsResponses;
export type * from './shared_interfaces'; export type * from './shared_interfaces';

View File

@ -1,2 +0,0 @@
export * from './organizationRequests';
export * from './organizationResponses';

View File

@ -1,10 +0,0 @@
import { BusterSocketRequestBase } from '../base_interfaces';
export type OrganizationPostRequest = BusterSocketRequestBase<
'/organizations/post',
{
name: string;
}
>;
export type OrganizationsEmits = OrganizationPostRequest;

View File

@ -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;

View File

@ -1,7 +1,6 @@
import { useMemoizedFn } from '@/hooks'; import { useMemoizedFn } from '@/hooks';
import { useSocketQueryMutation } from '@/api/buster_socket_query';
import type { BusterUserResponse } from '@/api/asset_interfaces/users'; import type { BusterUserResponse } from '@/api/asset_interfaces/users';
import { useUpdateUser } from '@/api/buster_rest'; import { useCreateOrganization, useUpdateUser } from '@/api/buster_rest';
export const useUserOrganization = ({ export const useUserOrganization = ({
userResponse, userResponse,
@ -10,10 +9,7 @@ export const useUserOrganization = ({
userResponse: BusterUserResponse | null | undefined; userResponse: BusterUserResponse | null | undefined;
refetchUserResponse: () => Promise<unknown>; refetchUserResponse: () => Promise<unknown>;
}) => { }) => {
const { mutateAsync: createOrganization } = useSocketQueryMutation({ const { mutateAsync: createOrganization } = useCreateOrganization();
emitEvent: '/organizations/post',
responseEvent: '/organizations/post:post'
});
const { mutateAsync: updateUserInfo } = useUpdateUser(); const { mutateAsync: updateUserInfo } = useUpdateUser();

View File

@ -3,7 +3,6 @@ import { UserResponses } from '@/api/buster_socket/user';
import { TermsResponses } from '@/api/buster_socket/terms/termsResponses'; import { TermsResponses } from '@/api/buster_socket/terms/termsResponses';
import { TeamResponses } from '@/api/buster_socket/teams/teamResponses'; import { TeamResponses } from '@/api/buster_socket/teams/teamResponses';
import { SearchResponses } from '@/api/buster_socket/search'; import { SearchResponses } from '@/api/buster_socket/search';
import { OrganizationResponses } from '@/api/buster_socket/organizations';
import { SQLResponses } from '@/api/buster_socket/sql'; import { SQLResponses } from '@/api/buster_socket/sql';
import type { import type {
BusterSocketResponseBase, BusterSocketResponseBase,
@ -36,7 +35,6 @@ const isKnownMessageRoute = (parsedMessage: BusterSocketResponseMessage) => {
...TermsResponses, ...TermsResponses,
...TeamResponses, ...TeamResponses,
...SearchResponses, ...SearchResponses,
...OrganizationResponses,
...ChatsResponses ...ChatsResponses
}; };
const event = parsedMessage?.event; const event = parsedMessage?.event;