-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This page will display the best courses available
- Loading branch information
Showing
7 changed files
with
158 additions
and
23 deletions.
There are no files selected for viewing
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,25 @@ | ||
import { CourseDto } from "$api/routes/courses/course-dto"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Rating } from "@/routes/-components/rating"; | ||
import { cn } from "@/utilities/shadcn-utils"; | ||
import { GraduationCapIcon } from "lucide-react"; | ||
|
||
export function CourseLargeResult({ course }: { course: CourseDto }) { | ||
return ( | ||
<div className="group flex cursor-pointer justify-between gap-4 rounded-lg p-4 hover:bg-zinc-200/60 active:opacity-70"> | ||
<div className="flex items-center gap-4"> | ||
<GraduationCapIcon className="shrink-0" /> | ||
<Badge className="h-min shrink-0 text-nowrap">{course.code}</Badge> | ||
<p | ||
className={cn("shrink group-hover:opacity-80", { | ||
"text-sm": course.title.length > 40, | ||
})} | ||
> | ||
{course.title} | ||
</p> | ||
</div> | ||
|
||
<Rating rating={course.rating} reviewCount={course.reviewCount} /> | ||
</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
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,41 @@ | ||
import { BackToSearchBar } from "@/routes/-components/back-to-search-bar"; | ||
import { CourseLargeResult } from "@/routes/-components/course-large-result"; | ||
import { api } from "@/utilities/http-client"; | ||
import { QueryKey } from "@/utilities/query-key"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { createFileRoute, Link } from "@tanstack/react-router"; | ||
|
||
export const Route = createFileRoute("/courses/")({ | ||
component: CoursesPage, | ||
}); | ||
|
||
function CoursesPage() { | ||
const { data: courses } = useQuery({ | ||
queryKey: [QueryKey.Courses], | ||
queryFn: async () => { | ||
const response = await api.courses.index.get({ | ||
query: { | ||
ordering: "descending", | ||
}, | ||
}); | ||
return response.data; | ||
}, | ||
}); | ||
return ( | ||
<div className="mx-auto flex max-w-[600px] flex-col"> | ||
<h1 className="py-5 text-center text-3xl">Courses (best)</h1> | ||
<div className="flex flex-col"> | ||
{courses?.map((course) => ( | ||
<Link | ||
key={course.id} | ||
to="/courses/$courseId" | ||
params={{ courseId: course.code }} | ||
> | ||
<CourseLargeResult course={course} /> | ||
</Link> | ||
))} | ||
</div> | ||
<BackToSearchBar /> | ||
</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