diff --git a/src/apis/auth/refresh.api.ts b/src/apis/auth/refresh.api.ts index 06a9555..48c21ed 100644 --- a/src/apis/auth/refresh.api.ts +++ b/src/apis/auth/refresh.api.ts @@ -21,13 +21,13 @@ export async function refresh(): Promise { } } -export async function refreshWorkSpace(): Promise { +export async function refreshWorkSpace( + workspaceId: number +): Promise { try { - const workspaceId = localStorage.getItem('selectedWorkSpaceId'); - const parsedWorkspaceId = workspaceId ? parseInt(workspaceId, 10) : null; const response = await axios.post( `${BASE_URI}/users/reissue-workspace`, - { workspaceId: parsedWorkspaceId }, + { workspaceId }, { withCredentials: true, } diff --git a/src/components/common/sider/WorkSpace.tsx b/src/components/common/sider/WorkSpace.tsx index 34f7a50..86bb9da 100644 --- a/src/components/common/sider/WorkSpace.tsx +++ b/src/components/common/sider/WorkSpace.tsx @@ -18,9 +18,9 @@ import { import { WorkSpaceMenuItem } from '@finnect/interface/SlideMenuInterface'; -import { refreshWorkSpace } from '@finnect/apis/auth/refresh.api'; import { useGetWorkSpaceQuery } from '@finnect/hooks/queries/workspace/useGetWorkSpaceQuery'; import { usePostWorkSpaceQuery } from '@finnect/hooks/queries/workspace/usePostWorkSpaceQuery'; +import { useRefreshQuery } from '@finnect/hooks/queries/auth/useRefreshQuery'; const WorkSpace = () => { const { data, isPending, isError, error, refetch } = useGetWorkSpaceQuery(); @@ -35,6 +35,7 @@ const WorkSpace = () => { useRecoilState(modalVisibleState); const [newItemTitle, setNewItemTitle] = useRecoilState(newItemTitleState); + const { mutate: refreshData } = useRefreshQuery(); useEffect(() => { if (data) { @@ -56,9 +57,10 @@ const WorkSpace = () => { (item: WorkSpaceMenuItem) => { set(selectedWorkSpaceState, item.title); set(selectedWorkSpaceIdState, item.key); - refreshWorkSpace(); + refreshData(parseInt(item.key)); + localStorage.setItem('selectedWorkSpace', item.title); - localStorage.setItem('selectedWorkSpaceId', item.key.toString()); + localStorage.setItem('selectedWorkSpaceId', item.key); } ); diff --git a/src/mocks/handler/people/PeopleHandler.ts b/src/mocks/handler/people/PeopleHandler.ts index dded3c3..da7e2ca 100644 --- a/src/mocks/handler/people/PeopleHandler.ts +++ b/src/mocks/handler/people/PeopleHandler.ts @@ -1,4 +1,4 @@ -import { IPeopleProps } from '@finnect/interface/PeopleInterface'; +import { IMemberProps } from '@finnect/interface/MemberInterface'; import { http, HttpResponse } from 'msw'; export const PeopleHandler = [ @@ -23,7 +23,7 @@ export const PeopleHandler = [ }), http.post('/workspaces/members', async ({ request }) => { - const { nickname, role, phone } = (await request.json()) as IPeopleProps; + const { nickname, role, phone } = (await request.json()) as IMemberProps; if (!nickname || !role || !phone) { return HttpResponse.json(