mekasu0124

Untitled

Feb 18th, 2024
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import "../styles/pages/about.css";
  2. import { useState, useEffect } from 'react';
  3. import api from "../api";
  4.  
  5. export default function About() {
  6.   const [aboutQuestions, setAboutQuestions] = useState([]);
  7.  
  8.   useEffect(() => {
  9.     api("/about-questions/")
  10.     .then(res => {
  11.       setAboutQuestions(res.data.aboutQuestions)
  12.     });
  13.   }, []);
  14.  
  15.   const getTableOfContents = () => {
  16.     return aboutQuestions.map((q) => {
  17.       let tuple = [q[0], q[1]];
  18.       let [id, question] = tuple;
  19.       let fixed_question = "#" + question.toLowerCase().replace(/ /g, "-");
  20.       const new_question = fixed_question.slice(0,-1);
  21.  
  22.       return (
  23.         <a className="about-link" href={new_question} key={id}>{question}</a>
  24.       );
  25.     });
  26.   };
  27.  
  28.   const getAboutQuestions = () => {
  29.     return aboutQuestions.map((q) => {
  30.       let tuple = [q[0], q[1], q[2]];
  31.       let [id, question, answer] = tuple;
  32.       let fixed_question = "#" + question.toLowerCase().replace(/ /g, "-");
  33.       let new_question = fixed_question.slice(0, -1);
  34.  
  35.       return (
  36.         <div className="story container" key={id} id={new_question}>
  37.           <div className="story-box container">
  38.             <label className="label-header">{question}</label>
  39.             <span className="details">{answer}</span>
  40.           </div>
  41.         </div>
  42.       );
  43.     });
  44.   };
  45.  
  46.   return (
  47.     <div className="main-container container-fluid">
  48.       <div className="title-container container">
  49.         <h1 className="title">About Mek</h1>
  50.       </div>
  51.  
  52.       <div className="body-container container">
  53.         <div className="links container">
  54.           <label className="label-header">Table of Contents:</label>
  55.           {getTableOfContents()}
  56.         </div>
  57.  
  58.         <div className="questionAnswers">
  59.           {getAboutQuestions()}
  60.         </div>
  61.  
  62.         <label className="footer-label">
  63.           If you have other details you wish to see here, please send me
  64.           a support message, and we can discuss it from there
  65.         </label>
  66.       </div>
  67.     </div>
  68.   );
  69. };
Advertisement
Add Comment
Please, Sign In to add comment