Skip to content

Commit a47204a

Browse files
committed
refactor: migrate project pages to use Next.js navigation hooks for next v15 breaking changes
1 parent 9424336 commit a47204a

File tree

20 files changed

+214
-103
lines changed

20 files changed

+214
-103
lines changed

apps/kafka-consumer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"dev": "tsx watch --env-file=.env src/index.ts ",
6+
"non-dev": "tsx watch --env-file=.env src/index.ts ",
77
"build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.js --external:express --external:cors",
88
"start": "node dist/index.js",
99
"type-check": "tsc"

apps/web/app/(main)/dashboard/page.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import { OrganizationProfile, useOrganization } from "@clerk/nextjs";
44
import NoOrg from "@/components/empty-states/no-org";
55
import ProjectList from "@/components/projects/project-list";
6+
import { useSearchParams } from "next/navigation";
67

7-
type DashboardPageProps = {
8-
searchParams: {
9-
settings?: string;
10-
};
11-
};
128

13-
const DashboardPage = ({ searchParams: { settings } }: DashboardPageProps) => {
9+
const DashboardPage = () => {
10+
11+
const searchParams = useSearchParams();
12+
const settings = searchParams.get("settings");
13+
1414
const { organization } = useOrganization();
1515

1616
if (settings) {

apps/web/app/(main)/projects/[id]/changelogs/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import {
1111
} from "@/components/ui/dropdown-menu";
1212
import { ScrollArea } from "@/components/ui/scroll-area";
1313
import { useChangelogModal } from "@/lib/store/use-changelog-modal";
14-
import type { PagePropsWithProjectId } from "@/lib/types";
14+
import type { ProjectId } from "@/lib/types";
1515
import { Eye, FileText, MoreHorizontal, Plus } from "lucide-react";
1616
import Link from "next/link";
17+
import { useParams } from "next/navigation";
18+
19+
const ChangelogsPage = () => {
20+
21+
const { id } = useParams<ProjectId>()
1722

18-
const ChangelogsPage = ({ params: { id } }: PagePropsWithProjectId) => {
1923
const { onOpen } = useChangelogModal();
2024

2125
return (
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use client";
2+
3+
import { api } from "@repo/backend/convex/_generated/api";
4+
import { useCurrentUser } from "@/lib/hooks/use-current-user";
5+
import type { ProjectId } from "@/lib/types";
6+
import { useQuery } from "convex/react";
7+
import { Loader2 } from "lucide-react";
8+
import OwnedTaskTable from "../_components/owned-task-table";
9+
10+
const ProjectDashboardClientPage = ({ id }: ProjectId) => {
11+
const currentUser = useCurrentUser();
12+
13+
const myTasks = useQuery(api.work_item.list, { projectId: id })?.filter(
14+
(task) => task.assigneeId === currentUser?._id
15+
);
16+
17+
return (
18+
<section className="bg-primary-foreground/80 md:p-5 py-5 px-3 m-1 rounded-lg">
19+
<h4 className="mb-5 text-lg">Your task list</h4>
20+
{myTasks ? (
21+
<OwnedTaskTable tasks={myTasks} />
22+
) : (
23+
<div className="h-36 flex items-center justify-center">
24+
<Loader2 className="h-6 w-6 animate-spin" />
25+
</div>
26+
)}
27+
</section>
28+
);
29+
};
30+
31+
export default ProjectDashboardClientPage;

apps/web/app/(main)/projects/[id]/dashboard/page.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
1-
"use client";
2-
3-
import { api } from "@repo/backend/convex/_generated/api";
4-
import { useCurrentUser } from "@/lib/hooks/use-current-user";
51
import type { PagePropsWithProjectId } from "@/lib/types";
6-
import { useQuery } from "convex/react";
7-
import { Loader2 } from "lucide-react";
8-
import OwnedTaskTable from "../_components/owned-task-table";
9-
2+
import ProjectDashboardClientPage from "./page-client";
103

11-
const ProjectDashboardPage = ({
12-
params: { id },
13-
}: PagePropsWithProjectId) => {
14-
const currentUser = useCurrentUser();
15-
16-
const myTasks = useQuery(api.work_item.list, { projectId: id })?.filter(
17-
(task) => task.assigneeId === currentUser?._id
18-
);
4+
const ProjectDashboardPage = async ({ params }: PagePropsWithProjectId) => {
5+
const id = (await params).id;
196

207
return (
218
<section>
229
<h3 className="font-bold text-xl md:text-2xl lg:text-3xl mb-5">
2310
Project Dashboard
2411
</h3>
25-
<section className="bg-primary-foreground/80 md:p-5 py-5 px-3 m-1 rounded-lg">
26-
<h4 className="mb-5 text-lg">Your task list</h4>
27-
{myTasks ? (
28-
<OwnedTaskTable tasks={myTasks} />
29-
) : (
30-
<div className="h-36 flex items-center justify-center">
31-
<Loader2 className="h-6 w-6 animate-spin" />
32-
</div>
33-
)}
34-
</section>
12+
<ProjectDashboardClientPage id={id} />
3513
</section>
3614
);
3715
};

apps/web/app/(main)/projects/[id]/feedbacks/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ import { Button } from "@/components/ui/button";
66
import { ScrollArea } from "@/components/ui/scroll-area";
77
import { api } from "@repo/backend/convex/_generated/api";
88
import { useFeedbackModal } from "@/lib/store/use-feedback-modal";
9-
import type { PagePropsWithProjectId } from "@/lib/types";
9+
import type { ProjectId } from "@/lib/types";
1010
import { useQuery } from "convex/react";
1111
import { FileText, Plus } from "lucide-react";
12+
import { useParams } from "next/navigation";
1213

13-
const FeedbacksPage = ({ params }: PagePropsWithProjectId) => {
14-
const feedbacks = useQuery(api.feedback.list, { projectId: params.id });
14+
const FeedbacksPage = () => {
15+
16+
const { id } = useParams<ProjectId>()
17+
18+
const feedbacks = useQuery(api.feedback.list, { projectId: id });
1519

1620
const { onOpen } = useFeedbackModal();
1721

apps/web/app/(main)/projects/[id]/messages/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import MessageInput from "@/components/messages/message-input";
22
import MessagesList from "@/components/messages/messages-list";
33
import type { PagePropsWithProjectId } from "@/lib/types";
44

5-
const MessagesPage = ({ params: { id } }: PagePropsWithProjectId) => {
6-
5+
const MessagesPage = async ({ params }: PagePropsWithProjectId) => {
6+
7+
const id = (await params).id;
78
return (
89
<div className="min-h-full px-2 space-y-2">
910
<h3 className="font-bold text-xl md:text-2xl lg:text-3xl mb-3">

apps/web/app/(main)/projects/[id]/settings/danger-zone/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import ConfirmModal from "@/components/modals/confirm-modal";
44
import { Button } from "@/components/ui/button";
55
import { DASHBOARD_ROUTE } from "@/lib/constants";
66
import useApiMutation from "@/lib/hooks/use-api-mutation";
7-
import type { PagePropsWithProjectId } from "@/lib/types";
7+
import type { ProjectId } from "@/lib/types";
88
import { api } from "@repo/backend/convex/_generated/api";
99
import { KafkaMessage } from "@repo/backend/lib/types";
10-
import { useRouter } from "next/navigation";
10+
import { useParams, useRouter } from "next/navigation";
1111
import { toast } from "sonner";
1212

13-
const ProjectSettingsDangerZonePage = ({
14-
params: { id },
15-
}: PagePropsWithProjectId) => {
13+
const ProjectSettingsDangerZonePage = () => {
14+
15+
const { id } = useParams<ProjectId>()
16+
1617
const { isPending, mutate: deleteProject } = useApiMutation(
1718
api.project.remove
1819
);

apps/web/app/(main)/projects/[id]/settings/layout.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use client";
22

33
import { Separator } from "@/components/ui/separator";
4-
import type { PagePropsWithProjectId } from "@/lib/types";
4+
import type { ProjectId } from "@/lib/types";
55
import { cn } from "@/lib/utils";
66
import Link from "next/link";
7-
import { usePathname } from "next/navigation";
7+
import { useParams, usePathname } from "next/navigation";
88
import type { PropsWithChildren } from "react";
99

10-
type ProjectSettingsLayoutProps = PropsWithChildren & PagePropsWithProjectId;
1110

1211
const ProjectSettingsLayout = ({
1312
children,
14-
params: { id },
15-
}: ProjectSettingsLayoutProps) => {
13+
}: PropsWithChildren) => {
14+
15+
const { id } = useParams<ProjectId>()
1616
const url = usePathname();
1717

1818
const isDangerZone = url.includes("danger-zone");

apps/web/app/(main)/projects/[id]/settings/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ import { Textarea } from "@/components/ui/textarea";
2929
import { api } from "@repo/backend/convex/_generated/api";
3030
import { PROJECTS_STAGES } from "@/lib/constants";
3131
import useApiMutation from "@/lib/hooks/use-api-mutation";
32-
import type { PagePropsWithProjectId } from "@/lib/types";
32+
import type { ProjectId } from "@/lib/types";
33+
import { useParams } from "next/navigation";
3334

34-
const ProjectSettingsPage = ({ params: { id } }: PagePropsWithProjectId) => {
35+
const ProjectSettingsPage = () => {
36+
37+
const { id } = useParams<ProjectId>()
3538
const project = useQuery(api.project.get, { id });
3639

3740
const { mutate: updateProject, isPending } = useApiMutation(

0 commit comments

Comments
 (0)