Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "../styles/pages/about.css";
- import { useState, useEffect } from 'react';
- import api from "../api";
- export default function About() {
- const [aboutQuestions, setAboutQuestions] = useState([]);
- useEffect(() => {
- api("/about-questions/")
- .then(res => {
- setAboutQuestions(res.data.aboutQuestions)
- });
- }, []);
- const getTableOfContents = () => {
- return aboutQuestions.map((q) => {
- let tuple = [q[0], q[1]];
- let [id, question] = tuple;
- let fixed_question = "#" + question.toLowerCase().replace(/ /g, "-");
- const new_question = fixed_question.slice(0,-1);
- return (
- <a className="about-link" href={new_question} key={id}>{question}</a>
- );
- });
- };
- const getAboutQuestions = () => {
- return aboutQuestions.map((q) => {
- let tuple = [q[0], q[1], q[2]];
- let [id, question, answer] = tuple;
- let fixed_question = "#" + question.toLowerCase().replace(/ /g, "-");
- let new_question = fixed_question.slice(0, -1);
- return (
- <div className="story container" key={id} id={new_question}>
- <div className="story-box container">
- <label className="label-header">{question}</label>
- <span className="details">{answer}</span>
- </div>
- </div>
- );
- });
- };
- return (
- <div className="main-container container-fluid">
- <div className="title-container container">
- <h1 className="title">About Mek</h1>
- </div>
- <div className="body-container container">
- <div className="links container">
- <label className="label-header">Table of Contents:</label>
- {getTableOfContents()}
- </div>
- <div className="questionAnswers">
- {getAboutQuestions()}
- </div>
- <label className="footer-label">
- If you have other details you wish to see here, please send me
- a support message, and we can discuss it from there
- </label>
- </div>
- </div>
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment