diff --git a/src/components/cards/cardBlog.tsx b/src/components/cards/cardBlog.tsx index 54545d9..7508ed8 100644 --- a/src/components/cards/cardBlog.tsx +++ b/src/components/cards/cardBlog.tsx @@ -1,13 +1,10 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; import getSession from "@/lib/session"; +import { Session, CardBlogProps } from "@/lib/types"; + + -type CardBlogProps = { - title: string; - description: string; - date: string; - slug: string; -}; export default async function CardBlog({ title, @@ -15,7 +12,7 @@ export default async function CardBlog({ date, slug, }: CardBlogProps) { - const session = await getSession(); + const session: Session = await getSession(); return ( <> diff --git a/src/components/layout/header.tsx b/src/components/layout/header.tsx index aba9bdb..fbe17c0 100644 --- a/src/components/layout/header.tsx +++ b/src/components/layout/header.tsx @@ -3,37 +3,36 @@ import { Avatar, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import Link from "next/link"; import getSession from "@/lib/session"; - - +import { Session } from "@/lib/types"; export default async function Header() { - const session = await getSession(); + const session: Session = await getSession(); return (

Weekly Journal Nicolas'

- {!session && ( - - )} + {!session && ( + + )} - {session && ( - <> -
- - - - - {session.user.isAdmin && ( - - - - )} -
- - )} + {session && ( + <> +
+ + + + + {session?.user?.isAdmin && ( + + + + )} +
+ + )}
); -} \ No newline at end of file +} diff --git a/src/lib/session.ts b/src/lib/session.ts index 2300337..fc3c122 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -1,7 +1,9 @@ import { auth } from "@/lib/auth" +import { User } from "next-auth"; +import { Session } from "@/lib/types"; -export default async function getSession() { +export default async function getSession(): Promise { const session = await auth() - + return session } \ No newline at end of file diff --git a/src/lib/types.d.ts b/src/lib/types.d.ts new file mode 100644 index 0000000..7120d49 --- /dev/null +++ b/src/lib/types.d.ts @@ -0,0 +1,16 @@ +// types.d.ts or in your component file +export type User = { + isAdmin?: boolean; + image?: string; +}; + +export type Session = { + user?: User; +}; + +export type CardBlogProps = { + title: string; + description: string; + date: string; + slug: string; +};