Skip to content

Commit 9177797

Browse files
committed
move exports out of page
1 parent 34e80bc commit 9177797

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

app/star-wars/people/[id]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { type Person, sleep } from '../page';
1+
import { type Person } from '../../types';
22
import { Metadata } from 'next';
33
import { notFound } from 'next/navigation';
4+
import sleep from '@/util/sleep';
45

56
type Props = {
67
params: { id: string };

app/star-wars/people/page.tsx

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import Link from 'next/link';
2+
import sleep from '@/util/sleep';
3+
import { type Person } from '../types';
24

35
async function getPeople(): Promise<Person[]> {
46
await sleep();
@@ -11,31 +13,6 @@ export const metadata = {
1113
title: 'Star Wars People',
1214
};
1315

14-
export function sleep(ms = 2000) {
15-
return new Promise((resolve) => {
16-
setTimeout(resolve, ms);
17-
});
18-
}
19-
20-
export type Person = {
21-
name: string;
22-
height: string;
23-
mass: string;
24-
hair_color: string;
25-
skin_color: string;
26-
eye_color: string;
27-
birth_year: string;
28-
gender: string;
29-
homeworld: string;
30-
films: string[];
31-
species: string[];
32-
vehicles: string[];
33-
starships: string[];
34-
created: string;
35-
edited: string;
36-
url: string;
37-
};
38-
3916
export default async function Page() {
4017
const people = await getPeople();
4118

app/star-wars/types.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export type Person = {
2+
name: string;
3+
height: string;
4+
mass: string;
5+
hair_color: string;
6+
skin_color: string;
7+
eye_color: string;
8+
birth_year: string;
9+
gender: string;
10+
homeworld: string;
11+
films: string[];
12+
species: string[];
13+
vehicles: string[];
14+
starships: string[];
15+
created: string;
16+
edited: string;
17+
url: string;
18+
};

util/sleep.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function sleep(ms = 2000) {
2+
return new Promise((resolve) => {
3+
setTimeout(resolve, ms);
4+
});
5+
}

0 commit comments

Comments
 (0)