[WEB-871] chore: update leave project modal message in members settings page. (#4230)

* [WEB-871] chore: update leave project modal message in members settings page.

* fix: build errors.
This commit is contained in:
Prateek Shourya 2024-04-23 12:51:20 +05:30 committed by GitHub
parent 38daf72361
commit c50a0602f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,13 +1,14 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { useRouter } from "next/router";
import { AlertTriangle } from "lucide-react"; import { AlertTriangle } from "lucide-react";
import { Dialog, Transition } from "@headlessui/react"; import { Dialog, Transition } from "@headlessui/react";
import { IUserLite } from "@plane/types";
// hooks
import { Button } from "@plane/ui";
import { useUser } from "@/hooks/store";
// ui
// types // types
import { IUserLite } from "@plane/types";
// ui
import { Button } from "@plane/ui";
// hooks
import { useProject, useUser } from "@/hooks/store";
type Props = { type Props = {
data: IUserLite; data: IUserLite;
@ -18,10 +19,14 @@ type Props = {
export const ConfirmProjectMemberRemove: React.FC<Props> = observer((props) => { export const ConfirmProjectMemberRemove: React.FC<Props> = observer((props) => {
const { data, onSubmit, isOpen, onClose } = props; const { data, onSubmit, isOpen, onClose } = props;
// router
const router = useRouter();
const { projectId } = router.query;
// states // states
const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [isDeleteLoading, setIsDeleteLoading] = useState(false);
// store hooks // store hooks
const { currentUser } = useUser(); const { currentUser } = useUser();
const { getProjectById } = useProject();
const handleClose = () => { const handleClose = () => {
onClose(); onClose();
@ -36,7 +41,10 @@ export const ConfirmProjectMemberRemove: React.FC<Props> = observer((props) => {
handleClose(); handleClose();
}; };
if (!projectId) return <></>;
const isCurrentUser = currentUser?.id === data?.id; const isCurrentUser = currentUser?.id === data?.id;
const currentProjectDetails = getProjectById(projectId.toString());
return ( return (
<Transition.Root show={isOpen} as={React.Fragment}> <Transition.Root show={isOpen} as={React.Fragment}>
@ -76,9 +84,19 @@ export const ConfirmProjectMemberRemove: React.FC<Props> = observer((props) => {
</Dialog.Title> </Dialog.Title>
<div className="mt-2"> <div className="mt-2">
<p className="text-sm text-custom-text-200"> <p className="text-sm text-custom-text-200">
Are you sure you want to remove member-{" "} {isCurrentUser ? (
<span className="font-bold">{data?.display_name}</span>? They will no longer have access to <>
this project. This action cannot be undone. Are you sure you want to leave the{" "}
<span className="font-bold">{currentProjectDetails?.name}</span> project? You will be able
to join the project if invited again or if it{"'"}s public.
</>
) : (
<>
Are you sure you want to remove member-{" "}
<span className="font-bold">{data?.display_name}</span>? They will no longer have access
to this project. This action cannot be undone.
</>
)}
</p> </p>
</div> </div>
</div> </div>