Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pages/tutorials/create-your-first-crud.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ export default function Page() {

Now, in the `PageAdminProject.tsx` we can add an edit button which links to the update page.

```tsx {1-4, 14-22} filename="src/features/projects/PageAdminProject.tsx" showLineNumbers
```tsx {1-4, 14-25} filename="src/features/projects/PageAdminProject.tsx" showLineNumbers
import Link from "next/link";
import { LuPenLine } from "react-icons/lu";
import { ResponsiveIconButton } from "@/components/ResponsiveIconButton";
Expand All @@ -2191,11 +2191,14 @@ export default function PageAdminProject() {
<AdminLayoutPageTopBar
leftActions={<AdminBackButton />}
rightActions={
<ResponsiveIconButton
as={Link}
href={ROUTES_PROJECTS.admin.update({ id: project.id })}
icon={<LuPenLine />}
>
<ResponsiveIconButton
as={Link}
href={ROUTES_PROJECTS.admin.update({
params?.id?.toString() ?? 'unknown',
})}
Comment on lines +2196 to +2198
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use proper route parameter construction.

The current implementation concatenates the id directly which could lead to invalid routes. Consider using proper route parameter construction:

-              href={ROUTES_PROJECTS.admin.update({
-                params?.id?.toString() ?? 'unknown',
-              })}
+              href={ROUTES_PROJECTS.admin.update({
+                id: params?.id?.toString() ?? '',
+              })}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
href={ROUTES_PROJECTS.admin.update({
params?.id?.toString() ?? 'unknown',
})}
href={ROUTES_PROJECTS.admin.update({
id: params?.id?.toString() ?? '',
})}

isDisabled={!params?.id}
icon={<LuPenLine />}
>
Edit
</ResponsiveIconButton>
}
Expand Down