Skip to content

Commit 3f977f4

Browse files
Merge pull request #273 from karannfr/prod
fixed: #266, #270, #271, #269
2 parents b84666c + 0cb3d6e commit 3f977f4

6 files changed

Lines changed: 51 additions & 22 deletions

File tree

src/app/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export default function RootLayout({
122122
<div className="bg-[#F3F5FF] dark:bg-[#070114]">
123123
<Navbar />
124124
<ChildrenWrapper>{children}</ChildrenWrapper>
125-
126125
<Footer />
127126
</div>
128127
</ThemeProvider>

src/app/pinned/page.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1+
"use client";
2+
13
import React from "react";
24
import SearchBar from "@/components/Searchbar/searchbar";
35
import PinnedPapersCarousel from "@/components/PinnedPapersCarousel";
6+
import { type IUpcomingPaper } from "@/interface";
7+
import { useState } from "react";
48

59
const Pinned = () => {
10+
const [displayPapers, setDisplayPapers] = useState<IUpcomingPaper[]>([]);
611
return (
712
<div id="pinned" className="mt-5 flex flex-col justify-between">
813
<h1 className="mx-auto my-8 hidden text-center font-vipnabd text-3xl font-extrabold md:block">
914
Pinned Subjects
1015
</h1>
11-
1216
<div className="mb-3 flex w-full flex-col items-center gap-2 px-6">
1317
<div className="w-full">
14-
<SearchBar type="pinned" />
18+
<SearchBar type="pinned" displayPapers = {displayPapers.length > 0} />
1519
</div>
1620
</div>
17-
<div className="min-h-[20vh]">
18-
<PinnedPapersCarousel carouselType="users" />
21+
<div className="min-h-[40vh]">
22+
<PinnedPapersCarousel carouselType="users" displayPapers = {displayPapers} setDisplayPapers = {setDisplayPapers} />
1923
</div>
2024
<div className="mt-6 flex w-full items-center justify-center">
2125
<p>You can pin upto 8 Subjects here</p>

src/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function Footer() {
5050
};
5151

5252
return (
53-
<footer className="w-full overflow-hidden bg-gradient-to-b from-[#F3F5FF] to-[#A599CE] px-6 py-10 text-white dark:from-[#070114] dark:to-[#1F0234]">
53+
<footer className="w-full overflow-hidden bg-gradient-to-b from-[#F3F5FF] to-[#A599CE] px-6 py-10 pt-16 text-white dark:from-[#070114] dark:to-[#1F0234]">
5454
<div className="mx-auto flex max-w-7xl flex-wrap justify-between gap-y-10 text-center sm:text-left">
5555
{/* Branding & Socials */}
5656
<div className="flex w-full flex-col gap-4 sm:w-[45%] lg:w-[30%]">

src/components/PinnedPapersCarousel.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ import { chunkArray } from "@/util/utils";
1919
import { StoredSubjects } from "@/interface";
2020
import SkeletonPaperCard from "./SkeletonPaperCard";
2121

22+
type PinnedPapersCarouselProps = {
23+
carouselType: "users" | "upcoming",
24+
displayPapers: IUpcomingPaper[],
25+
setDisplayPapers: React.Dispatch<React.SetStateAction<IUpcomingPaper[]>>
26+
}
27+
2228
function PinnedPapersCarousel({
2329
carouselType = "upcoming",
24-
}: {
25-
carouselType: "users" | "upcoming";
26-
}) {
27-
const [displayPapers, setDisplayPapers] = useState<IUpcomingPaper[]>([]);
30+
displayPapers,
31+
setDisplayPapers
32+
} : PinnedPapersCarouselProps) {
2833
const [isLoading, setIsLoading] = useState(true);
2934
const [chunkSize, setChunkSize] = useState<number>(4);
3035

@@ -107,6 +112,7 @@ function PinnedPapersCarousel({
107112
return (
108113
<div className="px-4">
109114
<div className="">
115+
{displayPapers.length > 0 ?
110116
<Carousel
111117
opts={{
112118
align: "start",
@@ -115,12 +121,13 @@ function PinnedPapersCarousel({
115121
plugins={plugins}
116122
className="w-full"
117123
>
124+
{displayPapers.length > 8 &&
118125
<div
119-
className={`relative mt-4 flex justify-end gap-4 ${displayPapers.length > 0 ? "block" : "hidden"}`}
126+
className={`relative mt-4 flex justify-end gap-4`}
120127
>
121128
<CarouselPrevious className="relative" />
122129
<CarouselNext className="relative" />
123-
</div>
130+
</div>}
124131
<CarouselContent>
125132
{isLoading ? (
126133
<CarouselItem
@@ -167,7 +174,11 @@ function PinnedPapersCarousel({
167174
})
168175
)}
169176
</CarouselContent>
170-
</Carousel>
177+
</Carousel> :
178+
<div className={`relative flex justify-center gap-4 items-center h-max text-center mt-48 font-bold`}
179+
>
180+
Start pinning subjects for quick and easy access.
181+
</div>}
171182
</div>
172183
</div>
173184
);

src/components/Searchbar/pinned-searchbar.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import Fuse from "fuse.js";
99
import NavDropdownButton from "../NavDropdownButton";
1010
import { StoredSubjects } from "@/interface";
1111
import FloatingControls from "./floating-controls";
12+
import { type IUpcomingPaper } from "@/interface";
1213

1314
function PinnedSearchBar({
1415
initialSubjects,
16+
displayPapers,
1517
filtersNotPulled,
1618
}: {
1719
initialSubjects: string[];
20+
displayPapers: boolean;
1821
filtersNotPulled?: () => void;
1922
}) {
2023
const router = useRouter();
@@ -234,6 +237,7 @@ function PinnedSearchBar({
234237
}}
235238
disabled={!showControls || searchText.trim() === ""}
236239
/>
240+
{displayPapers &&
237241
<button
238242
onClick={() => {
239243
handleRemoveAll();
@@ -242,15 +246,15 @@ function PinnedSearchBar({
242246
className="flex items-center gap-2 rounded-full border border-[#3A3745] bg-[#e8e9ff] px-3 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-slate-50 dark:bg-black dark:text-white dark:hover:bg-[#1A1823]"
243247
>
244248
Remove All <X className="h-4 w-4" />
245-
</button>
249+
</button>}
246250
</FloatingControls>
247251
</div>
248252
</div>
249253
</div>
250254
</form>
251255
</div>
252256
</div>
253-
257+
{displayPapers &&
254258
<div className="mt-2 hidden w-full md:block">
255259
<div className="ml-auto w-fit">
256260
<button
@@ -263,7 +267,7 @@ function PinnedSearchBar({
263267
Remove All <X className="h-4 w-4" />
264268
</button>
265269
</div>
266-
</div>
270+
</div>}
267271
</div>
268272
);
269273
}
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
"use server";
1+
"use client";
22

33
import React from "react";
44
import axios from "axios";
55
import { type ICourses } from "@/interface";
66
import SearchBarChild from "./searchbar-child";
77
import PinnedSearchBar from "./pinned-searchbar";
8+
import { type IUpcomingPaper } from "@/interface";
9+
import { useState, useEffect } from "react";
810

911
export async function fetchSubjects() {
1012
try {
1113
const response = await axios.get<ICourses[]>(
12-
`${process.env.SERVER_URL}/api/course-list`,
14+
`/api/course-list`,
1315
);
1416

1517
return response.data.map((course) => course.name);
@@ -19,16 +21,25 @@ export async function fetchSubjects() {
1921
}
2022
}
2123

22-
export default async function SearchBar({
24+
export default function SearchBar({
2325
type = "default",
26+
displayPapers
2427
}: {
2528
type?: "default" | "pinned";
29+
displayPapers: boolean;
2630
}) {
27-
const subjects = await fetchSubjects();
31+
const [subjects,setSubjects] = useState<string[]>([]);
32+
33+
useEffect(() => {
34+
async function getSubjects() {
35+
setSubjects(await fetchSubjects());
36+
}
37+
void getSubjects()
38+
},[])
2839

2940
return type === "pinned" ? (
30-
<PinnedSearchBar initialSubjects={subjects} />
41+
<PinnedSearchBar initialSubjects={subjects} displayPapers = {displayPapers} />
3142
) : (
3243
<SearchBarChild initialSubjects={subjects} />
3344
);
34-
}
45+
}

0 commit comments

Comments
 (0)