import BasicPage from "../../components/basic-page-template";
import WCard from "../../components/werefox-card";
import TCard from "../../components/testimonial-card";
import axios from "axios";

// Async functions to grab user avatars server-side

export const getIcon = async ({ json, name }) =>
  await axios.get(json).then(
    ({ data }) => [name, data["icon"]["url"]],
    (error) => {
      console.log(error);
      return [name, null];
    }
  );

export const getStaticProps = async () => {
  const promises = Object.entries(USERS).map(([name, { json }]) =>
    getIcon({ name, json })
  );
  const iconUrls = await Promise.all(promises);
  return {
    props: {
      iconUrls: iconUrls.reduce(
        (acc, [name, url]) => ({ ...acc, [name]: url }),
        {}
      ),
    },
  };
};

// This is where you put the testimonial users' info

const USERS = {
  colabunny: {
    json: "https://yiff.life/@colabunny.json",
    url: "https://yiff.life/@colabunny",
    content: '"please stay your jokes are funny and smart"',
  },
  ElfLord: {
    url: "https://freedom.horse/@ElfLord",
    json: "https://freedom.horse/@ElfLord.json",
    content: `"Someday I'm gonna visit you in Texas, and when I get there, I'm going to realize you don't live in Texas at all, and I'm in the wrong state"`,
  },
  Decimal: {
    url: "https://plush.city/@Decimal",
    json: "https://plush.city/@Decimal.json",
    content: `"I will appreciate the heck out of you any day"`,
  },
  skelly: {
    url: "https://redroo.ml/@skelly",
    json: "https://redroo.ml/@skelly.json",
    content: `"this an an official invitation for any one of you to put 'fuck you i dont give testimonials' as a testimonial by me on your profile"`,
  },
  Drako_Fenris: {
    url: "https://yiff.life/@Drako_Fenris",
    json: "https://yiff.life/@Drako_Fenris.json",
    content: `"[Alexis' future wife] lives in the ether yet to be revealed. she awaits the day her big tiddie goth gf rides in on her unicorn and rescues her."`,
  },
  "00dani": {
    url: "https://vulpine.club/@00dani",
    json: "https://vulpine.club/@00dani.json",
    content: `"*falls in love with you* haha whoopsies 😳"`,
  },
  Gumby: {
    url: "https://puppy.cafe/@Gumby",
    json: "https://puppy.cafe/@Gumby.json",
    content: `"im love alexis a lot 💚 🐀"`,
  },
  AshBunny: {
    url: "https://vulpine.club/@AshBunny",
    json: "https://vulpine.club/@AshBunny.json",
    content: `"heck. I don't think I can take all of this support."`,
  },
  heatherhorns: {
    url: "https://plush.city/@heatherhorns",
    json: "https://plush.city/@heatherhorns.json",
    content: `";~;

    gpsd gosh"`,
  },
  MutoShack: {
    url: "https://functional.cafe/@MutoShack",
    json: "https://functional.cafe/@MutoShack.json",
    content: `"yess w'all say nice things! usually "alexis is the good" and "alexis is the gay"

    because it is the truth"`,
  },
  immychan: {
    url: "https://antabaka.me/@immychan",
    json: "https://antabaka.me/@immychan.json",
    content: `"Oh damn you're cute 😳"`,
  },
  nautilee: {
    url: "https://dragon.style/@nautilee",
    json: "https://dragon.style/@nautilee.json",
    content: `"...how are you so goshdarn cute"`,
  },
  lindsays: {
    url: "https://hackers.town/@lindsays",
    json: "https://hackers.town/@lindsays.json",
    content: `"Regarding @shadow8t4  : She's an amazing, sweet, beautiful dork, and a spectacular best friend. also, a butt."`,
  },
};

export default function Testimonials({ iconUrls }) {
  return (
    <BasicPage page_title="Werefox Testimonials" card_title="Testimonials!">
      <WCard>
        <p className="p-6 text-lg text-center text-werefox-blue-dark dark:text-werefox-blue">
          Sometimes, people say some nice things about me. Here are some
          examples!
        </p>
      </WCard>
      {Object.keys(USERS).map((user) => (
        <TCard
          key={USERS[user].url}
          src={iconUrls[user]}
          alt={`${user}'s Avatar`}
          url={USERS[user].url}
          user={user}
          innerText={USERS[user].content}
        />
      ))}
    </BasicPage>
  );
}
