Skip to content

Commit

Permalink
feat: faq page (closes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
BitMap4 committed Nov 5, 2024
1 parent 20de293 commit 565f630
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 13 deletions.
51 changes: 38 additions & 13 deletions src/app/faq/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
import { ReactNode } from 'react';
import At from '@/components/At';
import faqs from '@/content/faqs.json';
import Link from 'next/link';

interface QuestionProps {
title: string;
title: ReactNode;
children: ReactNode;
}

function parseContent(text: string): ReactNode[] {
const atParts = text.split('@');
const result: ReactNode[] = [];

atParts.forEach((part, index) => {
if (index > 0) {
result.push(<At key={`at-${index}`} />);
}
result.push(...replaceLinks(part, index));
});

return result;
}

function replaceLinks(text: string, keyPrefix: number): ReactNode[] {
const urlRegex = /(https?:\/\/[^\s]+)/g;
const parts = text.split(urlRegex);

return parts.map((part, index) =>
urlRegex.test(part) ? (
<Link key={`link-${keyPrefix}-${index}`} href={part} className='underline'>
{part}
</Link>
) : (
part
)
);
}

const Question = ({ title, children }: QuestionProps) => (
<div className="space-y-6">
<h2 className="text-2xl">{title}</h2>
Expand All @@ -19,18 +51,11 @@ export default function FAQs() {
<h1 className="text-4xl font-semibold mb-4 text-center">FAQs</h1>
<div className={`mb-4 text-justify`}>
<div className="space-y-12">
<Question title="What is game theory?">
Game theory is the study of mathematical models of strategic interaction among rational decision-makers. It has applications in various fields, including economics, political science, psychology, and computer science.
</Question>
<Question title="How is game theory used in economics?">
In economics, game theory is used to model the behavior of individuals and firms in situations where their decisions affect each other. It helps in understanding competitive behaviors, market strategies, and the outcomes of different economic scenarios.
</Question>
<Question title="What are some common concepts in game theory?">
Some common concepts in game theory include Nash equilibrium, dominant strategies, Pareto efficiency, and zero-sum games. These concepts help in analyzing and predicting the outcomes of strategic interactions.
</Question>
<Question title="Can game theory be applied to real-life situations?">
Yes, game theory can be applied to various real-life situations, such as business negotiations, political campaigns, and social interactions. It provides a framework for understanding and predicting the behavior of individuals and groups in strategic settings.
</Question>
{faqs.map((faq, index) => (
<Question key={index} title={parseContent(faq.question)}>
{parseContent(faq.answer)}
</Question>
))}
</div>
</div>
</main>
Expand Down
38 changes: 38 additions & 0 deletions src/content/faqs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"question": "What is GameTheory@IIITH?",
"answer": "GameTheory@IIITH is a student-run club at IIITH to learn, practice, and master strategic and critical thinking through games like poker, Monopoly, etc in a fun and social environment. We host weekly Poker nights, workshops, and other board games as well."
},
{
"question": "Are there any membership requirements for GameTheory@IIITH?",
"answer": "You must fill out the membership form (which contains a non-disclosure agreement) to gain access to any and all of our future events. https://forms.gle/b3FtfsSFQmboAUoDA"
},
{
"question": "Do I need to know how to play poker to participate?",
"answer": "The club is open to the entire IIIT community, regardless of their familiarity with strategy games. Beginners are always welcome— a beginner table is always reserved for learning purposes and a member will teach you."
},
{
"question": "Do I have to have prior experience in the game before joining the event?",
"answer": "No prior experience is needed! We welcome players of all levels and provide instruction of relevant board games when necessary."
},
{
"question": "Why play strategy games?",
"answer": "Strategy games encourage you to think ahead, weigh risks, and make calculated decisions—skills that are valuable in many real-world scenarios. Playing these games regularly can help you become a more strategic thinker."
},
{
"question": "How do I stay updated on upcoming events?",
"answer": "You can stay informed through our Instagram pages, Outlook email announcements, or our WhatsApp group. Watch out for upcoming event schedules and special theme nights!"
},
{
"question": "Are there prizes or competitions at these game nights?",
"answer": "Yes! Apart from being featured on our social media and being added to our leaderboard, we often add a competitive element with small prizes or bragging rights for the winners."
},
{
"question": "Can I suggest a new game or event idea?",
"answer": "Absolutely! We’re always open to new ideas and suggestions. If you have a favorite strategy game or a unique event idea, let us know."
},
{
"question": "How can I join GameTheory@IIITH as a team member?",
"answer": "We usually have recruitments in the monsoon semester of every year. Follow our social media and watch out on Outlook!"
}
]

0 comments on commit 565f630

Please sign in to comment.