Skip to content

Commit

Permalink
project page
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Jan 3, 2025
1 parent d96c3be commit 10857a9
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* limitations under the License.
*/

import { useEffect } from "react";
import {
generatePath,
Outlet,
useNavigate,
useOutletContext,
useParams,
} from "react-router-dom-v5-compat";
Expand All @@ -30,10 +33,10 @@ import { useGetNamespacesByNamespaceProjectsAndSlugQuery } from "../../projectsV
import ProjectNotFound from "../../projectsV2/notFound/ProjectNotFound";
import ProjectPageHeader from "../ProjectPageHeader/ProjectPageHeader";
import ProjectPageNav from "../ProjectPageNav/ProjectPageNav";
import { ABSOLUTE_ROUTES } from "../../../routing/routes.constants";

export default function ProjectPageContainer() {
const { namespace, slug } = useParams<{
id: string | undefined;
namespace: string | undefined;
slug: string | undefined;
}>();
Expand All @@ -43,6 +46,28 @@ export default function ProjectPageContainer() {
slug: slug ?? "",
});

const navigate = useNavigate();

useEffect(() => {
if (namespace && data && data.namespace !== namespace) {
navigate(
generatePath(ABSOLUTE_ROUTES.v2.projects.show.root, {
namespace: data.namespace,
slug: data.slug,
}),
{ replace: true }
);
} else if (slug && data && data.slug !== slug) {
navigate(
generatePath(ABSOLUTE_ROUTES.v2.projects.show.root, {
namespace: data.namespace,
slug: data.slug,
}),
{ replace: true }
);
}
}, [data, namespace, navigate, slug]);

if (isLoading) return <Loader className="align-self-center" />;

if (error || data == null) {
Expand Down

0 comments on commit 10857a9

Please sign in to comment.