fix: workspace memebers mutate issue

This commit is contained in:
sriram veeraghanta 2023-08-24 17:44:20 +05:30
parent 7fca01d8c9
commit f97597958a
2 changed files with 13 additions and 8 deletions

View File

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

View File

@ -99,6 +99,11 @@ const MembersSettings: NextPage = () => {
const currentUser = workspaceMembers?.find((item) => item.member?.id === user?.id);
const handleInviteModalSuccess = () => {
mutateInvitations();
mutateMembers();
};
return (
<WorkspaceAuthorizationLayout
breadcrumbs={
@ -139,8 +144,9 @@ const MembersSettings: NextPage = () => {
});
})
.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}
/>
<div className="p-8">
<SettingsHeader />