import React from "react"; import { useRouter } from "next/router"; import useSWR, { mutate } from "swr"; // services import projectService from "services/project.service"; // lib import { requiredAdmin } from "lib/auth"; // layouts import AppLayout from "layouts/app-layout"; // hooks import useToast from "hooks/use-toast"; // ui import { SecondaryButton } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // icons import { ContrastIcon, PeopleGroupIcon, ViewListIcon } from "components/icons"; // types import { IProject, UserAuth } from "types"; import type { NextPage, GetServerSidePropsContext } from "next"; // fetch-keys import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; const FeaturesSettings: NextPage = (props) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { setToastAlert } = useToast(); const { data: projectDetails } = useSWR( workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null, workspaceSlug && projectId ? () => projectService.getProject(workspaceSlug as string, projectId as string) : null ); const handleSubmit = async (formData: Partial) => { if (!workspaceSlug || !projectId) return; mutate( PROJECT_DETAILS(projectId as string), (prevData) => ({ ...(prevData as IProject), ...formData }), false ); mutate( PROJECTS_LIST(workspaceSlug as string), (prevData) => prevData?.map((p) => { if (p.id === projectId) return { ...p, ...formData, }; return p; }), false ); await projectService .updateProject(workspaceSlug as string, projectId as string, formData) .then((res) => { mutate(PROJECT_DETAILS(projectId as string)); mutate(PROJECTS_LIST(workspaceSlug as string)); setToastAlert({ title: "Success!", type: "success", message: "Project features updated successfully.", }); }) .catch((err) => { console.error(err); }); }; return ( } settingsLayout >

Features

Cycles

Cycles are enabled for all the projects in this workspace. Access them from the navigation bar.

Modules

Modules are enabled for all the projects in this workspace. Access it from the navigation bar.

Views

Modules are enabled for all the projects in this workspace. Access it from the navigation bar.

); }; export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { const projectId = ctx.query.projectId as string; const workspaceSlug = ctx.query.workspaceSlug as string; const memberDetail = await requiredAdmin(workspaceSlug, projectId, ctx.req?.headers.cookie); return { props: { isOwner: memberDetail?.role === 20, isMember: memberDetail?.role === 15, isViewer: memberDetail?.role === 10, isGuest: memberDetail?.role === 5, }, }; }; export default FeaturesSettings;