-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from nimit9/feat/user-profile-menu
feat: user profile dropdown
- Loading branch information
Showing
15 changed files
with
295 additions
and
132 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20240402112352_remove_course_from_bookmark/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `courseId` on the `Bookmark` table. All the data in the column will be lost. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Bookmark" DROP CONSTRAINT "Bookmark_courseId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Bookmark" DROP COLUMN "courseId"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { CourseSkeleton } from '@/components/CourseCard'; | ||
|
||
export default function Loading() { | ||
return ( | ||
<div className="max-w-screen-xl justify-between mx-auto p-4 cursor-pointer grid grid-cols-1 gap-5 md:grid-cols-3"> | ||
{[1, 2, 3].map((v) => ( | ||
<CourseSkeleton key={v} /> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import db from '@/db'; | ||
import { getServerSession } from 'next-auth'; | ||
import { authOptions } from '@/lib/auth'; | ||
import { Content, CourseContent, VideoProgress } from '@prisma/client'; | ||
import { TBookmarkWithContent } from '@/actions/bookmark/types'; | ||
import BookmarkView from '@/components/bookmark/BookmarkView'; | ||
|
||
export type TWatchHistory = VideoProgress & { | ||
content: Content & { | ||
parent: { id: number; courses: CourseContent[] } | null; | ||
VideoMetadata: { duration: number | null } | null; | ||
}; | ||
}; | ||
|
||
const getBookmarkData = async (): Promise< | ||
TBookmarkWithContent[] | { error: string } | ||
> => { | ||
const session = await getServerSession(authOptions); | ||
const userId = session.user.id; | ||
|
||
return await db.bookmark.findMany({ | ||
where: { | ||
userId, | ||
}, | ||
include: { | ||
content: { | ||
include: { | ||
parent: { | ||
select: { | ||
id: true, | ||
courses: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
orderBy: { | ||
createdAt: 'desc', | ||
}, | ||
}); | ||
}; | ||
|
||
export default async function CoursesComponent() { | ||
const bookmarkData = await getBookmarkData(); | ||
|
||
return <BookmarkView bookmarkData={bookmarkData} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.