From f97597958afbe90d07f6e8bd9a0d4997bc1e984a Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Thu, 24 Aug 2023 17:44:20 +0530 Subject: [PATCH] fix: workspace memebers mutate issue --- .../workspace/send-workspace-invitation-modal.tsx | 10 ++++------ apps/app/pages/[workspaceSlug]/settings/members.tsx | 11 +++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/app/components/workspace/send-workspace-invitation-modal.tsx b/apps/app/components/workspace/send-workspace-invitation-modal.tsx index 5bffa3264..c9d090405 100644 --- a/apps/app/components/workspace/send-workspace-invitation-modal.tsx +++ b/apps/app/components/workspace/send-workspace-invitation-modal.tsx @@ -25,6 +25,7 @@ type Props = { setIsOpen: React.Dispatch>; workspace_slug: string; user: ICurrentUserResponse | undefined; + onSuccess: () => void; }; type EmailRole = { @@ -45,12 +46,8 @@ const defaultValues: FormValues = { ], }; -const SendWorkspaceInvitationModal: React.FC = ({ - isOpen, - setIsOpen, - workspace_slug, - user, -}) => { +const SendWorkspaceInvitationModal: React.FC = (props) => { + const { isOpen, setIsOpen, workspace_slug, user, onSuccess } = props; const { control, reset, @@ -88,6 +85,7 @@ const SendWorkspaceInvitationModal: React.FC = ({ title: "Success!", message: "Invitations sent successfully.", }); + onSuccess(); }) .catch((err) => { setToastAlert({ diff --git a/apps/app/pages/[workspaceSlug]/settings/members.tsx b/apps/app/pages/[workspaceSlug]/settings/members.tsx index 5f6fbc150..85131dab7 100644 --- a/apps/app/pages/[workspaceSlug]/settings/members.tsx +++ b/apps/app/pages/[workspaceSlug]/settings/members.tsx @@ -99,6 +99,11 @@ const MembersSettings: NextPage = () => { const currentUser = workspaceMembers?.find((item) => item.member?.id === user?.id); + const handleInviteModalSuccess = () => { + mutateInvitations(); + mutateMembers(); + }; + return ( { }); }) .finally(() => { - mutateMembers((prevData: any) => - prevData?.filter((item: any) => item.id !== selectedRemoveMember) + mutateMembers( + (prevData: any) => + prevData?.filter((item: any) => item.id !== selectedRemoveMember) ); }); } @@ -180,6 +186,7 @@ const MembersSettings: NextPage = () => { setIsOpen={setInviteModal} workspace_slug={workspaceSlug as string} user={user} + onSuccess={handleInviteModalSuccess} />