-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c85050
commit 17c47f6
Showing
16 changed files
with
650 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/app/(dashboard)/dashboard/recipe/[recipeId]/edit/loading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { RecipeSkeleton } from '@/components/skeleton/RecipeSkeleton'; | ||
|
||
export default function RecipeLoading() { | ||
return <RecipeSkeleton />; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/app/(dashboard)/dashboard/recipe/[recipeId]/edit/not-found.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ErrorCard } from '@/components/cards/error-card'; | ||
import { Shell } from '@/components/shells/shell'; | ||
|
||
export default function RecipeNotFound() { | ||
return ( | ||
<Shell variant="centered" className="max-w-md"> | ||
<ErrorCard | ||
title="Recipe not found" | ||
description="The recipe you are looking for does not exist." | ||
retryLink="/recipes" | ||
retryLinkText="Go to Recipes" | ||
/> | ||
</Shell> | ||
); | ||
} |
68 changes: 68 additions & 0 deletions
68
src/app/(dashboard)/dashboard/recipe/[recipeId]/edit/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { serverClient } from '@/app/_trpc/serverClient'; | ||
Check warning on line 1 in src/app/(dashboard)/dashboard/recipe/[recipeId]/edit/page.tsx CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)❌ New issue: Complex Conditional
|
||
import { EditRecipeForm } from '@/components/forms/recipe/UpdateRecipeForm'; | ||
import { Breadcrumbs } from '@/components/pagers/breadcrumbs'; | ||
import { Shell } from '@/components/shells/shell'; | ||
import { toTitleCase } from '@/lib/utils'; | ||
import { currentUser } from '@clerk/nextjs/server'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
interface ProductPageProps { | ||
params: { | ||
recipeId: string; | ||
}; | ||
} | ||
|
||
export async function generateMetadata({ params }: ProductPageProps) { | ||
if (!params.recipeId) { | ||
return {}; | ||
} | ||
|
||
const recipe = await serverClient.recipe | ||
.getRecipe({ id: params.recipeId }) | ||
.catch(() => null); | ||
|
||
if (!recipe) { | ||
return {}; | ||
} | ||
|
||
return { | ||
title: toTitleCase(recipe.title), | ||
description: recipe.description ?? undefined, | ||
}; | ||
} | ||
|
||
export default async function ProductPage({ | ||
params, | ||
}: Readonly<ProductPageProps>) { | ||
if (!params.recipeId) { | ||
notFound(); | ||
} | ||
|
||
const user = await currentUser(); | ||
|
||
const recipe = await serverClient.recipe | ||
.getRecipe({ id: params.recipeId }) | ||
.catch(() => null); | ||
|
||
if (!recipe || !user || recipe.userId !== user.id) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<Shell> | ||
<Breadcrumbs | ||
segments={[ | ||
{ | ||
title: 'My Recipes', | ||
href: '/dashboard/recipes', | ||
}, | ||
{ | ||
title: recipe.title, | ||
href: `/dashboard/recipe/${recipe.id}`, | ||
}, | ||
]} | ||
/> | ||
<EditRecipeForm recipeId={recipe.id} initialRecipe={recipe} /> | ||
</Shell> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.