Skip to content

Commit d803fd0

Browse files
committed
fix: types
1 parent 49a091e commit d803fd0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/app/polls/[id]/page.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import { COMMON_APP_TITLE } from '@/constants';
77
import { env } from '@/constants/env';
88
import { IMAGE_QUERY_SCHEMA } from '@/constants/zod';
99
import { getPoll } from '@/services/getPoll';
10+
import { NextPageProps } from '@/types/utility';
1011

11-
interface PageProps {
12-
params: { id: string };
13-
searchParams: { [key: string]: string };
14-
}
12+
interface PageProps extends NextPageProps<{ id: string }, { [key: string]: string }> {}
13+
14+
export async function generateMetadata(props: PageProps): Promise<Metadata> {
15+
const params = await props.params;
16+
const searchParams = await props.searchParams;
1517

16-
export async function generateMetadata({ params, searchParams }: PageProps): Promise<Metadata> {
1718
const queryData = IMAGE_QUERY_SCHEMA.parse({
1819
...searchParams,
1920
id: params.id,
@@ -43,6 +44,8 @@ export async function generateMetadata({ params, searchParams }: PageProps): Pro
4344
};
4445
}
4546

46-
export default async function Page({ searchParams }: PageProps) {
47+
export default async function Page(props: PageProps) {
48+
const searchParams = await props.searchParams;
49+
4750
return <RedirectProfile profileUrl={searchParams.author} />;
4851
}

src/types/utility.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface NextPageProps<Params = never, SearchParams = never> {
2+
params: Params extends never ? never : Promise<Params>;
3+
searchParams: SearchParams extends never ? never : Promise<SearchParams>;
4+
}

0 commit comments

Comments
 (0)