From ceb0a2872e5f7b10fda9c70e38b04d1472973394 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 10 Mar 2025 21:28:06 -0600 Subject: [PATCH] ripped out organization --- .../api/buster_rest/organizations/queryRequests.ts | 11 +++++++++-- web/src/api/buster_rest/organizations/requests.ts | 5 +++++ web/src/api/buster_socket/index.ts | 8 -------- web/src/api/buster_socket/organizations/index.ts | 2 -- .../organizations/organizationRequests.ts | 10 ---------- .../organizations/organizationResponses.ts | 13 ------------- web/src/context/Users/useUserOrganization.ts | 8 ++------ web/src/hooks/useWebSocket/helpers.ts | 2 -- 8 files changed, 16 insertions(+), 43 deletions(-) delete mode 100644 web/src/api/buster_socket/organizations/index.ts delete mode 100644 web/src/api/buster_socket/organizations/organizationRequests.ts delete mode 100644 web/src/api/buster_socket/organizations/organizationResponses.ts diff --git a/web/src/api/buster_rest/organizations/queryRequests.ts b/web/src/api/buster_rest/organizations/queryRequests.ts index dc0e4b449..5707119aa 100644 --- a/web/src/api/buster_rest/organizations/queryRequests.ts +++ b/web/src/api/buster_rest/organizations/queryRequests.ts @@ -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 + }); +}; diff --git a/web/src/api/buster_rest/organizations/requests.ts b/web/src/api/buster_rest/organizations/requests.ts index 2c4af0989..90b6fdcec 100644 --- a/web/src/api/buster_rest/organizations/requests.ts +++ b/web/src/api/buster_rest/organizations/requests.ts @@ -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 => { return serverFetch(`/organizations/${organizationId}/users`); }; + +export const createOrganization = async (organization: { name: string }) => { + return mainApi.post('/organizations', organization).then((res) => res.data); +}; diff --git a/web/src/api/buster_socket/index.ts b/web/src/api/buster_socket/index.ts index 5ec9f6364..c1760dcb0 100644 --- a/web/src/api/buster_socket/index.ts +++ b/web/src/api/buster_socket/index.ts @@ -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'; diff --git a/web/src/api/buster_socket/organizations/index.ts b/web/src/api/buster_socket/organizations/index.ts deleted file mode 100644 index 8d7268c41..000000000 --- a/web/src/api/buster_socket/organizations/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './organizationRequests'; -export * from './organizationResponses'; diff --git a/web/src/api/buster_socket/organizations/organizationRequests.ts b/web/src/api/buster_socket/organizations/organizationRequests.ts deleted file mode 100644 index b4eb9c861..000000000 --- a/web/src/api/buster_socket/organizations/organizationRequests.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { BusterSocketRequestBase } from '../base_interfaces'; - -export type OrganizationPostRequest = BusterSocketRequestBase< - '/organizations/post', - { - name: string; - } ->; - -export type OrganizationsEmits = OrganizationPostRequest; diff --git a/web/src/api/buster_socket/organizations/organizationResponses.ts b/web/src/api/buster_socket/organizations/organizationResponses.ts deleted file mode 100644 index c6beb247e..000000000 --- a/web/src/api/buster_socket/organizations/organizationResponses.ts +++ /dev/null @@ -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; diff --git a/web/src/context/Users/useUserOrganization.ts b/web/src/context/Users/useUserOrganization.ts index 0047836cf..2845543cc 100644 --- a/web/src/context/Users/useUserOrganization.ts +++ b/web/src/context/Users/useUserOrganization.ts @@ -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; }) => { - const { mutateAsync: createOrganization } = useSocketQueryMutation({ - emitEvent: '/organizations/post', - responseEvent: '/organizations/post:post' - }); + const { mutateAsync: createOrganization } = useCreateOrganization(); const { mutateAsync: updateUserInfo } = useUpdateUser(); diff --git a/web/src/hooks/useWebSocket/helpers.ts b/web/src/hooks/useWebSocket/helpers.ts index e448636ee..a0351c49d 100644 --- a/web/src/hooks/useWebSocket/helpers.ts +++ b/web/src/hooks/useWebSocket/helpers.ts @@ -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;