diff --git a/apps/app/components/workspace/delete-workspace-modal.tsx b/apps/app/components/workspace/delete-workspace-modal.tsx index 54ddedc3b..b896a87e7 100644 --- a/apps/app/components/workspace/delete-workspace-modal.tsx +++ b/apps/app/components/workspace/delete-workspace-modal.tsx @@ -50,8 +50,10 @@ export const DeleteWorkspaceModal: React.FC = ({ isOpen, data, onClose, u const canDelete = confirmWorkspaceName === data?.name && confirmDeleteMyWorkspace; const handleClose = () => { - onClose(); setIsDeleteLoading(false); + setConfirmWorkspaceName(""); + setConfirmDeleteMyWorkspace(false); + onClose(); }; const handleDeletion = async () => { diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx index 7de91c823..4287cee5d 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx @@ -34,7 +34,7 @@ import { truncateText } from "helpers/string.helper"; import { IProject, IWorkspace } from "types"; import type { NextPage } from "next"; // fetch-keys -import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; +import { PROJECTS_LIST, PROJECT_DETAILS, USER_PROJECT_VIEW } from "constants/fetch-keys"; // constants import { NETWORK_CHOICES } from "constants/project"; @@ -62,6 +62,13 @@ const GeneralSettings: NextPage = () => { : null ); + const { data: memberDetails, error } = useSWR( + workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, + workspaceSlug && projectId + ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) + : null + ); + const { register, handleSubmit, @@ -157,6 +164,8 @@ const GeneralSettings: NextPage = () => { const currentNetwork = NETWORK_CHOICES.find((n) => n.key === projectDetails?.network); + const isAdmin = memberDetails?.role === 20; + return ( {
{projectDetails ? ( - + {isSubmitting ? "Updating Project..." : "Update Project"} ) : ( @@ -364,32 +373,34 @@ const GeneralSettings: NextPage = () => { )}
-
-
-

Danger Zone

-

- The danger zone of the project delete page is a critical area that requires careful - consideration and attention. When deleting a project, all of the data and resources - within that project will be permanently removed and cannot be recovered. -

+ {memberDetails?.role === 20 && ( +
+
+

Danger Zone

+

+ The danger zone of the project delete page is a critical area that requires + careful consideration and attention. When deleting a project, all of the data and + resources within that project will be permanently removed and cannot be recovered. +

+
+
+ {projectDetails ? ( +
+ setSelectedProject(projectDetails.id ?? null)} + outline + > + Delete Project + +
+ ) : ( + + + + )} +
-
- {projectDetails ? ( -
- setSelectedProject(projectDetails.id ?? null)} - outline - > - Delete Project - -
- ) : ( - - - - )} -
-
+ )}
diff --git a/apps/app/pages/[workspaceSlug]/settings/index.tsx b/apps/app/pages/[workspaceSlug]/settings/index.tsx index af46e0884..a254c7a49 100644 --- a/apps/app/pages/[workspaceSlug]/settings/index.tsx +++ b/apps/app/pages/[workspaceSlug]/settings/index.tsx @@ -28,7 +28,7 @@ import { copyTextToClipboard, truncateText } from "helpers/string.helper"; import type { IWorkspace } from "types"; import type { NextPage } from "next"; // fetch-keys -import { WORKSPACE_DETAILS, USER_WORKSPACES } from "constants/fetch-keys"; +import { WORKSPACE_DETAILS, USER_WORKSPACES, WORKSPACE_MEMBERS_ME } from "constants/fetch-keys"; // constants import { ORGANIZATION_SIZE } from "constants/workspace"; @@ -50,6 +50,11 @@ const WorkspaceSettings: NextPage = () => { const { user } = useUserAuth(); + const { data: memberDetails } = useSWR( + workspaceSlug ? WORKSPACE_MEMBERS_ME(workspaceSlug.toString()) : null, + workspaceSlug ? () => workspaceService.workspaceMemberMe(workspaceSlug.toString()) : null + ); + const { setToastAlert } = useToast(); const { data: activeWorkspace } = useSWR( @@ -142,6 +147,8 @@ const WorkspaceSettings: NextPage = () => { }); }; + const isAdmin = memberDetails?.role === 20; + return ( {
- + {isSubmitting ? "Updating..." : "Update Workspace"}
-
-
-

Danger Zone

-

- The danger zone of the workspace delete page is a critical area that requires - careful consideration and attention. When deleting a workspace, all of the data - and resources within that workspace will be permanently removed and cannot be - recovered. -

+ {memberDetails?.role === 20 && ( +
+
+

Danger Zone

+

+ The danger zone of the workspace delete page is a critical area that requires + careful consideration and attention. When deleting a workspace, all of the data + and resources within that workspace will be permanently removed and cannot be + recovered. +

+
+
+ setIsOpen(true)} outline> + Delete the workspace + +
-
- setIsOpen(true)} outline> - Delete the workspace - -
-
+ )}
) : (