Skip to content

Commit

Permalink
fix:bookmark (#1172)
Browse files Browse the repository at this point in the history
  • Loading branch information
paahaad authored Sep 10, 2024
1 parent 881b135 commit 08b4a2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/app/(main)/(pages)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';
import { getServerSession } from 'next-auth';
import { Redirect } from '@/components/Redirect';

interface Props {
children: React.ReactNode;
}

export default function MainLayout(props: Props) {
export default async function MainLayout(props: Props) {
const session = await getServerSession();

if (!session?.user) {
return <Redirect to={'/'} />;
}
return <div className="w-full py-16">{props.children}</div>;
}
5 changes: 1 addition & 4 deletions src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export const CourseCard = ({
onClick: () => void;
}) => {
const router = useRouter();
const imageUrl =
course.imageUrl
? course.imageUrl
: 'banner_placeholder.png';
const imageUrl = course.imageUrl ? course.imageUrl : 'banner_placeholder.png';
return (
<div
className={`flex w-full cursor-pointer flex-col rounded-2xl bg-primary/5 transition-all duration-300 hover:-translate-y-2 hover:border-primary/20`}
Expand Down
3 changes: 3 additions & 0 deletions src/db/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const getBookmarkDataWithContent = async (): Promise<
> => {
const session = await getServerSession(authOptions);
const userId = session?.user.id;
if (!userId) {
return { error: 'Unauthorized' };
}

return await db.bookmark.findMany({
where: {
Expand Down

0 comments on commit 08b4a2e

Please sign in to comment.