diff --git a/app/components/subjects.tsx b/app/components/subjects.tsx index 588c63a..81944f6 100644 --- a/app/components/subjects.tsx +++ b/app/components/subjects.tsx @@ -10,6 +10,7 @@ const subjects = { "Engineering Physics", "Engineering Graphics & Design", "English Communication", + "Workshop Practice", ], "Semester-2": [ "Digital Electronics & Logic Circuits", @@ -79,6 +80,7 @@ const subjectCodes: Record = { "Engineering Graphics & Design": "egd", "English Communication": "ec", "Basics of Mechanical Engineering": "bme", + "Workshop Practice": "wp", "Digital Electronics & Logic Circuits": "delc", "OOPs with Java": "oops", @@ -129,8 +131,7 @@ const subjectCodes: Record = { }; // Available subjects -const available = ["ep", "c", "em1", "em2", "oops", "dsc", "coa", "os", "ml", "dops", "cd", "cle", "ec", "dbms", "bme", "cns", "vlsi", "mb"]; - +const available = ["ep", "c", "em1", "em2", "oops", "dsc", "coa", "os", "ml", "dops", "cd", "cle", "ec", "dbms", "bme", "cns", "vlsi", "mb", "wp"]; export default function SubjectsSection() { return (
diff --git a/app/sem1/wp/[chapter]/page.tsx b/app/sem1/wp/[chapter]/page.tsx new file mode 100644 index 0000000..730dcda --- /dev/null +++ b/app/sem1/wp/[chapter]/page.tsx @@ -0,0 +1,167 @@ +import Link from "next/link"; +import { Metadata } from "next"; +import { Righteous } from "next/font/google"; +import { Ch0Content } from "../content/chapter0"; +import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; +import { chapters, Chapter, SubTopic } from "../constants"; + +function findChapterOrSubtopic(chapterId: string) { + const chapter = chapters.find((c) => c.id === chapterId); + if (chapter) return { data: chapter, isSubTopic: false, parentChapter: null }; + + for (const ch of chapters) { + if (ch.subTopics) { + const sub = ch.subTopics.find( + (s) => s.id === chapterId && s.isPage + ) as (SubTopic & { isPage: true }) | undefined; + if (sub) return { data: sub, isSubTopic: true, parentChapter: ch }; + } + } + return { data: undefined, isSubTopic: false, parentChapter: null }; +} + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +// Only ch0 is available for now — more chapters added in future PRs +const chapterComponents: Record = { + ch0: Ch0Content, +}; + +type ChapterProps = { + params: Promise<{ chapter: string }>; +}; + +export async function generateMetadata({ params }: ChapterProps): Promise { + const { chapter: chapterId } = await params; + const { data: chapterData } = findChapterOrSubtopic(chapterId); + const title = chapterData + ? `${chapterData.title} | Workshop Practice | openCSE` + : "Workshop Practice | openCSE"; + return { title }; +} + +export default async function ChapterPage({ params }: ChapterProps) { + const { chapter: chapterId } = await params; + const { data: chapterData, isSubTopic, parentChapter } = + findChapterOrSubtopic(chapterId); + + if (!chapterData) { + return ( +
+

Chapter not found

+ + Return to Course Outline + +
+ ); + } + + const ChapterComponent = chapterComponents[chapterData.id]; + let prevChapter = null; + let nextChapter = null; + + if (isSubTopic && parentChapter && parentChapter.subTopics) { + const pageSubTopics = parentChapter.subTopics.filter( + (s): s is SubTopic & { isPage: true } => !!s.isPage + ); + const subIndex = pageSubTopics.findIndex((s) => s.id === chapterId); + if (subIndex > 0) { + prevChapter = pageSubTopics[subIndex - 1]; + } else { + prevChapter = { id: parentChapter.id, title: `Back to ${parentChapter.title}` }; + } + if (subIndex < pageSubTopics.length - 1) { + nextChapter = pageSubTopics[subIndex + 1]; + } else { + const parentIndex = chapters.findIndex((c) => c.id === parentChapter.id); + if (parentIndex < chapters.length - 1) nextChapter = chapters[parentIndex + 1]; + } + } else { + const currentIndex = chapters.findIndex((c) => c.id === chapterId); + prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; + nextChapter = + currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + } + + return ( +
+
+

+ Workshop Practice +

+

+ {isSubTopic && parentChapter + ? `${parentChapter.title} / ${chapterData.title}` + : chapterData.title} +

+
+ {prevChapter ? ( + + Previous + + ) : ( +
+ )} + {nextChapter ? ( + + Next + + ) : ( +
+ )} +
+
+ {ChapterComponent ? ( + + ) : ( +
+

Coming Soon

+

+ This chapter is under development. Check back soon! +

+
+ )} +
+
+ {prevChapter ? ( + + {prevChapter.title} + + ) : ( +
+ )} + {nextChapter ? ( + + {nextChapter.title}{" "} + + + ) : ( +
+ )} +
+
+ ); +} \ No newline at end of file diff --git a/app/sem1/wp/components/sidebar.tsx b/app/sem1/wp/components/sidebar.tsx new file mode 100644 index 0000000..bc6a803 --- /dev/null +++ b/app/sem1/wp/components/sidebar.tsx @@ -0,0 +1,107 @@ +"use client"; +import { Righteous } from "next/font/google"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { useState, useEffect } from "react"; +import { chapters } from "../constants"; + +const righteous = Righteous({ + subsets: ["latin"], + weight: "400", + variable: "--font-righteous", +}); + +export default function Sidebar() { + const pathname = usePathname(); + const [open, setOpen] = useState(false); + + useEffect(() => { + if (window.innerWidth >= 768) { + setOpen(true); + } + }, []); + + return ( + <> +
setOpen(false)} + /> +
+ + +
+ + ); +} \ No newline at end of file diff --git a/app/sem1/wp/constants.ts b/app/sem1/wp/constants.ts new file mode 100644 index 0000000..e9fa374 --- /dev/null +++ b/app/sem1/wp/constants.ts @@ -0,0 +1,20 @@ +export type SubTopic = + | { id: string; title: string; isPage: true } + | { id: string; title: string; isPage?: false }; + +export type Chapter = { + id: string; + title: string; + subTopics?: SubTopic[]; +}; + +export const chapters: Chapter[] = [ + { id: "ch0", title: "Course Outline" }, + { id: "ch1", title: "Fitting Shop" }, + { id: "ch2", title: "Welding Shop" }, + { id: "ch3", title: "Carpentry Shop" }, + { id: "ch4", title: "Smithy Shop" }, + { id: "ch5", title: "Sheet Metal Shop" }, + { id: "ch6", title: "Foundry Shop" }, + { id: "ch7", title: "Turning Shop" }, +]; \ No newline at end of file diff --git a/app/sem1/wp/content/chapter0.tsx b/app/sem1/wp/content/chapter0.tsx new file mode 100644 index 0000000..0b524d8 --- /dev/null +++ b/app/sem1/wp/content/chapter0.tsx @@ -0,0 +1,36 @@ +export function Ch0Content() { + return ( +
+

+ Workshop Practice introduces first-year engineering students to hands-on + manufacturing and fabrication skills across various engineering trades. This + module covers fitting, welding, carpentry, smithy, sheet metal, foundry, and + turning shops — including theory, tools, safety practices, and viva questions. +

+ +
+

Shops at a Glance

+
    +
  • Ch 1 — Fitting Shop: hand tools, marking, filing
  • +
  • Ch 2 — Welding Shop: arc & gas welding basics
  • +
  • Ch 3 — Carpentry Shop: wood joints & finishing
  • +
  • Ch 4 — Smithy Shop: forging operations
  • +
  • Ch 5 — Sheet Metal Shop: bending, cutting, joining
  • +
  • Ch 6 — Foundry Shop: sand casting process
  • +
  • Ch 7 — Turning Shop: lathe machine operations
  • +
+
+ +
+

What Each Shop Module Covers

+
    +
  • Introduction and theory
  • +
  • Important tools used
  • +
  • Safety measures
  • +
  • Labelled diagrams
  • +
  • Most asked viva questions
  • +
+
+
+ ); +} \ No newline at end of file diff --git a/app/sem1/wp/layout.tsx b/app/sem1/wp/layout.tsx new file mode 100644 index 0000000..f78a868 --- /dev/null +++ b/app/sem1/wp/layout.tsx @@ -0,0 +1,18 @@ +import Navbar from "@/app/components/navbar"; +import Sidebar from "./components/sidebar"; + +export default function WorkshopLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( +
+ +
+ +
{children}
+
+
+ ); +} \ No newline at end of file