import type { NextPage } from 'next';
import Head from 'next/head';
import Layout from '@themes/infra/components/Layout';
import Link from '@themes/signpost/components/Link';
import links from '../content/links.json';
import dedicatedServers from '../content/dedicated-servers.json';
import virtualServers from '../content/virtual-servers.json';
import loadbalancers from '../content/loadbalancers.json';
import kubernetes from '../content/kubernetes.json';

const Home: NextPage = () => {
  return (
    <>
      <Head>
        <title>infra.mareshq.com</title>
        <meta
          name="description"
          content="Vojtech Mares (MaresHQ) Infrastructure overview"
        />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      <Layout>
        <h3 className="text-gray-600">infra.mareshq.com</h3>

        <main>
          <h1 className="font-sans font-bold text-4xl">
            MaresHQ Infrastructure
          </h1>
          <div className="grid grid-cols-12 gap-4">
            <div className="col-span-3">
              <div className="mt-4">
                <h2 className="text-3xl font-bold">links</h2>
                <ul>
                  {links.map((l) => (
                    <li key={l.name} className="my-2">
                      <Link title={l.name} url={l.url} />
                    </li>
                  ))}
                </ul>
              </div>
            </div>
            <div className="col-span-9">
              <div className="mt-4">
                <h2 className="text-3xl font-bold">
                  virtual servers
                </h2>
                <table className="table-fixed w-full">
                  <thead className="text-left">
                    <tr>
                      <th>name</th>
                      <th>provider</th>
                      <th>zone</th>
                      <th>ip</th>
                      <th>belongs to</th>
                    </tr>
                  </thead>
                  <tbody>
                    {virtualServers.map((vs) => (
                      <tr key={vs.name}>
                        <td>{vs.name}</td>
                        <td>{vs.provider}</td>
                        <td>{vs.zone}</td>
                        <td>
                          <code>{vs.ip}</code>
                        </td>
                        <td>{vs.belongsTo}</td>
                      </tr>
                    ))}
                  </tbody>
                </table>
              </div>
              <div className="mt-4">
                <h2 className="text-3xl font-bold">
                  dedicated servers
                </h2>
                <table className="table-fixed w-full">
                  <thead className="text-left">
                    <tr>
                      <th>name</th>
                      <th>provider</th>
                      <th>zone</th>
                      <th>ip</th>
                      <th>belongs to</th>
                    </tr>
                  </thead>
                  <tbody>
                    {dedicatedServers.map((ds) => (
                      <tr key={ds.name}>
                        <td>{ds.name}</td>
                        <td>{ds.provider}</td>
                        <td>{ds.zone}</td>
                        <td>
                          <code>{ds.ip}</code>
                        </td>
                        <td>{ds.belongsTo}</td>
                      </tr>
                    ))}
                  </tbody>
                </table>
              </div>
              <div className="mt-4">
                <h2 className="text-3xl font-bold">load balancers</h2>
                <table className="table-fixed w-full">
                  <thead className="text-left">
                    <tr>
                      <th>name</th>
                      <th>provider</th>
                      <th>zone</th>
                      <th>ip</th>
                      <th>belongs to</th>
                    </tr>
                  </thead>
                  <tbody>
                    {loadbalancers.map((lb) => (
                      <tr key={lb.name}>
                        <td>{lb.name}</td>
                        <td>{lb.provider}</td>
                        <td>{lb.zone}</td>
                        <td>
                          <code>{lb.ip}</code>
                        </td>
                        <td>{lb.belongsTo}</td>
                      </tr>
                    ))}
                  </tbody>
                </table>
              </div>
              <div className="mt-4">
                <h2 className="text-3xl font-bold">
                  kubernetes clusters
                </h2>
                <table className="table-fixed w-full">
                  <thead className="text-left">
                    <tr>
                      <th>name</th>
                      <th>provider</th>
                      <th>zone</th>
                      <th>url</th>
                      <th></th>
                    </tr>
                  </thead>
                  <tbody>
                    {kubernetes.map((k8s) => (
                      <tr key={k8s.name}>
                        <td>{k8s.name}</td>
                        <td>{k8s.provider}</td>
                        <td>{k8s.zone}</td>
                        <td>{k8s.url}</td>
                        <td></td>
                      </tr>
                    ))}
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </main>
      </Layout>
    </>
  );
};

export default Home;
