Skip to content
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: 28 additions & 0 deletions src/app/api/syllabus/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { connectToDatabase } from "@/lib/database/mongoose";
import { Course } from "@/db/course";
import { success, failure } from "@/lib/utils/response";

export const dynamic = "force-dynamic";

export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const subject = searchParams.get("subject");

if (!subject) {
return failure("Subject parameter is required", 400);
}

await connectToDatabase();

const course = await Course.findOne(
{ name: subject },
{ syllabus: 1, _id: 0 }
).lean<{ syllabus?: string } | null>();

return success({ syllabus: course?.syllabus ?? null });
} catch (error) {
console.error("Error fetching syllabus:", error);
return failure("Failed to fetch syllabus", 500);
}
}
2 changes: 2 additions & 0 deletions src/app/paper/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { type Metadata } from "next";
import { redirect } from "next/navigation";
import { PaperProvider } from "@/context/PaperContext";
import PDFViewer from "@/components/newPdfViewer";
import SyllabusDock from "@/components/SyllabusDock";

export async function generateMetadata({
params,
Expand Down Expand Up @@ -187,6 +188,7 @@ const PaperPage = async ({ params }: { params: { id: string } }) => {
</PaperProvider>
</center>
<RelatedPapers />
<SyllabusDock subject={paper.subject} />
</>
)}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/CatalogueContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FilterProvider, useFilters } from "@/context/filterContext";
import EmptyState from "./ui/EmptyState";
import SelectionToolbar from "./SelectionToolbar";
import SortComponent from "./ui/sorting";
import SyllabusDock from "./SyllabusDock";

const CatalogueContentInner = ({ subject }: { subject: string | null }) => {
const [isMounted, setIsMounted] = useState(false);
Expand Down Expand Up @@ -414,6 +415,7 @@ const CatalogueContent = () => {
return (
<FilterProvider subject={subject}>
<CatalogueContentInner subject={subject} />
<SyllabusDock subject={subject} />
</FilterProvider>
);
};
Expand Down
Loading
Loading