feat(tasker): open project settings in modal
This commit is contained in:
+12
-1
@@ -6,8 +6,12 @@
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { Outlet } from "react-router";
|
||||
import { Outlet, redirect } from "react-router";
|
||||
// components
|
||||
import {
|
||||
buildProjectSettingsModalUrl,
|
||||
getProjectSettingsModalTabFromPath,
|
||||
} from "@/components/project/settings/project-settings-modal.utils";
|
||||
import { getProjectActivePath } from "@/components/settings/helper";
|
||||
import { SettingsMobileNav } from "@/components/settings/mobile/nav";
|
||||
// layouts
|
||||
@@ -16,6 +20,13 @@ import { ProjectAuthWrapper } from "@/layouts/auth-layout/project-wrapper";
|
||||
import type { Route } from "./+types/layout";
|
||||
import { ProjectSettingsSidebarRoot } from "@/components/settings/project/sidebar";
|
||||
|
||||
export const clientLoader = ({ params, request }: Route.ClientLoaderArgs) => {
|
||||
const { workspaceSlug, projectId } = params;
|
||||
const tab = getProjectSettingsModalTabFromPath(new URL(request.url).pathname);
|
||||
|
||||
throw redirect(buildProjectSettingsModalUrl(workspaceSlug, projectId, tab));
|
||||
};
|
||||
|
||||
function ProjectDetailSettingsLayout({ params }: Route.ComponentProps) {
|
||||
const { workspaceSlug, projectId } = params;
|
||||
// router
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@
|
||||
import { useEffect } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Outlet } from "react-router";
|
||||
import { buildProjectSettingsModalUrl } from "@/components/project/settings/project-settings-modal.utils";
|
||||
// hooks
|
||||
import { useProject } from "@/hooks/store/use-project";
|
||||
import { useAppRouter } from "@/hooks/use-app-router";
|
||||
@@ -23,7 +24,7 @@ function ProjectSettingsLayout({ params }: Route.ComponentProps) {
|
||||
useEffect(() => {
|
||||
if (projectId) return;
|
||||
if (joinedProjectIds.length > 0) {
|
||||
router.push(`/${workspaceSlug}/settings/projects/${joinedProjectIds[0]}`);
|
||||
router.push(buildProjectSettingsModalUrl(workspaceSlug, joinedProjectIds[0]));
|
||||
}
|
||||
}, [joinedProjectIds, router, workspaceSlug, projectId]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user