diff --git a/backend/src/workspace-users/types/find-workspace-users-response.type.ts b/backend/src/workspace-users/types/find-workspace-users-response.type.ts index ee39236f..5709c103 100644 --- a/backend/src/workspace-users/types/find-workspace-users-response.type.ts +++ b/backend/src/workspace-users/types/find-workspace-users-response.type.ts @@ -7,4 +7,7 @@ export class FindWorkspaceUsersResponse { @ApiProperty({ type: String, description: "The ID of last workspace user" }) cursor: string | null; + + @ApiProperty({ type: Number, description: "The number of total workspace users" }) + totalLength: number; } diff --git a/backend/src/workspace-users/workspace-users.service.ts b/backend/src/workspace-users/workspace-users.service.ts index 0489ced1..400dc08b 100644 --- a/backend/src/workspace-users/workspace-users.service.ts +++ b/backend/src/workspace-users/workspace-users.service.ts @@ -55,9 +55,22 @@ export class WorkspaceUsersService { ...additionalOptions, }); + const totalLength = await this.prismaService.user.count({ + where: { + userWorkspaceList: { + some: { + workspaceId: { + equals: workspaceId, + }, + }, + }, + }, + }); + return { workspaceUsers: workspaceUserList.slice(0, pageSize), cursor: workspaceUserList.length > pageSize ? workspaceUserList[pageSize].id : null, + totalLength, }; } } diff --git a/frontend/src/hooks/api/types/workspaceUser.d.ts b/frontend/src/hooks/api/types/workspaceUser.d.ts index 3aac0c21..57747c95 100644 --- a/frontend/src/hooks/api/types/workspaceUser.d.ts +++ b/frontend/src/hooks/api/types/workspaceUser.d.ts @@ -3,4 +3,5 @@ import { User } from "./user"; export class GetWorkspaceUserListResponse { cursor: string | null; workspaceUsers: Array; + totalLength: number; } diff --git a/frontend/src/pages/workspace/member/Index.tsx b/frontend/src/pages/workspace/member/Index.tsx index eaedb0f3..7bc064bc 100644 --- a/frontend/src/pages/workspace/member/Index.tsx +++ b/frontend/src/pages/workspace/member/Index.tsx @@ -1,5 +1,4 @@ -import { useParams } from "react-router-dom"; -import { useGetWorkspaceQuery } from "../../../hooks/api/workspace"; +import AddIcon from "@mui/icons-material/Add"; import { Box, Button, @@ -15,16 +14,18 @@ import { TableRow, Typography, } from "@mui/material"; -import InfiniteScroll from "react-infinite-scroller"; -import { useGetWorkspaceUserListQuery } from "../../../hooks/api/workspaceUser"; import { useMemo, useState } from "react"; -import AddIcon from "@mui/icons-material/Add"; -import { User } from "../../../hooks/api/types/user"; +import InfiniteScroll from "react-infinite-scroller"; +import { useParams } from "react-router-dom"; import MemberModal from "../../../components/modals/MemberModal"; +import { User } from "../../../hooks/api/types/user"; +import { useGetWorkspaceQuery } from "../../../hooks/api/workspace"; +import { useGetWorkspaceUserListQuery } from "../../../hooks/api/workspaceUser"; function MemberIndex() { const params = useParams(); const { data: workspace } = useGetWorkspaceQuery(params.workspaceSlug); + const { data: workspaceUserPageList, fetchNextPage, @@ -51,7 +52,7 @@ function MemberIndex() { {workspace?.title}{" "} - {userList.length} + {workspaceUserPageList?.pages[0].totalLength}