import { NextPageContext } from "next";

function ErrorPage({ statusCode }: { statusCode?: number }) {
  return (
    <div
      style={{
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        minHeight: "100vh",
        backgroundColor: "#252A2F",
        color: "white",
        fontFamily: "Lato, sans-serif",
      }}
    >
      <h1 style={{ fontSize: 24, fontWeight: 700 }}>
        {statusCode === 404
          ? "404 - Halaman Tidak Ditemukan"
          : "Terjadi Kesalahan"}
      </h1>
    </div>
  );
}

ErrorPage.getInitialProps = ({ res, err }: NextPageContext) => {
  const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
  return { statusCode };
};

export default ErrorPage;
