Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:tracks pagination #692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions apps/web/components/Tracks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
initial={{ y: -20, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ duration: 0.5, ease: "easeInOut", type: "spring", damping: 10, delay: 0.5 }}
className="flex max-w-5xl flex-col gap-4 w-full mx-auto p-4"
className="mx-auto flex w-full max-w-5xl flex-col gap-4 p-4"
id="tracks"
>
<div className="flex w-full gap-4 justify-between items-center flex-col md:flex-row">
<div className="flex items-center gap-2 p-2 rounded-lg bg-primary/5 mx-auto md:mx-0 justify-center">
<div className="flex w-full flex-col items-center justify-between gap-4 md:flex-row">
<div className="bg-primary/5 mx-auto flex items-center justify-center gap-2 rounded-lg p-2 md:mx-0">
<Button
size={"lg"}
variant={"ghost"}
Expand All @@ -141,7 +141,7 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
>
Cohort 2.0
</Button>
<Separator className="w-0.5 h-4 bg-primary/25" />
<Separator className="bg-primary/25 h-4 w-0.5" />
<Button
size={"lg"}
variant={"ghost"}
Expand All @@ -151,9 +151,9 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
Cohort 3.0
</Button>
</div>
<div className="flex gap-2 p-2.5 bg-primary/5 rounded-lg w-full md:w-fit">
<div className="bg-primary/5 flex w-full gap-2 rounded-lg p-2.5 md:w-fit">
{/* Filter by Categories */}
<div className="flex gap-2 items-center ">
<div className="flex items-center gap-2">
<Select onValueChange={(e) => setSelectedCategory(e === "All" ? "" : e)}>
<SelectTrigger className="w-[250px]">
<SelectValue placeholder={selectedCategory || "All"} />
Expand Down Expand Up @@ -187,12 +187,12 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
</div>

{/* Tracks with Animation */}
<motion.ul className="flex flex-col gap-4 w-full" variants={trackAnimation} initial="hidden" animate="show">
<motion.ul className="flex w-full flex-col gap-4" variants={trackAnimation} initial="hidden" animate="show">
{loading ? (
Array.from({ length: tracksPerPage }).map((_, idx) => (
<div
key={idx}
className="flex items-center space-x-4 w-full h-24 bg-neutral-100 dark:bg-neutral-900 p-4 rounded-xl"
className="flex h-24 w-full items-center space-x-4 rounded-xl bg-neutral-100 p-4 dark:bg-neutral-900"
>
<Skeleton className="h-12 w-12 rounded-2xl" />
<div className="space-y-2">
Expand All @@ -202,11 +202,11 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
</div>
))
) : visibleTracks.length === 0 ? (
<p className="text-center font-medium tracking-tighter text-lg max-w-screen-sm px-4 mx-auto">
<p className="mx-auto max-w-screen-sm px-4 text-center text-lg font-medium tracking-tighter">
☹️ Sorry - currently there are no tracks available.
</p>
) : (
filteredTracks.map((t) => (
visibleTracks.map((t) => (
<motion.li key={t.id} className="w-full" variants={{ hidden: { opacity: 0 }, show: { opacity: 1 } }}>
<TrackCard2 track={t} />
</motion.li>
Expand All @@ -216,7 +216,7 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {

{/* Skeleton */}
{filteredTracks.length < tracksPerPage && (
<div className="flex items-center space-x-4 w-full h-24 bg-neutral-100 dark:bg-neutral-900 p-4 rounded-xl">
<div className="flex h-24 w-full items-center space-x-4 rounded-xl bg-neutral-100 p-4 dark:bg-neutral-900">
<Skeleton className="h-12 w-12 rounded-2xl" />
<div className="space-y-2">
<Skeleton className="h-4 w-[250px]" />
Expand All @@ -225,7 +225,7 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
</div>
)}
{/* Pagination Controls */}
<div className="flex justify-end items-end mt-4 w-full">
<div className="mt-4 flex w-full items-end justify-end">
<Pagination>
<PaginationContent>
<PaginationItem className="cursor-pointer">
Expand All @@ -248,9 +248,7 @@ export const Tracks = ({ tracks, categories }: TracksWithCategoriesProps) => {
</>
)}

<PaginationItem
className="cursor-pointer"
>
<PaginationItem className="cursor-pointer">
<PaginationNext
onClick={() => {
setCurrentPage((prev) => Math.min(prev + 1, totalPages));
Expand Down
Loading