Skip to content

Commit eace9fd

Browse files
Update dependencies and refactor async props handling in page components
1 parent 2cbe4ec commit eace9fd

File tree

10 files changed

+90
-41
lines changed

10 files changed

+90
-41
lines changed

package-lock.json

Lines changed: 43 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@radix-ui/react-label": "^2.1.2",
13-
"@radix-ui/react-slot": "^1.1.2",
13+
"@radix-ui/react-slot": "^1.2.2",
1414
"@tabler/icons": "^3.31.0",
1515
"@tabler/icons-react": "^3.31.0",
1616
"@types/canvas-confetti": "^1.9.0",

src/app/questions/[quesId]/[quesName]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import DeleteQuestion from "./DeleteQuestion";
2626
import EditQuestion from "./EditQuestion";
2727
import { TracingBeam } from "@/components/ui/tracing-beam";
2828

29-
const Page = async ({ params }: { params: { quesId: string; quesName: string } }) => {
29+
const Page = async (props: { params: Promise<{ quesId: string; quesName: string }> }) => {
30+
const params = await props.params;
3031
const [question, answers, upvotes, downvotes, comments] = await Promise.all([
3132
databases.getDocument(db, questionCollection, params.quesId),
3233
databases.listDocuments(db, answerCollection, [
@@ -51,7 +52,7 @@ const Page = async ({ params }: { params: { quesId: string; quesName: string } }
5152
Query.orderDesc("$createdAt"),
5253
]),
5354
]);
54-
55+
5556

5657
// since it is dependent on the question, we fetch it here outside of the Promise.all
5758
const author = await users.get<UserPrefs>(question.authorId);

src/app/questions/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Particles } from "@/components/magicui/particles";
1515
const Page = async ({
1616
searchParams,
1717
}: {
18-
searchParams: { page?: string; tag?: string; search?: string };
18+
searchParams: Promise<{ page?: string; tag?: string; search?: string }>;
1919
}) => {
2020
const searchForParams = await searchParams;
2121
const params = {

src/app/users/[userId]/[userSlug]/answers/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import { Query } from "node-appwrite";
1010
import React from "react";
1111

1212

13-
const Page = async ({
14-
params,
15-
searchParams,
16-
}: {
17-
params: { userId: string; userSlug: string };
18-
searchParams: { page?: string };
19-
}) => {
13+
const Page = async (
14+
props: {
15+
params: Promise<{ userId: string; userSlug: string }>;
16+
searchParams: Promise<{ page?: string }>;
17+
}
18+
) => {
19+
const searchParams = await props.searchParams;
20+
const params = await props.params;
2021
searchParams.page ||= "1";
2122

2223
const queries = [

src/app/users/[userId]/[userSlug]/layout.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ import EditButton from "./EditButton";
88
import Navbar from "./Navbar";
99
import { IconClockFilled, IconUserFilled } from "@tabler/icons-react";
1010

11-
const Layout = async ({
12-
children,
13-
params,
14-
}: {
15-
children: React.ReactNode;
16-
params: { userId: string; userSlug: string };
17-
}) => {
11+
const Layout = async (
12+
props: {
13+
children: React.ReactNode;
14+
params: Promise<{ userId: string; userSlug: string }>;
15+
}
16+
) => {
17+
const params = await props.params;
18+
19+
const {
20+
children
21+
} = props;
22+
1823
const user = await users.get<UserPrefs>(params.userId);
1924

2025
return (

src/app/users/[userId]/[userSlug]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { answerCollection, db, questionCollection } from "@/models/name";
88
import { Query } from "node-appwrite";
99
import { Particles } from "@/components/magicui/particles";
1010

11-
const Page = async ({ params }: { params: { userId: string; userSlug: string } }) => {
11+
const Page = async (props: { params: Promise<{ userId: string; userSlug: string }> }) => {
12+
const params = await props.params;
1213
const [user, questions, answers] = await Promise.all([
1314
users.get<UserPrefs>(params.userId),
1415
databases.listDocuments(db, questionCollection, [

src/app/users/[userId]/[userSlug]/questions/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { Query } from "node-appwrite";
88
import React from "react";
99
import { Particles } from "@/components/magicui/particles";
1010

11-
const Page = async ({
12-
params,
13-
searchParams,
14-
}: {
15-
params: { userId: string; userSlug: string };
16-
searchParams: { page?: string };
17-
}) => {
11+
const Page = async (
12+
props: {
13+
params: Promise<{ userId: string; userSlug: string }>;
14+
searchParams: Promise<{ page?: string }>;
15+
}
16+
) => {
17+
const searchParams = await props.searchParams;
18+
const params = await props.params;
1819
searchParams.page ||= "1";
1920

2021
const queries = [

src/app/users/[userId]/[userSlug]/votes/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import { Query } from "node-appwrite";
99
import React from "react";
1010
import { Particles } from "@/components/magicui/particles";
1111

12-
const Page = async ({
13-
params,
14-
searchParams,
15-
}: {
16-
params: { userId: string; userSlug: string };
17-
searchParams: { page?: string; voteStatus?: "upvoted" | "downvoted" };
18-
}) => {
12+
const Page = async (
13+
props: {
14+
params: Promise<{ userId: string; userSlug: string }>;
15+
searchParams: Promise<{ page?: string; voteStatus?: "upvoted" | "downvoted" }>;
16+
}
17+
) => {
18+
const searchParams = await props.searchParams;
19+
const params = await props.params;
1920
searchParams.page ||= "1";
2021

2122
const query = [

src/components/magicui/confetti.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
"use client";
23

34
import type {
@@ -17,7 +18,8 @@ import React, {
1718
useRef,
1819
} from "react";
1920

20-
import { Button, ButtonProps } from "@/components/ui/button";
21+
import { Button } from "@/components/ui/button";
22+
import { ButtonHTMLAttributes } from "react";
2123

2224
type Api = {
2325
fire: (options?: ConfettiOptions) => void;
@@ -109,7 +111,7 @@ ConfettiComponent.displayName = "Confetti";
109111
// Export as Confetti
110112
export const Confetti = ConfettiComponent;
111113

112-
interface ConfettiButtonProps extends ButtonProps {
114+
interface ConfettiButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
113115
options?: ConfettiOptions &
114116
ConfettiGlobalOptions & { canvas?: HTMLCanvasElement };
115117
children?: React.ReactNode;

0 commit comments

Comments
 (0)