Skip to content

Commit

Permalink
Merge pull request #59 from diggerhq/feat/redirect-deleted-projects
Browse files Browse the repository at this point in the history
Redirect deleted projects to dashboard
  • Loading branch information
ZIJ authored Sep 20, 2024
2 parents c792a06 + 4d87bc7 commit 71465f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getSlimProjectBySlug } from "@/data/user/projects";
import { projectSlugParamSchema } from "@/utils/zod-schemas/params";
import type { Metadata } from "next";
import { redirect } from 'next/navigation';
import AllRunsDetails from "./AllRunsDetails";

type ProjectPageProps = {
Expand All @@ -25,6 +26,10 @@ export default async function ProjectPage({ params }: { params: unknown }) {
const { projectSlug } = projectSlugParamSchema.parse(params);
const slimProject = await getSlimProjectBySlug(projectSlug);

if (slimProject.deleted_at) {
redirect("/dashboard");
}

return (
<div className="flex flex-col space-y-4 max-w-5xl mt-2">
<AllRunsDetails projectId={slimProject.id} projectSlug={projectSlug} />
Expand Down
2 changes: 1 addition & 1 deletion src/data/user/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getSlimProjectBySlug = async (projectSlug: string) => {
const supabaseClient = createSupabaseUserServerComponentClient();
const { data, error } = await supabaseClient
.from("projects")
.select("id, slug, name, organization_id, branch")
.select("id, slug, name, organization_id, branch, deleted_at")
.eq("slug", projectSlug)
.single();
if (error) {
Expand Down

0 comments on commit 71465f4

Please sign in to comment.