mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
c270c8689f
* chore: implemented project layout and integrated sidebar component * chore: implemented workspace layout and integrated sidebar component
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import { useState } from "react";
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
|
// layouts
|
|
import { ProjectSettingLayout } from "layouts/setting-layout/project-setting-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";
|
|
|
|
// services
|
|
// const projectService = new ProjectService();
|
|
|
|
const GeneralSettings: NextPage = observer(() => {
|
|
const { project: projectStore } = useMobxStore();
|
|
// states
|
|
const [selectProject, setSelectedProject] = useState<string | null>(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;
|
|
console.log("isAdmin", isAdmin);
|
|
|
|
return (
|
|
<ProjectSettingLayout header={<ProjectSettingHeader title="General Settings" />}>
|
|
{projectDetails && (
|
|
<DeleteProjectModal
|
|
project={projectDetails}
|
|
isOpen={Boolean(selectProject)}
|
|
onClose={() => setSelectedProject(null)}
|
|
/>
|
|
)}
|
|
|
|
<div className={`pr-9 py-8 w-full overflow-y-auto ${isAdmin ? "" : "opacity-60"}`}>
|
|
{projectDetails && workspaceSlug ? (
|
|
<ProjectDetailsForm project={projectDetails} workspaceSlug={workspaceSlug.toString()} isAdmin={isAdmin} />
|
|
) : (
|
|
<ProjectDetailsFormLoader />
|
|
)}
|
|
|
|
{isAdmin && (
|
|
<DeleteProjectSection
|
|
projectDetails={projectDetails}
|
|
handleDelete={() => setSelectedProject(projectDetails.id ?? null)}
|
|
/>
|
|
)}
|
|
</div>
|
|
</ProjectSettingLayout>
|
|
);
|
|
});
|
|
|
|
export default GeneralSettings;
|