From 1a46c6c39973a5d0a32b1e2063bdf3330326482d Mon Sep 17 00:00:00 2001 From: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Date: Wed, 1 Nov 2023 20:23:21 +0530 Subject: [PATCH] feat: search project & workspace members (#2590) * feat: search project & workspace members * chore: formatting --- web/components/project/member-list.tsx | 24 ++++++++++++++++++- .../workspace/settings/members-list.tsx | 13 +++++++--- .../[workspaceSlug]/settings/members.tsx | 16 +++++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/web/components/project/member-list.tsx b/web/components/project/member-list.tsx index 7a8f6184d..1dfc87b8f 100644 --- a/web/components/project/member-list.tsx +++ b/web/components/project/member-list.tsx @@ -11,6 +11,8 @@ import useUser from "hooks/use-user"; import { ProjectMemberListItem, SendProjectInvitationModal } from "components/project"; // ui import { Button, Loader } from "@plane/ui"; +// icons +import { Search } from "lucide-react"; // services const projectInvitationService = new ProjectInvitationService(); @@ -25,6 +27,7 @@ export const ProjectMemberList: React.FC = observer(() => { // states const [inviteModal, setInviteModal] = useState(false); + const [searchQuery, setSearchQuery] = useState(""); const { user } = useUser(); @@ -72,6 +75,12 @@ export const ProjectMemberList: React.FC = observer(() => { })) || []), ]; + const searchedMembers = members?.filter((member) => { + const fullName = `${member.first_name} ${member.last_name}`.toLowerCase(); + const displayName = member.display_name.toLowerCase(); + return displayName.includes(searchQuery.toLowerCase()) || fullName.includes(searchQuery.toLowerCase()); + }); + return ( <> {

Members

+
+ + setSearchQuery(e.target.value)} + /> +
@@ -101,8 +120,11 @@ export const ProjectMemberList: React.FC = observer(() => { ) : (
{members.length > 0 - ? members.map((member) => ) + ? searchedMembers.map((member) => ) : null} + {searchedMembers.length === 0 && ( +

No matching member

+ )}
)} diff --git a/web/components/workspace/settings/members-list.tsx b/web/components/workspace/settings/members-list.tsx index 297fde72c..d09f2558d 100644 --- a/web/components/workspace/settings/members-list.tsx +++ b/web/components/workspace/settings/members-list.tsx @@ -11,8 +11,7 @@ import { WorkspaceMembersListItem } from "components/workspace"; import { Loader } from "@plane/ui"; const workspaceService = new WorkspaceService(); - -export const WorkspaceMembersList: React.FC = observer(() => { +export const WorkspaceMembersList: React.FC<{ searchQuery: string }> = observer(({ searchQuery }) => { const router = useRouter(); const { workspaceSlug } = router.query; // store @@ -53,6 +52,11 @@ export const WorkspaceMembersList: React.FC = observer(() => { accountCreated: true, })) || []), ]; + const searchedMembers = members?.filter((member) => { + const fullName = `${member.first_name} ${member.last_name}`.toLowerCase(); + const displayName = member.display_name.toLowerCase(); + return displayName.includes(searchQuery.toLowerCase()) || fullName.includes(searchQuery.toLowerCase()); + }); if (!workspaceMembers || !workspaceInvitations || !user) return ( @@ -67,8 +71,11 @@ export const WorkspaceMembersList: React.FC = observer(() => { return (
{members.length > 0 - ? members.map((member) => ) + ? searchedMembers.map((member) => ) : null} + {searchedMembers.length === 0 && ( +

No matching member

+ )}
); }); diff --git a/web/pages/[workspaceSlug]/settings/members.tsx b/web/pages/[workspaceSlug]/settings/members.tsx index 7644560c9..32d173c45 100644 --- a/web/pages/[workspaceSlug]/settings/members.tsx +++ b/web/pages/[workspaceSlug]/settings/members.tsx @@ -12,10 +12,12 @@ import { SendWorkspaceInvitationModal, WorkspaceMembersList } from "components/w import { Button } from "@plane/ui"; // types import type { NextPage } from "next"; +// icons +import { Search } from "lucide-react"; const MembersSettings: NextPage = () => { const [inviteModal, setInviteModal] = useState(false); - + const [searchQuery, setSearchQuery] = useState(""); const router = useRouter(); const { workspaceSlug } = router.query; @@ -35,11 +37,21 @@ const MembersSettings: NextPage = () => {

Members

+
+ + setSearchQuery(e.target.value)} + /> +
- +