fix: bugs (#2761)
* fix: semicolon on estimate settings page * refactor: project settings automations store implementation * fix: active cycle stuck on infinite loading * fix: removed delete project option from sidebar * fix: discloser not opening when navigating to project * fix: clear filter not working & filter appearing even if nothing is selected * refactor: select label store implementation * refactor: select state store implementation
This commit is contained in:
parent
964e880fc4
commit
e96f059f65
7 changed files with 87 additions and 102 deletions
|
|
@ -1,14 +1,12 @@
|
|||
import React, { ReactElement } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
// services
|
||||
import { ProjectService, ProjectMemberService } from "services/project";
|
||||
import { observer } from "mobx-react-lite";
|
||||
// store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// layouts
|
||||
import { AppLayout } from "layouts/app-layout";
|
||||
import { ProjectSettingLayout } from "layouts/settings-layout";
|
||||
// hooks
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
import useProjectDetails from "hooks/use-project-details";
|
||||
import useToast from "hooks/use-toast";
|
||||
// components
|
||||
import { AutoArchiveAutomation, AutoCloseAutomation } from "components/automation";
|
||||
|
|
@ -16,45 +14,32 @@ import { ProjectSettingHeader } from "components/headers";
|
|||
// types
|
||||
import { NextPageWithLayout } from "types/app";
|
||||
import { IProject } from "types";
|
||||
// constant
|
||||
import { USER_PROJECT_VIEW } from "constants/fetch-keys";
|
||||
|
||||
// services
|
||||
const projectService = new ProjectService();
|
||||
const projectMemberService = new ProjectMemberService();
|
||||
|
||||
const AutomationSettingsPage: NextPageWithLayout = () => {
|
||||
const AutomationSettingsPage: NextPageWithLayout = observer(() => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
|
||||
const { user } = useUserAuth();
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const { projectDetails } = useProjectDetails();
|
||||
|
||||
const { data: memberDetails } = useSWR(
|
||||
workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null,
|
||||
workspaceSlug && projectId
|
||||
? () => projectMemberService.projectMemberMe(workspaceSlug.toString(), projectId.toString())
|
||||
: null
|
||||
);
|
||||
// store
|
||||
const {
|
||||
user: { currentProjectRole },
|
||||
project: { currentProjectDetails: projectDetails, updateProject },
|
||||
} = useMobxStore();
|
||||
|
||||
const handleChange = async (formData: Partial<IProject>) => {
|
||||
if (!workspaceSlug || !projectId || !projectDetails) return;
|
||||
|
||||
await projectService
|
||||
.updateProject(workspaceSlug as string, projectId as string, formData, user)
|
||||
.then(() => {})
|
||||
.catch(() => {
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Something went wrong. Please try again.",
|
||||
});
|
||||
await updateProject(workspaceSlug.toString(), projectId.toString(), formData).catch(() => {
|
||||
setToastAlert({
|
||||
type: "error",
|
||||
title: "Error!",
|
||||
message: "Something went wrong. Please try again.",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const isAdmin = memberDetails?.role === 20;
|
||||
const isAdmin = currentProjectRole === 20;
|
||||
|
||||
return (
|
||||
<section className={`pr-9 py-8 w-full overflow-y-auto ${isAdmin ? "" : "opacity-60"}`}>
|
||||
|
|
@ -65,7 +50,7 @@ const AutomationSettingsPage: NextPageWithLayout = () => {
|
|||
<AutoCloseAutomation handleChange={handleChange} />
|
||||
</section>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
AutomationSettingsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const EstimatesSettingsPage: NextPageWithLayout = () => (
|
|||
EstimatesSettingsPage.getLayout = function getLayout(page: ReactElement) {
|
||||
return (
|
||||
<AppLayout header={<ProjectSettingHeader title="Estimates Settings" />} withProjectWrapper>
|
||||
<ProjectSettingLayout>{page}; </ProjectSettingLayout>
|
||||
<ProjectSettingLayout>{page}</ProjectSettingLayout>
|
||||
</AppLayout>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue