From c9ff589f57bd458b43b7ef631f8a5d33adf69884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=84=EC=A1=B0?= Date: Fri, 20 Sep 2024 07:13:29 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EB=93=B1=20=ED=95=A8=EC=88=98=20=EB=B0=8F=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/memberApi.ts | 11 +++++++++++ frontend/src/api/workspaceApi.ts | 19 ++++++++++++++++++- .../members/useSearchMembersByEmailQuery.ts | 9 +++++++++ .../workspaces/useWorkspaceMembersQuery.ts | 9 +++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 frontend/src/api/memberApi.ts create mode 100644 frontend/src/queries/members/useSearchMembersByEmailQuery.ts create mode 100644 frontend/src/queries/workspaces/useWorkspaceMembersQuery.ts diff --git a/frontend/src/api/memberApi.ts b/frontend/src/api/memberApi.ts new file mode 100644 index 0000000..c9bbca9 --- /dev/null +++ b/frontend/src/api/memberApi.ts @@ -0,0 +1,11 @@ +import api from '@/api/axiosConfig'; +import { MemberSearchResponse } from '@/types'; + +export async function searchMembersByEmail(keyword: string) { + return api + .get(`/api/members`, { + params: { keyword }, + withCredentials: true, + }) + .then(({ data }) => data); +} diff --git a/frontend/src/api/workspaceApi.ts b/frontend/src/api/workspaceApi.ts index bc45383..063036f 100644 --- a/frontend/src/api/workspaceApi.ts +++ b/frontend/src/api/workspaceApi.ts @@ -1,5 +1,11 @@ import api from '@/api/axiosConfig'; -import { WorkspaceListResponse, WorkspaceRequest, WorkspaceResponse, ReviewResponse } from '@/types'; +import { + WorkspaceListResponse, + WorkspaceRequest, + WorkspaceResponse, + ReviewResponse, + WorkspaceMemberResponse, +} from '@/types'; export async function getWorkspaceList(memberId: number, lastWorkspaceId?: number, limit?: number) { return api @@ -67,3 +73,14 @@ export async function getWorkspaceReviews( }) .then(({ data }) => data); } +export async function removeWorkspaceMember(workspaceId: number, memberId: number, targetMemberId: number) { + return api + .delete(`/workspaces/${workspaceId}/members/${targetMemberId}`, { + params: { memberId }, + }) + .then(({ data }) => data); +} + +export async function getWorkspaceMembers(workspaceId: number) { + return api.get(`/workspaces/${workspaceId}/members`).then(({ data }) => data); +} diff --git a/frontend/src/queries/members/useSearchMembersByEmailQuery.ts b/frontend/src/queries/members/useSearchMembersByEmailQuery.ts new file mode 100644 index 0000000..54137da --- /dev/null +++ b/frontend/src/queries/members/useSearchMembersByEmailQuery.ts @@ -0,0 +1,9 @@ +import { searchMembersByEmail } from '@/api/memberApi'; +import { useSuspenseQuery } from '@tanstack/react-query'; + +export default function useSearchMembersByEmailQuery(keyword: string) { + return useSuspenseQuery({ + queryKey: ['members', keyword], + queryFn: () => searchMembersByEmail(keyword), + }); +} diff --git a/frontend/src/queries/workspaces/useWorkspaceMembersQuery.ts b/frontend/src/queries/workspaces/useWorkspaceMembersQuery.ts new file mode 100644 index 0000000..8f2f31e --- /dev/null +++ b/frontend/src/queries/workspaces/useWorkspaceMembersQuery.ts @@ -0,0 +1,9 @@ +import { getWorkspaceMembers } from '@/api/workspaceApi'; +import { useSuspenseQuery } from '@tanstack/react-query'; + +export default function useWorkspaceMembersQuery(workspaceId: number) { + return useSuspenseQuery({ + queryKey: ['workspaceMembers', workspaceId], + queryFn: () => getWorkspaceMembers(workspaceId), + }); +}