Merge pull request #1966 from makeplane/fix/workspace-members-mutate

fix: workspace members mutate issue
This commit is contained in:
sriram veeraghanta 2023-08-24 18:26:11 +05:30 committed by GitHub
commit 489ef6a3cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -25,6 +25,7 @@ type Props = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
workspace_slug: string; workspace_slug: string;
user: ICurrentUserResponse | undefined; user: ICurrentUserResponse | undefined;
onSuccess: () => void;
}; };
type EmailRole = { type EmailRole = {
@ -45,12 +46,8 @@ const defaultValues: FormValues = {
], ],
}; };
const SendWorkspaceInvitationModal: React.FC<Props> = ({ const SendWorkspaceInvitationModal: React.FC<Props> = (props) => {
isOpen, const { isOpen, setIsOpen, workspace_slug, user, onSuccess } = props;
setIsOpen,
workspace_slug,
user,
}) => {
const { const {
control, control,
reset, reset,
@ -88,6 +85,7 @@ const SendWorkspaceInvitationModal: React.FC<Props> = ({
title: "Success!", title: "Success!",
message: "Invitations sent successfully.", message: "Invitations sent successfully.",
}); });
onSuccess();
}) })
.catch((err) => { .catch((err) => {
setToastAlert({ setToastAlert({

View File

@ -99,6 +99,10 @@ const MembersSettings: NextPage = () => {
const currentUser = workspaceMembers?.find((item) => item.member?.id === user?.id); const currentUser = workspaceMembers?.find((item) => item.member?.id === user?.id);
const handleInviteModalSuccess = () => {
mutateInvitations();
};
return ( return (
<WorkspaceAuthorizationLayout <WorkspaceAuthorizationLayout
breadcrumbs={ breadcrumbs={
@ -139,7 +143,8 @@ const MembersSettings: NextPage = () => {
}); });
}) })
.finally(() => { .finally(() => {
mutateMembers((prevData: any) => mutateMembers(
(prevData: any) =>
prevData?.filter((item: any) => item.id !== selectedRemoveMember) prevData?.filter((item: any) => item.id !== selectedRemoveMember)
); );
}); });
@ -180,6 +185,7 @@ const MembersSettings: NextPage = () => {
setIsOpen={setInviteModal} setIsOpen={setInviteModal}
workspace_slug={workspaceSlug as string} workspace_slug={workspaceSlug as string}
user={user} user={user}
onSuccess={handleInviteModalSuccess}
/> />
<div className="p-8"> <div className="p-8">
<SettingsHeader /> <SettingsHeader />