-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.tsx
40 lines (30 loc) · 892 Bytes
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import getCurrentUser from "@/actions/getCurrentUser";
import getDogsById from "@/actions/getDogsById";
import { SIGN_IN_PATH } from "@/lib/constants";
import { redirect } from "next/navigation";
import DogProfile from "@/app/(main)/dogs/_components/DogProfile";
interface DogPageParams {
params: { dogId: string };
}
const DogPage = async ({ params }: DogPageParams) => {
if (!params) throw new Error("No params found");
const { dogId } = params;
if (!dogId) throw new Error("No dog id found");
const currentUser = await getCurrentUser();
if (!currentUser) {
redirect(`${process.env.NEXT_PUBLIC_ORIGIN}${SIGN_IN_PATH}`);
}
const [dog] = await getDogsById({
dogIdsToRetrieve: [dogId],
user: currentUser,
});
if (!dog) {
throw new Error("No dog found");
}
return (
<>
<DogProfile dog={dog} />
</>
);
};
export default DogPage;