fix: leave project mutation (#2976)

This commit is contained in:
Aaryan Khandelwal 2023-12-05 13:44:01 +05:30 committed by sriram veeraghanta
parent 41f0d55dab
commit d12bd9507e
3 changed files with 9 additions and 4 deletions

View File

@ -33,6 +33,7 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
const { const {
user: { currentUser, currentProjectMemberInfo, currentProjectRole, leaveProject }, user: { currentUser, currentProjectMemberInfo, currentProjectRole, leaveProject },
projectMember: { removeMemberFromProject, updateMember }, projectMember: { removeMemberFromProject, updateMember },
project: { fetchProjects },
} = useMobxStore(); } = useMobxStore();
// hooks // hooks
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -46,7 +47,11 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
if (memberDetails.id === currentUser?.id) { if (memberDetails.id === currentUser?.id) {
await leaveProject(workspaceSlug.toString(), projectId.toString()) await leaveProject(workspaceSlug.toString(), projectId.toString())
.then(() => router.push(`/${workspaceSlug}/projects`)) .then(async () => {
await fetchProjects(workspaceSlug.toString());
router.push(`/${workspaceSlug}/projects`);
})
.catch((err) => .catch((err) =>
setToastAlert({ setToastAlert({
type: "error", type: "error",
@ -174,7 +179,7 @@ export const ProjectMemberListItem: React.FC<Props> = observer((props) => {
onClick={() => setRemoveMemberModal(true)} onClick={() => setRemoveMemberModal(true)}
className="opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto" className="opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto"
> >
<XCircle className="h-3.5 w-3.5 text-custom-text-400" strokeWidth={2} /> <XCircle className="h-3.5 w-3.5 text-red-500" strokeWidth={2} />
</button> </button>
</Tooltip> </Tooltip>
)} )}

View File

@ -284,7 +284,7 @@ export const ProjectSidebarListItem: React.FC<Props> = observer((props) => {
<CustomMenu.MenuItem onClick={handleLeaveProject}> <CustomMenu.MenuItem onClick={handleLeaveProject}>
<div className="flex items-center justify-start gap-2"> <div className="flex items-center justify-start gap-2">
<LogOut className="h-3.5 w-3.5 stroke-[1.5]" /> <LogOut className="h-3.5 w-3.5 stroke-[1.5]" />
<span>Leave Project</span> <span>Leave project</span>
</div> </div>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
)} )}

View File

@ -243,7 +243,7 @@ export const WorkspaceMembersListItem: FC<Props> = observer((props) => {
: "opacity-0 pointer-events-none" : "opacity-0 pointer-events-none"
} }
> >
<XCircle className="h-3.5 w-3.5 text-custom-text-400" strokeWidth={2} /> <XCircle className="h-3.5 w-3.5 text-red-500" strokeWidth={2} />
</button> </button>
</Tooltip> </Tooltip>
</div> </div>