Skip to content

Commit

Permalink
courses ui bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
subinsk committed Jan 15, 2023
1 parent d54c8d7 commit fced206
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pages/api/db/courses/review_upvote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function courseReviewUpvoteHandler(

await prisma.course_review_upvote.deleteMany({
where: {
id: parseInt(id as string),
course_review_id: parseInt(id as string),
user_id,
},
})
Expand Down
2 changes: 2 additions & 0 deletions src/pages/courses/[...id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Course: NextPage = ({}) => {
//? contexts
const { user, loading }: any = useAuth()

//? functions
const sortReviews = (reviews: Array<any>) => {
reviews.sort((reviewA: any, reviewB: any) =>
reviewA.upvotes.length > reviewB.upvotes.length ? -1 : 1
Expand Down Expand Up @@ -62,6 +63,7 @@ const Course: NextPage = ({}) => {
}
}

//? effects
useEffect(() => {
setIsDataFetching(true)
if (router.query.id) {
Expand Down
14 changes: 9 additions & 5 deletions src/pages/courses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,18 @@ export default function Courses() {
.map((course: any) => {
return (
<div
onClick={() =>
router.push('/courses/' + course.id)
}
className="cursor-pointer group bg-primary/5 shadow-md hover:shadow-xl duration-150 transition-all p-6 w-full md:w-[20rem] rounded-md flex flex-col gap-3"
className="cursor-pointer bg-primary/5 shadow-xl duration-150 transition-all p-6 w-full md:w-[20rem] rounded-md flex flex-col gap-3"
key={course.id}
>
<div className="flex gap-7 items-center justify-between">
<p className="font-semibold text-primary group-hover:underline duration-150 transition-all text-xl">
<p
onClick={() =>
router.push(
'/courses/' + course.id
)
}
className="font-semibold text-primary hover:underline duration-150 transition-all text-xl"
>
{course.title}
</p>
{user &&
Expand Down

0 comments on commit fced206

Please sign in to comment.