import { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Disclosure, Transition } from "@headlessui/react"; // layouts import { ProjectAuthorizationWrapper } from "layouts/auth-layout-legacy"; // services import { ProjectService } from "services/project"; // components import { DeleteProjectModal, ProjectDetailsForm, ProjectDetailsFormLoader, SettingsSidebar } from "components/project"; import { Button, Loader } from "@plane/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import { ChevronDown, ChevronUp } from "lucide-react"; // helpers import { truncateText } from "helpers/string.helper"; // types import type { NextPage } from "next"; // fetch-keys import { USER_PROJECT_VIEW } from "constants/fetch-keys"; import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; // services const projectService = new ProjectService(); const GeneralSettings: NextPage = observer(() => { const { project: projectStore } = useMobxStore(); // states const [selectProject, setSelectedProject] = useState(null); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // derived values const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null; console.log("projectDetails", projectDetails); console.log("condition", workspaceSlug && projectId && !projectDetails); console.log("wow", projectId); // api call to fetch project details useSWR( workspaceSlug && projectId ? "PROJECT_DETAILS" : null, workspaceSlug && projectId ? () => projectStore.fetchProjectDetails(workspaceSlug.toString(), projectId.toString()) : null ); // API call to fetch user privileges const { data: memberDetails } = useSWR( workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, workspaceSlug && projectId ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) : null ); // const currentNetwork = NETWORK_CHOICES.find((n) => n.key === projectDetails?.network); // const selectedNetwork = NETWORK_CHOICES.find((n) => n.key === watch("network")); const isAdmin = memberDetails?.role === 20; return ( } > {projectDetails && ( setSelectedProject(null)} /> )}
{projectDetails && workspaceSlug ? ( ) : ( )} {isAdmin && ( {({ open }) => (
Delete Project {open ? : }
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 ? (
) : ( )}
)}
)}
); }); export default GeneralSettings;