mekasu0124

Untitled

Feb 18th, 2024
127
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. import logo from "../images/me.jpg";
  5.  
  6. export default function About() {
  7.   const [aboutQuestions, setAboutQuestions] = useState([]);
  8.  
  9.   useEffect(() => {
  10.     api("/about-questions/")
  11.     .then(res => {
  12.       setAboutQuestions(res.data.aboutQuestions)
  13.     });
  14.   }, []);
  15.  
  16.   const getTableOfContents = () => {
  17.     return aboutQuestions.map((q) => {
  18.       let tuple = [q[0], q[1]];
  19.       let [id, question] = tuple;
  20.       let fixed_question = "#" + question.toLowerCase().replace(/ /g, "-");
  21.       const new_question = fixed_question.slice(0,-1);
  22.  
  23.       return (
  24.         <a className="about-link" href={new_question} key={id}>{question}</a>
  25.       );
  26.     });
  27.   };
  28.  
  29.   const getAboutQuestions = () => {
  30.     return aboutQuestions.map((q) => {
  31.       let tuple = [q[0], q[1], q[2]];
  32.       let [id, question, answer] = tuple;
  33.       let fixed_question = question.toLowerCase().replace(/ /g, "-");
  34.       let new_question = fixed_question.slice(0, -1);
  35.  
  36.       return (
  37.         <div className="story container" key={id} id={new_question}>
  38.           <div className="story-box container">
  39.             <label className="label-header">{question}</label>
  40.             <span className="details">{answer}</span>
  41.             <a className="top" href="/about/">Top</a>
  42.           </div>
  43.         </div>
  44.       );
  45.     });
  46.   };
  47.  
  48.   return (
  49.     <div className="main-container container-fluid">
  50.       <div className="background container">
  51.         <div className="el centerImage title-container container">
  52.           <img src={logo} alt="Website Creator, Mek" />
  53.         </div>
  54.  
  55.         <div className="sub-links container">
  56.           <a href="https://github.com/mekasu0124" className="sub-link">GitHub</a>
  57.           <a href="https://discord.gg/3HbEM8tcST" className="sub-link">Discord</a>
  58.           <a href="" className="sub-link">Empty</a>
  59.           <a href="" className="sub-link">Empty</a>
  60.           <a href="" className="sub-link">Empty</a>
  61.         </div>
  62.       </div>
  63.  
  64.       <div className="body-container container">
  65.         <div className="links container">
  66.           <label className="label-header">Table of Contents:</label>
  67.           {getTableOfContents()}
  68.         </div>
  69.  
  70.         <div className="questionAnswers">
  71.           {getAboutQuestions()}
  72.         </div>
  73.  
  74.         <label className="footer-label">
  75.           If you have other details you wish to see here, please send me
  76.           a support message, and we can discuss it from there
  77.         </label>
  78.       </div>
  79.     </div>
  80.   );
  81. };
Advertisement
Add Comment
Please, Sign In to add comment