Feat: 이메일 검색 등 함수 및 쿼리 추가

This commit is contained in:
정현조 2024-09-20 07:13:29 +09:00
parent ea344dca19
commit c9ff589f57
4 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,11 @@
import api from '@/api/axiosConfig';
import { MemberSearchResponse } from '@/types';
export async function searchMembersByEmail(keyword: string) {
return api
.get<MemberSearchResponse[]>(`/api/members`, {
params: { keyword },
withCredentials: true,
})
.then(({ data }) => data);
}

View File

@ -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<WorkspaceMemberResponse[]>(`/workspaces/${workspaceId}/members`).then(({ data }) => data);
}

View File

@ -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),
});
}

View File

@ -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),
});
}