Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/app/api/papers/count/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { success, failure } from "@/lib/utils/response";

export const dynamic = "force-dynamic";

export async function GET(req: Request) {
export async function GET() {
try {
const courseCount = await getCourseCounts();

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/report-tag/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reportTag, ReportTagBody } from "@/lib/services/report";
import { reportTag, type ReportTagBody } from "@/lib/services/report";
import { rateLimitCheck } from "@/lib/utils/rate-limiter";
import { success, failure } from "@/lib/utils/response";
import { customErrorHandler } from "@/lib/utils/error";
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/user-papers/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { connectToDatabase } from "@/lib/database/mongoose";
import Paper from "@/db/papers";
import { StoredSubjects } from "@/interface";
import { type StoredSubjects } from "@/interface";
import { transformPapersToSubjectSlots } from "@/lib/services/paper-transform";
import { success, failure } from "@/lib/utils/response";

Expand Down
1 change: 0 additions & 1 deletion src/app/pinned/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import SearchBar from "@/components/Searchbar/searchbar";
import PinnedPapersCarousel from "@/components/PinnedPapersCarousel";

const Pinned = () => {
return (
Expand Down
9 changes: 1 addition & 8 deletions src/app/request/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ import { Input } from "@/components/ui/input";
import axios from "axios";
import Fuse from "fuse.js";
import { type IUpcomingPaper } from "@/interface";
import { Skeleton } from "../../components/ui/skeleton";
import UpcomingPaper from "../../components/UpcomingPaper";
import toast from "react-hot-toast";
import { Search } from "lucide-react";
import SkeletonPaperCard from "@/components/SkeletonPaperCard";
import { useCourses } from "@/context/courseContext";
import { type ApiResponse } from '@/interface'

type Course = {
name?: string | null;
courseName?: string | null;
title?: string | null;
};

export default function PaperRequest() {
const [subjects, setSubjects] = useState<string[]>([]);
const [searchText, setSearchText] = useState("");
Expand All @@ -39,7 +32,7 @@ export default function PaperRequest() {
const suggestionsRef = useRef<HTMLUListElement | null>(null);
const [displayPapers, setDisplayPapers] = useState<IUpcomingPaper[]>([]);
const [isLoading, setIsLoading] = useState(true);
const { courses, loading, error, refetch } = useCourses();
const { courses } = useCourses();

useEffect(() => {
setSubjects(courses.map((course) => course.name));
Expand Down
6 changes: 1 addition & 5 deletions src/app/upload/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,7 @@ export default function Page() {
}}
multiple={true}
>
{({ getRootProps, getInputProps, isDragActive }) => {
const pdfUploaded = files.some(
(f) => f.type === "application/pdf",
);

{({ getRootProps, getInputProps }) => {
return (
<section
{...getRootProps()}
Expand Down
4 changes: 2 additions & 2 deletions src/components/CatalogueContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import axios, { type AxiosError } from "axios";
import axios from "axios";
import { Button } from "@/components/ui/button";
import { type IPaper, type Filters, type StoredSubjects, type ApiResponse } from "@/interface";
import Card from "./Card";
Expand Down Expand Up @@ -64,7 +64,7 @@ const CatalogueContentInner = ({ subject }: { subject: string | null }) => {

useEffect(() => {
setCurrentPage(1);
}, [subject]);
}, [subject, setCurrentPage]);

// Fetch related subjects when subject changes
useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/FloatingNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { usePathname } from "next/navigation";
import Link from "next/link";
import { useState } from "react";
import {
ArrowUpRight,
ChevronDown,
Pin,
UploadIcon,
} from "lucide-react";
import ModeToggle from "./toggle-theme";
Expand Down
17 changes: 2 additions & 15 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use client";

import Link from "next/link";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
import { useState } from "react";
import { Button } from "./ui/button";
import { Input } from "@/components/ui/input";
import {
Expand All @@ -13,24 +12,12 @@ import {
FaXTwitter,
FaYoutube,
} from "react-icons/fa6";
import { Bold, Mail } from "lucide-react";
import { Mail } from "lucide-react";
import toast from "react-hot-toast";
import type { ApiResponse } from '@/interface'

type SubscribeResponse = {
success?: boolean;
message?: string;
};

export default function Footer() {
const { theme } = useTheme();
const [isDarkMode, setIsDarkMode] = useState<boolean | null>(true);
const [email, setEmail] = useState("");
useEffect(() => {
if (theme) {
setIsDarkMode(theme === "dark");
}
}, [theme]);
const handleSubscribe = async () => {
if (!email.trim()) {
toast.error("Please enter your email.");
Expand Down
8 changes: 2 additions & 6 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
"use client";

import { useState, useEffect } from "react";
import Image, { StaticImageData } from "next/image";
import Image, { type StaticImageData } from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
import ccLogo from "../assets/codechef_logo.svg";
import ModeToggle from "@/components/toggle-theme";
import {
ArrowDownLeftIcon,
Pin,
ArrowUpRight,
ChevronDown,
} from "lucide-react";
import FloatingNavbar from "./FloatingNavbar";
import PWAInstallButton from "./ui/PWAInstallButton";
import SearchBarChild from "./Searchbar/searchbar-child";
import Banner from "@/components/ui/banners/bannerDismiss";
import type { ICourses } from "@/interface";
import {
DropdownMenu,
DropdownMenuTrigger,
Expand All @@ -32,7 +28,7 @@ function Navbar() {
const pathname: string = usePathname() ?? "/";

const [dropdownOpen, setDropdownOpen] = useState<boolean>(false);
const { courses, loading, error, refetch } = useCourses();
const { courses } = useCourses();

useEffect(() => {
if (pathname !== "/catalogue") return;
Expand Down
1 change: 0 additions & 1 deletion src/components/PapersCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@/components/ui/carousel";
import Autoplay from "embla-carousel-autoplay";
import { chunkArray } from "@/lib/utils/array";
import { Skeleton } from "@/components/ui/skeleton";
import SkeletonPaperCard from "@/components/SkeletonPaperCard";
import { type ApiResponse } from "@/interface"

Expand Down
7 changes: 2 additions & 5 deletions src/components/ReportTagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Button } from "@/components/ui/button";
import { MultiSelect } from "@/components/multi-select";
import LabeledInput from "@/components/ui/LabeledInput";
import LabeledSelect from "@/components/ui/LabeledSelect";
import axios, { AxiosError } from "axios";
import axios from "axios";
import toast from "react-hot-toast";
import { type ApiResponse } from '@/interface'

Expand Down Expand Up @@ -54,7 +54,6 @@ const ReportTagModal = ({
const [originalCategoryValues, setOriginalCategoryValues] = useState<
Record<string, string>
>({});
const [originalEmail, setOriginalEmail] = useState("");
const [loading, setLoading] = useState(false);

const SCROLL_THRESHOLD = 4;
Expand Down Expand Up @@ -102,7 +101,7 @@ const ReportTagModal = ({
else if (c === "year" && year)
setCategoryValues((s) => ({ ...s, [c]: year }));
}
}, [selectedCategories, subject, exam, slot, year]);
}, [selectedCategories, subject, exam, slot, year, categoryValues]);

useEffect(() => {
if (open) {
Expand All @@ -121,14 +120,12 @@ const ReportTagModal = ({
if (slot) base.slot = slot;
if (year) base.year = year;
setOriginalCategoryValues(base);
setOriginalEmail("");
} else {
setSelectedCategories([]);
setCategoryValues({});
setComment("");
setEmail("");
setOriginalCategoryValues({});
setOriginalEmail("");
}
}, [open, subject, exam, slot, year]);

Expand Down
8 changes: 0 additions & 8 deletions src/components/Searchbar/pinned-searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { useState, useRef, useEffect } from "react";
import { Search } from "lucide-react";
import { useRouter } from "next/navigation";
import { Input } from "@/components/ui/input";
import PinButton from "../PinButton";
import Fuse from "fuse.js";
Expand All @@ -11,15 +10,13 @@ import { type StoredSubjects, type ICourseWithCount, type IUpcomingPaper } from
function PinnedSearchBar({
initialSubjects,
setDisplayPapers,
displayPapers,
filtersNotPulled,
}: {
initialSubjects: ICourseWithCount[];
setDisplayPapers: React.Dispatch<React.SetStateAction<IUpcomingPaper[]>>;
displayPapers : IUpcomingPaper[];
filtersNotPulled?: () => void;
}) {
const router = useRouter();
const [searchText, setSearchText] = useState("");
const [suggestions, setSuggestions] = useState<string[]>([]);
const suggestionsRef = useRef<HTMLUListElement | null>(null);
Expand Down Expand Up @@ -154,11 +151,6 @@ function PinnedSearchBar({
};
}, []);

const handleRemoveAll = () => {
localStorage.setItem("userSubjects", JSON.stringify([]));
window.dispatchEvent(new Event("userSubjectsChanged"));
};

useEffect(() => {
const storedSubjects = JSON.parse(
localStorage.getItem("userSubjects") ?? "[]",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Searchbar/searchbar-child.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Search } from "lucide-react";
import { useRouter } from "next/navigation";
import { Input } from "@/components/ui/input";
import Fuse from "fuse.js";
import { ICourseWithCount } from "@/interface";
import { type ICourseWithCount } from "@/interface";

function SearchBarChild({
initialSubjects,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Searchbar/searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function SearchBar({
displayPapers?:IUpcomingPaper[]
setDisplayPapers?: React.Dispatch<React.SetStateAction<IUpcomingPaper[]>>
}) {
const { courses, loading, error, refetch } = useCourses();
const { courses } = useCourses();

return type === "pinned" && setDisplayPapers !== undefined && displayPapers !== undefined ? (
<PinnedSearchBar initialSubjects={courses} setDisplayPapers={setDisplayPapers} displayPapers={displayPapers} />
Expand Down
8 changes: 4 additions & 4 deletions src/components/UpcomingPaper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {

import { useRouter } from "next/navigation";
import { Pin } from "lucide-react";
import React, { useContext, useEffect, useState } from "react";
import { StoredSubjects } from "@/interface";
import React, { useEffect, useState } from "react";
import { type StoredSubjects } from "@/interface";
import { useCourses } from "@/context/courseContext";
import { Capsule } from "@/components/ui/capsule";

Expand All @@ -18,7 +18,7 @@ interface PaperCardProps {
export default function PaperCard({ subject, slots }: PaperCardProps) {
const courseName = extractWithoutBracketContent(subject);
const courseCode = extractBracketContent(subject);
const { courses, loading, error, refetch } = useCourses();
const { courses } = useCourses();
const [pinned, setPinned] = useState<boolean>(false);
const [paperCount, setPaperCount] = useState<number>(0);

Expand Down Expand Up @@ -54,7 +54,7 @@ export default function PaperCard({ subject, slots }: PaperCardProps) {
} else {
setPaperCount(0);
}
}, [subject, courseName]);
}, [subject, courseName, courses]);

const router = useRouter();
return (
Expand Down
1 change: 0 additions & 1 deletion src/components/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export const MultiSelect = React.forwardRef<
animation = 0,
maxCount = 3,
modalPopover = false,
asChild = false,
className,
...props
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/newPdfViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function WheelZoom({ documentId, viewerRef }: WheelZoomProps) {
viewer.removeEventListener("wheel", handleWheel);
if (rafId.current !== null) cancelAnimationFrame(rafId.current);
};
}, [handleWheel]);
}, [handleWheel, viewerRef]);

return null;
}
Expand Down
7 changes: 2 additions & 5 deletions src/components/screens/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import {
Check,
Filter,
Book,
ArrowUpRight,
} from "lucide-react";
import Image from "next/image";
import man from "@/assets/man.svg" assert { type: "image/svg" };
import man1 from "@/assets/man1.svg" assert { type: "image/svg" };
import Link from "next/link";
import { Button } from "@/components/ui/button";
import man from "@/assets/man.svg" with { type: "image/svg" };
import man1 from "@/assets/man1.svg" with { type: "image/svg" };
import PWAInstallButton from "../ui/PWAInstallButton";

function Info() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/PWAInstallButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const PWAInstallButton = () => {
const [deferredPrompt, setDeferredPrompt] =
useState<BeforeInstallPromptEvent | null>(null);
const [canInstall, setCanInstall] = useState(false);
const [isMobile, setIsMobile] = useState(false);
const [, setIsMobile] = useState(false);

useEffect(() => {
const checkMobile = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/PinnedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const PinnedModal = ({
page?: string;
}) => {
const [displayPapers, setDisplayPapers] = useState<IUpcomingPaper[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [, setIsLoading] = useState(true);
const [open, setOpen] = useState(false);
const sensors = useSensors(useSensor(PointerSensor));

Expand Down
8 changes: 1 addition & 7 deletions src/components/ui/RequestModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ import { exams, slots, years } from "@/components/select_options";
import Fuse from 'fuse.js';
import { useCourses } from "@/context/courseContext";

type Course = {
name?: string | null;
courseName?: string | null;
title?: string | null;
};

const RequestModal = ({section = "navbar"} : {section? : string}) => {
const [open, setOpen] = useState(false);
const [subjects, setSubjects] = useState<string[]>([]);
Expand All @@ -43,7 +37,7 @@ const RequestModal = ({section = "navbar"} : {section? : string}) => {
const [selectedExam, setSelectedExam] = useState<string | null>(null);
const [selectedSlot, setSelectedSlot] = useState<string | null>(null);
const [selectedYear, setSelectedYear] = useState<string | null>(null);
const { courses, loading, error, refetch } = useCourses();
const { courses } = useCourses();

useEffect(() => {
setSubjects(courses.map((course) => course.name));
Expand Down
2 changes: 1 addition & 1 deletion src/context/PaperContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { createContext, useContext, ReactNode } from "react";
import { createContext, useContext, type ReactNode } from "react";

interface PaperContextType {
paperId: string;
Expand Down
4 changes: 0 additions & 4 deletions src/context/courseContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ interface CoursesContextType {
refetch: () => Promise<void>;
}

interface ApiError {
message?: string;
}

const CoursesContext = createContext<CoursesContextType | undefined>(undefined);

export function CoursesProvider({ children }: { children: React.ReactNode }) {
Expand Down
Loading
Loading