-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more text pages and disclaimers (#422)
- Loading branch information
Showing
18 changed files
with
1,030 additions
and
552 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/app/[lang]/(mods-pages)/(side-pages)/contribute/ContributeComment.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
111
src/app/[lang]/(mods-pages)/(side-pages)/contribute/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.