import { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // layouts import { AppLayout } from "layouts/app-layout"; import { ProjectSettingLayout } from "layouts/settings-layout"; // components import { ProjectSettingHeader } from "components/headers"; import { DeleteProjectModal, DeleteProjectSection, ProjectDetailsForm, ProjectDetailsFormLoader, } from "components/project"; // types import type { NextPage } from "next"; // fetch-keys import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; 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; // api call to fetch project details useSWR( workspaceSlug && projectId ? "PROJECT_DETAILS" : null, workspaceSlug && projectId ? () => projectStore.fetchProjectDetails(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 = projectDetails?.member_role === 20; return ( } withProjectWrapper> {projectDetails && ( setSelectedProject(null)} /> )}
{projectDetails && workspaceSlug ? ( ) : ( )} {isAdmin && ( setSelectedProject(projectDetails.id ?? null)} /> )}
); }); export default GeneralSettings;