Skip to content

Commit

Permalink
Add totalLength property in FindWorkspaceUsersResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
choidabom committed Jan 23, 2025
1 parent 666c8d2 commit 7ea0bb5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 13 additions & 0 deletions backend/src/workspace-users/workspace-users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
1 change: 1 addition & 0 deletions frontend/src/hooks/api/types/workspaceUser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { User } from "./user";
export class GetWorkspaceUserListResponse {
cursor: string | null;
workspaceUsers: Array<User>;
totalLength: number;
}
15 changes: 8 additions & 7 deletions frontend/src/pages/workspace/member/Index.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -51,7 +52,7 @@ function MemberIndex() {
<Typography variant="h5" fontWeight="bold">
{workspace?.title}{" "}
<Typography component="span" variant="inherit" color="primary">
{userList.length}
{workspaceUserPageList?.pages[0].totalLength}
</Typography>
</Typography>
<Button
Expand Down

0 comments on commit 7ea0bb5

Please sign in to comment.