import { FreshContext, Handlers } from "$fresh/server.ts";
import { State } from "$root/defaults/interfaces.ts";

export const handler: Handlers<unknown, State> = {
  GET(_request: Request, context: FreshContext<State>) {
    if (context.state.isAuthenticated) {
      return new Response(null, {
        status: 302,
        headers: { Location: "/apps" },
      });
    }
    return context.render();
  },
};

export default function Home() {
  return (
    <>
      <h2>PolyMPR</h2>
      <h3>
        The <em>ultimate</em> HR platform
      </h3>
      <p>
        <a href="/login">Se connecter</a>
      </p>
    </>
  );
}
