Skip to content

Commit

Permalink
feat: more text pages and disclaimers (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew authored Aug 21, 2024
2 parents e073314 + ad72090 commit 6c336d7
Show file tree
Hide file tree
Showing 18 changed files with 1,030 additions and 552 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@sentry/nextjs": "^7.113.0",
"@supabase/supabase-js": "^2.39.7",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/typography": "^0.5.10",
"@tailwindcss/typography": "^0.5.14",
"@tanstack/query-sync-storage-persister": "^5.40.0",
"@tanstack/react-query": "^5.51.15",
"@tanstack/react-query-persist-client": "^5.39.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use client";

import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { auth } from "@/config/firebase";
import supabase from "@/config/supabase";
import { useHeadlessAIS } from "@/hooks/contexts/useHeadlessAIS";
import { getStudentCourses } from "@/lib/headless_ais/courses";
import { useQuery } from "@tanstack/react-query";
import { useAuthState } from "react-firebase-hooks/auth";
import { MinimalCourse, selectMinimalStr } from "@/types/courses";
import {
getStudentCommentState,
hasUserCommented,
getUserCommentsCourses,
} from "@/lib/headless_ais/comments";
import { NewCommentDialog } from "@/components/CourseDetails/NewCommentDialog";
import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import CommentsNotSignedIn from "@/components/CourseDetails/CommentsNotSignedIn";

const ContributeComment = () => {
const [user, loading, error] = useAuthState(auth);
const { getACIXSTORE } = useHeadlessAIS();

const { data: courses = [], isLoading } = useQuery({
queryKey: ["user_courses", user],
queryFn: async () => {
const token = await getACIXSTORE();
if (!token) {
throw new Error("Failed to fetch user token");
}
const res = await getStudentCourses(token);
if (!res) {
throw new Error("Failed to fetch student courses.");
}
const { data: coursesData, error } = await supabase
.from("courses")
.select(selectMinimalStr)
.in("raw_id", res.courses);
if (error) throw error;
if (!coursesData) {
return [];
}
const userCommented = await getUserCommentsCourses();
return coursesData.map((course, index) => {
return {
...course,
commented: userCommented.includes(course.raw_id),
};
});
},
enabled: !!user,
placeholderData: [],
});

const commentedLength = courses.filter((c) => c.commented).length;

if (!user)
return (
<div className="not-prose">
<CommentsNotSignedIn />
</div>
);

return (
<Card>
<CardHeader>
<CardDescription className="my-0">
投了{commentedLength}門課程的評論{commentedLength > 0 ? "❤️" : ""}
</CardDescription>
</CardHeader>
<CardContent>
<ScrollArea className="h-72">
<div className="flex flex-col gap-3">
{courses.map((course, index) => (
<div className="flex flex-col" key={course.raw_id}>
<div className="flex flex-row w-full gap-3">
{course.commented ? (
<Button disabled variant="outline">
已評論
</Button>
) : (
<NewCommentDialog course={course as MinimalCourse} />
)}
<div className="flex flex-col">
<div className="font-bold">
{course.name_zh} - {course.teacher_zh.join(",")}
</div>
<div className="text-sm">
{course.name_en} - {course.teacher_en!.join(",")}
</div>
</div>
</div>
</div>
))}
</div>
</ScrollArea>
</CardContent>
</Card>
);
};

export default ContributeComment;
111 changes: 111 additions & 0 deletions src/app/[lang]/(mods-pages)/(side-pages)/contribute/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { Button } from "@/components/ui/button";
import {
BugIcon,
Github,
Instagram,
Lightbulb,
Mail,
Paperclip,
} from "lucide-react";
import Link from "next/link";
import ContributeComment from "./ContributeComment";
import IssueFormDialog from "@/components/Forms/IssueFormDialog";

const ContributePage = () => {
return (
<div className="px-4">
<article className="prose">
<h1>Be a Contributor</h1>
<p>
NTHUMods is a 100% pure student-led, open source project. We rely on
the support of our contributors, and NTHU students to keep this
platform alive. Many students have provided critical feedback and
suggested improvements that have shaped how NTHUMods is. No matter
your background, we welcome you to contribute to this platform!
</p>

<h1>For Everyone</h1>
<h2>Share your experiences</h2>
<p>{`You've took a fair share of courses, so share how your courses went to all students. Every insight that you can provide brings value to NTHUMods!`}</p>
<ContributeComment />
<h2>Share your feedback</h2>
<p>
We are always open for feedback! If you have any suggestions, ideas,
or feedback, or you think this particular shade of purple looks ugly!
Let us know using the links below.
</p>
<div className="flex flex-row gap-2 mb-8">
<IssueFormDialog>
<div className="rounded-md hover:shadow-md transition-shadow cursor-pointer bg-neutral-800 text-white grid place-items-center w-28 h-28">
<div className="flex flex-col items-center gap-2">
<Paperclip />
<div className="text-sm no-underline">Form</div>
</div>
</div>
</IssueFormDialog>
<Link href="mailto:nthumods@gmail.com">
<div className="rounded-md hover:shadow-md transition-shadow cursor-pointer bg-red-600 text-white grid place-items-center w-28 h-28">
<div className="flex flex-col items-center gap-2">
<Mail />
<div className="text-sm no-underline">Email</div>
</div>
</div>
</Link>
<Link href="https://instagram.com/nthumods">
<div className="rounded-md hover:shadow-md transition-shadow cursor-pointer bg-[#515BD4] text-white grid place-items-center w-28 h-28">
<div className="flex flex-col items-center gap-2">
<Instagram />
<div className="text-sm no-underline">Instagram</div>
</div>
</div>
</Link>
</div>

<h1>For Developers</h1>
<h2>File Bug Reports and Feature Requests</h2>
<p>
Found a bug? Want to see a new feature? File an issue on our GitHub
repository!
</p>
<div className="flex flex-row gap-2 mb-8">
<Link href="https://github.com/nthumodifications/courseweb/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=">
<div className="rounded-md hover:shadow-md transition-shadow cursor-pointer p-4 bg-neutral-800 text-white flex flex-row items-center gap-4">
<BugIcon />
<div className="flex flex-col">
<div className="font-bold">Bug</div>
<div className="text-sm">Report a bug on Github</div>
</div>
</div>
</Link>
<Link
href="https://github.com/nthumodifications/courseweb/issues/new?assignees=&labels=&projects=&template=feature_request.md&title="
className="text-inherit no-underline"
>
<div className="rounded-md hover:shadow-md transition-shadow cursor-pointer p-4 bg-neutral-800 text-white flex flex-row items-center gap-4">
<Lightbulb />
<div className="flex flex-col">
<div className="font-bold">Feature</div>
<div className="text-sm">Submit a Feature Idea</div>
</div>
</div>
</Link>
</div>

<h2>Contribute Code and Design</h2>
<p>
Wish to directly help us code/design NTHUMods? We welcome all
contributors, no matter your level. Try getting started by looking at
good first issues! And join your Discord server for any discussions!
</p>
<Button variant="outline" asChild>
<Link href="https://github.com/nthumodifications/courseweb">
<Github />
<span>GitHub</span>
</Link>
</Button>
</article>
</div>
);
};

export default ContributePage;
84 changes: 41 additions & 43 deletions src/app/[lang]/(mods-pages)/(side-pages)/issues/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,49 @@ const IssueButton = ({

const IssuesPage = () => {
return (
<div className="flex flex-col max-w-2xl px-4">
<h1 className="font-semibold text-3xl text-gray-400 py-3">
{"Report an Issue"}
</h1>
<div className="flex flex-row w-max m-4 rounded-md shadow-md divide-x divide-gray-200">
<IssueButton
title="Data Issue"
description="Report an issue with the data"
icon={<Database className="w-8 h-8" />}
href="#dataissue"
/>
<IssueButton
title="Bug/Feature"
description="Report a bug or request a feature"
icon={<Codepen className="w-8 h-8" />}
href="https://github.com/nthumodifications/courseweb/issues/new/choose"
/>
<IssueButton
title="Other"
description="Report an issue that doesn't fit in the above categories"
icon={<Globe className="w-8 h-8" />}
href="mailto:nthumods@googlegroups.com"
/>
</div>
<Separator />
<div id="dataissue" className="flex flex-col gap-4 py-4">
<div className="flex flex-col max-w-2xl px-4 prose">
<h1>Report an Issue</h1>
<div id="dataissue" className="flex flex-col">
{/* Explainer of the data sources */}
<h2 className="font-semibold text-xl text-gray-600 dark:text-gray-400 pb-2">
{"Data Sources"}
</h2>
<p className="text-gray-600 dark:text-gray-400">
{
"We use the following data sources to generate the course information."
}
<h2>{"Data Sources"}</h2>
<p>
We collect a variety of data sources to compile the best course
information for you. These include:
</p>
<ul className="list-disc list-inside">
<li className="text-gray-600 dark:text-gray-400">
{"Course information is from the NTHU Courses JSON file."}
</li>
<li className="text-gray-600 dark:text-gray-400">
{"Course reviews are from PTT NTHU course reviews."}
</li>
</ul>
<p className="text-gray-600 dark:text-gray-400">
{"If you find any issues with the data, please report it below."}
<div className="flex flex-col gap-2">
<div className="flex flex-col">
<div className="text-lg font-bold">最新課程資料《 JSON格式》</div>
<a
className="text-muted-foreground text-sm"
href="https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/OPENDATA/open_course_data.json"
target="_blank"
>
https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/OPENDATA/open_course_data.json
</a>
</div>
<div className="flex flex-col">
<div className="text-lg font-bold">校務資訊系統課程總表</div>
<a
className="text-muted-foreground text-sm"
href="https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/6/6.2/6.2.9/JH629001.php"
target="_blank"
>
https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/6/6.2/6.2.9/JH629001.php
</a>
</div>
<div className="flex flex-col">
<div className="text-lg font-bold">課程平均值及標準差查詢</div>
<a
className="text-muted-foreground text-sm"
href="https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/8/8.4/8.4.2/JH84201.php"
target="_blank"
>
https://www.ccxp.nthu.edu.tw/ccxp/INQUIRE/JH/8/8.4/8.4.2/JH84201.php
</a>
</div>
</div>
<p>
{`We fetch and update the data daily at 8 AM. If there are issues with the course details on NTHUMods, please verify from the above links if the its an error on NTHUMods's side. Then feel free to report it below. `}
</p>
{/* Data issue form */}
</div>
Expand Down
Loading

0 comments on commit 6c336d7

Please sign in to comment.